Bug 949181 - Update robocop tests to get rid of dependency on HomePager.Page. r=mcomella
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 17 Dec 2013 13:34:13 -0800
changeset 160911 014d5ead8420a311e0876cb2d256b58484939b6f
parent 160910 2dd48acdb5c045c10dc8efe136686a32efd93eee
child 160912 60c16e794a1488c099261574c28da98ae0be606f
push id4023
push usermleibovic@mozilla.com
push dateTue, 17 Dec 2013 21:34:30 +0000
treeherderfx-team@014d5ead8420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs949181
milestone29.0a1
Bug 949181 - Update robocop tests to get rid of dependency on HomePager.Page. r=mcomella
mobile/android/base/tests/components/AboutHomeComponent.java
mobile/android/base/tests/testAboutHomePageNavigation.java
mobile/android/base/tests/testAboutHomeVisibility.java
--- a/mobile/android/base/tests/components/AboutHomeComponent.java
+++ b/mobile/android/base/tests/components/AboutHomeComponent.java
@@ -2,32 +2,39 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.tests.components;
 
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.*;
 
 import org.mozilla.gecko.Actions;
-import org.mozilla.gecko.home.HomePager.Page;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.tests.helpers.*;
 import org.mozilla.gecko.tests.UITestContext;
 
 import com.jayway.android.robotium.solo.Condition;
 import com.jayway.android.robotium.solo.Solo;
 
 import android.support.v4.view.PagerAdapter;
 import android.support.v4.view.ViewPager;
 import android.view.View;
 
 /**
  * A class representing any interactions that take place on the Awesomescreen.
  */
 public class AboutHomeComponent extends BaseComponent {
+    // The different types of pages that can be present on about:home
+    public enum PageType {
+        HISTORY,
+        TOP_SITES,
+        BOOKMARKS,
+        READING_LIST
+    }
+
     // TODO: Having a specific ordering of pages is prone to fail and thus temporary.
     // Hopefully the work in bug 940565 will alleviate the need for these enums.
     // Explicit ordering of HomePager pages on a phone.
     private enum PhonePage {
         HISTORY,
         TOP_SITES,
         BOOKMARKS,
         READING_LIST
@@ -48,17 +55,17 @@ public class AboutHomeComponent extends 
     public AboutHomeComponent(final UITestContext testContext) {
         super(testContext);
     }
 
     private ViewPager getHomePagerView() {
         return (ViewPager) mSolo.getView(R.id.home_pager);
     }
 
-    public AboutHomeComponent assertCurrentPage(final Page expectedPage) {
+    public AboutHomeComponent assertCurrentPage(final PageType expectedPage) {
         assertVisible();
 
         final int expectedPageIndex = getPageIndexForDevice(expectedPage.ordinal());
         assertEquals("The current HomePager page is " + expectedPage,
                      expectedPageIndex, getHomePagerView().getCurrentItem());
         return this;
     }
 
@@ -118,17 +125,17 @@ public class AboutHomeComponent extends 
             public boolean isSatisfied() {
                 return (getHomePagerView().getCurrentItem() == expectedIndex);
             }
         });
     }
 
     /**
      * Gets the page index in the device specific Page enum for the given index in the
-     * HomePager.Page enum.
+     * PageType enum.
      */
     private int getPageIndexForDevice(final int pageIndex) {
-        final String pageName = Page.values()[pageIndex].name();
+        final String pageName = PageType.values()[pageIndex].name();
         final Class devicePageEnum =
                 DeviceHelper.isTablet() ? TabletPage.class : PhonePage.class;
         return Enum.valueOf(devicePageEnum, pageName).ordinal();
     }
 }
--- a/mobile/android/base/tests/testAboutHomePageNavigation.java
+++ b/mobile/android/base/tests/testAboutHomePageNavigation.java
@@ -1,85 +1,85 @@
 package org.mozilla.gecko.tests;
 
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.*;
 
-import org.mozilla.gecko.home.HomePager.Page;
+import org.mozilla.gecko.tests.components.AboutHomeComponent.PageType;
 import org.mozilla.gecko.tests.helpers.*;
 
 /**
  * Tests functionality related to navigating between the various about:home pages.
  */
 public class testAboutHomePageNavigation extends UITest {
     // TODO: Define this test dynamically by creating dynamic representations of the Page
     // enum for both phone and tablet, then swiping through the pages. This will also
     // benefit having a HomePager with custom pages.
     public void testAboutHomePageNavigation() {
         GeckoHelper.blockForReady();
 
         mAboutHome.assertVisible()
-                  .assertCurrentPage(Page.TOP_SITES);
+                  .assertCurrentPage(PageType.TOP_SITES);
 
         mAboutHome.swipeToPageOnRight();
-        mAboutHome.assertCurrentPage(Page.BOOKMARKS);
+        mAboutHome.assertCurrentPage(PageType.BOOKMARKS);
 
         mAboutHome.swipeToPageOnRight();
-        mAboutHome.assertCurrentPage(Page.READING_LIST);
+        mAboutHome.assertCurrentPage(PageType.READING_LIST);
 
         // 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() {
         mAboutHome.swipeToPageOnRight();
-        mAboutHome.assertCurrentPage(Page.HISTORY);
+        mAboutHome.assertCurrentPage(PageType.HISTORY);
 
         // Edge case.
         mAboutHome.swipeToPageOnRight();
-        mAboutHome.assertCurrentPage(Page.HISTORY);
+        mAboutHome.assertCurrentPage(PageType.HISTORY);
 
         mAboutHome.swipeToPageOnLeft();
-        mAboutHome.assertCurrentPage(Page.READING_LIST);
+        mAboutHome.assertCurrentPage(PageType.READING_LIST);
 
         mAboutHome.swipeToPageOnLeft();
-        mAboutHome.assertCurrentPage(Page.BOOKMARKS);
+        mAboutHome.assertCurrentPage(PageType.BOOKMARKS);
 
         mAboutHome.swipeToPageOnLeft();
-        mAboutHome.assertCurrentPage(Page.TOP_SITES);
+        mAboutHome.assertCurrentPage(PageType.TOP_SITES);
 
         // Edge case.
         mAboutHome.swipeToPageOnLeft();
-        mAboutHome.assertCurrentPage(Page.TOP_SITES);
+        mAboutHome.assertCurrentPage(PageType.TOP_SITES);
     }
 
     private void helperTestPhone() {
         // Edge case.
         mAboutHome.swipeToPageOnRight();
-        mAboutHome.assertCurrentPage(Page.READING_LIST);
+        mAboutHome.assertCurrentPage(PageType.READING_LIST);
 
         mAboutHome.swipeToPageOnLeft();
-        mAboutHome.assertCurrentPage(Page.BOOKMARKS);
+        mAboutHome.assertCurrentPage(PageType.BOOKMARKS);
 
         mAboutHome.swipeToPageOnLeft();
-        mAboutHome.assertCurrentPage(Page.TOP_SITES);
+        mAboutHome.assertCurrentPage(PageType.TOP_SITES);
 
         mAboutHome.swipeToPageOnLeft();
-        mAboutHome.assertCurrentPage(Page.HISTORY);
+        mAboutHome.assertCurrentPage(PageType.HISTORY);
 
         // Edge case.
         mAboutHome.swipeToPageOnLeft();
-        mAboutHome.assertCurrentPage(Page.HISTORY);
+        mAboutHome.assertCurrentPage(PageType.HISTORY);
 
         mAboutHome.swipeToPageOnRight();
-        mAboutHome.assertCurrentPage(Page.TOP_SITES);
+        mAboutHome.assertCurrentPage(PageType.TOP_SITES);
     }
 
     // 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
--- a/mobile/android/base/tests/testAboutHomeVisibility.java
+++ b/mobile/android/base/tests/testAboutHomeVisibility.java
@@ -1,47 +1,47 @@
 package org.mozilla.gecko.tests;
 
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.*;
 
-import org.mozilla.gecko.home.HomePager.Page;
+import org.mozilla.gecko.tests.components.AboutHomeComponent.PageType;
 import org.mozilla.gecko.tests.helpers.*;
 
 /**
  * Tests the visibility of about:home after various interactions with the browser.
  */
 public class testAboutHomeVisibility extends UITest {
     public void testAboutHomeVisibility() {
         GeckoHelper.blockForReady();
 
         // Check initial state on about:home.
         mToolbar.assertTitle(StringHelper.ABOUT_HOME_TITLE);
         mAboutHome.assertVisible()
-                  .assertCurrentPage(Page.TOP_SITES);
+                  .assertCurrentPage(PageType.TOP_SITES);
 
         // Go to blank 01.
         NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_BLANK_PAGE_01_URL);
         mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
         mAboutHome.assertNotVisible();
 
         // Go to blank 02.
         NavigationHelper.enterAndLoadUrl(StringHelper.ROBOCOP_BLANK_PAGE_02_URL);
         mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
         mAboutHome.assertNotVisible();
 
         // Enter editing mode, where the about:home UI should be visible.
         mToolbar.enterEditingMode();
         mAboutHome.assertVisible()
-                  .assertCurrentPage(Page.TOP_SITES);
+                  .assertCurrentPage(PageType.TOP_SITES);
 
         // Dismiss editing mode, where the about:home UI should be gone.
         mToolbar.dismissEditingMode();
         mAboutHome.assertNotVisible();
 
         // Loading about:home should show about:home again.
         NavigationHelper.enterAndLoadUrl(StringHelper.ABOUT_HOME_URL);
         mToolbar.assertTitle(StringHelper.ABOUT_HOME_TITLE);
         mAboutHome.assertVisible()
-                  .assertCurrentPage(Page.TOP_SITES);
+                  .assertCurrentPage(PageType.TOP_SITES);
 
         // TODO: Type in a url and assert the go button is visible.
     }
 }