Revision: 8744
Author: fre...@google.com
Date: Thu Sep  9 17:05:41 2010
Log: 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 hopefully:
- 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-then-history-went-back-too-far
rather than:
A timeout expired after 5000ms elapsed
Review by: kpro...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=8744

Modified:
 /trunk/user/test/com/google/gwt/user/client/ui/HistoryTest.java

=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/HistoryTest.java Thu Mar 25 10:46:07 2010 +++ /trunk/user/test/com/google/gwt/user/client/ui/HistoryTest.java Thu Sep 9 17:05:41 2010
@@ -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-then-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 the browser 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