aboutsummaryrefslogtreecommitdiffstats
path: root/devtest/src/main/java/com/google/gwt
diff options
context:
space:
mode:
Diffstat (limited to 'devtest/src/main/java/com/google/gwt')
-rw-r--r--devtest/src/main/java/com/google/gwt/query/client/DevTestRunner.java50
-rw-r--r--devtest/src/main/java/com/google/gwt/query/client/MyTestCase.java8
-rw-r--r--devtest/src/main/java/com/google/gwt/query/public/test.html2
3 files changed, 55 insertions, 5 deletions
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 912e16d8..81e718f6 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
@@ -22,6 +22,9 @@ import com.google.gwt.dom.client.Element;
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.css.CSS;
+import com.google.gwt.query.client.css.RGBColor;
+import com.google.gwt.query.client.js.JsCache;
import com.google.gwt.query.client.js.JsUtils;
import com.google.gwt.query.client.plugins.Events;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation;
@@ -49,8 +52,7 @@ public class DevTestRunner extends MyTestCase implements EntryPoint {
public void onModuleLoad() {
try {
gwtSetUp();
- testLive();
-// testPropertiesAnimationComputeEffects();
+ testJsCache();
} catch (Exception ex) {
ex.printStackTrace();
$(e).html("").after("<div>ERROR: " + ex.getMessage() + "</div>");
@@ -63,10 +65,51 @@ public class DevTestRunner extends MyTestCase implements EntryPoint {
}
+ public void testJsCache() {
+ String[] slist = new String[]{"A", "B", "C"};
+
+ JsCache c = JsCache.create();
+ assertTrue(c.isEmpty());
+ for (int i=0; i < slist.length; i++) {
+ c.put(i, slist[i]);
+ }
+ assertFalse(c.isEmpty());
+ assertEquals(3, c.length());
+ assertEquals(slist[1], c.get(1));
+ for (int i=0; i < slist.length; i++) {
+ c.put(slist[i], slist[i]);
+ }
+ assertEquals(6, c.length());
+ assertEquals(slist[1], c.get(1));
+ assertEquals(slist[1], c.get(slist[1]));
+ c.put(1, null);
+ c.put("X", "X");
+ assertNull(c.get(1));
+ assertEquals(slist[2], c.get(2));
+ assertEquals(7, c.length());
+ assertEquals(7, c.keys().length);
+ assertEquals(7, c.elements().length);
+
+ assertTrue(c.exists(2));
+ assertFalse(c.exists(3));
+ assertTrue(c.exists("X"));
+ assertFalse(c.exists("V"));
+
+ c.delete(2);
+ c.delete("C");
+ assertEquals(5, c.length());
+
+ c.put(-1, "N");
+ assertEquals(6, c.length());
+ assertEquals("N", c.get(-1));
+ System.out.println(c.tostring());
+ }
+
public void testLive() {
$(e).html("<div id=d1 class='clickMe'>Content 1</div>");
- GQuery q = $(".clickMe").live(Event.ONCLICK, new Function(){
+ final GQuery q = $(".clickMe").live(Event.ONCLICK, new Function(){
public void f(Element e) {
+ System.out.println($(e));
$(e).css("color", "red");
}
});
@@ -74,6 +117,7 @@ public class DevTestRunner extends MyTestCase implements EntryPoint {
assertEquals("", $("#d1").css("color"));
$(".clickMe", e).click();
+
assertEquals("red", $("#d1").css("color"));
assertEquals("red", $("#d2").css("color"));
diff --git a/devtest/src/main/java/com/google/gwt/query/client/MyTestCase.java b/devtest/src/main/java/com/google/gwt/query/client/MyTestCase.java
index 04cedfa4..8d8751a0 100644
--- a/devtest/src/main/java/com/google/gwt/query/client/MyTestCase.java
+++ b/devtest/src/main/java/com/google/gwt/query/client/MyTestCase.java
@@ -36,10 +36,18 @@ public class MyTestCase {
check(!b, "assertTrue: actual should be false but is true");
}
+ public static void assertFalse(String msg, boolean b) {
+ check(!b, msg);
+ }
+
public static void assertNotNull(Object a) {
check(a != null, "assertNotNull: actual object is null");
}
+ public static void assertNull(Object a) {
+ check(a == null, "assertNull: actual object is not null");
+ }
+
public static void assertTrue(boolean b) {
check(b, "assertTrue: actual should be true but is false");
}
diff --git a/devtest/src/main/java/com/google/gwt/query/public/test.html b/devtest/src/main/java/com/google/gwt/query/public/test.html
index fded2886..aa38d9c8 100644
--- a/devtest/src/main/java/com/google/gwt/query/public/test.html
+++ b/devtest/src/main/java/com/google/gwt/query/public/test.html
@@ -4,8 +4,6 @@
</head>
<body>
<script language="javascript" src="test.nocache.js"></script>
- <script src="atest.nocache.js"></script>
-
</body>
</html>