From 5fa644614e98de88b4efeb2c0186378161f49323 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Mon, 25 Oct 2010 07:57:57 +0000 Subject: first attemp to save the number of permutations. Optimized Sizzle selector for IE --- .../com/google/gwt/query/client/DevTestRunner.java | 68 +++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'devtest/src/main') diff --git a/devtest/src/main/java/com/google/gwt/query/client/DevTestRunner.java b/devtest/src/main/java/com/google/gwt/query/client/DevTestRunner.java index da78946d..193635fc 100644 --- a/devtest/src/main/java/com/google/gwt/query/client/DevTestRunner.java +++ b/devtest/src/main/java/com/google/gwt/query/client/DevTestRunner.java @@ -26,6 +26,8 @@ import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.query.client.impl.SelectorEngineImpl; +import com.google.gwt.query.client.plugins.Events; +import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; /** @@ -48,13 +50,77 @@ public class DevTestRunner extends MyTestCase implements EntryPoint { public void onModuleLoad() { try { gwtSetUp(); - testCompiledSelectors(); + testSiblings(); } catch (Exception ex) { ex.printStackTrace(); $(e).html("").after("
ERROR: " + ex.getMessage() + "
"); } } + public void testSiblings() { + String content = "
12
12
"; + $(e).html(content); + $(".r1").css("background", "red"); + + $(".r1").hover(new Function() { + public void f(Element e) { + $(e).add($(e).siblings()).text("A"); + } + },new Function() { + public void f(Element e) { + $(e).add($(e).siblings()).text("B"); + } + }); + } + + + public void testNamedBinding() { + $(e).html("

Content

"); + + $("p", e, Events.Events).bind("click.first.namespace", null, new Function() {; + public void f(Element elem) { + $(elem).css("color", "red"); + } + }); + $("p", e, Events.Events).bind("click.second.namespace", null, new Function() {; + public void f(Element elem) { + $(elem).css("background", "green"); + } + }); + $("p", e, Events.Events).bind("click", null, new Function() {; + public void f(Element elem) { + $(elem).css("fontSize", "24px"); + } + }); + $("p", e, Events.Events).trigger(Event.ONCLICK); + assertEquals("red", $("p", e).css("color")); + assertEquals("green", $("p", e).css("background-color")); + assertEquals(24.0d, GQUtils.cur($("p", e).get(0), "fontSize", true)); + + $("p", e).css("color","").css("background-color","").css("fontSize", "12px"); + assertFalse("red".equalsIgnoreCase($("p", e).css("color"))); + assertFalse("green".equalsIgnoreCase($("p", e).css("background-color"))); + assertEquals(12.0d, GQUtils.cur($("p", e).get(0), "fontSize", true)); + + $("p", e, Events.Events).unbind("click.first.namespace"); + $("p", e, Events.Events).trigger(Event.ONCLICK); + assertFalse("red".equalsIgnoreCase($("p", e).css("color"))); + assertEquals("green", $("p", e).css("background-color")); + assertEquals(24.0d, GQUtils.cur($("p", e).get(0), "fontSize", true)); + + + $("p", e).css("color","").css("background-color","").css("fontSize", "12px"); + assertFalse("red".equalsIgnoreCase($("p", e).css("color"))); + assertFalse("green".equalsIgnoreCase($("p", e).css("background-color"))); + assertEquals(12.0d, GQUtils.cur($("p", e).get(0), "fontSize", true)); + + $("p", e, Events.Events).unbind("click"); + $("p", e, Events.Events).trigger(Event.ONCLICK); + assertFalse("red".equalsIgnoreCase($("p", e).css("color"))); + assertFalse("green".equalsIgnoreCase($("p", e).css("background-color"))); + assertEquals(12.0d, GQUtils.cur($("p", e).get(0), "fontSize", true)); + } + public void testSelectorEngineNative() { SelectorEngineImpl selEng = GWT.create(SelectorEngineImpl.class); executeSelectorEngineTests(selEng); -- cgit v1.2.3