Bug 947550 - Wait for Gecko:DelayedStartup in testAboutHomePageNavigation. r=margaret
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 04 Feb 2014 18:57:54 -0800
changeset 169375 efedd01c7fbc4310a263d1427e850eabdd71c2bf
parent 169374 3dd09d1e89d8803c26c8a33d41dde379af7a1ccd
child 169376 34e1187b5711b438a004c1456510bdfcc241a7b4
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmargaret
bugs947550
milestone30.0a1
Bug 947550 - Wait for Gecko:DelayedStartup in testAboutHomePageNavigation. r=margaret
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. */ }
 
     protected 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 panels.
  */
 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 panels. This will also
     // benefit having a HomePager with custom panels.
     public void testAboutHomePageNavigation() {
-        GeckoHelper.blockForReady();
+        GeckoHelper.blockForDelayedStartup();
 
         mAboutHome.assertVisible()
                   .assertCurrentPanel(PanelType.TOP_SITES);
 
         mAboutHome.swipeToPanelOnRight();
         mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
 
         mAboutHome.swipeToPanelOnRight();