Author: [email protected]
Date: Mon Mar 9 09:21:53 2009
New Revision: 4959
Modified:
releases/1.6/user/src/com/google/gwt/user/client/ui/RootPanel.java
releases/1.6/user/test/com/google/gwt/user/client/ui/ElementWrappingTest.java
releases/1.6/user/test/com/google/gwt/user/client/ui/ImageTest.java
Log:
Fixes several broken tests, most of which were occurring because
ElementWrappingTest.testOnUnloadDetachesAllWidgets() was leaving the default
RootPanel in an unattached state. We deal with this by having
RootPanel.detachWidgets() clear out the RootPanel cache.
Also fixes ImageTest.testWrapThenSetUrlAndVisibleRect(), which would
otherwise
begin failing the build as soon as these other issues are fixed (it began
failing after recent changes to RootPanel behavior began catching certain
errors earlier).
Review by: scottb (desk check)
Modified: releases/1.6/user/src/com/google/gwt/user/client/ui/RootPanel.java
==============================================================================
--- releases/1.6/user/src/com/google/gwt/user/client/ui/RootPanel.java
(original)
+++ releases/1.6/user/src/com/google/gwt/user/client/ui/RootPanel.java Mon
Mar 9 09:21:53 2009
@@ -229,6 +229,12 @@
}
widgetsToDetach.clear();
+
+ // Clear the RootPanel cache, since we've "detached" all RootPanels at
this
+ // point. This would be pointless, since it only happens on unload,
but it
+ // is very helpful for unit tests, because it allows RootPanel.get()
to work
+ // properly even after a synthesized "unload".
+ rootPanels.clear();
}
/**
Modified:
releases/1.6/user/test/com/google/gwt/user/client/ui/ElementWrappingTest.java
==============================================================================
---
releases/1.6/user/test/com/google/gwt/user/client/ui/ElementWrappingTest.java
(original)
+++
releases/1.6/user/test/com/google/gwt/user/client/ui/ElementWrappingTest.java
Mon Mar 9 09:21:53 2009
@@ -292,30 +292,26 @@
/**
* Tests that wrapping an element that is already a child of an existing
* widget's element fails.
- *
- * TODO: Re-enable this test asap. When running the full UISuite, a
previous
- * test is somehow leaving the RootPanel in an unattached state (which
shouldn't
- * normally be possible).
*/
-// public void testWrappingChildElementFails() {
-// // Testing hosted-mode-only assertion.
-// if (!GWT.isScript()) {
-// try {
-// // Create a panel that contains HTML with a unique id, which
we're
-// // going to try and wrap below.
-// FlowPanel p = new FlowPanel();
-// RootPanel.get().add(p);
-// p.add(new HTML("<a id='twcef_id'>foo</a>"));
-//
-// // Get the element and try to wrap it.
-// Element unwrappableElement =
Document.get().getElementById("twcef_id");
-// Anchor.wrap(unwrappableElement);
-// fail("Attempting to wrap the above element should have failed.");
-// } catch (AssertionError e) {
-// // Expected error.
-// }
-// }
-// }
+ public void testWrappingChildElementFails() {
+ // Testing hosted-mode-only assertion.
+ if (!GWT.isScript()) {
+ try {
+ // Create a panel that contains HTML with a unique id, which we're
+ // going to try and wrap below.
+ FlowPanel p = new FlowPanel();
+ RootPanel.get().add(p);
+ p.add(new HTML("<a id='twcef_id'>foo</a>"));
+
+ // Get the element and try to wrap it.
+ Element unwrappableElement =
Document.get().getElementById("twcef_id");
+ Anchor.wrap(unwrappableElement);
+ fail("Attempting to wrap the above element should have failed.");
+ } catch (AssertionError e) {
+ // Expected error.
+ }
+ }
+ }
/**
* Tests that wrap() may only be called on elements that are already
attached
Modified:
releases/1.6/user/test/com/google/gwt/user/client/ui/ImageTest.java
==============================================================================
--- releases/1.6/user/test/com/google/gwt/user/client/ui/ImageTest.java
(original)
+++ releases/1.6/user/test/com/google/gwt/user/client/ui/ImageTest.java Mon
Mar 9 09:21:53 2009
@@ -15,6 +15,7 @@
*/
package com.google.gwt.user.client.ui;
+import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.event.dom.client.ErrorEvent;
import com.google.gwt.event.dom.client.ErrorHandler;
@@ -430,9 +431,10 @@
*/
public void testWrapThenSetUrlAndVisibleRect() {
String uid = Document.get().createUniqueId();
- HTML html = new HTML("<img id='" + uid
+ DivElement div = Document.get().createDivElement();
+ div.setInnerHTML("<img id='" + uid
+ "' src='counting-backwards.png' width='16' height='16'>");
- RootPanel.get().add(html);
+ Document.get().getBody().appendChild(div);
final Image image = Image.wrap(Document.get().getElementById(uid));
assertEquals(0, image.getOriginLeft());
@@ -448,5 +450,4 @@
assertEquals(16, image.getHeight());
assertEquals("clipped", getCurrentImageStateName(image));
}
-
}
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---