Fixed the asynchronous tests where testDelayFinish(..) was not being called before finishTest()
Patch by: amitmanjhi,rjrjr
Review by: rjrjr,amitmanjhi
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6270 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/javadoc/com/google/gwt/examples/AsyncJUnitExample.java b/user/javadoc/com/google/gwt/examples/AsyncJUnitExample.java
index fb73afb..275ff84 100644
--- a/user/javadoc/com/google/gwt/examples/AsyncJUnitExample.java
+++ b/user/javadoc/com/google/gwt/examples/AsyncJUnitExample.java
@@ -30,6 +30,11 @@
* Tests the Timer class asynchronously.
*/
public void testTimer() {
+
+ // Set a delay period significantly longer than the
+ // event is expected to take.
+ delayTestFinish(500);
+
// Setup an asynchronous event handler.
Timer timer = new Timer() {
@Override
@@ -41,10 +46,6 @@
}
};
- // Set a delay period significantly longer than the
- // event is expected to take.
- delayTestFinish(500);
-
// Schedule the event and return control to the test system.
timer.schedule(100);
}
diff --git a/user/test/com/google/gwt/animation/client/AnimationTest.java b/user/test/com/google/gwt/animation/client/AnimationTest.java
index 1ed09cf..1249dfc 100644
--- a/user/test/com/google/gwt/animation/client/AnimationTest.java
+++ b/user/test/com/google/gwt/animation/client/AnimationTest.java
@@ -141,6 +141,7 @@
public void testCancelBeforeStarted() {
final TestAnimation anim = new TestAnimation();
double curTime = Duration.currentTimeMillis();
+ delayTestFinish(20 * DELAY_MULTIPLIER);
anim.run(10 * DELAY_MULTIPLIER, curTime + 10 * DELAY_MULTIPLIER);
// Check progress
@@ -168,9 +169,6 @@
finishTest();
}
}.schedule(15 * DELAY_MULTIPLIER);
-
- // Wait for test to finish
- delayTestFinish(20 * DELAY_MULTIPLIER);
}
/**
@@ -178,6 +176,7 @@
*/
public void testCancelWhenComplete() {
final TestAnimation anim = new TestAnimation();
+ delayTestFinish(25 * DELAY_MULTIPLIER);
anim.run(10 * DELAY_MULTIPLIER);
// Check progress
@@ -204,9 +203,6 @@
finishTest();
}
}.schedule(20 * DELAY_MULTIPLIER);
-
- // Wait for test to finish
- delayTestFinish(25 * DELAY_MULTIPLIER);
}
/**
@@ -214,6 +210,7 @@
*/
public void testCancelWhileRunning() {
final TestAnimation anim = new TestAnimation();
+ delayTestFinish(20 * DELAY_MULTIPLIER);
anim.run(50 * DELAY_MULTIPLIER);
// Check progress
@@ -239,9 +236,6 @@
finishTest();
}
}.schedule(15 * DELAY_MULTIPLIER);
-
- // Wait for test to finish
- delayTestFinish(20 * DELAY_MULTIPLIER);
}
/**
@@ -328,6 +322,7 @@
final TestAnimation animPast = new TestAnimation();
final TestAnimation animFuture = new TestAnimation();
+ delayTestFinish(50 * DELAY_MULTIPLIER);
// Run animations
double curTime = Duration.currentTimeMillis();
animNow.run(30 * DELAY_MULTIPLIER);
@@ -416,8 +411,6 @@
animFuture.assertStarted(true);
animFuture.assertCompleted(false);
animFuture.assertProgressRange(0.0, 1.0);
-
- finishTest();
}
}.schedule(35 * DELAY_MULTIPLIER);
@@ -440,8 +433,5 @@
finishTest();
}
}.schedule(45 * DELAY_MULTIPLIER);
-
- // Wait for the test to finish
- delayTestFinish(50 * DELAY_MULTIPLIER);
}
}
diff --git a/user/test/com/google/gwt/dev/jjs/test/RunAsyncFailureTest.java b/user/test/com/google/gwt/dev/jjs/test/RunAsyncFailureTest.java
index 26357df..05e80d0 100644
--- a/user/test/com/google/gwt/dev/jjs/test/RunAsyncFailureTest.java
+++ b/user/test/com/google/gwt/dev/jjs/test/RunAsyncFailureTest.java
@@ -46,7 +46,7 @@
}
// Repeated runAsync using a Timer
- public void runAsync1(final int attempt) {
+ private void runAsync1(final int attempt) {
log("runAsync1: attempt = " + attempt);
GWT.runAsync(new MyRunAsyncCallback() {
public void onFailure(Throwable caught) {
diff --git a/user/test/com/google/gwt/resources/client/ImageResourceTest.java b/user/test/com/google/gwt/resources/client/ImageResourceTest.java
index 21e53fe..9da158a 100644
--- a/user/test/com/google/gwt/resources/client/ImageResourceTest.java
+++ b/user/test/com/google/gwt/resources/client/ImageResourceTest.java
@@ -113,6 +113,7 @@
assertEquals(a.getLeft(), b.getTop());
assertEquals(a.getLeft(), c.getTop());
+ delayTestFinish(1000);
// See if the size of the image strip is what we expect
Image i = new Image(a.getURL());
i.addLoadHandler(new LoadHandler() {
@@ -127,7 +128,6 @@
});
RootPanel.get().add(i);
- delayTestFinish(1000);
}
public void testPacking() {
diff --git a/user/test/com/google/gwt/resources/client/TextResourceTest.java b/user/test/com/google/gwt/resources/client/TextResourceTest.java
index 2b4ad40..2c9093f 100644
--- a/user/test/com/google/gwt/resources/client/TextResourceTest.java
+++ b/user/test/com/google/gwt/resources/client/TextResourceTest.java
@@ -47,6 +47,8 @@
public void testExternal() throws ResourceException {
final Resources r = GWT.create(Resources.class);
+ delayTestFinish(2000);
+
ResourceCallback<TextResource> c = new ResourceCallback<TextResource>() {
public void onError(ResourceException e) {
@@ -61,7 +63,6 @@
}
};
- delayTestFinish(2000);
r.helloWorldExternal().getText(c);
}
diff --git a/user/test/com/google/gwt/user/client/CommandExecutorTest.java b/user/test/com/google/gwt/user/client/CommandExecutorTest.java
index ca18dc7..1e970d9 100644
--- a/user/test/com/google/gwt/user/client/CommandExecutorTest.java
+++ b/user/test/com/google/gwt/user/client/CommandExecutorTest.java
@@ -114,13 +114,13 @@
}
});
+ delayTestFinish(TEST_FINISH_DELAY_MILLIS);
ce.submit(new Command() {
public void execute() {
finishTest();
}
});
- delayTestFinish(TEST_FINISH_DELAY_MILLIS);
ce.doExecuteCommands(Duration.currentTimeMillis());
}
};
diff --git a/user/test/com/google/gwt/user/client/CookieTest.java b/user/test/com/google/gwt/user/client/CookieTest.java
index 7ecef1b..a51ef3d 100644
--- a/user/test/com/google/gwt/user/client/CookieTest.java
+++ b/user/test/com/google/gwt/user/client/CookieTest.java
@@ -76,6 +76,7 @@
Cookies.setCookie(lateCookie, "late", expiresLate);
Cookies.setCookie(sessionCookie, "forever", null);
+ delayTestFinish(6 * 1000);
// Wait until the cookie expires before checking it
Timer timer = new Timer() {
@Override
@@ -96,7 +97,6 @@
}
};
timer.schedule(5010);
- delayTestFinish(6 * 1000);
}
/**
diff --git a/user/test/com/google/gwt/user/client/WindowTest.java b/user/test/com/google/gwt/user/client/WindowTest.java
index f25219c..b50e698 100644
--- a/user/test/com/google/gwt/user/client/WindowTest.java
+++ b/user/test/com/google/gwt/user/client/WindowTest.java
@@ -149,6 +149,7 @@
final Label largeDOM = new Label();
largeDOM.setPixelSize(oldClientWidth + 100, oldClientHeight + 100);
RootPanel.get().add(largeDOM);
+ delayTestFinish(200);
DeferredCommand.addCommand(new Command() {
public void execute() {
int newClientHeight = Window.getClientHeight();
@@ -159,7 +160,6 @@
finishTest();
}
});
- delayTestFinish(200);
}
/**
diff --git a/user/test/com/google/gwt/user/client/rpc/InheritanceTest.java b/user/test/com/google/gwt/user/client/rpc/InheritanceTest.java
index 6023899..6544b75 100644
--- a/user/test/com/google/gwt/user/client/rpc/InheritanceTest.java
+++ b/user/test/com/google/gwt/user/client/rpc/InheritanceTest.java
@@ -180,6 +180,7 @@
}
public void testSerializationExceptionPreventsCall() {
+ delayTestFinish(TEST_DELAY);
final boolean serializationExceptionCaught[] = new boolean[1];
new Timer() {
@Override
@@ -189,7 +190,6 @@
finishTest();
}
}.schedule(TEST_DELAY / 2);
- delayTestFinish(TEST_DELAY);
InheritanceTestServiceAsync service = getServiceAsync();
service.echo(new AnonymousClassInterface() {
diff --git a/user/test/com/google/gwt/user/client/ui/DialogBoxTest.java b/user/test/com/google/gwt/user/client/ui/DialogBoxTest.java
index d794eea..3cc558c 100644
--- a/user/test/com/google/gwt/user/client/ui/DialogBoxTest.java
+++ b/user/test/com/google/gwt/user/client/ui/DialogBoxTest.java
@@ -102,6 +102,7 @@
UIObjectTest.assertDebugId("myDialogBox-content",
DOM.getParent(content.getElement()));
+ delayTestFinish(250);
// Check the header IDs
DeferredCommand.addCommand(new Command() {
public void execute() {
@@ -110,7 +111,6 @@
finishTest();
}
});
- delayTestFinish(250);
}
@Override
diff --git a/user/test/com/google/gwt/user/client/ui/DisclosurePanelTest.java b/user/test/com/google/gwt/user/client/ui/DisclosurePanelTest.java
index 8e12014..98f8eb5 100644
--- a/user/test/com/google/gwt/user/client/ui/DisclosurePanelTest.java
+++ b/user/test/com/google/gwt/user/client/ui/DisclosurePanelTest.java
@@ -48,6 +48,7 @@
panel.setOpen(true);
+ delayTestFinish(500);
// Allow the animation time to finish
Timer t = new Timer() {
@Override
@@ -59,7 +60,6 @@
}
};
t.schedule(450);
- delayTestFinish(500);
}
public void testAttachDetachOrder() {
diff --git a/user/test/com/google/gwt/user/client/ui/HistoryTest.java b/user/test/com/google/gwt/user/client/ui/HistoryTest.java
index 34f5373..0d1bd85 100644
--- a/user/test/com/google/gwt/user/client/ui/HistoryTest.java
+++ b/user/test/com/google/gwt/user/client/ui/HistoryTest.java
@@ -125,6 +125,7 @@
* Verify that no events are issued via newItem if there were not reqeuested.
*/
public void testNoEvents() {
+ delayTestFinish(5000);
addHistoryListenerImpl(new HistoryListener() {
{
timer = new Timer() {
@@ -139,7 +140,6 @@
fail("onHistoryChanged should not have been called");
}
});
- delayTestFinish(5000);
History.newItem("testNoEvents", false);
}
@@ -197,9 +197,10 @@
* called once per {@link History#newItem(String)}.
*/
public void testHistoryChangedCount() {
+ delayTestFinish(5000);
timer = new Timer() {
private int count = 0;
-
+
public void run() {
if (count++ == 0) {
// verify that duplicates don't issue another event
@@ -222,7 +223,6 @@
timer.schedule(500);
}
});
- delayTestFinish(5000);
History.newItem("testHistoryChangedCount");
}
diff --git a/user/test/com/google/gwt/user/client/ui/ImageTest.java b/user/test/com/google/gwt/user/client/ui/ImageTest.java
index fdb9873..62d5cda 100644
--- a/user/test/com/google/gwt/user/client/ui/ImageTest.java
+++ b/user/test/com/google/gwt/user/client/ui/ImageTest.java
@@ -99,6 +99,7 @@
final Image image = new Image("counting-forwards.png", 12, 13, 8, 8);
assertEquals("clipped", getCurrentImageStateName(image));
+ delayTestFinish(5000);
image.addLoadListener(new LoadListener() {
private int onLoadEventCount = 0;
@@ -121,7 +122,6 @@
}
});
- delayTestFinish(5000);
RootPanel.get().add(image);
}
@@ -134,6 +134,7 @@
final Image image = new Image("counting-forwards.png");
assertEquals("unclipped", getCurrentImageStateName(image));
+ delayTestFinish(5000);
image.addLoadListener(new LoadListener() {
private int onLoadEventCount = 0;
@@ -157,7 +158,6 @@
}
});
- delayTestFinish(5000);
RootPanel.get().add(image);
}
@@ -169,6 +169,7 @@
public void disabledTestCreateImage() {
final Image image = new Image("counting-forwards.png");
+ delayTestFinish(5000);
image.addLoadListener(new LoadListener() {
private int onLoadEventCount = 0;
@@ -185,7 +186,6 @@
}
});
- delayTestFinish(5000);
RootPanel.get().add(image);
assertEquals(0, image.getOriginLeft());
assertEquals(0, image.getOriginTop());
@@ -202,6 +202,7 @@
public void disabledTestSetUrlAndLoadEventsOnUnclippedImage() {
final Image image = new Image();
+ delayTestFinish(5000);
image.addLoadListener(new LoadListener() {
private int onLoadEventCount = 0;
@@ -218,7 +219,6 @@
}
});
- delayTestFinish(5000);
RootPanel.get().add(image);
image.setUrl("counting-backwards.png");
}
@@ -233,6 +233,7 @@
public void disabledTestSetUrlAndVisibleRectOnUnclippedImage() {
final Image image = new Image("counting-backwards.png");
+ delayTestFinish(5000);
image.addLoadListener(new LoadListener() {
private int onLoadEventCount = 0;
@@ -256,7 +257,6 @@
}
});
- delayTestFinish(5000);
RootPanel.get().add(image);
assertEquals("unclipped", getCurrentImageStateName(image));
}
@@ -273,6 +273,7 @@
public void testCreateClippedImage() {
final Image image = new Image("counting-forwards.png", 16, 16, 16, 16);
+ delayTestFinish(5000);
final TestLoadListener listener = new TestLoadListener(image) {
private int onLoadEventCount = 0;
@@ -303,7 +304,6 @@
});
image.addErrorHandler(new TestErrorHandler(image));
- delayTestFinish(5000);
RootPanel.get().add(image);
assertEquals(16, image.getOriginLeft());
assertEquals(16, image.getOriginTop());
@@ -344,6 +344,7 @@
@DoNotRunWith({Platform.Htmlunit})
public void testSetUrlAndVisibleRectOnClippedImage() {
final Image image = new Image("counting-backwards.png", 12, 12, 12, 12);
+ delayTestFinish(5000);
final TestLoadListener listener = new TestLoadListener(image) {
private int onLoadEventCount = 0;
@@ -381,7 +382,6 @@
});
image.addErrorHandler(new TestErrorHandler(image));
- delayTestFinish(5000);
RootPanel.get().add(image);
assertEquals("clipped", getCurrentImageStateName(image));
image.setUrlAndVisibleRect("counting-forwards.png", 0, 16, 16, 16);
@@ -396,6 +396,7 @@
public void testSetVisibleRectAndLoadEventsOnClippedImage() {
final Image image = new Image("counting-backwards.png", 16, 16, 16, 16);
+ delayTestFinish(5000);
final TestLoadListener listener = new TestLoadListener(image) {
private int onLoadEventCount = 0;
@@ -422,7 +423,6 @@
});
image.addErrorHandler(new TestErrorHandler(image));
- delayTestFinish(5000);
RootPanel.get().add(image);
image.setVisibleRect(0, 0, 16, 16);
image.setVisibleRect(0, 0, 16, 16);
diff --git a/user/test/com/google/gwt/user/client/ui/ListBoxTest.java b/user/test/com/google/gwt/user/client/ui/ListBoxTest.java
index 5b116de..97e9501 100644
--- a/user/test/com/google/gwt/user/client/ui/ListBoxTest.java
+++ b/user/test/com/google/gwt/user/client/ui/ListBoxTest.java
@@ -49,6 +49,7 @@
list.ensureDebugId("myList");
UIObjectTest.assertDebugId("myList", list.getElement());
+ delayTestFinish(250);
DeferredCommand.addCommand(new Command() {
public void execute() {
UIObjectTest.assertDebugIdContents("myList-item0", "option0");
@@ -58,7 +59,6 @@
finishTest();
}
});
- delayTestFinish(250);
}
public void testInsert() {
diff --git a/user/test/com/google/gwt/user/client/ui/MenuBarTest.java b/user/test/com/google/gwt/user/client/ui/MenuBarTest.java
index 1785aeb..a33f64c 100644
--- a/user/test/com/google/gwt/user/client/ui/MenuBarTest.java
+++ b/user/test/com/google/gwt/user/client/ui/MenuBarTest.java
@@ -236,6 +236,7 @@
bar.ensureDebugId("myMenu");
UIObjectTest.assertDebugId("myMenu", bar.getElement());
+ delayTestFinish(250);
DeferredCommand.addCommand(new Command() {
public void execute() {
UIObjectTest.assertDebugIdContents("myMenu-item0", "top0");
@@ -248,7 +249,6 @@
finishTest();
}
});
- delayTestFinish(250);
}
/**
diff --git a/user/test/com/google/gwt/user/client/ui/PopupTest.java b/user/test/com/google/gwt/user/client/ui/PopupTest.java
index 0ec6231..eb64dc0 100644
--- a/user/test/com/google/gwt/user/client/ui/PopupTest.java
+++ b/user/test/com/google/gwt/user/client/ui/PopupTest.java
@@ -333,6 +333,7 @@
}
}.schedule(1000);
+ delayTestFinish(5000);
// Give time for any errors to occur
new Timer() {
@Override
@@ -340,7 +341,5 @@
finishTest();
}
}.schedule(2000);
-
- delayTestFinish(5000);
}
}
diff --git a/user/test/com/google/gwt/user/client/ui/RichTextAreaTest.java b/user/test/com/google/gwt/user/client/ui/RichTextAreaTest.java
index e0de2c4..eaae8cb 100644
--- a/user/test/com/google/gwt/user/client/ui/RichTextAreaTest.java
+++ b/user/test/com/google/gwt/user/client/ui/RichTextAreaTest.java
@@ -228,6 +228,7 @@
public void testSetTextBeforeInit() {
final RichTextArea richTextArea = new RichTextArea();
richTextArea.setText("foo");
+ delayTestFinish(RICH_TEXT_ASYNC_DELAY);
richTextArea.addInitializeHandler(new InitializeHandler() {
public void onInitialize(InitializeEvent event) {
assertEquals("foo", richTextArea.getText());
@@ -236,6 +237,5 @@
});
RootPanel.get().add(richTextArea);
assertEquals("foo", richTextArea.getText());
- delayTestFinish(RICH_TEXT_ASYNC_DELAY);
}
}
diff --git a/user/test/com/google/gwt/user/client/ui/TabPanelTest.java b/user/test/com/google/gwt/user/client/ui/TabPanelTest.java
index 75c634e..0db70a3 100644
--- a/user/test/com/google/gwt/user/client/ui/TabPanelTest.java
+++ b/user/test/com/google/gwt/user/client/ui/TabPanelTest.java
@@ -202,6 +202,7 @@
p.add(new Button("foo"), "foo");
p.add(new Button("bar"), "bar");
+ this.delayTestFinish(1000);
// Make sure selecting a tab fires both events in the right order.
p.addTabListener(new TabListener() {
private boolean onBeforeFired;
@@ -217,7 +218,6 @@
}
});
- this.delayTestFinish(1000);
p.selectTab(1);
}