Adds some logging to GWTTestCase at level FINE.
Patch also includes some fixes to test cases that revealed itself
when the Logger is added.
The cluprit of breakage was; DevMode was failed to execute some JSNI calls
(e.g. window.console.log) when document body is cleared.
Change-Id: Idb501edcb83c1e150804f1619024072cec1d6de3
diff --git a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/GWTTestCase.java b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/GWTTestCase.java
index 001913e..098b4c8 100644
--- a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/GWTTestCase.java
+++ b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/GWTTestCase.java
@@ -24,6 +24,9 @@
import junit.framework.TestCase;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
/**
* The translatable implementation of {@link GWTTestCase}.
*/
@@ -71,6 +74,8 @@
}
}
+ private final Logger logger = Logger.getLogger("GWTTestCase");
+
/**
* Tracks whether the main test body has run (for asynchronous mode).
*/
@@ -141,6 +146,7 @@
@Override
public void runBare() throws Throwable {
+ logger.log(Level.FINE, this + " -> Running");
setUp();
runTest();
// No tearDown call here; we do it from reportResults.
@@ -157,6 +163,7 @@
}
protected final void delayTestFinish(int timeoutMillis) {
+ logger.log(Level.FINE, this + " -> Delay test finish: " + timeoutMillis);
if (timer != null) {
// Cancel the pending timer
timer.cancel();
@@ -246,12 +253,15 @@
// ignore any exceptions thrown from tearDown
}
- JUnitResult myResult = new JUnitResult();
+ JUnitResult result = new JUnitResult();
if (ex != null) {
- myResult.setException(ex);
+ result.setException(ex);
}
- GWTRunner.get().reportResultsAndGetNextMethod(myResult);
+ String resultMsg = result.isAnyException() ? "FAILURE" : "SUCCESS";
+ logger.log(Level.FINE, this + " -> Result: " + resultMsg, result.getException());
+
+ GWTRunner.get().reportResultsAndGetNextMethod(result);
}
/**
@@ -289,6 +299,11 @@
}
}
+ @Override
+ public String toString() {
+ return getName() + "(" + testClass + ")";
+ }
+
private static void setAllUncaughtExceptionHandlers(UncaughtExceptionHandler handler) {
Impl.setUncaughtExceptionHandlerForTest(handler);
// TODO(goktug) There is still code out there using GWT#getUncaughtExceptionHandler to report
diff --git a/user/super/com/google/gwt/junit/translatable/junit/framework/TestCase.java b/user/super/com/google/gwt/junit/translatable/junit/framework/TestCase.java
index 77193d5..635b875 100644
--- a/user/super/com/google/gwt/junit/translatable/junit/framework/TestCase.java
+++ b/user/super/com/google/gwt/junit/translatable/junit/framework/TestCase.java
@@ -48,11 +48,6 @@
this.name = name;
}
- @Override
- public String toString() {
- return getName() + "(" + this.getClass().getName() + ")";
- }
-
/**
* Do not override this method, the generated class will override it for you.
*/
diff --git a/user/test/com/google/gwt/dev/jjs/test/RunAsyncMetricsIntegrationTest.java b/user/test/com/google/gwt/dev/jjs/test/RunAsyncMetricsIntegrationTest.java
index 83987e5..0b388d4 100644
--- a/user/test/com/google/gwt/dev/jjs/test/RunAsyncMetricsIntegrationTest.java
+++ b/user/test/com/google/gwt/dev/jjs/test/RunAsyncMetricsIntegrationTest.java
@@ -18,6 +18,8 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.RunAsyncCallback;
+import com.google.gwt.junit.DoNotRunWith;
+import com.google.gwt.junit.Platform;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
@@ -81,6 +83,7 @@
= $stats;
$stats = function(evt) {
self.@com.google.gwt.dev.jjs.test.RunAsyncMetricsIntegrationTest.LightweightMetricsObserver::recordEvent(Lcom/google/gwt/dev/jjs/test/RunAsyncMetricsIntegrationTest$LightweightMetricsEvent;)(evt);
+ return false;
}
}-*/;
@@ -119,11 +122,8 @@
lwmObserver.uninstall();
}
+ @DoNotRunWith(Platform.Devel)
public void testMetricsSignalled() {
- if (!GWT.isScript()) {
- // There are no runAsync lightweight metrics in Development Mode
- return;
- }
delayTestFinish(TIMEOUT);
GWT.runAsync(new RunAsyncCallback() {
@Override
diff --git a/user/test/com/google/gwt/dom/client/DocumentTest.java b/user/test/com/google/gwt/dom/client/DocumentTest.java
index 6139126..2cfeacc 100644
--- a/user/test/com/google/gwt/dom/client/DocumentTest.java
+++ b/user/test/com/google/gwt/dom/client/DocumentTest.java
@@ -147,7 +147,6 @@
Document doc = Document.get();
DivElement div = doc.createDivElement();
- doc.getBody().removeAllChildren();
doc.getBody().appendChild(div);
div.setInnerHTML("<span><button id='foo'>foo</button><span><button>bar</button></span></span>");
@@ -178,7 +177,9 @@
@DoNotRunWith(Platform.HtmlUnitLayout)
public void testScrollLeft() {
Document doc = Document.get();
- doc.getBody().setInnerHTML("<div style='width: 5000px; height: 5000px'></div>");
+ DivElement element = doc.createDivElement();
+ element.setInnerHTML("<div style='width: 5000px; height: 5000px'></div>");
+ doc.getBody().appendChild(element);
doc.setScrollLeft(15);
assertEquals(15, doc.getScrollLeft());
@@ -187,7 +188,9 @@
@DoNotRunWith(Platform.HtmlUnitLayout)
public void testScrollTop() {
Document doc = Document.get();
- doc.getBody().setInnerHTML("<div style='width: 5000px; height: 5000px'></div>");
+ DivElement element = doc.createDivElement();
+ element.setInnerHTML("<div style='width: 5000px; height: 5000px'></div>");
+ doc.getBody().appendChild(element);
doc.setScrollTop(15);
assertEquals(15, doc.getScrollTop());