From 88a468430f75dcb02f5137391c9cd2e9f78f3673 Mon Sep 17 00:00:00 2001 From: Julien Dramaix Date: Sun, 10 Apr 2011 19:58:50 +0000 Subject: [PATCH] add testLiveWithEventBit and testLiveWithMultipleEvent tests ! --- .../gwt/query/client/GQueryEventsTest.java | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java index 876ee78d..8eeaf2bf 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java @@ -359,12 +359,29 @@ public class GQueryEventsTest extends GWTTestCase { assertEquals("red", $("#div1", e).css(CSS.COLOR)); assertEquals("blue", $("#div2", e).css(CSS.COLOR)); + //ensure taht handler related to mouseover event was not called assertNotSame("yellow", $("#div2", e).css(CSS.BACKGROUND_COLOR)); } -public void testLiveWithMultipleFunction() { + public void testLiveWithEventBit() { + $(e).html("
Content 1 blop
"); + + $(".clickable", e).live(Event.ONCLICK, new Function(){ + public void f(Element e) { + $(e).css(CSS.COLOR.with(RGBColor.RED)); + } + }); + + $("#div1", e).addClass("clickable"); + $("#span1", e).click(); + + assertEquals("red", $("#div1", e).css(CSS.COLOR)); + + } + + public void testLiveWithMultipleFunction() { $(e).html("
Content 1 blop
"); @@ -388,7 +405,47 @@ public void testLiveWithMultipleFunction() { } - + public void testLiveWithMultipleEvent() { + + $(e).html("
Content 1 blop
"); + + $(".myClass", e).live("click mouseover", new Function(){ + public void f(Element e) { + $(e).css(CSS.COLOR.with(RGBColor.RED)); + } + }); + + $("#div1", e).addClass("myClass"); + + $("#div1", e).click(); + + assertEquals("red", $("#div1", e).css(CSS.COLOR)); + + $("#div1", e).css(CSS.COLOR.with(RGBColor.BLACK)); + + $("#div1", e).trigger(Event.ONMOUSEOVER); + assertEquals("red", $("#div1", e).css(CSS.COLOR)); + + $(".myClass2", e).live(Event.ONCLICK|Event.ONMOUSEDOWN, new Function(){ + public void f(Element e) { + $(e).css(CSS.COLOR.with(RGBColor.YELLOW)); + } + }); + + $("#div2", e).addClass("myClass2"); + + $("#div2", e).click(); + + assertEquals("yellow", $("#div2", e).css(CSS.COLOR)); + + $("#div2", e).css(CSS.COLOR.with(RGBColor.BLACK)); + + $("#div2", e).trigger(Event.ONMOUSEDOWN); + assertEquals("yellow", $("#div2", e).css(CSS.COLOR)); + + + + } public void testNamedBinding() { -- 2.39.5