Revision: 6270
Author: [email protected]
Date: Wed Sep 30 16:46:38 2009
Log: Fixed the asynchronous tests where testDelayFinish(..) was not being  
called before finishTest()

Patch by: amitmanjhi,rjrjr
Review by: rjrjr,amitmanjhi


http://code.google.com/p/google-web-toolkit/source/detail?r=6270

Modified:
  /trunk/user/javadoc/com/google/gwt/examples/AsyncJUnitExample.java
  /trunk/user/test/com/google/gwt/animation/client/AnimationTest.java
  /trunk/user/test/com/google/gwt/dev/jjs/test/RunAsyncFailureTest.java
  /trunk/user/test/com/google/gwt/resources/client/ImageResourceTest.java
  /trunk/user/test/com/google/gwt/resources/client/TextResourceTest.java
  /trunk/user/test/com/google/gwt/user/client/CommandExecutorTest.java
  /trunk/user/test/com/google/gwt/user/client/CookieTest.java
  /trunk/user/test/com/google/gwt/user/client/WindowTest.java
  /trunk/user/test/com/google/gwt/user/client/rpc/InheritanceTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/DialogBoxTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/DisclosurePanelTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/HistoryTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/ImageTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/ListBoxTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/MenuBarTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/RichTextAreaTest.java
  /trunk/user/test/com/google/gwt/user/client/ui/TabPanelTest.java

=======================================
--- /trunk/user/javadoc/com/google/gwt/examples/AsyncJUnitExample.java  Thu  
Nov 20 14:17:44 2008
+++ /trunk/user/javadoc/com/google/gwt/examples/AsyncJUnitExample.java  Wed  
Sep 30 16:46:38 2009
@@ -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);
    }
=======================================
--- /trunk/user/test/com/google/gwt/animation/client/AnimationTest.java Wed  
May 21 14:20:27 2008
+++ /trunk/user/test/com/google/gwt/animation/client/AnimationTest.java Wed  
Sep 30 16:46:38 2009
@@ -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);
    }
  }
=======================================
--- /trunk/user/test/com/google/gwt/dev/jjs/test/RunAsyncFailureTest.java       
 
Tue Apr 28 08:49:38 2009
+++ /trunk/user/test/com/google/gwt/dev/jjs/test/RunAsyncFailureTest.java       
 
Wed Sep 30 16:46:38 2009
@@ -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) {
=======================================
--- /trunk/user/test/com/google/gwt/resources/client/ImageResourceTest.java     
 
Mon Aug 31 07:42:01 2009
+++ /trunk/user/test/com/google/gwt/resources/client/ImageResourceTest.java     
 
Wed Sep 30 16:46:38 2009
@@ -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() {
=======================================
--- /trunk/user/test/com/google/gwt/resources/client/TextResourceTest.java      
 
Thu Sep  3 10:59:12 2009
+++ /trunk/user/test/com/google/gwt/resources/client/TextResourceTest.java      
 
Wed Sep 30 16:46:38 2009
@@ -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);
    }

=======================================
--- /trunk/user/test/com/google/gwt/user/client/CommandExecutorTest.java        
 
Mon May 18 11:47:32 2009
+++ /trunk/user/test/com/google/gwt/user/client/CommandExecutorTest.java        
 
Wed Sep 30 16:46:38 2009
@@ -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());
        }
      };
=======================================
--- /trunk/user/test/com/google/gwt/user/client/CookieTest.java Tue Sep  1  
10:44:31 2009
+++ /trunk/user/test/com/google/gwt/user/client/CookieTest.java Wed Sep 30  
16:46:38 2009
@@ -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);
    }

    /**
=======================================
--- /trunk/user/test/com/google/gwt/user/client/WindowTest.java Thu Jul 30  
13:47:31 2009
+++ /trunk/user/test/com/google/gwt/user/client/WindowTest.java Wed Sep 30  
16:46:38 2009
@@ -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);
    }

    /**
=======================================
--- /trunk/user/test/com/google/gwt/user/client/rpc/InheritanceTest.java        
 
Mon Jul  6 16:17:17 2009
+++ /trunk/user/test/com/google/gwt/user/client/rpc/InheritanceTest.java        
 
Wed Sep 30 16:46:38 2009
@@ -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() {
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/DialogBoxTest.java   Thu  
Jul 30 13:47:31 2009
+++ /trunk/user/test/com/google/gwt/user/client/ui/DialogBoxTest.java   Wed  
Sep 30 16:46:38 2009
@@ -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
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/DisclosurePanelTest.java     
 
Wed Sep 23 10:15:52 2009
+++ /trunk/user/test/com/google/gwt/user/client/ui/DisclosurePanelTest.java     
 
Wed Sep 30 16:46:38 2009
@@ -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() {
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/HistoryTest.java     Thu Jul 
 
30 13:47:31 2009
+++ /trunk/user/test/com/google/gwt/user/client/ui/HistoryTest.java     Wed Sep 
 
30 16:46:38 2009
@@ -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");
    }

=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/ImageTest.java       Thu Jul 
 
30 13:47:31 2009
+++ /trunk/user/test/com/google/gwt/user/client/ui/ImageTest.java       Wed Sep 
 
30 16:46:38 2009
@@ -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);
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/ListBoxTest.java     Tue  
Feb  5 11:36:45 2008
+++ /trunk/user/test/com/google/gwt/user/client/ui/ListBoxTest.java     Wed Sep 
 
30 16:46:38 2009
@@ -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() {
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/MenuBarTest.java     Thu Jul 
 
30 13:47:31 2009
+++ /trunk/user/test/com/google/gwt/user/client/ui/MenuBarTest.java     Wed Sep 
 
30 16:46:38 2009
@@ -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);
    }

    /**
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java       Wed Sep 
 
23 10:15:52 2009
+++ /trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java       Wed Sep 
 
30 16:46:38 2009
@@ -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);
    }
  }
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/RichTextAreaTest.java        
 
Wed Sep 23 13:12:51 2009
+++ /trunk/user/test/com/google/gwt/user/client/ui/RichTextAreaTest.java        
 
Wed Sep 30 16:46:38 2009
@@ -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);
    }
  }
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/TabPanelTest.java    Wed  
Sep 23 10:15:52 2009
+++ /trunk/user/test/com/google/gwt/user/client/ui/TabPanelTest.java    Wed  
Sep 30 16:46:38 2009
@@ -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);
    }


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

Reply via email to