1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/base/tests/testAboutHomePageNavigation.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 1.4 +package org.mozilla.gecko.tests; 1.5 + 1.6 +import org.mozilla.gecko.tests.components.AboutHomeComponent.PanelType; 1.7 +import org.mozilla.gecko.tests.helpers.DeviceHelper; 1.8 +import org.mozilla.gecko.tests.helpers.GeckoHelper; 1.9 + 1.10 +/** 1.11 + * Tests functionality related to navigating between the various about:home panels. 1.12 + */ 1.13 +public class testAboutHomePageNavigation extends UITest { 1.14 + // TODO: Define this test dynamically by creating dynamic representations of the Page 1.15 + // enum for both phone and tablet, then swiping through the panels. This will also 1.16 + // benefit having a HomePager with custom panels. 1.17 + public void testAboutHomePageNavigation() { 1.18 + GeckoHelper.blockForDelayedStartup(); 1.19 + 1.20 + mAboutHome.assertVisible() 1.21 + .assertCurrentPanel(PanelType.TOP_SITES); 1.22 + 1.23 + mAboutHome.swipeToPanelOnRight(); 1.24 + mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS); 1.25 + 1.26 + mAboutHome.swipeToPanelOnRight(); 1.27 + mAboutHome.assertCurrentPanel(PanelType.READING_LIST); 1.28 + 1.29 + // Ideally these helpers would just be their own tests. However, by keeping this within 1.30 + // one method, we're saving test setUp and tearDown resources. 1.31 + if (DeviceHelper.isTablet()) { 1.32 + helperTestTablet(); 1.33 + } else { 1.34 + helperTestPhone(); 1.35 + } 1.36 + } 1.37 + 1.38 + private void helperTestTablet() { 1.39 + mAboutHome.swipeToPanelOnRight(); 1.40 + mAboutHome.assertCurrentPanel(PanelType.HISTORY); 1.41 + 1.42 + // Edge case. 1.43 + mAboutHome.swipeToPanelOnRight(); 1.44 + mAboutHome.assertCurrentPanel(PanelType.HISTORY); 1.45 + 1.46 + mAboutHome.swipeToPanelOnLeft(); 1.47 + mAboutHome.assertCurrentPanel(PanelType.READING_LIST); 1.48 + 1.49 + mAboutHome.swipeToPanelOnLeft(); 1.50 + mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS); 1.51 + 1.52 + mAboutHome.swipeToPanelOnLeft(); 1.53 + mAboutHome.assertCurrentPanel(PanelType.TOP_SITES); 1.54 + 1.55 + // Edge case. 1.56 + mAboutHome.swipeToPanelOnLeft(); 1.57 + mAboutHome.assertCurrentPanel(PanelType.TOP_SITES); 1.58 + } 1.59 + 1.60 + private void helperTestPhone() { 1.61 + // Edge case. 1.62 + mAboutHome.swipeToPanelOnRight(); 1.63 + mAboutHome.assertCurrentPanel(PanelType.READING_LIST); 1.64 + 1.65 + mAboutHome.swipeToPanelOnLeft(); 1.66 + mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS); 1.67 + 1.68 + mAboutHome.swipeToPanelOnLeft(); 1.69 + mAboutHome.assertCurrentPanel(PanelType.TOP_SITES); 1.70 + 1.71 + mAboutHome.swipeToPanelOnLeft(); 1.72 + mAboutHome.assertCurrentPanel(PanelType.HISTORY); 1.73 + 1.74 + // Edge case. 1.75 + mAboutHome.swipeToPanelOnLeft(); 1.76 + mAboutHome.assertCurrentPanel(PanelType.HISTORY); 1.77 + 1.78 + mAboutHome.swipeToPanelOnRight(); 1.79 + mAboutHome.assertCurrentPanel(PanelType.TOP_SITES); 1.80 + } 1.81 + 1.82 + // TODO: bug 943706 - reimplement this old test code. 1.83 + /* 1.84 + // Removed by Bug 896576 - [fig] Remove [getAllPagesList] from BaseTest 1.85 + // ListView list = getAllPagesList("about:firefox"); 1.86 + 1.87 + // Test normal sliding of the list left and right 1.88 + ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0); 1.89 + mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected"); 1.90 + 1.91 + int width = mDriver.getGeckoWidth() / 2; 1.92 + int y = mDriver.getGeckoHeight() / 2; 1.93 + mActions.drag(width, 0, y, y); 1.94 + mAsserter.is(pager.getCurrentItem(), 1, "Bookmarks page is selected"); 1.95 + 1.96 + mActions.drag(0, width, y, y); 1.97 + mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected"); 1.98 + 1.99 + // Test tapping on the tab strip changes tabs 1.100 + TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0); 1.101 + mSolo.clickOnView(tabwidget.getChildAt(1)); 1.102 + mAsserter.is(pager.getCurrentItem(), 1, "Clicking on tab selected bookmarks page"); 1.103 + 1.104 + // Test typing in the awesomebar changes tabs and prevents panning 1.105 + mSolo.typeText(0, "woot"); 1.106 + mAsserter.is(pager.getCurrentItem(), 0, "Searching switched to all pages tab"); 1.107 + mSolo.scrollToSide(Solo.LEFT); 1.108 + mAsserter.is(pager.getCurrentItem(), 0, "Dragging left is not allowed when searching"); 1.109 + 1.110 + mSolo.scrollToSide(Solo.RIGHT); 1.111 + mAsserter.is(pager.getCurrentItem(), 0, "Dragging right is not allowed when searching"); 1.112 + 1.113 + mActions.sendSpecialKey(Actions.SpecialKey.BACK); 1.114 + */ 1.115 +}