aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core/src/test
diff options
context:
space:
mode:
authorJulien Dramaix <julien.dramaix@gmail.com>2011-04-10 07:10:31 +0000
committerJulien Dramaix <julien.dramaix@gmail.com>2011-04-10 07:10:31 +0000
commit4e04e209edc63690d942d79bada0725eea2d37b2 (patch)
tree0b925b502b0b4485696ec4aa83fe858c310e6ce7 /gwtquery-core/src/test
parent7b7edb5b840175464f13f6082b9486e499c689e2 (diff)
downloadgwtquery-4e04e209edc63690d942d79bada0725eea2d37b2.tar.gz
gwtquery-4e04e209edc63690d942d79bada0725eea2d37b2.zip
- correct live implementation to accept an array of Function
- method live(String, Object, Function) loop on itself
Diffstat (limited to 'gwtquery-core/src/test')
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java73
1 files changed, 49 insertions, 24 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 99515ec3..af3f2465 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
@@ -363,6 +363,54 @@ public class GQueryEventsTest extends GWTTestCase {
}
+
+public void testLiveWithMultipleFunction() {
+
+ $(e).html("<div id='div1'><div id='div2'>Content 1<span id='span1'> blop</span></div></div>");
+
+ $(".clickable", e).live("click", new Function(){
+ public void f(Element e) {
+ $(e).css(CSS.COLOR.with(RGBColor.RED));
+ }
+ }, new Function(){
+ public void f(Element e) {
+ $(e).css(CSS.BACKGROUND_COLOR.with(RGBColor.YELLOW));
+ }
+ });
+
+ $("#div1", e).addClass("clickable");
+
+ $("#span1", e).click();
+
+ assertEquals("red", $("#div1", e).css(CSS.COLOR));
+ assertNotSame("yellow", $("#div1", e).css(CSS.BACKGROUND_COLOR));
+
+
+ }
+
+public void testLiveWithMultipleEvent() {
+
+ $(e).html("<div id='div1'><div id='div2'>Content 1<span id='span1'> blop</span></div></div>");
+
+ $(".clickable", e).live(Event.ONCLICK | Event.ONMOUSEMOVE, 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));
+
+ //reset
+ $("#div1", e).css(CSS.COLOR.with(RGBColor.BLACK));
+
+
+
+}
+
public void testNamedBinding() {
$(e).html("<p>Content</p>");
@@ -475,30 +523,7 @@ public class GQueryEventsTest extends GWTTestCase {
assertEquals($("#test").attr("tabIndex"), "2");
}
- public void testUnbindMultipleEvents() {
- String content = "<p>content</p>";
- $(e).html(content);
- $(document).bind(Event.ONMOUSEMOVE, null, new Function() {
- public void f(Element e){
- $("p").css(CSS.COLOR.with(RGBColor.RED));
- }
- });
- $(document).bind(Event.ONMOUSEUP, null, new Function(){
- public void f(Element e){
- $("p").css(CSS.COLOR.with(RGBColor.YELLOW));
- }
- });
- $(document).trigger(Event.ONMOUSEMOVE);
- assertEquals("red", $("p").css("color"));
- $(document).trigger(Event.ONMOUSEUP);
- assertEquals("yellow", $("p").css("color"));
- $("p").css(CSS.COLOR.with(RGBColor.BLACK));
- $(document).unbind(Event.ONMOUSEUP|Event.ONMOUSEMOVE);
- $(document).trigger(Event.ONMOUSEMOVE);
- assertEquals("black", $("p").css("color"));
- $(document).trigger(Event.ONMOUSEUP);
- assertEquals("black", $("p").css("color"));
- }
+
public void testWidgetEvents() {
final Button b = new Button("click-me");