Bug 947550 - Wait for Gecko:DelayedStartup in testAboutHomePageNavigation. r=margaret, a=test-only
☠☠ backed out by 3ee550e22c98 ☠ ☠
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 04 Feb 2014 18:57:54 -0800
changeset 176326 8fbd24c57aea79dc65e02b2e760ac79c10a8c216
parent 176325 c9caee36b9d3248e74bc72499a202a795121db75
child 176327 3ee550e22c985677a693eef969e13900feb95f91
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, test-only
bugs947550
milestone28.0
Bug 947550 - Wait for Gecko:DelayedStartup in testAboutHomePageNavigation. r=margaret, a=test-only
mobile/android/base/tests/helpers/GeckoHelper.java
mobile/android/base/tests/testAboutHomePageNavigation.java
--- a/mobile/android/base/tests/helpers/GeckoHelper.java
+++ b/mobile/android/base/tests/helpers/GeckoHelper.java
@@ -22,18 +22,30 @@ public final class GeckoHelper {
     private GeckoHelper() { /* To disallow instantiation. */ }
 
     public static void init(final UITestContext context) {
         sActivity = context.getActivity();
         sActions = context.getActions();
     }
 
     public static void blockForReady() {
-        final EventExpecter geckoReady = sActions.expectGeckoEvent("Gecko:Ready");
+        blockForEvent("Gecko:Ready");
+    }
 
-        final boolean isReady = GeckoThread.checkLaunchState(LaunchState.GeckoRunning);
-        if (!isReady) {
-            geckoReady.blockForEvent();
+    /**
+     * Blocks for the "Gecko:DelayedStartup" event, which occurs after "Gecko:Ready" and the
+     * first page load.
+     */
+    public static void blockForDelayedStartup() {
+        blockForEvent("Gecko:DelayedStartup");
+    }
+
+    private static void blockForEvent(final String eventName) {
+        final EventExpecter eventExpecter = sActions.expectGeckoEvent(eventName);
+
+        final boolean isRunning = GeckoThread.checkLaunchState(LaunchState.GeckoRunning);
+        if (!isRunning) {
+            eventExpecter.blockForEvent();
         }
 
-        geckoReady.unregisterListener();
+        eventExpecter.unregisterListener();
     }
 }
--- a/mobile/android/base/tests/testAboutHomePageNavigation.java
+++ b/mobile/android/base/tests/testAboutHomePageNavigation.java
@@ -8,17 +8,17 @@ 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();
+        GeckoHelper.blockForDelayedStartup();
 
         mAboutHome.assertVisible()
                   .assertCurrentPage(Page.TOP_SITES);
 
         mAboutHome.swipeToPageOnRight();
         mAboutHome.assertCurrentPage(Page.BOOKMARKS);
 
         mAboutHome.swipeToPageOnRight();