aboutsummaryrefslogtreecommitdiffstats
path: root/devtest/src
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2010-05-13 10:40:53 +0000
committerManolo Carrasco <manolo@apache.org>2010-05-13 10:40:53 +0000
commit8582e98291c4efe46bee985277da6fb14dfea352 (patch)
tree319c3b7b0305c76d7c0d4c032077f57675f7dda8 /devtest/src
parent6be799d97d91f355b512da5a2c954201605e1830 (diff)
downloadgwtquery-8582e98291c4efe46bee985277da6fb14dfea352.tar.gz
gwtquery-8582e98291c4efe46bee985277da6fb14dfea352.zip
added more assertions to the devtest module
Diffstat (limited to 'devtest/src')
-rw-r--r--devtest/src/main/java/com/google/gwt/query/client/DevTestRunner.java36
-rw-r--r--devtest/src/main/java/com/google/gwt/query/client/MyTestCase.java10
-rw-r--r--devtest/src/main/java/com/google/gwt/query/public/test.html7
3 files changed, 50 insertions, 3 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 046fdf11..47da99e9 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
@@ -18,6 +18,9 @@ package com.google.gwt.query.client;
import static com.google.gwt.query.client.GQuery.$;
import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.Event;
/**
* This module is thought to emulate a test environment similar to
@@ -32,10 +35,37 @@ import com.google.gwt.core.client.EntryPoint;
public class DevTestRunner extends MyTestCase implements EntryPoint {
public void onModuleLoad() {
- gwtSetUp();
- testDomManip();
- }
+ try {
+ gwtSetUp();
+
+ testIssue23();
+ $(e).after("<div>OK</div>");
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ $(e).after("<div>ERROR: " + ex.getMessage() + "</div>");
+ }
+ }
+
+ int done = 0;
+
+ public void testIssue23() {
+ $(e).html("<table><tr><td><input type='radio' name='n' value='v1'>1</input><input type='radio' name='n' value='v2' checked='checked'>2</input></td><td><button>Click</button></tr><td></table>");
+ $("button").click(new Function() {
+ public boolean f(Event e) {
+ $("table > tbody > tr > td > input:checked").each(new Function() {
+ public void f(Element e) {
+ done ++;
+ }
+ });
+ return true;
+ }
+ });
+ done = 0;
+ $("button").click();
+ assertEquals(1,done);
+ }
+
public void testDomManip() {
String content = "<span class='branchA'><span class='target'>branchA target</span></span>"
+ "<span class='branchB'><span class='target'>branchB target</span></span>";
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 e505812a..a409da0b 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
@@ -45,6 +45,14 @@ public class MyTestCase {
public static void assertEquals(Object a, Object b) {
check(a.equals(b), "assertEquals: expected=" + a + " actual=" + b);
}
+
+ public static void assertTrue(boolean b) {
+ check(b, "assertTrue: actual should be true but is false");
+ }
+
+ public static void assertFalse(boolean b) {
+ check(!b, "assertTrue: actual should be false but is true");
+ }
public static void check(boolean condition, String message) {
if (!condition) {
@@ -66,4 +74,6 @@ public class MyTestCase {
replaceAll(" added=[^ >]+", "");
}
+
+
}
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 1c447858..69862e2a 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
@@ -1,3 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+
+<!--
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+ -->
<html>
<head>
<script language="javascript" src="test.nocache.js"></script>