aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2013-11-01 13:26:54 +0100
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2013-11-01 13:26:54 +0100
commitfd879510528580969e3645ee3f83a545c7ccb4e1 (patch)
tree0a83826f959af1311bcc16aa60e3e6963e520eca
parent883ffe6cd477ab52234203b48bef98d1a3475454 (diff)
downloadgwtquery-fd879510528580969e3645ee3f83a545c7ccb4e1.tar.gz
gwtquery-fd879510528580969e3645ee3f83a545c7ccb4e1.zip
Fix an effects test which was randomly failing
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java65
1 files changed, 35 insertions, 30 deletions
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java
index b71b2300..2dcefa3a 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java
@@ -15,13 +15,13 @@
*/
package com.google.gwt.query.client;
-import static com.google.gwt.query.client.GQuery.$;
-import static com.google.gwt.query.client.GQuery.$$;
-
+import static com.google.gwt.query.client.GQuery.*;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.RepeatingCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.query.client.GQuery.Offset;
-import com.google.gwt.query.client.plugins.Effects;
+import com.google.gwt.query.client.plugins.effects.Bezier.EasingCurve;
import com.google.gwt.query.client.plugins.effects.Fx.ColorFx;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing;
@@ -71,38 +71,43 @@ public class GQueryEffectsTestGwt extends GWTTestCase {
GQuery back = $("div", e);
assertEquals(0, back.size());
- g.as(Effects.Effects).clipDisappear(duration);
-
- // Check that the back div has been created
- back = $("div", e);
- assertEquals(1, back.size());
-
// Configure the max duration for this test
- delayTestFinish(duration * 2);
+ delayTestFinish(duration * 3);
// each timer calls the next one
- //final Timer timer1 = new Timer() {
- //public void run() {
+ final Timer endTimer = new Timer() {
+ public void run() {
// Check that the back div has been removed
- //GQuery back = $("div", e);
- //assertEquals(0, back.size());
+ GQuery back = $("div", e);
+ assertEquals(0, back.size());
// Check that the attribute clip has been removed
- //assertEquals("", g.css("clip"));
- //finishTest();
- //}
- //};
- final Timer timer2 = new Timer() {
- public void run() {
- // Check that the attribute clip has been set
- String re = "rect\\(\\d+px[, ]+\\d+px[, ]+\\d+px[, ]+\\d+px\\)";
- assertTrue(g.css("clip") + " does not match " + re, g.css("clip").matches(re));
+ assertTrue(g.css("clip").matches("(|auto)"));
finishTest();
- //timer1.schedule(duration/2 + 1);
}
};
+
+ Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() {
+ int c = 0;
+ // Run until we detect the rect has been changed or timeout
+ public boolean execute() {
+ String re = "rect\\(\\d+px[, ]+\\d+px[, ]+\\d+px[, ]+\\d+px\\)";
+ if (g.css("clip").matches(re)) {
+ endTimer.schedule(duration);
+ return false;
+ }
+ if (duration < (c += 10)) {
+ fail(g.css("clip") + " does not matched " + re);
+ return false;
+ }
+ return true;
+ }
+ }, 100);
+
+ g.as(Effects).clipDisappear(duration);
- // Start the first timer
- timer2.schedule(duration/2);
+ // Check that the back div has been created
+ back = $("div", e);
+ assertEquals(1, back.size());
}
public void testEffectsShouldBeQueued() {
@@ -112,7 +117,7 @@ public class GQueryEffectsTestGwt extends GWTTestCase {
final Offset o = g.offset();
final int duration = 1000;
- g.as(Effects.Effects).
+ g.as(Effects).
animate($$("left: '+=100'"), duration, Easing.LINEAR).
animate($$("top: '+=100'"), duration, Easing.LINEAR).
animate($$("left: '-=100'"), duration, Easing.LINEAR).
@@ -241,7 +246,7 @@ public class GQueryEffectsTestGwt extends GWTTestCase {
.toString());
prop1 = GQuery.$$("marginTop: '-110px', marginLeft: '-110px', top: '50%', left: '50%', width: '174px', height: '174px', padding: '20px'");
- PropertiesAnimation an = new PropertiesAnimation(Easing.SWING, g.get(0), prop1);
+ PropertiesAnimation an = new PropertiesAnimation(EasingCurve.SWING, g.get(0), prop1);
an.onStart();
an.onComplete();
@@ -352,7 +357,7 @@ public class GQueryEffectsTestGwt extends GWTTestCase {
delayTestFinish(duration * 3);
- g.as(Effects.Effects).
+ g.as(Effects).
animate($$("$width: +=100; $border: +=4"), duration, Easing.LINEAR);
final Timer timer = new Timer() {