Bug 943705 - Aggregate countdown timer in waitForPageLoad. r=mcomella
authorIsura Edirisinghe <isurae@gmail.com>
Wed, 30 Apr 2014 14:11:31 -0700
changeset 181568 51c6a235e6214e21838bcbe5eed754ddf4c002cf
parent 181567 4253ca7dfe1a7940c4463991fafe1049c8a5c40a
child 181569 f84446d45985b104eafa8e8be253a00a177281f9
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersmcomella
bugs943705
milestone32.0a1
Bug 943705 - Aggregate countdown timer in waitForPageLoad. r=mcomella
mobile/android/base/tests/helpers/WaitHelper.java
--- a/mobile/android/base/tests/helpers/WaitHelper.java
+++ b/mobile/android/base/tests/helpers/WaitHelper.java
@@ -95,27 +95,31 @@ public final class WaitHelper {
         // PAGE_LOAD_WAIT_MS is the total time we wait for all events to finish.
         final long expecterStartMillis = SystemClock.uptimeMillis();
         for (final EventExpecter expecter : eventExpecters) {
             final int eventWaitTimeMillis = PAGE_LOAD_WAIT_MS - (int)(SystemClock.uptimeMillis() - expecterStartMillis);
             expecter.blockForEventDataWithTimeout(eventWaitTimeMillis);
             expecter.unregisterListener();
         }
 
+        // The timeout wait time should be the aggregate time for all ChangeVerifiers.
+        final long verifierStartMillis = SystemClock.uptimeMillis();
+
         // Verify remaining state has changed.
         for (final ChangeVerifier verifier : pageLoadVerifiers) {
             // If we timeout, either the state is set to the same value (which is fine), or
             // the state has not yet changed. Since we can't be sure it will ever change, move
             // on and let the assertions fail if applicable.
+            final int verifierWaitMillis = CHANGE_WAIT_MS - (int)(SystemClock.uptimeMillis() - verifierStartMillis);
             final boolean hasTimedOut = !sSolo.waitForCondition(new Condition() {
                 @Override
                 public boolean isSatisfied() {
                     return verifier.hasStateChanged();
                 }
-            }, CHANGE_WAIT_MS);
+            }, verifierWaitMillis);
 
             sContext.dumpLog(verifier.getLogTag(),
                     (hasTimedOut ? "timed out." : "was satisfied."));
         }
     }
 
     /**
      * Implementations of this interface verify that the state of the test has changed from