diff options
author | Manolo Carrasco <manolo@apache.org> | 2010-05-30 09:12:41 +0000 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2010-05-30 09:12:41 +0000 |
commit | f47c9b3e4353a300fd55769bbf97ccce335dd46c (patch) | |
tree | fc059ef9dc2d9bc0a109507eef71b943567b76f8 | |
parent | 47cb10658ebdb1d65059dd82408210c05aa2a281 (diff) | |
download | gwtquery-f47c9b3e4353a300fd55769bbf97ccce335dd46c.tar.gz gwtquery-f47c9b3e4353a300fd55769bbf97ccce335dd46c.zip |
fixed the test for HtmlUnit
-rw-r--r-- | gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTest.java | 89 |
1 files changed, 52 insertions, 37 deletions
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTest.java index 05e1cca8..333092c1 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTest.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTest.java @@ -39,7 +39,7 @@ public class GQueryEffectsTest extends GWTTestCase { public String getModuleName() { return "com.google.gwt.query.Query"; } - + public void gwtSetUp() { if (e == null) { testPanel = new HTML(); @@ -52,8 +52,9 @@ public class GQueryEffectsTest extends GWTTestCase { } public void testEffects() { - $(e).html( - "<p id='id1'>Content 1</p><p id='id2'>Content 2</p><p id='id3'>Content 3</p>"); + $(e) + .html( + "<p id='id1'>Content 1</p><p id='id2'>Content 2</p><p id='id3'>Content 3</p>"); final GQuery sectA = $("#id1"); final GQuery sectB = $("#id2"); @@ -86,9 +87,13 @@ public class GQueryEffectsTest extends GWTTestCase { Timer timerShortTime = new Timer() { public void run() { double o = Double.valueOf(sectA.css("opacity")); - assertTrue("'sectA' opacity must be in the interval 0-0.5 but is: " + o, o > 0 && o < 0.5); + assertTrue( + "'sectA' opacity must be in the interval 0-0.5 but is: " + o, o > 0 + && o < 0.5); o = Double.valueOf(sectB.css("opacity")); - assertTrue("'sectB' opacity must be in the interval 0.5-1 but is: " + o, o > 0.5 && o < 1); + assertTrue( + "'sectB' opacity must be in the interval 0.5-1 but is: " + o, + o > 0.5 && o < 1); } }; Timer timerMidTime = new Timer() { @@ -96,16 +101,21 @@ public class GQueryEffectsTest extends GWTTestCase { assertEquals("", sectA.css("display")); assertEquals("", sectB.css("display")); double o = Double.valueOf(sectA.css("opacity")); - assertTrue("'sectA' opacity must be in the interval 0.5-1 but is: " + o, o > 0.5 && o < 1); + assertTrue( + "'sectA' opacity must be in the interval 0.5-1 but is: " + o, + o > 0.5 && o < 1); o = Double.valueOf(sectB.css("opacity")); - assertTrue("'sectB' opacity must be in the interval 0-0.5 but is: " + o, o > 0 && o < 0.5); + assertTrue( + "'sectB' opacity must be in the interval 0-0.5 but is: " + o, o > 0 + && o < 0.5); } }; Timer timerLongTime = new Timer() { public void run() { assertEquals("", sectA.css("display")); assertEquals("none", sectB.css("display")); - // Last delayed assertion has to stop the test to avoid a timeout failure + // Last delayed assertion has to stop the test to avoid a timeout + // failure finishTest(); } }; @@ -114,40 +124,27 @@ public class GQueryEffectsTest extends GWTTestCase { timerMidTime.schedule(1200); timerLongTime.schedule(2200); } - - - void assertPosition(GQuery g, Offset min, Offset max) { - int a = Math.min(min.top, max.top); - int b = Math.max(min.top, max.top); - boolean c = a <= g.position().top && g.position().top <= b; - String msg = "Top has the value " + g.position().top + ", but should be in the range: " + a + " - " + b; - assertTrue(msg, c); - - a = Math.min(min.left, max.left); - b = Math.max(min.left, max.left); - c = a <= g.position().left && g.position().left <= b; - msg = "Left has the value " + g.position().left + ", but should be in the range: " + a + " - " + b; - assertTrue(msg, c); - } - - + public void testEffectsShouldBeQueued() { - $(e).html( - "<p id='id1'>Content 1</p><p id='id2'>Content 2</p><p id='id3'>Content 3</p>"); - - final GQuery g = $("#id1").css("position", "relative"); - final Offset o = g.position(); + $(e).html("<p id='idtest'>Content 1</p></p>"); + + final GQuery g = $("#idtest").css("position", "absolute"); + final Offset o = g.offset(); g.as(Effects). - animate($$("left: '+=100'"), 400, LINEAR, null). - animate($$("top: '+=100'"), 400, LINEAR, null). - animate($$("left: '-=100'"), 400, LINEAR, null). - animate($$("top: '-=100'"), 400, LINEAR, null); + animate($$("left: '+=100'"), 400, LINEAR, null). + animate($$("top: '+=100'"), 400, LINEAR, null). + animate($$("left: '-=100'"), 400, LINEAR, null). + animate($$("top: '-=100'"), 400, LINEAR, null); + - delayTestFinish(2500); + // Configure the max duration for this test + delayTestFinish(400 * 4); + // each timer calls the next one final Timer timer1 = new Timer() { public void run() { - assertPosition(g, o.add(99, 0), o.add(1,0)); + assertPosition(g, o.add(99, 0), o.add(1, 0)); + // Last timer should finish the test finishTest(); } }; @@ -169,9 +166,27 @@ public class GQueryEffectsTest extends GWTTestCase { timer3.schedule(400); } }; - + + // Starts the first timer timer4.schedule(200); } + private void assertPosition(GQuery g, Offset min, Offset max) { + int a = Math.min(min.top, max.top); + int b = Math.max(min.top, max.top); + int v = g.offset().top; + boolean c = a <= v && v <= b; + String msg = "Top has the value " + v + ", but should be in the range: " + + a + " - " + b; + assertTrue(msg, c); + + a = Math.min(min.left, max.left); + b = Math.max(min.left, max.left); + v = g.offset().left; + c = a <= v && v <= b; + msg = "Left has the value " + v + ", but should be in the range: " + a + + " - " + b; + assertTrue(msg, c); + } } |