Reviewers: kathrin,

Description:
Delay start of history token transitions in HistoryTest.testHistory() so
that when tokens are lost during
subsequent parts of the test, History.back() does not go back too far
(i.e. before the web page containing
the test module), which would cause subsequent tests to timeout and
fail.

This change doesn't actually fix the flaky test, but it does:
- allow for other tests to proceed after this test fails
- present a consistent failure message:
Expecting token 'foo bar' after Hisotry.back(), but got:
if-you-see-this-history-went-back-too-far
rather than:
A timeout expired after 5000ms elapsed

Please review this at http://gwt-code-reviews.appspot.com/850802/show

Affected files:
  M user/test/com/google/gwt/user/client/ui/HistoryTest.java


Index: user/test/com/google/gwt/user/client/ui/HistoryTest.java
===================================================================
--- user/test/com/google/gwt/user/client/ui/HistoryTest.java    (revision 8728)
+++ user/test/com/google/gwt/user/client/ui/HistoryTest.java    (working copy)
@@ -151,7 +151,15 @@
       // History.back() is broken on Safari2, so we skip this test.
       return;
     }
-    delayTestFinish(5000);
+
+    /*
+ * Sentinel token which should only be seen if tokens are lost during the + * rest of the test. Without this, History.back() might send the browser too + * far back, i.e. back to before the web app containing our test module.
+     */
+    History.newItem("if-you-see-this-history-went-back-too-far");
+
+    delayTestFinish(10000);
     addHistoryListenerImpl(new HistoryListener() {
       private int state = 0;

@@ -179,7 +187,7 @@

           case 2: {
             if (!historyToken.equals("foo bar")) {
- fail("Expecting token 'foo bar' after back, but got: " + historyToken); + fail("Expecting token 'foo bar' after History.back(), but got: " + historyToken);
             }
             finishTest();
             break;
@@ -187,8 +195,17 @@
         }
       }
     });
-
-    History.newItem("foo bar");
+
+    /*
+ * Delay kicking off the history transitions, so safari has time to process
+     * the initial sentinel token
+     */
+    new Timer() {
+      @Override
+      public void run() {
+        History.newItem("foo bar");
+      }
+    }.schedule(5000);
   }

   /**


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to