diff options
author | Manolo Carrasco <manolo@apache.org> | 2011-04-12 22:53:35 +0000 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2011-04-12 22:53:35 +0000 |
commit | e739b2414640e62456613ece6bfd909d6de9f8ef (patch) | |
tree | 9a1f1f53c756ffb20312f0917ef6470fc5367936 | |
parent | 55f5dbb606bf0343edb4b77f02ebb06953c4313b (diff) | |
download | gwtquery-e739b2414640e62456613ece6bfd909d6de9f8ef.tar.gz gwtquery-e739b2414640e62456613ece6bfd909d6de9f8ef.zip |
pom changes in devtest module. Missing assertions and latest tests
4 files changed, 56 insertions, 7 deletions
diff --git a/devtest/pom.xml b/devtest/pom.xml index add223c3..934fd945 100644 --- a/devtest/pom.xml +++ b/devtest/pom.xml @@ -33,7 +33,6 @@ </dependency> </dependencies> <build> - <outputDirectory>./target/www/WEB-INF/classes</outputDirectory> <resources> <resource> <directory>${basedir}/src/main/java</directory> @@ -50,7 +49,6 @@ <directory>${basedir}/src/test/resources</directory> </testResource> </testResources> - <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> @@ -84,5 +82,6 @@ </configuration> </plugin> </plugins> + <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> </build> </project> 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>
|