Bug 906662 - Fix openAboutHomeTab to work witht he new Tablet UI (r=lucasr)
authorAdrian Tamas <adrian.tamas@softvision.ro>
Mon, 19 Aug 2013 16:56:20 +0300
changeset 143563 1d639fdd1f261e587e0ab701fa392db8fb2d0849
parent 143562 cb129e23e51439d47b1b6f626daa500c3d272366
child 143564 20273eaf47db49bdf84dbb1f2042c1e85035ddd4
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs906662
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 906662 - Fix openAboutHomeTab to work witht he new Tablet UI (r=lucasr)
mobile/android/base/tests/AboutHomeTest.java.in
--- a/mobile/android/base/tests/AboutHomeTest.java.in
+++ b/mobile/android/base/tests/AboutHomeTest.java.in
@@ -302,67 +302,74 @@ abstract class AboutHomeTest extends Bas
             return true;
         } else {
             clickOnButton("Cancel");
             waitForText("about:home");
             return false;
         }
     }
 
+   // A wait in order for the about:home tab to be rendered after drag/tab selection
+    private void waitForAboutHomeTab(final int tabIndex) {
+        boolean correctTab = waitForTest(new BooleanTest() {
+            @Override
+            public boolean test() {
+              ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
+              return (pager.getCurrentItem() == tabIndex);
+            }
+        }, MAX_WAIT_MS);
+        mAsserter.ok(correctTab, "Checking that the correct tab is displayed", "The " + aboutHomeTabs.get(tabIndex) + " tab is displayed");
+    }
+ 
     /**
      * This method can be used to open the different tabs of about:home
      * @param AboutHomeTabs enum item {MOST_VISITED, MOST_RECENT, TABS_FROM_LAST_TIME, BOOKMARKS, READING_LIST}
      */
     protected void openAboutHomeTab(AboutHomeTabs tab) {
         int halfWidth = mDriver.getGeckoWidth() / 2;
         int halfHeight = mDriver.getGeckoHeight() / 2;
         focusUrlBar();
         ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
         switch (tab) {
             case BOOKMARKS : {
-                 mSolo.clickOnText(BOOKMARKS_LABEL);
-                 waitForEnabledText(BOOKMARKS_LABEL);
-                 mAsserter.is(pager.getCurrentItem(), aboutHomeTabs.indexOf(tab.toString()), "Bookmarks page is selected");
-                 break;
+                mSolo.clickOnText(BOOKMARKS_LABEL);
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(tab.toString()));
+                break;
             }
             case MOST_RECENT: {
                 mSolo.clickOnText(BOOKMARKS_LABEL);
-                waitForEnabledText(BOOKMARKS_LABEL);
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(BOOKMARKS_LABEL));
                 mActions.drag(0, halfWidth, halfHeight, halfHeight);
-                waitForEnabledText(HISTORY_LABEL);
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(HISTORY_LABEL));
                 TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
-                mAsserter.is(pager.getCurrentItem(), aboutHomeTabs.indexOf(HISTORY_LABEL), "The history tab is selected");
                 mSolo.clickOnView(tabwidget.getChildAt(1));
                 mAsserter.ok(waitForText(MOST_RECENT_LABEL), "Checking that we are in the most recent tab of about:home", "We are in the most recent tab");
                 break;
             }
             case READING_LIST: {
                 mSolo.clickOnText(BOOKMARKS_LABEL);
-                waitForEnabledText(BOOKMARKS_LABEL);
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(BOOKMARKS_LABEL));
                 mActions.drag(halfWidth, 0, halfHeight, halfHeight);
-                waitForEnabledText(READING_LIST_LABEL);
-                mAsserter.is(pager.getCurrentItem(), aboutHomeTabs.indexOf(tab.toString()), "Reading List is selected");
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(tab.toString()));
                 break;
             }
             case MOST_VISITED: {
                 mSolo.clickOnText(BOOKMARKS_LABEL);
-                waitForEnabledText(BOOKMARKS_LABEL);
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(BOOKMARKS_LABEL));
                 mActions.drag(0, halfWidth, halfHeight, halfHeight);
-                waitForEnabledText(HISTORY_LABEL);
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(HISTORY_LABEL));
                 TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
-                mAsserter.is(pager.getCurrentItem(), aboutHomeTabs.indexOf(HISTORY_LABEL), "The history tab is selected");
                 mSolo.clickOnView(tabwidget.getChildAt(0));
                 break;
             }
             case TABS_FROM_LAST_TIME: {
                 mSolo.clickOnText(BOOKMARKS_LABEL);
-                waitForEnabledText(BOOKMARKS_LABEL);
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(BOOKMARKS_LABEL));
                 mActions.drag(0, halfWidth, halfHeight, halfHeight);
-                waitForEnabledText(HISTORY_LABEL);
+                waitForAboutHomeTab(aboutHomeTabs.indexOf(HISTORY_LABEL));
                 TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
-                mAsserter.is(pager.getCurrentItem(), aboutHomeTabs.indexOf(HISTORY_LABEL), "The history tab is selected");
                 mSolo.clickOnView(tabwidget.getChildAt(2));
                 mAsserter.ok(waitForText(TABS_FROM_LAST_TIME_LABEL), "Checking that we are in the Tabs from last time tab of about:home", "We are in the Tabs from last time tab");
                 break;
             }
         }
     }
 }