mobile/android/base/tests/testAboutHomePageNavigation.java

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 package org.mozilla.gecko.tests;
michael@0 2
michael@0 3 import org.mozilla.gecko.tests.components.AboutHomeComponent.PanelType;
michael@0 4 import org.mozilla.gecko.tests.helpers.DeviceHelper;
michael@0 5 import org.mozilla.gecko.tests.helpers.GeckoHelper;
michael@0 6
michael@0 7 /**
michael@0 8 * Tests functionality related to navigating between the various about:home panels.
michael@0 9 */
michael@0 10 public class testAboutHomePageNavigation extends UITest {
michael@0 11 // TODO: Define this test dynamically by creating dynamic representations of the Page
michael@0 12 // enum for both phone and tablet, then swiping through the panels. This will also
michael@0 13 // benefit having a HomePager with custom panels.
michael@0 14 public void testAboutHomePageNavigation() {
michael@0 15 GeckoHelper.blockForDelayedStartup();
michael@0 16
michael@0 17 mAboutHome.assertVisible()
michael@0 18 .assertCurrentPanel(PanelType.TOP_SITES);
michael@0 19
michael@0 20 mAboutHome.swipeToPanelOnRight();
michael@0 21 mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
michael@0 22
michael@0 23 mAboutHome.swipeToPanelOnRight();
michael@0 24 mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
michael@0 25
michael@0 26 // Ideally these helpers would just be their own tests. However, by keeping this within
michael@0 27 // one method, we're saving test setUp and tearDown resources.
michael@0 28 if (DeviceHelper.isTablet()) {
michael@0 29 helperTestTablet();
michael@0 30 } else {
michael@0 31 helperTestPhone();
michael@0 32 }
michael@0 33 }
michael@0 34
michael@0 35 private void helperTestTablet() {
michael@0 36 mAboutHome.swipeToPanelOnRight();
michael@0 37 mAboutHome.assertCurrentPanel(PanelType.HISTORY);
michael@0 38
michael@0 39 // Edge case.
michael@0 40 mAboutHome.swipeToPanelOnRight();
michael@0 41 mAboutHome.assertCurrentPanel(PanelType.HISTORY);
michael@0 42
michael@0 43 mAboutHome.swipeToPanelOnLeft();
michael@0 44 mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
michael@0 45
michael@0 46 mAboutHome.swipeToPanelOnLeft();
michael@0 47 mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
michael@0 48
michael@0 49 mAboutHome.swipeToPanelOnLeft();
michael@0 50 mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
michael@0 51
michael@0 52 // Edge case.
michael@0 53 mAboutHome.swipeToPanelOnLeft();
michael@0 54 mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
michael@0 55 }
michael@0 56
michael@0 57 private void helperTestPhone() {
michael@0 58 // Edge case.
michael@0 59 mAboutHome.swipeToPanelOnRight();
michael@0 60 mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
michael@0 61
michael@0 62 mAboutHome.swipeToPanelOnLeft();
michael@0 63 mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
michael@0 64
michael@0 65 mAboutHome.swipeToPanelOnLeft();
michael@0 66 mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
michael@0 67
michael@0 68 mAboutHome.swipeToPanelOnLeft();
michael@0 69 mAboutHome.assertCurrentPanel(PanelType.HISTORY);
michael@0 70
michael@0 71 // Edge case.
michael@0 72 mAboutHome.swipeToPanelOnLeft();
michael@0 73 mAboutHome.assertCurrentPanel(PanelType.HISTORY);
michael@0 74
michael@0 75 mAboutHome.swipeToPanelOnRight();
michael@0 76 mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
michael@0 77 }
michael@0 78
michael@0 79 // TODO: bug 943706 - reimplement this old test code.
michael@0 80 /*
michael@0 81 // Removed by Bug 896576 - [fig] Remove [getAllPagesList] from BaseTest
michael@0 82 // ListView list = getAllPagesList("about:firefox");
michael@0 83
michael@0 84 // Test normal sliding of the list left and right
michael@0 85 ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
michael@0 86 mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected");
michael@0 87
michael@0 88 int width = mDriver.getGeckoWidth() / 2;
michael@0 89 int y = mDriver.getGeckoHeight() / 2;
michael@0 90 mActions.drag(width, 0, y, y);
michael@0 91 mAsserter.is(pager.getCurrentItem(), 1, "Bookmarks page is selected");
michael@0 92
michael@0 93 mActions.drag(0, width, y, y);
michael@0 94 mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected");
michael@0 95
michael@0 96 // Test tapping on the tab strip changes tabs
michael@0 97 TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
michael@0 98 mSolo.clickOnView(tabwidget.getChildAt(1));
michael@0 99 mAsserter.is(pager.getCurrentItem(), 1, "Clicking on tab selected bookmarks page");
michael@0 100
michael@0 101 // Test typing in the awesomebar changes tabs and prevents panning
michael@0 102 mSolo.typeText(0, "woot");
michael@0 103 mAsserter.is(pager.getCurrentItem(), 0, "Searching switched to all pages tab");
michael@0 104 mSolo.scrollToSide(Solo.LEFT);
michael@0 105 mAsserter.is(pager.getCurrentItem(), 0, "Dragging left is not allowed when searching");
michael@0 106
michael@0 107 mSolo.scrollToSide(Solo.RIGHT);
michael@0 108 mAsserter.is(pager.getCurrentItem(), 0, "Dragging right is not allowed when searching");
michael@0 109
michael@0 110 mActions.sendSpecialKey(Actions.SpecialKey.BACK);
michael@0 111 */
michael@0 112 }

mercurial