aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2011-11-03 10:53:52 +0000
committerManolo Carrasco <manolo@apache.org>2011-11-03 10:53:52 +0000
commite05275405689442f05ea6f3fc5da5ca1bf4636dd (patch)
treee14ae329071b801a96714f0f7bb5c4c72d004b32 /gwtquery-core
parente3a57614031bfdb5e83c147c003a3a2014bc455a (diff)
downloadgwtquery-e05275405689442f05ea6f3fc5da5ca1bf4636dd.tar.gz
gwtquery-e05275405689442f05ea6f3fc5da5ca1bf4636dd.zip
fix tests, group them in a gwt-suite to run in a jvm instance and speed up maven test
Diffstat (limited to 'gwtquery-core')
-rw-r--r--gwtquery-core/pom.xml40
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java276
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java27
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java29
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java31
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java (renamed from gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTest.java)9
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java (renamed from gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTest.java)7
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java (renamed from gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTest.java)7
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java (renamed from gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTest.java)7
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java (renamed from gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java)56
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java31
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java (renamed from gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTest.java)7
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java (renamed from gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTest.java)7
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java (renamed from gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTest.java)2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java13
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java8
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java29
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java6
20 files changed, 378 insertions, 223 deletions
diff --git a/gwtquery-core/pom.xml b/gwtquery-core/pom.xml
index afd465ce..520531a4 100644
--- a/gwtquery-core/pom.xml
+++ b/gwtquery-core/pom.xml
@@ -70,35 +70,17 @@
</plugin>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>false</skipTests>
- <additionalClasspathElements>
- <additionalClasspathElement>
- ${project.build.sourceDirectory}
- </additionalClasspathElement>
- <additionalClasspathElement>
- ${project.build.testSourceDirectory}
- </additionalClasspathElement>
- </additionalClasspathElements>
- <!-- Needed to run gwt-Tests -->
- <useManifestOnlyJar>false</useManifestOnlyJar>
- <!-- Necessary to run tests with return the same getModuleName-->
- <forkMode>always</forkMode>
- <!-- This makes emma:emma fail -->
- <!-- <useSystemClassLoader>true</useSystemClassLoader> -->
- <parallel>both</parallel>
- <threadCount>6</threadCount>
- <systemProperties>
- <property>
- <name>gwt.args</name>
- <value>-out target/www-junit</value>
- <name>gwt.noserver</name>
- <value>true</value>
- </property>
- </systemProperties>
- </configuration>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <additionalClasspathElements>
+ <additionalClasspathElement>${basedir}/src/main/java</additionalClasspathElement>
+ <additionalClasspathElement>${basedir}/src/test/java</additionalClasspathElement>
+ </additionalClasspathElements>
+ <!-- <useManifestOnlyJar>false</useManifestOnlyJar> -->
+ <!-- <forkMode>always</forkMode> -->
+ <useSystemClassLoader>false</useSystemClassLoader>
+ </configuration>
</plugin>
<plugin>
<groupId>org.riedelcastro</groupId>
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java
index 5e68a6fc..1ae86eec 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java
@@ -20,6 +20,7 @@ import java.util.List;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
+import com.google.gwt.core.client.JsArrayMixed;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.dom.client.BodyElement;
import com.google.gwt.dom.client.ButtonElement;
@@ -43,12 +44,15 @@ import com.google.gwt.query.client.js.JsCache;
import com.google.gwt.query.client.js.JsMap;
import com.google.gwt.query.client.js.JsNamedArray;
import com.google.gwt.query.client.js.JsNodeArray;
+import com.google.gwt.query.client.js.JsObjectArray;
import com.google.gwt.query.client.js.JsRegexp;
import com.google.gwt.query.client.js.JsUtils;
import com.google.gwt.query.client.plugins.Effects;
import com.google.gwt.query.client.plugins.Events;
import com.google.gwt.query.client.plugins.Plugin;
import com.google.gwt.query.client.plugins.Widgets;
+import com.google.gwt.query.client.plugins.ajax.Ajax;
+import com.google.gwt.query.client.plugins.ajax.Ajax.Settings;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing;
import com.google.gwt.query.client.plugins.events.EventsListener;
import com.google.gwt.user.client.DOM;
@@ -110,6 +114,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> andSelf();
/**
+ *
* The animate() method allows you to create animation effects on any numeric
* Attribute, CSS property, or color CSS property.
*
@@ -123,11 +128,10 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to the position top:500px and left:500px for 400ms.
- * //use a swing easing function for the transition
- * $("#foo").animate(Properties.create("{top:'500px',left:'500px'}"), 400, Easing.SWING);
- * // Change the width and border attributes of a table
- * $("table").animate(Properties.create("{$width: '500', $border: '10'}"), 400, Easing.LINEAR);
+ * //move the element from its original position to left:500px for 500ms
+ * $("#foo").animate("left:'500'");
+ * // Change the width attribute of a table
+ * $("table").animate("$width:'500'"), 400, Easing.LINEAR);
* </pre>
*
* In addition to numeric values, each property can take the strings 'show',
@@ -140,30 +144,35 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
- * $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
+ * //move the element from its original position to 500px to the left for 500ms and
+ * // change the background color of the element at the end of the animation
+ * $("#foo").animate("left:'+=500'", new Function(){
+ *
+ * public void f(Element e){
+ * $(e).css(CSS.BACKGROUND_COLOR.with(RGBColor.RED);
+ * }
+ *
+ * });
* </pre>
*
+ * The duration of the animation is 500ms.
+ *
* For color css properties, values can be specified via hexadecimal or rgb or
* literal values.
*
* Example:
*
* <pre class="code">
- * $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'"), 400, Easing.SWING);
+ * $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'");
* </pre>
*
- * @param stringOrProperties a String or a {@link Properties} object containing css properties to animate.
+ * @param prop the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
- * @param duration the duration in milliseconds of the animation
- * @param easing the easing function to use for the transition
*/
- LazyGQuery<T> animate(Object stringOrProperties, int duration, Easing easing, Function... funcs);
+ LazyGQuery<T> animate(Object stringOrProperties, Function... funcs);
/**
- *
* The animate() method allows you to create animation effects on any numeric
* Attribute, CSS property, or color CSS property.
*
@@ -177,10 +186,11 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
- * $("#foo").animate("left:'500'");
- * // Change the width attribute of a table
- * $("table").animate("$width:'500'"), 400, Easing.LINEAR);
+ * //move the element from its original position to the position top:500px and left:500px for 400ms.
+ * //use a swing easing function for the transition
+ * $("#foo").animate(Properties.create("{top:'500px',left:'500px'}"), 400, Easing.SWING);
+ * // Change the width and border attributes of a table
+ * $("table").animate(Properties.create("{$width: '500', $border: '10'}"), 400, Easing.LINEAR);
* </pre>
*
* In addition to numeric values, each property can take the strings 'show',
@@ -193,33 +203,27 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
- * // change the background color of the element at the end of the animation
- * $("#foo").animate("left:'+=500'", new Function(){
- *
- * public void f(Element e){
- * $(e).css(CSS.BACKGROUND_COLOR.with(RGBColor.RED);
- * }
- *
- * });
+ * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * //use a swing easing function for the transition
+ * $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
- * The duration of the animation is 500ms.
- *
* For color css properties, values can be specified via hexadecimal or rgb or
* literal values.
*
* Example:
*
* <pre class="code">
- * $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'");
+ * $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'"), 400, Easing.SWING);
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties a String or a {@link Properties} object containing css properties to animate.
* @param funcs an array of {@link Function} called once the animation is
* complete
+ * @param duration the duration in milliseconds of the animation
+ * @param easing the easing function to use for the transition
*/
- LazyGQuery<T> animate(Object stringOrProperties, Function... funcs);
+ LazyGQuery<T> animate(Object stringOrProperties, int duration, Easing easing, Function... funcs);
/**
* The animate() method allows you to create animation effects on any numeric
@@ -467,6 +471,17 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> closest(String selector);
/**
+ * Get the first ancestor element that matches the selector (for each matched
+ * element), beginning at the current element and progressing up through the
+ * DOM tree until reach the <code>context</code> node.
+ *
+ * If no context is passed in then the context of the gQuery object will be
+ * used instead.
+ *
+ */
+ LazyGQuery<T> closest(String selector, Node context);
+
+ /**
* Returns a {@link Map} object as key a selector and as value the list of
* ancestor elements matching this selectors, beginning at the first matched
* element and progressing up through the DOM. This method allows retrieving
@@ -491,17 +506,6 @@ public interface LazyGQuery<T> extends LazyBase<T>{
JsNamedArray<NodeList<Element>> closest(String[] selectors, Node context);
/**
- * Get the first ancestor element that matches the selector (for each matched
- * element), beginning at the current element and progressing up through the
- * DOM tree until reach the <code>context</code> node.
- *
- * If no context is passed in then the context of the gQuery object will be
- * used instead.
- *
- */
- LazyGQuery<T> closest(String selector, Node context);
-
- /**
* Filter the set of elements to those that contain the specified text.
*/
LazyGQuery<T> contains(String text);
@@ -714,12 +718,12 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Attach <code>handlers</code> to one or more events for all elements that
* match the <code>selector</code>, now or in the future, based on a specific
- * set of root elements.
+ * set of root elements.
*
* Example:
*
* <pre>
- * $("table").delegate("td", "click", new Function(){
+ * $("table").delegate("td", Event.ONCLICK, new Function(){
* public void f(Element e){
* $(e).css(CSS.BACKGROUND_COLOR.with(RGBColor.RED));
* }
@@ -732,7 +736,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* <pre>
* $("table").each(new Function(){
* public void f(Element table){
- * $("td", table).live("click", new Function(){
+ * $("td", table).live(Event.ONCLICK, new Function(){
* public void f(Element e){
* $(e).css(CSS.BACKGROUND_COLOR.with(RGBColor.RED));
* }
@@ -741,22 +745,21 @@ public interface LazyGQuery<T> extends LazyBase<T>{
*
* </pre>
*
- * You can pass attach the handlers to many events by specifying a String with espaced event type.
+ * You can attach the handlers to many events by using the '|' operator
* ex:
* <pre>
- * $("div.main").delegate(".subMain", "click dblclick", new Function(){...});
- * </pre>
+ * $("div.main").delegate(".subMain", Event.ONCLICK | Event.ONDBLCLICK, new Function(){...});
* </pre>
*/
- LazyGQuery<T> delegate(String selector, String eventType, Function... handlers);
+ LazyGQuery<T> delegate(String selector, int eventbits, Function... handlers);
/**
- * Attach <code>handlers</code> to one or more events for all elements that
- * match the <code>selector</code>, now or in the future, based on a specific
- * set of root elements.
- *
+ * Attach <code>handlers</code> to one or more events for all elements that match the <code>selector</code>,
+ * now or in the future, based on a specific set of root elements.
+ * The <code>data</code> parameter allows us
+ * to pass data to the handler.
+ *
* Example:
- *
* <pre>
* $("table").delegate("td", "click", new Function(){
* public void f(Element e){
@@ -764,10 +767,8 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* }
* });
* </pre>
- *
- * This code above add an handler on click event on all cell (the existing
- * oneand the future cell) of all table. This code is equivalent to :
- *
+ * This code above add an handler on click event on all cell (the existing oneand the future cell) of all table.
+ * This code is equivalent to :
* <pre>
* $("table").each(new Function(){
* public void f(Element table){
@@ -778,24 +779,25 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* }
* });
*
- * You can pass attach the handlers to many events by specifying a String with espaced event type.
+ * </pre>
+ *
+ * You can pass attach the handlers to many events by using the '|' operator
* ex:
* <pre>
- * $("div.main").delegate(".subMain", "click dblclick", new Function(){...});
- * </pre>
+ * $("div.main").delegate(".subMain", Event.ONCLICK | Event.ONDBLCLICK, new Function(){...});
* </pre>
*/
- LazyGQuery<T> delegate(String selector, String eventType, Object data, Function... handlers);
+ LazyGQuery<T> delegate(String selector, int eventbits, Object data, Function... handlers);
/**
* Attach <code>handlers</code> to one or more events for all elements that
* match the <code>selector</code>, now or in the future, based on a specific
- * set of root elements.
+ * set of root elements.
*
* Example:
*
* <pre>
- * $("table").delegate("td", Event.ONCLICK, new Function(){
+ * $("table").delegate("td", "click", new Function(){
* public void f(Element e){
* $(e).css(CSS.BACKGROUND_COLOR.with(RGBColor.RED));
* }
@@ -808,7 +810,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* <pre>
* $("table").each(new Function(){
* public void f(Element table){
- * $("td", table).live(Event.ONCLICK, new Function(){
+ * $("td", table).live("click", new Function(){
* public void f(Element e){
* $(e).css(CSS.BACKGROUND_COLOR.with(RGBColor.RED));
* }
@@ -817,21 +819,22 @@ public interface LazyGQuery<T> extends LazyBase<T>{
*
* </pre>
*
- * You can attach the handlers to many events by using the '|' operator
+ * You can pass attach the handlers to many events by specifying a String with espaced event type.
* ex:
* <pre>
- * $("div.main").delegate(".subMain", Event.ONCLICK | Event.ONDBLCLICK, new Function(){...});
+ * $("div.main").delegate(".subMain", "click dblclick", new Function(){...});
+ * </pre>
* </pre>
*/
- LazyGQuery<T> delegate(String selector, int eventbits, Function... handlers);
+ LazyGQuery<T> delegate(String selector, String eventType, Function... handlers);
/**
- * Attach <code>handlers</code> to one or more events for all elements that match the <code>selector</code>,
- * now or in the future, based on a specific set of root elements.
- * The <code>data</code> parameter allows us
- * to pass data to the handler.
- *
+ * Attach <code>handlers</code> to one or more events for all elements that
+ * match the <code>selector</code>, now or in the future, based on a specific
+ * set of root elements.
+ *
* Example:
+ *
* <pre>
* $("table").delegate("td", "click", new Function(){
* public void f(Element e){
@@ -839,8 +842,10 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* }
* });
* </pre>
- * This code above add an handler on click event on all cell (the existing oneand the future cell) of all table.
- * This code is equivalent to :
+ *
+ * This code above add an handler on click event on all cell (the existing
+ * oneand the future cell) of all table. This code is equivalent to :
+ *
* <pre>
* $("table").each(new Function(){
* public void f(Element table){
@@ -851,15 +856,14 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* }
* });
*
- * </pre>
- *
- * You can pass attach the handlers to many events by using the '|' operator
+ * You can pass attach the handlers to many events by specifying a String with espaced event type.
* ex:
* <pre>
- * $("div.main").delegate(".subMain", Event.ONCLICK | Event.ONDBLCLICK, new Function(){...});
+ * $("div.main").delegate(".subMain", "click dblclick", new Function(){...});
+ * </pre>
* </pre>
*/
- LazyGQuery<T> delegate(String selector, int eventbits, Object data, Function... handlers);
+ LazyGQuery<T> delegate(String selector, String eventType, Object data, Function... handlers);
/**
* Execute the next function on the Effects queue for the matched elements.
@@ -905,19 +909,19 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Remove an event handlers previously attached using
- * {@link #live(String, Function)} In order for this method to function
+ * {@link #live(int, Function)} In order for this method to function
* correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(String, Function)}
+ * initially used with {@link #live(int, Function)}
*/
- LazyGQuery<T> die(String eventName);
+ LazyGQuery<T> die(int eventbits);
/**
* Remove an event handlers previously attached using
- * {@link #live(int, Function)} In order for this method to function
+ * {@link #live(String, Function)} In order for this method to function
* correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(int, Function)}
+ * initially used with {@link #live(String, Function)}
*/
- LazyGQuery<T> die(int eventbits);
+ LazyGQuery<T> die(String eventName);
/**
* Run one or more Functions over each element of the GQuery. You have to
@@ -1083,15 +1087,15 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Reduce the set of matched elements to those that have a descendant
- * that matches the selector.
+ * that matches the Element.
*/
- LazyGQuery<T> has(String selector);
+ LazyGQuery<T> has(Element elem);
/**
* Reduce the set of matched elements to those that have a descendant
- * that matches the Element.
+ * that matches the selector.
*/
- LazyGQuery<T> has(Element elem);
+ LazyGQuery<T> has(String selector);
/**
* Returns true any of the specified classes are present on any of the matched
@@ -1226,6 +1230,11 @@ public interface LazyGQuery<T> extends LazyBase<T>{
boolean isEmpty();
/**
+ * Return true if the first element is visible.isVisible
+ */
+ boolean isVisible();
+
+ /**
* Bind a set of functions to the keydown event of each matched element. Or
* trigger the event if no functions are provided.
*/
@@ -1275,6 +1284,18 @@ public interface LazyGQuery<T> extends LazyBase<T>{
int length();
/**
+ * Attach a handler for this event to all elements which match the current
+ * selector, now and in the future.
+ */
+ LazyGQuery<T> live(int eventbits, Function... funcs);
+
+ /**
+ * Attach a handler for this event to all elements which match the current
+ * selector, now and in the future.
+ */
+ LazyGQuery<T> live(int eventbits, Object data, Function... funcs);
+
+ /**
* <p>
* Attach a handler for this event to all elements which match the current
* selector, now and in the future.
@@ -1328,18 +1349,6 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> live(String eventName, Function... funcs);
/**
- * Attach a handler for this event to all elements which match the current
- * selector, now and in the future.
- */
- LazyGQuery<T> live(int eventbits, Function... funcs);
-
- /**
- * Attach a handler for this event to all elements which match the current
- * selector, now and in the future.
- */
- LazyGQuery<T> live(int eventbits, Object data, Function... funcs);
-
- /**
* <p>
* Attach a handler for this event to all elements which match the current
* selector, now and in the future. The <code>data</code> parameter allows us
@@ -1394,9 +1403,28 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> live(String eventName, Object data, Function... funcs);
/**
- * Bind a function to the load event of each matched element.
+ * Load data from the server and place the returned HTML into the matched element.
+ *
+ * The url allows us to specify a portion of the remote document to be inserted.
+ * This is achieved with a special syntax for the url parameter.
+ * If one or more space characters are included in the string, the portion of
+ * the string following the first space is assumed to be a GQuery selector that
+ * determines the content to be loaded.
+ *
*/
- LazyGQuery<T> load(Function f);
+ LazyGQuery<T> load(String url);
+
+ /**
+ * Load data from the server and place the returned HTML into the matched element.
+ *
+ * The url allows us to specify a portion of the remote document to be inserted.
+ * This is achieved with a special syntax for the url parameter.
+ * If one or more space characters are included in the string, the portion of
+ * the string following the first space is assumed to be a GQuery selector that
+ * determines the content to be loaded.
+ *
+ */
+ LazyGQuery<T> load(String url, Properties data, Function onSuccess);
/**
* Reduce the set of matched elements to all elements before a given position.
@@ -1704,12 +1732,6 @@ public interface LazyGQuery<T> extends LazyBase<T>{
int queue();
/**
- * Show the number of functions in the queued named as queueName to be
- * executed on the first matched element.
- */
- int queue(String queueName);
-
- /**
* Put a set of {@link Function} at the end of the Effects queue.
*
* Example:
@@ -1739,6 +1761,12 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> queue(Function... f);
/**
+ * Show the number of functions in the queued named as queueName to be
+ * executed on the first matched element.
+ */
+ int queue(String queueName);
+
+ /**
* Put a set of {@link Function} at the end of a queue.
*
* Example:
@@ -1856,14 +1884,14 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> resize(Function... f);
/**
- * Save a set of Css properties of every matched element.
+ * Bind an event handler to the "resize" JavaScript event, or trigger that event on an element.
*/
- void restoreCssAttrs(String... cssProps);
+ LazyGQuery<T> resize(Function f);
/**
- * Bind an event handler to the "resize" JavaScript event, or trigger that event on an element.
+ * Save a set of Css properties of every matched element.
*/
- LazyGQuery<T> resize(Function f);
+ void restoreCssAttrs(String... cssProps);
/**
* Restore a set of previously saved Css properties in every matched element.
@@ -2042,7 +2070,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> submit(Function... funcs);
/**
- * Return the text contained in the first matched element.
+ * Return the concatened text contained in the matched elements.
*/
String text();
@@ -2077,7 +2105,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> toggleClass(String clz, boolean addOrRemove);
/**
- * Returns the computed left position of the first element matched.
+ * Returns the computed top position of the first element matched.
*/
int top();
@@ -2108,6 +2136,11 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> unbind(int eventbits);
/**
+ * Removes all events that match the eventList.
+ */
+ LazyGQuery<T> unbind(String eventList);
+
+ /**
* Remove all event delegation that have been bound using
* {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods
*/
@@ -2123,13 +2156,13 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Undelegate is a way of removing event handlers that have been bound using
* {@link #delegate(String, int, Function...)} method
*/
- LazyGQuery<T> undelegate(String selector, String eventName);
+ LazyGQuery<T> undelegate(String selector, int eventBit);
/**
* Undelegate is a way of removing event handlers that have been bound using
* {@link #delegate(String, int, Function...)} method
*/
- LazyGQuery<T> undelegate(String selector, int eventBit);
+ LazyGQuery<T> undelegate(String selector, String eventName);
/**
* Remove all duplicate elements from an array of elements. Note that this
@@ -2211,11 +2244,6 @@ public interface LazyGQuery<T> extends LazyBase<T>{
String[] vals();
/**
- * Return true if the first element is visible.isVisible
- */
- boolean isVisible();
-
- /**
* Return the first non null attached widget from the matched elements or null
* if there isn't any.
*/
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java
index 9f385dfb..beb89003 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java
@@ -27,6 +27,7 @@ import com.google.gwt.query.client.js.JsNodeArray;
import com.google.gwt.query.client.js.JsObjectArray;
import com.google.gwt.query.client.js.JsRegexp;
import com.google.gwt.query.client.js.JsUtils;
+import com.google.gwt.regexp.shared.RegExp;
/**
* Runtime selector engine implementation which translates selectors to XPath
@@ -192,6 +193,32 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
}
}
};
+
+ /**
+ * A replacer which works in both sides. Right now gquery JsRegexp is faster
+ * than gwt shared RegExp and does not uses HashSet
+ */
+ public static final Replacer replacerGwt = new Replacer() {
+ public String replaceAll(String s, String r, Object o) {
+ RegExp p = RegExp.compile(r, "g");
+ if (o instanceof ReplaceCallback) {
+ ReplaceCallback callback = (ReplaceCallback) o;
+ com.google.gwt.regexp.shared.MatchResult a = null;
+ while ((a = p.exec(s)) != null) {
+ ArrayList<String> args = new ArrayList<String>();
+ for (int i = 0; i < a.getGroupCount(); i++) {
+ args.add(a.getGroup(i));
+ }
+ String f = callback.foundMatch(args);
+ s = s.replace(a.getGroup(0), f);
+ p = RegExp.compile(r, "g");
+ }
+ return s;
+ } else {
+ return p.replace(s, o.toString());
+ }
+ }
+ };
public SelectorEngineCssToXPath() {
instance = this;
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
index e1103033..5dac2578 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
@@ -314,4 +314,9 @@ public class JsUtils {
return Properties.create();
}
}
+
+ public static native boolean isDefaultPrevented(JavaScriptObject e)/*-{
+ return e.defaultPrevented || e.returnValue === false || e.getPreventDefault && e.getPreventDefault() ? true : false;
+ }-*/;
+
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
index 95a92a19..e9bfaeaf 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
@@ -228,20 +228,27 @@ public class Events extends GQuery {
if ((eventbits | Event.ONMOUSEWHEEL) == Event.ONMOUSEWHEEL)
dispatchEvent(document.createMouseEvent("mousewheel", true, true, 0, 0,
0, 0, 0, false, false, false, false, NativeEvent.BUTTON_LEFT, null));
- if (eventbits == EventsListener.ONSUBMIT)
- triggerHtmlEvent("submit");
+ if (eventbits == EventsListener.ONSUBMIT) {
+ Event evt = document.createHtmlEvent("submit", true, true).cast();
+ dispatchEvent(evt, new Function() {
+ public native void f(Element e) /*-{
+ e.submit();
+ }-*/;
+ });
+ }
if (eventbits == EventsListener.ONRESIZE)
triggerHtmlEvent("resize");
return this;
}
-
+
/**
* Trigger a html event in all matched elements.
*
* @param htmlEvent An string representing the html event desired
+ * @functions a set of function to run if the event is not canceled.
*/
- public Events triggerHtmlEvent(String htmlEvent) {
- dispatchEvent(document.createHtmlEvent(htmlEvent, true, true));
+ public Events triggerHtmlEvent(String htmlEvent, Function...functions) {
+ dispatchEvent(document.createHtmlEvent(htmlEvent, true, true), functions);
return this;
}
@@ -289,11 +296,17 @@ public class Events extends GQuery {
}
return this;
}
-
- private void dispatchEvent(NativeEvent evt) {
+
+ private void dispatchEvent(NativeEvent evt, Function...funcs) {
for (Element e : elements()) {
if (isEventCapable(e)){
e.dispatchEvent(evt);
+ if (!JsUtils.isDefaultPrevented(evt)){
+ for (Function f: funcs) {
+ f.setEvent(Event.as(evt));
+ f.f(e);
+ }
+ }
}
}
}
@@ -306,7 +319,5 @@ public class Events extends GQuery {
}
return this;
}
-
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java
index 0dc01b72..2e8bac07 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java
@@ -19,6 +19,7 @@ import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
+import com.google.gwt.query.client.js.JsUtils;
import com.google.gwt.query.client.plugins.events.EventsListener;
import com.google.gwt.user.client.Event;
import com.google.gwt.query.client.LazyBase;
@@ -114,8 +115,9 @@ public interface LazyEvents<T> extends LazyBase<T>{
* Trigger a html event in all matched elements.
*
* @param htmlEvent An string representing the html event desired
+ * @functions a set of function to run if the event is not canceled.
*/
- LazyEvents<T> triggerHtmlEvent(String htmlEvent);
+ LazyEvents<T> triggerHtmlEvent(String htmlEvent, Function...functions);
/**
* Removes all handlers, that matches the events bits passed, from each
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java
index a90b6fe2..a726b6bd 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java
@@ -31,7 +31,6 @@ import com.google.gwt.query.client.Selector;
import com.google.gwt.query.client.impl.SelectorEngineCssToXPath;
import com.google.gwt.query.client.impl.SelectorEngineCssToXPath.ReplaceCallback;
import com.google.gwt.query.client.impl.SelectorEngineCssToXPath.Replacer;
-import com.google.gwt.regexp.shared.RegExp;
import com.google.gwt.user.rebind.SourceWriter;
/**
@@ -44,7 +43,7 @@ public class SelectorGeneratorCssToXPath extends SelectorGeneratorBase {
/**
* The replacer implementation for the JVM.
*/
- public static final Replacer replacerJvm = new Replacer() {
+ public static final Replacer replacer = new Replacer() {
public String replaceAll(String s, String r, Object o) {
Pattern p = Pattern.compile(r);
if (o instanceof ReplaceCallback) {
@@ -68,34 +67,6 @@ public class SelectorGeneratorCssToXPath extends SelectorGeneratorBase {
}
};
- /**
- * A replacer which works in both sides. Right now gquery JsRegexp is faster
- * than gwt shared RegExp and does not uses HashSet
- */
- public static final Replacer replacerGwt = new Replacer() {
- public String replaceAll(String s, String r, Object o) {
- RegExp p = RegExp.compile(r, "g");
- if (o instanceof ReplaceCallback) {
- ReplaceCallback callback = (ReplaceCallback) o;
- com.google.gwt.regexp.shared.MatchResult a = null;
- while ((a = p.exec(s)) != null) {
- ArrayList<String> args = new ArrayList<String>();
- for (int i = 0; i < a.getGroupCount(); i++) {
- args.add(a.getGroup(i));
- }
- String f = callback.foundMatch(args);
- s = s.replace(a.getGroup(0), f);
- p = RegExp.compile(r, "g");
- }
- return s;
- } else {
- return p.replace(s, o.toString());
- }
- }
- };
-
- public static final Replacer replacer = replacerGwt;
-
private SelectorEngineCssToXPath engine = new SelectorEngineCssToXPath(
replacer);
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java
index 7056a9a3..231db889 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java
@@ -16,6 +16,8 @@
package com.google.gwt.query.client;
+import static com.google.gwt.query.client.GQuery.$;
+
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.junit.client.GWTTestCase;
@@ -28,7 +30,7 @@ import com.google.gwt.user.client.ui.RootPanel;
/**
* Test class for testing ajax stuff.
*/
-public class GQueryAjaxTest extends GWTTestCase {
+public class GQueryAjaxTestGwt extends GWTTestCase {
static Element e = null;
@@ -38,6 +40,11 @@ public class GQueryAjaxTest extends GWTTestCase {
return "com.google.gwt.query.Query";
}
+ public void gwtTearDown() {
+ $(e).remove();
+ e = null;
+ }
+
public void gwtSetUp() {
if (e == null) {
testPanel = new HTML();
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
index 0149df5a..347adb1a 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
@@ -55,7 +55,7 @@ import java.util.List;
/**
* Test class for testing gwtquery-core api.
*/
-public class GQueryCoreTest extends GWTTestCase {
+public class GQueryCoreTestGwt extends GWTTestCase {
static Element e = null;
@@ -82,6 +82,11 @@ public class GQueryCoreTest extends GWTTestCase {
return "com.google.gwt.query.Query";
}
+ public void gwtTearDown() {
+ $(e).remove();
+ e = null;
+ }
+
public void gwtSetUp() {
if (e == null || DOM.getElementById("core-tst") == null) {
testPanel = new HTML();
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java
index 9ad7d71e..561a029e 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java
@@ -59,7 +59,7 @@ import com.google.gwt.user.client.ui.RootPanel;
/**
* Test class for testing css part.
*/
-public class GQueryCssTest extends GWTTestCase {
+public class GQueryCssTestGwt extends GWTTestCase {
static Element e = null;
@@ -68,6 +68,11 @@ public class GQueryCssTest extends GWTTestCase {
public String getModuleName() {
return "com.google.gwt.query.Query";
}
+
+ public void gwtTearDown() {
+ $(e).remove();
+ e = null;
+ }
public void gwtSetUp() {
if (e == null) {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java
index bc4f1b7f..f286d6f9 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java
@@ -32,7 +32,7 @@ import com.google.gwt.user.client.ui.RootPanel;
/**
* Test class for testing gwtquery effects plugin api.
*/
-public class GQueryEffectsTest extends GWTTestCase {
+public class GQueryEffectsTestGwt extends GWTTestCase {
static Element e = null;
@@ -42,6 +42,11 @@ public class GQueryEffectsTest extends GWTTestCase {
return "com.google.gwt.query.Query";
}
+ public void gwtTearDown() {
+ $(e).remove();
+ e = null;
+ }
+
public void gwtSetUp() {
if (e == null) {
testPanel = new HTML();
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java
index 601d9e99..5a8ba73e 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java
@@ -40,7 +40,7 @@ import com.google.gwt.user.client.ui.RootPanel;
/**
* Test class for testing gwt events plugin api.
*/
-public class GQueryEventsTest extends GWTTestCase {
+public class GQueryEventsTestGwt extends GWTTestCase {
static Element e = null;
@@ -51,6 +51,11 @@ public class GQueryEventsTest extends GWTTestCase {
public String getModuleName() {
return "com.google.gwt.query.Query";
}
+
+ public void gwtTearDown() {
+ $(e).remove();
+ e = null;
+ }
public void gwtSetUp() {
if (e == null) {
@@ -731,7 +736,39 @@ public void testUnDelegateAll2(){
g.width(400);
g.resize();
}
-
+
+ public void testBindUnbindSubmitEvent() {
+ // Add a form and an iframe to the dom. The form target is the iframe
+ $(e).html("<form action='whatever' target='miframe'><input type='text' value='Hello'><input type='submit' value='Go'></form><iframe name='miframe' id='miframe' src=\"javascript:''\">");
+ testSubmitEventCont = 0;
+
+ // Add an onsubmit function to the form returning false to cancel the action
+ $("form").bind(EventsListener.ONSUBMIT, null, new Function() {
+ public boolean f(Event e) {
+ testSubmitEventCont++;
+ return false;
+ }
+ });
+
+ // Check that the onsubmit function is called and the iframe has not changed
+ $("form").submit();
+ assertEquals(1, testSubmitEventCont);
+
+ // Remove the binding
+ $("form").unbind(EventsListener.ONSUBMIT);
+
+ // Check that on submit function is not called and the form has been
+ // submitted
+ $("form").submit();
+ assertEquals(1, testSubmitEventCont);
+ }
+
+ /**
+ * TODO: submit doesn't work with HtmlUnit, investigate and report.
+ * The problem is that preventDefault does not set the
+ * flag e.defaultPrevented || e.returnValue in HtmlUnit native event.
+ */
+ @DoNotRunWith({Platform.HtmlUnitLayout})
public void testSubmitEvent() {
// Add a form and an iframe to the dom. The form target is the iframe
$(e).html("<form action='whatever' target='miframe'><input type='text' value='Hello'><input type='submit' value='Go'></form><iframe name='miframe' id='miframe' src=\"javascript:''\">");
@@ -757,11 +794,14 @@ public void testUnDelegateAll2(){
// submitted
$("form").submit();
assertEquals(1, testSubmitEventCont);
+
+ delayTestFinish(1000);
new Timer() {
public void run() {
// Check that the server returns an error since the action does not
// exist
assertTrue($("#miframe").contents().find("body").text().contains("ERROR"));
+ finishTest();
}
}.schedule(500);
}
@@ -771,17 +811,17 @@ public void testUnDelegateAll2(){
* http://code.google.com/p/gwtquery/issues/detail?id=62
*/
public void testTabInbexInFocusEventBinding(){
- String content="<div id='test'>test content</div>";
+ String content="<div id='mtest'>test content</div>";
$(e).html(content);
- $("#test").focus(new Function(){});
+ $("#mtest").focus(new Function(){});
- assertEquals($("#test").attr("tabIndex"), "0");
+ assertEquals($("#mtest").attr("tabIndex"), "0");
- content="<div id='test' tabIndex='2'>test content</div>";
+ content="<div id='mtest' tabIndex='2'>test content</div>";
$(e).html(content);
- $("#test").focus(new Function(){});
+ $("#mtest").focus(new Function(){});
- assertEquals($("#test").attr("tabIndex"), "2");
+ assertEquals($("#mtest").attr("tabIndex"), "2");
}
public void testUnbindMultipleEvents() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java
new file mode 100644
index 00000000..613d1b58
--- /dev/null
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java
@@ -0,0 +1,31 @@
+package com.google.gwt.query.client;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import com.google.gwt.junit.tools.GWTTestSuite;
+import com.google.gwt.query.client.impl.SelectorEnginesTestGwt;
+
+/**
+ * Class to run all Gwt test in a jvm instance.
+ * It speeds up maven testing phase.
+ */
+public class GQueryGwtSuiteTest extends TestCase
+{
+ public static Test suite()
+ {
+ GWTTestSuite suite = new GWTTestSuite( "GQuery Suite" );
+ suite.addTestSuite(GQuerySelectorsTestGwt.class);
+ suite.addTestSuite(GQueryCoreTestGwt.class);
+ suite.addTestSuite(GQueryCssTestGwt.class);
+ suite.addTestSuite(GQueryEventsTestGwt.class);
+ suite.addTestSuite(GQueryEffectsTestGwt.class);
+ suite.addTestSuite(GQueryJsTestGwt.class);
+ suite.addTestSuite(GQueryWidgetsTestGwt.class);
+ suite.addTestSuite(GQueryAjaxTestGwt.class);
+ suite.addTestSuite(SelectorEnginesTestGwt.class);
+ return suite;
+ }
+
+
+}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java
index 6a1a0081..3884286c 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java
@@ -27,7 +27,7 @@ import com.google.gwt.user.client.ui.RootPanel;
/**
* Test class for testing js classes.
*/
-public class GQueryJsTest extends GWTTestCase {
+public class GQueryJsTestGwt extends GWTTestCase {
static Element e = null;
@@ -48,6 +48,11 @@ public class GQueryJsTest extends GWTTestCase {
}
}
+ public void gwtTearDown() {
+ $(e).remove();
+ e = null;
+ }
+
public void testJsCache() {
String[] slist = new String[]{"A", "B", "C"};
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java
index 9cba7b22..ea54759a 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java
@@ -39,7 +39,7 @@ import com.google.gwt.user.client.ui.RootPanel;
/**
* Test for selectors
*/
-public class GQuerySelectorsTest extends GWTTestCase {
+public class GQuerySelectorsTestGwt extends GWTTestCase {
boolean runSlow = false;
@@ -167,6 +167,11 @@ public class GQuerySelectorsTest extends GWTTestCase {
return "com.google.gwt.query.Query";
}
+ public void gwtTearDown() {
+ $(e).remove();
+ e = null;
+ }
+
public void gwtSetUp() {
if (e == null) {
testPanel = new HTML();
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java
index 9a9ee9d0..57d87dbf 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java
@@ -35,7 +35,7 @@ import com.google.gwt.user.client.ui.Widget;
/**
* Test class for testing gwtquery widgets plugin api.
*/
-public class GQueryWidgetsTest extends GWTTestCase {
+public class GQueryWidgetsTestGwt extends GWTTestCase {
static Element e = null;
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java
index f51e119b..41aabee6 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/JreQueryCoreTest.java
@@ -27,9 +27,9 @@ public class JreQueryCoreTest extends GWTTestCase {
}
public void testAssertHtmlEquals() {
- GQueryCoreTest.assertHtmlEquals("<span>hello</span>",
+ GQueryCoreTestGwt.assertHtmlEquals("<span>hello</span>",
"<span $h=\"5\">hello</span>");
- GQueryCoreTest.assertHtmlEquals("<p class=\"abc\">whatever</p> ",
+ GQueryCoreTestGwt.assertHtmlEquals("<p class=\"abc\">whatever</p> ",
" <p class=abc added=\"null\">Whatever</p>");
}
@@ -53,14 +53,5 @@ public class JreQueryCoreTest extends GWTTestCase {
assertEquals("{\"$x\":22.60,\"$y\":\".0\",\"h\":\"#y\"}", Properties
.wrapPropertiesString("$x:22.60,$y:.0,h:#y"));
}
-
- public void testtt() {
- String selector = "div[class!=madeup]";
- if (selector.matches(".*\\[\\w+!=[^\\]]+\\].*")) {
- System.out.println("OK");
- selector = selector.replaceAll("(\\[\\w+)!(=[^\\]]+\\])", ":not($1$2)");
- }
- System.out.println(selector);
- }
}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java
index 51a63104..a3422438 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java
@@ -16,6 +16,7 @@
package com.google.gwt.query.client.impl;
import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.query.rebind.SelectorGeneratorCssToXPath;
/**
* Test for selector engine implementations
@@ -23,12 +24,17 @@ import com.google.gwt.junit.client.GWTTestCase;
public class SelectorEnginesTest extends GWTTestCase {
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return null;
}
public void testCssToXpath() {
SelectorEngineCssToXPath sel = new SelectorEngineCssToXPath();
+ if (getModuleName() == null) {
+ sel = new SelectorEngineCssToXPath(SelectorEngineCssToXPath.replacerGwt);
+ }
+
+
assertEquals(".//div[starts-with(@class,'exa') and (substring(@class,string-length(@class)-3)='mple')]",
sel.css2Xpath("div[class^=exa][class$=mple]"));
assertEquals(".//div[not(contains(concat(' ',normalize-space(@class),' '),' example '))]",
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java
new file mode 100644
index 00000000..8ff63a51
--- /dev/null
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011, The gwtquery team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.query.client.impl;
+
+
+/**
+ * Test for selector engine implementations run in gwt
+ */
+public class SelectorEnginesTestGwt extends SelectorEnginesTest {
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.query.Query";
+ }
+
+}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java
index 7ebf3fa3..5830e9ec 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java
@@ -36,8 +36,8 @@ public class SelectorGeneratorsTest extends GWTTestCase {
Object[] regs = SelectorEngineCssToXPath.regs;
String r1 = s, r2 = s;
for (int i = 0; i < regs.length;) {
- r1 = SelectorGeneratorCssToXPath.replacerJvm.replaceAll(r1, regs[i].toString(), regs[i+1]);
- r2 = SelectorGeneratorCssToXPath.replacer.replaceAll(r2, regs[i].toString(), regs[i+1]);
+ r1 = SelectorGeneratorCssToXPath.replacer.replaceAll(r1, regs[i].toString(), regs[i+1]);
+ r2 = SelectorEngineCssToXPath.replacerGwt.replaceAll(r2, regs[i].toString(), regs[i+1]);
i+=2;
}
assertEquals(r1, r2);
@@ -100,7 +100,7 @@ public class SelectorGeneratorsTest extends GWTTestCase {
public void testReplaceAll() {
assertEquals("<img src='thumbs/01'/> <img src='thumbs/03'/>",
- SelectorGeneratorCssToXPath.replacerGwt.replaceAll("/[thumb01]/ /[thumb03]/", "/\\[thumb(\\d+)\\]/", new ReplaceCallback() {
+ SelectorEngineCssToXPath.replacerGwt.replaceAll("/[thumb01]/ /[thumb03]/", "/\\[thumb(\\d+)\\]/", new ReplaceCallback() {
public String foundMatch(ArrayList<String>s) {
return "<img src='thumbs/" + s.get(1) + "'/>";
}