mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 759041 - Add swipe between screens in awesomescreen. r=lucasr
This commit is contained in:
parent
c39ede05cb
commit
b553528d40
@ -8,6 +8,8 @@ package org.mozilla.gecko;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@ -28,6 +30,9 @@ public class AwesomeBarTabs extends TabHost {
|
||||
private LayoutInflater mInflater;
|
||||
private OnUrlOpenListener mUrlOpenListener;
|
||||
private View.OnTouchListener mListTouchListener;
|
||||
private boolean mSearching = false;
|
||||
private ViewPager mViewPager;
|
||||
private AwesomePagerAdapter mPagerAdapter;
|
||||
|
||||
private AwesomeBarTab mTabs[];
|
||||
|
||||
@ -41,9 +46,36 @@ public class AwesomeBarTabs extends TabHost {
|
||||
public void onEditSuggestion(String suggestion);
|
||||
}
|
||||
|
||||
private class AwesomePagerAdapter extends PagerAdapter {
|
||||
public AwesomePagerAdapter() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Object instantiateItem(ViewGroup group, int index) {
|
||||
AwesomeBarTab tab = mTabs[index];
|
||||
group.addView(tab.getView());
|
||||
return tab;
|
||||
}
|
||||
|
||||
public void destroyItem(ViewGroup group, int index, Object obj) {
|
||||
AwesomeBarTab tab = (AwesomeBarTab)obj;
|
||||
group.removeView(tab.getView());
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
if (mSearching)
|
||||
return 1;
|
||||
return mTabs.length;
|
||||
}
|
||||
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return getAwesomeBarTabForView(view) == object;
|
||||
}
|
||||
}
|
||||
|
||||
private AwesomeBarTab getCurrentAwesomeBarTab() {
|
||||
String tag = getCurrentTabTag();
|
||||
return getAwesomeBarTabForTag(tag);
|
||||
int index = mViewPager.getCurrentItem();
|
||||
return mTabs[index];
|
||||
}
|
||||
|
||||
public AwesomeBarTab getAwesomeBarTabForView(View view) {
|
||||
@ -53,7 +85,7 @@ public class AwesomeBarTabs extends TabHost {
|
||||
|
||||
public AwesomeBarTab getAwesomeBarTabForTag(String tag) {
|
||||
for (AwesomeBarTab tab : mTabs) {
|
||||
if (tag == tab.getTag()) {
|
||||
if (tag.equals(tab.getTag())) {
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
@ -107,24 +139,39 @@ public class AwesomeBarTabs extends TabHost {
|
||||
new HistoryTab(mContext)
|
||||
};
|
||||
|
||||
for (AwesomeBarTab tab : mTabs) {
|
||||
addAwesomeTab(tab);
|
||||
}
|
||||
final TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
|
||||
// hide the strip since we aren't using the TabHost...
|
||||
tabWidget.setStripEnabled(false);
|
||||
|
||||
styleSelectedTab();
|
||||
|
||||
setOnTabChangedListener(new TabHost.OnTabChangeListener() {
|
||||
public void onTabChanged(String tabId) {
|
||||
styleSelectedTab();
|
||||
mViewPager = (ViewPager) findViewById(R.id.tabviewpager);
|
||||
mPagerAdapter = new AwesomePagerAdapter();
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
mViewPager.setCurrentItem(0);
|
||||
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
public void onPageScrollStateChanged(int state) { }
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }
|
||||
public void onPageSelected(int position) {
|
||||
tabWidget.setCurrentTab(position);
|
||||
styleSelectedTab();
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < mTabs.length; i++) {
|
||||
addAwesomeTab(mTabs[i].getTag(),
|
||||
mTabs[i].getTitleStringId(),
|
||||
i);
|
||||
}
|
||||
|
||||
tabWidget.setCurrentTab(0);
|
||||
|
||||
styleSelectedTab();
|
||||
|
||||
// Initialize "App Pages" list with no filter
|
||||
filter("");
|
||||
}
|
||||
|
||||
private void styleSelectedTab() {
|
||||
int selIndex = getCurrentTab();
|
||||
int selIndex = mViewPager.getCurrentItem();
|
||||
TabWidget tabWidget = getTabWidget();
|
||||
for (int i = 0; i < tabWidget.getTabCount(); i++) {
|
||||
if (i == selIndex)
|
||||
@ -150,23 +197,21 @@ public class AwesomeBarTabs extends TabHost {
|
||||
}
|
||||
|
||||
|
||||
private void addAwesomeTab(AwesomeBarTab tab) {
|
||||
TabSpec tabspec = getTabSpec(tab.getTag(), tab.getTitleStringId());
|
||||
tabspec.setContent(tab.getFactory());
|
||||
addTab(tabspec);
|
||||
tab.setListTouchListener(mListTouchListener);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private TabSpec getTabSpec(String id, int titleId) {
|
||||
TabSpec tab = newTabSpec(id);
|
||||
|
||||
private View addAwesomeTab(String id, int titleId, final int contentId) {
|
||||
TextView indicatorView = (TextView) mInflater.inflate(R.layout.awesomebar_tab_indicator, null);
|
||||
indicatorView.setText(titleId);
|
||||
|
||||
tab.setIndicator(indicatorView);
|
||||
return tab;
|
||||
getTabWidget().addView(indicatorView);
|
||||
|
||||
// this MUST be done after tw.addView to overwrite the listener added by tabWidget
|
||||
// which delegates to TabHost (which we don't have)
|
||||
indicatorView.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mViewPager.setCurrentItem(contentId, true);
|
||||
}
|
||||
});
|
||||
|
||||
return indicatorView;
|
||||
}
|
||||
|
||||
private boolean hideSoftInput(View view) {
|
||||
@ -213,7 +258,10 @@ public class AwesomeBarTabs extends TabHost {
|
||||
setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
|
||||
|
||||
// The tabs should only be visible if there's no on-going search
|
||||
int tabsVisibility = (searchTerm.length() == 0 ? View.VISIBLE : View.GONE);
|
||||
mSearching = searchTerm.length() != 0;
|
||||
// reset the pager adapter to force repopulating the cache
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
int tabsVisibility = !mSearching ? View.VISIBLE : View.GONE;
|
||||
findViewById(R.id.tab_widget_container).setVisibility(tabsVisibility);
|
||||
|
||||
// Perform the actual search
|
||||
|
@ -77,6 +77,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
private boolean mAnimateSuggestions;
|
||||
private View mSuggestionsOptInPrompt;
|
||||
private Handler mHandler;
|
||||
private ListView mListView;
|
||||
|
||||
private static final int MESSAGE_LOAD_FAVICONS = 1;
|
||||
private static final int MESSAGE_UPDATE_FAVICONS = 2;
|
||||
@ -101,19 +102,6 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
public TabContentFactory getFactory() {
|
||||
return new TabContentFactory() {
|
||||
public View createTabContent(String tag) {
|
||||
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
handleItemClick(parent, view, position, id);
|
||||
}
|
||||
});
|
||||
return getAllPagesView();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int getTitleStringId() {
|
||||
return R.string.awesomebar_all_pages_title;
|
||||
}
|
||||
@ -122,28 +110,35 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private LinearLayout getAllPagesView() {
|
||||
if (mAllPagesView == null) {
|
||||
mAllPagesView = (LinearLayout) (LayoutInflater.from(mContext).inflate(R.layout.awesomebar_allpages_list, null));
|
||||
private ListView getListView() {
|
||||
if (mListView == null && mView != null) {
|
||||
mListView = (ListView) mView.findViewById(R.id.awesomebar_list);
|
||||
}
|
||||
return mAllPagesView;
|
||||
return mListView;
|
||||
}
|
||||
|
||||
public ListView getListView() {
|
||||
public View getView() {
|
||||
if (mView == null) {
|
||||
mView = getAllPagesView().findViewById(R.id.awesomebar_list);
|
||||
((Activity)mContext).registerForContextMenu(mView);
|
||||
mView = (LinearLayout) (LayoutInflater.from(mContext).inflate(R.layout.awesomebar_allpages_list, null));
|
||||
mView.setTag(TAG);
|
||||
AwesomeBarCursorAdapter adapter = getCursorAdapter();
|
||||
|
||||
ListView listView = (ListView) mView;
|
||||
listView.setAdapter(adapter);
|
||||
listView.setOnTouchListener(mListListener);
|
||||
ListView list = getListView();
|
||||
list.setTag(TAG);
|
||||
((Activity)mContext).registerForContextMenu(list);
|
||||
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
handleItemClick(parent, view, position, id);
|
||||
}
|
||||
});
|
||||
|
||||
AwesomeBarCursorAdapter adapter = getCursorAdapter();
|
||||
list.setAdapter(adapter);
|
||||
list.setOnTouchListener(mListListener);
|
||||
|
||||
mHandler = new AllPagesHandler();
|
||||
}
|
||||
|
||||
return (ListView)mView;
|
||||
return mView;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
@ -595,7 +590,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
}
|
||||
|
||||
private void showSuggestionsOptIn() {
|
||||
mSuggestionsOptInPrompt = LayoutInflater.from(mContext).inflate(R.layout.awesomebar_suggestion_prompt, getAllPagesView(), false);
|
||||
mSuggestionsOptInPrompt = LayoutInflater.from(mContext).inflate(R.layout.awesomebar_suggestion_prompt, (LinearLayout)getView(), false);
|
||||
((TextView) mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_title))
|
||||
.setText(getResources().getString(R.string.suggestions_prompt, mSearchEngines.get(0).name));
|
||||
mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_yes).setOnClickListener(new OnClickListener() {
|
||||
@ -609,7 +604,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
}
|
||||
});
|
||||
mSuggestionsOptInPrompt.setVisibility(View.GONE);
|
||||
getAllPagesView().addView(mSuggestionsOptInPrompt, 0);
|
||||
((LinearLayout)getView()).addView(mSuggestionsOptInPrompt, 0);
|
||||
}
|
||||
|
||||
private void setSuggestionsEnabled(final boolean enabled) {
|
||||
@ -629,12 +624,13 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
anim2.setDuration(ANIMATION_DURATION);
|
||||
anim2.setFillAfter(true);
|
||||
anim2.setStartOffset(anim1.getDuration());
|
||||
final LinearLayout view = (LinearLayout)getView();
|
||||
anim2.setAnimationListener(new Animation.AnimationListener() {
|
||||
public void onAnimationStart(Animation a) {
|
||||
// Increase the height of the view so a gap isn't shown during animation
|
||||
getAllPagesView().getLayoutParams().height = getAllPagesView().getHeight() +
|
||||
view.getLayoutParams().height = view.getHeight() +
|
||||
mSuggestionsOptInPrompt.getHeight();
|
||||
getAllPagesView().requestLayout();
|
||||
view.requestLayout();
|
||||
}
|
||||
public void onAnimationRepeat(Animation a) {}
|
||||
public void onAnimationEnd(Animation a) {
|
||||
@ -642,15 +638,15 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
// dispatchDraw(), possibly because this callback executes
|
||||
// before drawing is finished. Posting this as a Runnable fixes
|
||||
// the issue.
|
||||
getAllPagesView().post(new Runnable() {
|
||||
view.post(new Runnable() {
|
||||
public void run() {
|
||||
getAllPagesView().removeView(mSuggestionsOptInPrompt);
|
||||
view.removeView(mSuggestionsOptInPrompt);
|
||||
getListView().clearAnimation();
|
||||
mSuggestionsOptInPrompt = null;
|
||||
|
||||
if (enabled) {
|
||||
// Reset the view height
|
||||
getAllPagesView().getLayoutParams().height = LayoutParams.FILL_PARENT;
|
||||
view.getLayoutParams().height = LayoutParams.FILL_PARENT;
|
||||
|
||||
mSuggestionsEnabled = enabled;
|
||||
mAnimateSuggestions = true;
|
||||
@ -815,7 +811,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
||||
}
|
||||
|
||||
private void updateFavicons() {
|
||||
ListView listView = (ListView) mView;
|
||||
ListView listView = getListView();
|
||||
for (int i = 0; i < listView.getChildCount(); i++) {
|
||||
final View view = listView.getChildAt(i);
|
||||
final Object tag = view.getTag();
|
||||
|
@ -28,9 +28,9 @@ abstract public class AwesomeBarTab {
|
||||
abstract public String getTag();
|
||||
abstract public int getTitleStringId();
|
||||
abstract public void destroy();
|
||||
abstract public TabContentFactory getFactory();
|
||||
abstract public boolean onBackPressed();
|
||||
abstract public ContextMenuSubject getSubject(ContextMenu menu, View view, ContextMenuInfo menuInfo);
|
||||
abstract public View getView();
|
||||
|
||||
protected View mView = null;
|
||||
protected View.OnTouchListener mListListener;
|
||||
|
@ -53,23 +53,9 @@ public class BookmarksTab extends AwesomeBarTab {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public TabContentFactory getFactory() {
|
||||
return new TabContentFactory() {
|
||||
public View createTabContent(String tag) {
|
||||
final ListView list = getListView();
|
||||
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
handleItemClick(parent, view, position, id);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public ListView getListView() {
|
||||
public View getView() {
|
||||
if (mView == null) {
|
||||
mView = (ListView) (LayoutInflater.from(mContext).inflate(R.layout.awesomebar_list, null));
|
||||
mView = (LayoutInflater.from(mContext).inflate(R.layout.awesomebar_list, null));
|
||||
((Activity)mContext).registerForContextMenu(mView);
|
||||
mView.setTag(TAG);
|
||||
mView.setOnTouchListener(mListListener);
|
||||
@ -78,6 +64,11 @@ public class BookmarksTab extends AwesomeBarTab {
|
||||
ListView list = (ListView)mView;
|
||||
list.setAdapter(null);
|
||||
list.setAdapter(getCursorAdapter());
|
||||
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
handleItemClick(parent, view, position, id);
|
||||
}
|
||||
});
|
||||
|
||||
if (mShowReadingList) {
|
||||
String title = getResources().getString(R.string.bookmarks_folder_reading_list);
|
||||
@ -109,8 +100,7 @@ public class BookmarksTab extends AwesomeBarTab {
|
||||
// If the soft keyboard is visible in the bookmarks or history tab, the user
|
||||
// must have explictly brought it up, so we should try hiding it instead of
|
||||
// exiting the activity or going up a bookmarks folder level.
|
||||
ListView view = getListView();
|
||||
if (hideSoftInput(view))
|
||||
if (hideSoftInput(getView()))
|
||||
return true;
|
||||
|
||||
return moveToParentFolder();
|
||||
@ -162,7 +152,7 @@ public class BookmarksTab extends AwesomeBarTab {
|
||||
}
|
||||
|
||||
public void handleItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
ListView list = getListView();
|
||||
ListView list = (ListView)getView();
|
||||
if (list == null)
|
||||
return;
|
||||
|
||||
|
@ -63,39 +63,33 @@ public class HistoryTab extends AwesomeBarTab {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
public TabContentFactory getFactory() {
|
||||
return new TabContentFactory() {
|
||||
public View createTabContent(String tag) {
|
||||
final ExpandableListView list = (ExpandableListView)getListView();
|
||||
list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
||||
public boolean onChildClick(ExpandableListView parent, View view,
|
||||
int groupPosition, int childPosition, long id) {
|
||||
return handleItemClick(groupPosition, childPosition);
|
||||
}
|
||||
});
|
||||
|
||||
// This is to disallow collapsing the expandable groups in the
|
||||
// history expandable list view to mimic simpler sections. We should
|
||||
// Remove this if we decide to allow expanding/collapsing groups.
|
||||
list.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
|
||||
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public ListView getListView() {
|
||||
public ListView getView() {
|
||||
if (mView == null) {
|
||||
mView = (ExpandableListView) (LayoutInflater.from(mContext).inflate(R.layout.awesomebar_expandable_list, null));
|
||||
mView = LayoutInflater.from(mContext).inflate(R.layout.awesomebar_expandable_list, null);
|
||||
((Activity)mContext).registerForContextMenu(mView);
|
||||
mView.setTag(TAG);
|
||||
|
||||
ExpandableListView list = (ExpandableListView)mView;
|
||||
list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
||||
public boolean onChildClick(ExpandableListView parent, View view,
|
||||
int groupPosition, int childPosition, long id) {
|
||||
return handleItemClick(groupPosition, childPosition);
|
||||
}
|
||||
});
|
||||
|
||||
// This is to disallow collapsing the expandable groups in the
|
||||
// history expandable list view to mimic simpler sections. We should
|
||||
// Remove this if we decide to allow expanding/collapsing groups.
|
||||
list.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
|
||||
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
mView.setOnTouchListener(mListListener);
|
||||
|
||||
// We need to add the header before we set the adapter, hence make it null
|
||||
((ExpandableListView)mView).setAdapter(getCursorAdapter());
|
||||
list.setAdapter(getCursorAdapter());
|
||||
HistoryQueryTask task = new HistoryQueryTask();
|
||||
task.execute();
|
||||
}
|
||||
@ -111,7 +105,7 @@ public class HistoryTab extends AwesomeBarTab {
|
||||
// If the soft keyboard is visible in the bookmarks or history tab, the user
|
||||
// must have explictly brought it up, so we should try hiding it instead of
|
||||
// exiting the activity or going up a bookmarks folder level.
|
||||
ListView view = getListView();
|
||||
View view = getView();
|
||||
if (hideSoftInput(view))
|
||||
return true;
|
||||
|
||||
@ -360,7 +354,7 @@ public class HistoryTab extends AwesomeBarTab {
|
||||
BrowserDB.registerHistoryObserver(getContentResolver(), mContentObserver);
|
||||
}
|
||||
|
||||
final ExpandableListView historyList = (ExpandableListView)getListView();
|
||||
final ExpandableListView historyList = (ExpandableListView)getView();
|
||||
|
||||
// Hack: force this to the main thread, even though it should already be on it
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
|
@ -30,8 +30,15 @@
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/tabviewpager"
|
||||
style="@style/AwesomeBarList"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
</view>
|
||||
|
||||
|
@ -9,6 +9,8 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TabWidget;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import android.content.ContentValues;
|
||||
@ -28,6 +30,9 @@ import @ANDROID_PACKAGE_NAME@.*;
|
||||
|
||||
public class testAllPagesTab extends BaseTest {
|
||||
private static final String ABOUT_HOME_URL = "about:home";
|
||||
private static final int WAIT_FOR_CHILD_TIMEOUT = 2000;
|
||||
private static ListView listview = null;
|
||||
|
||||
private String[] bookmarks = new String[] {
|
||||
"about:firefox",
|
||||
"about:home",
|
||||
@ -53,11 +58,20 @@ public class testAllPagesTab extends BaseTest {
|
||||
}
|
||||
|
||||
private void testList(String url) {
|
||||
ListView list = getAllPagesList(url);
|
||||
final ListView list = getAllPagesList(url);
|
||||
mSolo.waitForText(url);
|
||||
|
||||
mAsserter.ok(list != null, "checking that all pages list exists", list.toString());
|
||||
// some basic checks for the tab strip
|
||||
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
||||
mAsserter.is(tabwidget.getTabCount(), 3, "Three tabs shown");
|
||||
mAsserter.is(tabwidget.isStripEnabled(), false, "Strip is hidden");
|
||||
|
||||
// check that the right tab is selected
|
||||
TabHost host = (TabHost)mSolo.getView(TabHost.class, 0);
|
||||
// This test fails, only when we're running tests
|
||||
// mAsserter.is(host.getCurrentTab(), 0, "All pages tab is selected in tab strip");
|
||||
|
||||
mAsserter.ok(list != null, "checking that all pages list exists", list.toString());
|
||||
mAsserter.is(list.getChildCount(), 5, "all pages list has 5 children (the default bookmarks)");
|
||||
|
||||
final int count = list.getChildCount();
|
||||
@ -132,9 +146,21 @@ public class testAllPagesTab extends BaseTest {
|
||||
Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
mSolo.waitForText(url);
|
||||
|
||||
TabHost tabHost = (TabHost)mSolo.getView(TabHost.class, 0);
|
||||
int listId = mDriver.findElement(getActivity(), "awesomebar_list").getId();
|
||||
return (ListView)tabHost.getCurrentView().findViewById(listId);
|
||||
final ArrayList<ListView> views = mSolo.getCurrentListViews();
|
||||
|
||||
listview = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
for (ListView view : views) {
|
||||
if (view.getTag() == "allPages") {
|
||||
listview = view;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, WAIT_FOR_CHILD_TIMEOUT);
|
||||
return listview;
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
|
@ -5,6 +5,7 @@ import @ANDROID_PACKAGE_NAME@.*;
|
||||
import android.app.Activity;
|
||||
import android.database.Cursor;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
@ -115,7 +116,8 @@ public class testBookmark extends PixelTest {
|
||||
|
||||
// Click on the bookmark we created and wait for the bookmarked page to load
|
||||
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
||||
mSolo.clickInList(1);
|
||||
View child = bookmarksList.getChildAt(1);
|
||||
mSolo.clickOnView(child);
|
||||
paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY);
|
||||
|
||||
// Clean up the bookmark we created
|
||||
@ -172,8 +174,12 @@ public class testBookmark extends PixelTest {
|
||||
// Click the "Bookmarks" tab to switch to bookmarks list
|
||||
mSolo.clickOnText("Bookmarks");
|
||||
|
||||
TabHost tabHost = (TabHost)mSolo.getView(TabHost.class, 0);
|
||||
return (ListView)tabHost.getCurrentView();
|
||||
ArrayList<ListView> views = mSolo.getCurrentListViews();
|
||||
for (ListView view : views) {
|
||||
if (view.getTag() == "bookmarks")
|
||||
return view;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// This method opens the menu and selects the "Bookmark" menu item
|
||||
|
@ -206,8 +206,21 @@ public class testBookmarksTab extends BaseTest {
|
||||
Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
mSolo.clickOnText("Bookmarks");
|
||||
|
||||
TabHost tabHost = (TabHost)mSolo.getView(TabHost.class, 0);
|
||||
return (ListView)tabHost.getCurrentView();
|
||||
final ArrayList<ListView> views = mSolo.getCurrentListViews();
|
||||
|
||||
list = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
for (ListView view : views) {
|
||||
if (view.getTag() == "bookmarks") {
|
||||
list = view;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, WAIT_FOR_CHILD_TIMEOUT);
|
||||
return list;
|
||||
}
|
||||
|
||||
private long addBookmark(String title, String url) {
|
||||
|
@ -7,11 +7,13 @@ import android.app.Activity;
|
||||
import java.util.ArrayList;
|
||||
import android.widget.TabHost;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
import android.util.Log;
|
||||
|
||||
public class testHistory extends PixelTest {
|
||||
private View mFirstChild;
|
||||
private static final int WAIT_FOR_CHILD_TIMEOUT = 2000;
|
||||
|
||||
@Override
|
||||
protected int getTestType() {
|
||||
@ -32,13 +34,38 @@ public class testHistory extends PixelTest {
|
||||
loadAndPaint(url3);
|
||||
verifyPageTitle("Browser Blank Page 03");
|
||||
|
||||
ListView hList = openHistoryList();
|
||||
final ListView hList = openHistoryList();
|
||||
mAsserter.ok(hList != null, "checking history exists", "history exists");
|
||||
|
||||
// Click on the history item and wait for the page to load
|
||||
// wait for the history list to be populated
|
||||
mFirstChild = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
mFirstChild = hList.getChildAt(1);
|
||||
if (mFirstChild == null) {
|
||||
return false;
|
||||
}
|
||||
if (mFirstChild instanceof android.view.ViewGroup) {
|
||||
ViewGroup group = (ViewGroup)mFirstChild;
|
||||
if (group.getChildCount() < 1) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < group.getChildCount(); i++) {
|
||||
View grandChild = group.getChildAt(i);
|
||||
if (grandChild instanceof android.widget.TextView) {
|
||||
mAsserter.ok(true, "found TextView:", ((android.widget.TextView)grandChild).getText().toString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mAsserter.dumpLog("first child not a ViewGroup: "+mFirstChild);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, WAIT_FOR_CHILD_TIMEOUT);
|
||||
|
||||
Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
|
||||
mFirstChild = hList.getChildAt(1);
|
||||
mAsserter.isnot(mFirstChild, null, "Got history item");
|
||||
mSolo.clickOnView(mFirstChild);
|
||||
contentEventExpecter.blockForEvent();
|
||||
@ -49,7 +76,11 @@ public class testHistory extends PixelTest {
|
||||
Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
mSolo.clickOnText("History");
|
||||
|
||||
TabHost tabHost = (TabHost)mSolo.getView(TabHost.class, 0);
|
||||
return (ListView)tabHost.getCurrentView();
|
||||
ArrayList<ListView> views = mSolo.getCurrentListViews();
|
||||
for (ListView view : views) {
|
||||
if (view.getTag() == "history")
|
||||
return view;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public class testHistoryTab extends PixelTest {
|
||||
private static final String ABOUT_HOME_URL = "about:home";
|
||||
private static final String OPEN_NEW_TAB = "Open in New Tab";
|
||||
private static final int WAIT_FOR_CHILD_TIMEOUT = 2000;
|
||||
private static ListView listview = null;
|
||||
private String[] bookmarks = new String[] {
|
||||
"http://mochi.test:8888/tests/robocop/robocop_blank_01.html"
|
||||
};
|
||||
@ -69,22 +70,20 @@ public class testHistoryTab extends PixelTest {
|
||||
testClick(url);
|
||||
}
|
||||
|
||||
private ListView list;
|
||||
|
||||
private void testList(String url) {
|
||||
list = getHistoryList();
|
||||
listview = getHistoryList();
|
||||
// clear VKB
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
mSolo.waitForText(url);
|
||||
|
||||
mAsserter.ok(list != null, "checking that history list exists", list.toString());
|
||||
mAsserter.ok(listview != null, "checking that history list exists", listview.toString());
|
||||
|
||||
mAsserter.is(list.getChildCount(), 3, "history list has 3 children");
|
||||
mAsserter.is(listview.getChildCount(), 3, "history list has 3 children");
|
||||
|
||||
final int count = list.getChildCount();
|
||||
final int count = listview.getChildCount();
|
||||
String loadUrl = "";
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
View child = list.getChildAt(i);
|
||||
View child = listview.getChildAt(i);
|
||||
|
||||
ArrayList<View> views = mSolo.getViews(child);
|
||||
ArrayList<ImageView> imageViews = new ArrayList<ImageView>();
|
||||
@ -132,7 +131,7 @@ public class testHistoryTab extends PixelTest {
|
||||
}
|
||||
|
||||
private void testContextMenu(String url) {
|
||||
list = getHistoryList();
|
||||
listview = getHistoryList();
|
||||
// clear VKB
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
mSolo.waitForText(url);
|
||||
@ -141,7 +140,7 @@ public class testHistoryTab extends PixelTest {
|
||||
mFirstChild = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
mFirstChild = list.getChildAt(1);
|
||||
mFirstChild = listview.getChildAt(1);
|
||||
if (mFirstChild == null) {
|
||||
return false;
|
||||
}
|
||||
@ -175,7 +174,7 @@ public class testHistoryTab extends PixelTest {
|
||||
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
|
||||
View child = list.getChildAt(0);
|
||||
View child = listview.getChildAt(0);
|
||||
mSolo.clickLongOnView(child);
|
||||
mAsserter.is(false, mSolo.waitForText("Open in New Tab"), "Header rows should not show a context menu");
|
||||
|
||||
@ -186,12 +185,12 @@ public class testHistoryTab extends PixelTest {
|
||||
}
|
||||
|
||||
private void testClick(String url) {
|
||||
list = getHistoryList();
|
||||
listview = getHistoryList();
|
||||
// clear VKB
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
mSolo.waitForText(url);
|
||||
|
||||
View child = list.getChildAt(0);
|
||||
View child = listview.getChildAt(0);
|
||||
mSolo.clickOnView(child);
|
||||
// nothing should happen
|
||||
|
||||
@ -199,7 +198,7 @@ public class testHistoryTab extends PixelTest {
|
||||
mFirstChild = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
mFirstChild = list.getChildAt(1);
|
||||
mFirstChild = listview.getChildAt(1);
|
||||
if (mFirstChild == null) {
|
||||
return false;
|
||||
}
|
||||
@ -219,8 +218,22 @@ public class testHistoryTab extends PixelTest {
|
||||
Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
mSolo.clickOnText("History");
|
||||
|
||||
TabHost tabHost = (TabHost)mSolo.getView(TabHost.class, 0);
|
||||
return (ListView)tabHost.getCurrentView();
|
||||
final ArrayList<ListView> views = mSolo.getCurrentListViews();
|
||||
|
||||
listview = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
public boolean test() {
|
||||
for (ListView view : views) {
|
||||
if (view.getTag() == "history") {
|
||||
listview = view;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, WAIT_FOR_CHILD_TIMEOUT);
|
||||
|
||||
return listview;
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user