From cfb69bb3d472032f78917d576eb01dfa18775fa2 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 15 Apr 2011 08:04:16 +0000 Subject: [PATCH] fix tests --- .../com/google/gwt/query/client/Function.java | 35 ++++++++++--------- .../gwt/query/client/GQueryCoreTest.java | 11 ++++-- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java index b32e4ccb..19e7221f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java @@ -31,6 +31,8 @@ public abstract class Function { * */ public void cancel(Element e) { + // This has to be the order of calls + cancel(e.cast()); } /** @@ -40,7 +42,6 @@ public abstract class Function { * */ public void cancel(com.google.gwt.dom.client.Element e) { - cancel((Element)e); } /** @@ -59,13 +60,8 @@ public abstract class Function { * */ public Object f(Element e, int i) { - Widget w = GQuery.getAssociatedWidget(e); - if (w != null){ - f(w, i); - } else { - f(e); - } - return null; + // This has to be the order of calls + return f(e.cast(), i); } /** @@ -76,7 +72,13 @@ public abstract class Function { * */ public Object f(com.google.gwt.dom.client.Element e, int i) { - return f(e.cast(), i); + Widget w = GQuery.getAssociatedWidget(e); + if (w != null){ + f(w, i); + } else { + f(e); + } + return null; } /** @@ -115,12 +117,8 @@ public abstract class Function { * @param e takes a com.google.gwt.user.client.Element */ public void f(Element e) { - Widget w = GQuery.getAssociatedWidget(e); - if (w != null){ - f(w); - }else{ - f(); - } + // This has to be the order of calls + f(e.cast()); } /** @@ -130,7 +128,12 @@ public abstract class Function { * @param e takes a com.google.gwt.dom.client.Element */ public void f(com.google.gwt.dom.client.Element e) { - f((Element)e); + Widget w = GQuery.getAssociatedWidget(e); + if (w != null){ + f(w); + }else{ + f(); + } } /** 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/GQueryCoreTest.java index b44a8394..b3c6bf94 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/GQueryCoreTest.java @@ -1271,15 +1271,20 @@ public class GQueryCoreTest extends GWTTestCase { } public void testMap() { - String html = "

"; + String html = "
" + + "" + + "

" + + "" + + "" + + "" + + ""; $(e).html(html); GQuery c = $(e).children(); - assertEquals(8, c.size()); + assertEquals(7, c.size()); // A list of lists containing tag,class,id, remove elements without id List> m = $(e).children().map(new Function() { - @SuppressWarnings("unchecked") public List f(Element e, int i) { // map does not add to the list null elements if ($(e).attr("id").isEmpty() || $(e).attr("class").isEmpty()) { -- 2.39.5