mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 22:05:44 +00:00
Bug 1004850 - (Part 7) Update robocop tests to account for new panel. r=mcomella
This commit is contained in:
parent
b25f0d2647
commit
99121ef2e2
@ -89,7 +89,7 @@ public class HistoryPanel extends HomeFragment {
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
mList = (HomeListView) view.findViewById(R.id.list);
|
||||
mList.setTag(HomePager.LIST_TAG_MOST_RECENT);
|
||||
mList.setTag(HomePager.LIST_TAG_HISTORY);
|
||||
|
||||
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
|
@ -68,8 +68,7 @@ public class HomePager extends ViewPager {
|
||||
static final String LIST_TAG_BOOKMARKS = "bookmarks";
|
||||
static final String LIST_TAG_READING_LIST = "reading_list";
|
||||
static final String LIST_TAG_TOP_SITES = "top_sites";
|
||||
static final String LIST_TAG_MOST_RECENT = "most_recent";
|
||||
static final String LIST_TAG_LAST_TABS = "last_tabs";
|
||||
static final String LIST_TAG_RECENT_TABS = "recent_tabs";
|
||||
static final String LIST_TAG_BROWSER_SEARCH = "browser_search";
|
||||
|
||||
public interface OnUrlOpenListener {
|
||||
|
@ -115,7 +115,7 @@ public class RecentTabsPanel extends HomeFragment
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
mList = (HomeListView) view.findViewById(R.id.list);
|
||||
mList.setTag(HomePager.LIST_TAG_LAST_TABS);
|
||||
mList.setTag(HomePager.LIST_TAG_RECENT_TABS);
|
||||
|
||||
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
|
@ -26,7 +26,14 @@ import com.jayway.android.robotium.solo.Condition;
|
||||
* To use any of these methods in your test make sure it extends AboutHomeTest instead of BaseTest
|
||||
*/
|
||||
abstract class AboutHomeTest extends PixelTest {
|
||||
protected enum AboutHomeTabs {HISTORY, MOST_RECENT, TABS_FROM_LAST_TIME, TOP_SITES, BOOKMARKS, READING_LIST};
|
||||
protected enum AboutHomeTabs {
|
||||
RECENT_TABS,
|
||||
HISTORY,
|
||||
TOP_SITES,
|
||||
BOOKMARKS,
|
||||
READING_LIST
|
||||
};
|
||||
|
||||
private ArrayList<String> aboutHomeTabs = new ArrayList<String>() {{
|
||||
add("TOP_SITES");
|
||||
add("BOOKMARKS");
|
||||
@ -42,8 +49,10 @@ abstract class AboutHomeTest extends PixelTest {
|
||||
// Update it for tablets vs. phones.
|
||||
if (mDevice.type.equals("phone")) {
|
||||
aboutHomeTabs.add(0, AboutHomeTabs.HISTORY.toString());
|
||||
aboutHomeTabs.add(0, AboutHomeTabs.RECENT_TABS.toString());
|
||||
} else {
|
||||
aboutHomeTabs.add(AboutHomeTabs.HISTORY.toString());
|
||||
aboutHomeTabs.add(AboutHomeTabs.RECENT_TABS.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -223,7 +232,7 @@ abstract class AboutHomeTest extends PixelTest {
|
||||
/**
|
||||
* This method can be used to open the different tabs of about:home.
|
||||
*
|
||||
* @param AboutHomeTabs enum item {MOST_RECENT, TABS_FROM_LAST_TIME, TOP_SITES, BOOKMARKS, READING_LIST}
|
||||
* @param AboutHomeTabs enum item
|
||||
*/
|
||||
protected void openAboutHomeTab(AboutHomeTabs tab) {
|
||||
focusUrlBar();
|
||||
@ -233,71 +242,13 @@ abstract class AboutHomeTest extends PixelTest {
|
||||
|
||||
// Handle tablets by just clicking the visible tab title.
|
||||
if (mDevice.type.equals("tablet")) {
|
||||
if (AboutHomeTabs.MOST_RECENT == tab || AboutHomeTabs.TABS_FROM_LAST_TIME == tab) {
|
||||
tabOffset = aboutHomeTabs.indexOf(AboutHomeTabs.HISTORY.toString()) - currentTabIndex;
|
||||
swipeAboutHome(tabOffset);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.HISTORY_LABEL));
|
||||
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
||||
|
||||
switch (tab) {
|
||||
case MOST_RECENT: {
|
||||
mSolo.clickOnView(tabwidget.getChildAt(0));
|
||||
// We can determine if we are on the MOST_RECENT tab only if pages were first visited during the test
|
||||
mAsserter.ok(waitForText(StringHelper.TODAY_LABEL), "Checking that we are in the most recent tab of about:home", "We are in the most recent tab");
|
||||
break;
|
||||
}
|
||||
case TABS_FROM_LAST_TIME: {
|
||||
mSolo.clickOnView(tabwidget.getChildAt(1));
|
||||
mAsserter.ok(waitForText(StringHelper.TABS_FROM_LAST_TIME_LABEL), "Checking that we are in the Tabs from last time tab of about:home", "We are in the Tabs from last time tab");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
clickAboutHomeTab(tab);
|
||||
}
|
||||
clickAboutHomeTab(tab);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle phones (non-tablets).
|
||||
tabOffset = aboutHomeTabs.indexOf(tab.toString()) - currentTabIndex;
|
||||
switch (tab) {
|
||||
case TOP_SITES : {
|
||||
swipeAboutHome(tabOffset);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(tab.toString()));
|
||||
break;
|
||||
}
|
||||
case BOOKMARKS : {
|
||||
swipeAboutHome(tabOffset);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(tab.toString()));
|
||||
break;
|
||||
}
|
||||
case MOST_RECENT: {
|
||||
// MOST_RECENT is contained in the HISTORY tab.
|
||||
tabOffset = aboutHomeTabs.indexOf(AboutHomeTabs.HISTORY.toString()) - currentTabIndex;
|
||||
swipeAboutHome(tabOffset);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.HISTORY_LABEL));
|
||||
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
||||
mSolo.clickOnView(tabwidget.getChildAt(0));
|
||||
// We can determine if we are on the MOST_RECENT tab only if pages were first visited during the test
|
||||
mAsserter.ok(waitForText(StringHelper.TODAY_LABEL), "Checking that we are in the most recent tab of about:home", "We are in the most recent tab");
|
||||
break;
|
||||
}
|
||||
case TABS_FROM_LAST_TIME: {
|
||||
// TABS_FROM_LAST_TIME is contained in the HISTORY tab.
|
||||
tabOffset = aboutHomeTabs.indexOf(AboutHomeTabs.HISTORY.toString()) - currentTabIndex;
|
||||
swipeAboutHome(tabOffset);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(StringHelper.HISTORY_LABEL));
|
||||
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
||||
mSolo.clickOnView(tabwidget.getChildAt(1));
|
||||
mAsserter.ok(waitForText(StringHelper.TABS_FROM_LAST_TIME_LABEL), "Checking that we are in the Tabs from last time tab of about:home", "We are in the Tabs from last time tab");
|
||||
break;
|
||||
}
|
||||
case READING_LIST: {
|
||||
swipeAboutHome(tabOffset);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(tab.toString()));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
swipeAboutHome(tabOffset);
|
||||
waitForAboutHomeTab(aboutHomeTabs.indexOf(tab.toString()));
|
||||
}
|
||||
}
|
||||
|
@ -30,13 +30,15 @@ public class AboutHomeComponent extends BaseComponent {
|
||||
HISTORY,
|
||||
TOP_SITES,
|
||||
BOOKMARKS,
|
||||
READING_LIST
|
||||
READING_LIST,
|
||||
RECENT_TABS
|
||||
}
|
||||
|
||||
// TODO: Having a specific ordering of panels is prone to fail and thus temporary.
|
||||
// Hopefully the work in bug 940565 will alleviate the need for these enums.
|
||||
// Explicit ordering of HomePager panels on a phone.
|
||||
private enum PhonePanel {
|
||||
RECENT_TABS,
|
||||
HISTORY,
|
||||
TOP_SITES,
|
||||
BOOKMARKS,
|
||||
@ -48,7 +50,8 @@ public class AboutHomeComponent extends BaseComponent {
|
||||
TOP_SITES,
|
||||
BOOKMARKS,
|
||||
READING_LIST,
|
||||
HISTORY
|
||||
HISTORY,
|
||||
RECENT_TABS
|
||||
}
|
||||
|
||||
// The percentage of the panel to swipe between 0 and 1. This value was set through
|
||||
|
@ -6,6 +6,8 @@ import org.mozilla.gecko.tests.helpers.GeckoHelper;
|
||||
|
||||
/**
|
||||
* Tests functionality related to navigating between the various about:home panels.
|
||||
*
|
||||
* TODO: Update this test to account for recent tabs panel (bug 1028727).
|
||||
*/
|
||||
public class testAboutHomePageNavigation extends UITest {
|
||||
// TODO: Define this test dynamically by creating dynamic representations of the Page
|
||||
|
@ -21,9 +21,9 @@ public class testHistory extends AboutHomeTest {
|
||||
inputAndLoadUrl(url3);
|
||||
verifyPageTitle("Browser Blank Page 03");
|
||||
|
||||
openAboutHomeTab(AboutHomeTabs.MOST_RECENT);
|
||||
openAboutHomeTab(AboutHomeTabs.HISTORY);
|
||||
|
||||
final ListView hList = findListViewWithTag("most_recent");
|
||||
final ListView hList = findListViewWithTag("history");
|
||||
mAsserter.is(waitForNonEmptyListToLoad(hList), true, "list is properly loaded");
|
||||
|
||||
// Click on the history item and wait for the page to load
|
||||
|
@ -106,8 +106,8 @@ public class testReaderMode extends AboutHomeTest {
|
||||
mAsserter.ok(mSolo.waitForText("Robocop Text Page"), "Verify if the page is added to your Reading List", "The page is present in your Reading List");
|
||||
|
||||
// Check if the page is added in History tab like a Reading List item
|
||||
openAboutHomeTab(AboutHomeTabs.MOST_RECENT);
|
||||
list = findListViewWithTag("most_recent");
|
||||
openAboutHomeTab(AboutHomeTabs.HISTORY);
|
||||
list = findListViewWithTag("history");
|
||||
child = list.getChildAt(1);
|
||||
mAsserter.ok(child != null, "item can be retrieved", child != null ? child.toString() : "null!");
|
||||
mSolo.clickLongOnView(child);
|
||||
|
@ -119,10 +119,10 @@ public class testShareLink extends AboutHomeTest {
|
||||
mSolo.clickLongOnView(mostVisitedItem);
|
||||
verifySharePopup(shareOptions,"top_sites");
|
||||
|
||||
// Test the share popup in the Most Recent tab
|
||||
openAboutHomeTab(AboutHomeTabs.MOST_RECENT);
|
||||
// Test the share popup in the history tab
|
||||
openAboutHomeTab(AboutHomeTabs.HISTORY);
|
||||
|
||||
ListView mostRecentList = findListViewWithTag("most_recent");
|
||||
ListView mostRecentList = findListViewWithTag("history");
|
||||
mAsserter.is(waitForNonEmptyListToLoad(mostRecentList), true, "list is properly loaded");
|
||||
|
||||
// Getting second child after header views because the first is the "Today" label
|
||||
|
Loading…
Reference in New Issue
Block a user