mobile/android/base/tests/testAboutHomePageNavigation.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

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

mercurial