import com.google.gwt.event.dom.client.FocusHandler;\r
import com.google.gwt.event.shared.GwtEvent;\r
import com.google.gwt.event.shared.HandlerRegistration;\r
+import com.google.gwt.query.client.css.CSS;\r
+import com.google.gwt.query.client.css.RGBColor;\r
+import com.google.gwt.query.client.js.JsCache;\r
import com.google.gwt.query.client.js.JsUtils;\r
import com.google.gwt.query.client.plugins.Events;\r
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation;\r
public void onModuleLoad() {\r
try {\r
gwtSetUp();\r
- testLive();\r
-// testPropertiesAnimationComputeEffects();\r
+ testJsCache();\r
} catch (Exception ex) {\r
ex.printStackTrace();\r
$(e).html("").after("<div>ERROR: " + ex.getMessage() + "</div>");\r
\r
}\r
\r
+ public void testJsCache() {\r
+ String[] slist = new String[]{"A", "B", "C"};\r
+ \r
+ JsCache c = JsCache.create();\r
+ assertTrue(c.isEmpty());\r
+ for (int i=0; i < slist.length; i++) {\r
+ c.put(i, slist[i]);\r
+ }\r
+ assertFalse(c.isEmpty());\r
+ assertEquals(3, c.length());\r
+ assertEquals(slist[1], c.get(1));\r
+ for (int i=0; i < slist.length; i++) {\r
+ c.put(slist[i], slist[i]);\r
+ }\r
+ assertEquals(6, c.length());\r
+ assertEquals(slist[1], c.get(1));\r
+ assertEquals(slist[1], c.get(slist[1]));\r
+ c.put(1, null);\r
+ c.put("X", "X");\r
+ assertNull(c.get(1));\r
+ assertEquals(slist[2], c.get(2));\r
+ assertEquals(7, c.length());\r
+ assertEquals(7, c.keys().length);\r
+ assertEquals(7, c.elements().length);\r
+ \r
+ assertTrue(c.exists(2));\r
+ assertFalse(c.exists(3));\r
+ assertTrue(c.exists("X"));\r
+ assertFalse(c.exists("V"));\r
+ \r
+ c.delete(2);\r
+ c.delete("C");\r
+ assertEquals(5, c.length());\r
+\r
+ c.put(-1, "N");\r
+ assertEquals(6, c.length());\r
+ assertEquals("N", c.get(-1));\r
+ System.out.println(c.tostring());\r
+ }\r
+ \r
public void testLive() {\r
$(e).html("<div id=d1 class='clickMe'>Content 1</div>");\r
- GQuery q = $(".clickMe").live(Event.ONCLICK, new Function(){\r
+ final GQuery q = $(".clickMe").live(Event.ONCLICK, new Function(){\r
public void f(Element e) {\r
+ System.out.println($(e));\r
$(e).css("color", "red");\r
}\r
});\r
assertEquals("", $("#d1").css("color"));\r
\r
$(".clickMe", e).click();\r
+ \r
assertEquals("red", $("#d1").css("color"));\r
assertEquals("red", $("#d2").css("color"));\r
\r