2013-12-05 02:32:53 +00:00
|
|
|
package org.mozilla.gecko.tests;
|
|
|
|
|
|
|
|
import static org.mozilla.gecko.tests.helpers.AssertionHelper.*;
|
|
|
|
|
2014-01-11 01:18:07 +00:00
|
|
|
import org.mozilla.gecko.tests.components.AboutHomeComponent.PanelType;
|
2013-12-05 02:32:53 +00:00
|
|
|
import org.mozilla.gecko.tests.helpers.*;
|
|
|
|
|
|
|
|
/**
|
2014-01-23 20:27:10 +00:00
|
|
|
* Tests functionality related to navigating between the various about:home panels.
|
2013-12-05 02:32:53 +00:00
|
|
|
*/
|
|
|
|
public class testAboutHomePageNavigation extends UITest {
|
|
|
|
// TODO: Define this test dynamically by creating dynamic representations of the Page
|
2014-01-23 20:27:10 +00:00
|
|
|
// enum for both phone and tablet, then swiping through the panels. This will also
|
|
|
|
// benefit having a HomePager with custom panels.
|
2013-12-05 02:32:53 +00:00
|
|
|
public void testAboutHomePageNavigation() {
|
2014-02-05 02:57:54 +00:00
|
|
|
GeckoHelper.blockForDelayedStartup();
|
2013-12-05 02:32:53 +00:00
|
|
|
|
|
|
|
mAboutHome.assertVisible()
|
2014-01-23 20:27:10 +00:00
|
|
|
.assertCurrentPanel(PanelType.TOP_SITES);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnRight();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnRight();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
|
|
|
// Ideally these helpers would just be their own tests. However, by keeping this within
|
|
|
|
// one method, we're saving test setUp and tearDown resources.
|
|
|
|
if (DeviceHelper.isTablet()) {
|
|
|
|
helperTestTablet();
|
|
|
|
} else {
|
|
|
|
helperTestPhone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void helperTestTablet() {
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnRight();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.HISTORY);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
|
|
|
// Edge case.
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnRight();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.HISTORY);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnLeft();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnLeft();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnLeft();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
|
|
|
// Edge case.
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnLeft();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
|
2013-12-05 02:32:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void helperTestPhone() {
|
|
|
|
// Edge case.
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnRight();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnLeft();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnLeft();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnLeft();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.HISTORY);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
|
|
|
// Edge case.
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnLeft();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.HISTORY);
|
2013-12-05 02:32:53 +00:00
|
|
|
|
2014-01-23 20:27:10 +00:00
|
|
|
mAboutHome.swipeToPanelOnRight();
|
|
|
|
mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
|
2013-12-05 02:32:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: bug 943706 - reimplement this old test code.
|
|
|
|
/*
|
|
|
|
// Removed by Bug 896576 - [fig] Remove [getAllPagesList] from BaseTest
|
|
|
|
// ListView list = getAllPagesList("about:firefox");
|
|
|
|
|
|
|
|
// Test normal sliding of the list left and right
|
|
|
|
ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
|
|
|
|
mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected");
|
|
|
|
|
|
|
|
int width = mDriver.getGeckoWidth() / 2;
|
|
|
|
int y = mDriver.getGeckoHeight() / 2;
|
|
|
|
mActions.drag(width, 0, y, y);
|
|
|
|
mAsserter.is(pager.getCurrentItem(), 1, "Bookmarks page is selected");
|
|
|
|
|
|
|
|
mActions.drag(0, width, y, y);
|
|
|
|
mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected");
|
|
|
|
|
|
|
|
// Test tapping on the tab strip changes tabs
|
|
|
|
TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
|
|
|
|
mSolo.clickOnView(tabwidget.getChildAt(1));
|
|
|
|
mAsserter.is(pager.getCurrentItem(), 1, "Clicking on tab selected bookmarks page");
|
|
|
|
|
|
|
|
// Test typing in the awesomebar changes tabs and prevents panning
|
|
|
|
mSolo.typeText(0, "woot");
|
|
|
|
mAsserter.is(pager.getCurrentItem(), 0, "Searching switched to all pages tab");
|
|
|
|
mSolo.scrollToSide(Solo.LEFT);
|
|
|
|
mAsserter.is(pager.getCurrentItem(), 0, "Dragging left is not allowed when searching");
|
|
|
|
|
|
|
|
mSolo.scrollToSide(Solo.RIGHT);
|
|
|
|
mAsserter.is(pager.getCurrentItem(), 0, "Dragging right is not allowed when searching");
|
|
|
|
|
|
|
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
|
|
|
*/
|
|
|
|
}
|