Reviewers: jlabanca, Description: Extends ClassInitTest (the mockability test) to ensure the mockability of classes in com.google.gwt.dom.client, and fixes a couple of spots where they weren't.
Please review this at http://gwt-code-reviews.appspot.com/20803 Affected files: user/src/com/google/gwt/dom/client/ImageSrcIE6.java user/src/com/google/gwt/dom/client/StyleInjector.java user/test/com/google/gwt/user/ClassInitTest.java Index: user/test/com/google/gwt/user/ClassInitTest.java =================================================================== --- user/test/com/google/gwt/user/ClassInitTest.java (revision 5228) +++ user/test/com/google/gwt/user/ClassInitTest.java (working copy) @@ -22,9 +22,14 @@ import java.io.File; /** - * Tests that every class in com.google.gwt.user.client.ui and - * com.google.gwt.user.datepicker.client can be init'd by the real Java - * runtime. By ensuring this, we ensure that these classes all may be referenced + * Tests that every class in various UI packages can be init'd by the real Java + * runtime, specifically: + * <ul> + * <li>com.google.gwt.user.client.ui + * <li>com.google.gwt.user.datepicker.client + * <li>com.google.gwt.dom.client + * </ul> + * <p>By ensuring this, we ensure that these classes all may be referenced * mocked out by pure Java unit tests, e.g. with EasyMock Class Extension */ public class ClassInitTest extends TestCase { @@ -49,6 +54,10 @@ doPackage("com.google.gwt.user.datepicker.client"); } + public void testDom() throws ClassNotFoundException { + doPackage("com.google.gwt.dom.client"); + } + private void doPackage(String packageName) throws ClassNotFoundException { String path = packageNameToPath(packageName); File directory = pathToResourceDirectory(path); Index: user/src/com/google/gwt/dom/client/StyleInjector.java =================================================================== --- user/src/com/google/gwt/dom/client/StyleInjector.java (revision 5228) +++ user/src/com/google/gwt/dom/client/StyleInjector.java (working copy) @@ -85,9 +85,18 @@ * multiple GWT modules are living in the same page. */ private static final int MAX_STYLE_SHEETS = 30; - private static final JsArray<StyleElement> STYLE_ELEMENTS = JavaScriptObject.createArray().cast(); - private static final JsArrayInteger STYLE_ELEMENT_LENGTHS = JavaScriptObject.createArray().cast(); - + private static final JsArray<StyleElement> STYLE_ELEMENTS; + private static final JsArrayInteger STYLE_ELEMENT_LENGTHS; + static { + if (GWT.isScript()) { + STYLE_ELEMENTS = JavaScriptObject.createArray().cast(); + STYLE_ELEMENT_LENGTHS = JavaScriptObject.createArray().cast(); + } else { + STYLE_ELEMENTS = null; + STYLE_ELEMENT_LENGTHS = null; + } + } + public native void appendContents(StyleElement style, String contents) /*-{ style.cssText += contents; }-*/; Index: user/src/com/google/gwt/dom/client/ImageSrcIE6.java =================================================================== --- user/src/com/google/gwt/dom/client/ImageSrcIE6.java (revision 5228) +++ user/src/com/google/gwt/dom/client/ImageSrcIE6.java (working copy) @@ -15,6 +15,7 @@ */ package com.google.gwt.dom.client; +import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; /** @@ -35,7 +36,9 @@ private static JavaScriptObject srcImgMap; static { - executeBackgroundImageCacheCommand(); + if (GWT.isScript()) { + executeBackgroundImageCacheCommand(); + } } /** --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---