Implement a -standardsMode flag for junit tests, but don't enable the
tests just yet.
Review by: jlabanca
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6580 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/build.xml b/user/build.xml
index 26838ad..326784e 100755
--- a/user/build.xml
+++ b/user/build.xml
@@ -43,6 +43,12 @@
<property name="gwt.junit.testcase.noserver.excludes" value="" />
<!--
+ Run LayoutTest in CSS standards mode
+ -->
+ <property name="gwt.junit.testcase.standards.includes" value="**/LayoutTest.class" />
+ <property name="gwt.junit.testcase.standards.excludes" value="" />
+
+ <!--
Whether I18NSuite should test e.g. Foo$InnerMsgs_fr.properties (if the
value is "dollar") or Foo_Inner_fr.properties (for "bar")
-->
@@ -400,6 +406,21 @@
</gwt.junit>
</target>
+ <target name="test.standards"
+ depends="compile, compile.tests"
+ description="Run standards mode tests for this project."
+ unless="test.standards.disable">
+ <fileset id="test.standards.tests" dir="${javac.junit.out}"
+ includes="${gwt.junit.testcase.standards.includes}"
+ excludes="${gwt.junit.testcase.standards.excludes}" />
+ <gwt.junit test.args="${test.args} -web -standardsMode"
+ test.out="${junit.out}/standards" test.cases="test.standards.tests">
+ <extraclasspaths>
+ <path refid="test.extraclasspath" />
+ </extraclasspaths>
+ </gwt.junit>
+ </target>
+
<target name="test.web.htmlunit"
depends="compile, compile.tests"
description="Run web-mode tests with HtmlUnit."
@@ -483,6 +504,8 @@
<!-- <antcall target="test.web.htmlunit"/> -->
<!-- <antcall target="test.draft.htmlunit"/> -->
<!-- <antcall target="test.nometa.htmlunit"/> -->
+ <!-- TODO(rice) : Enable standards mode tests when they are stable. -->
+ <!-- <antcall target="test.standards"/> -->
</parallel>
</limit>
</target>
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index ba83433..0e91b94 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -285,6 +285,24 @@
return true;
}
});
+
+ registerHandler(new ArgHandlerFlag() {
+ @Override
+ public String getPurpose() {
+ return "Use CSS standards mode (rather than quirks mode) for the hosting page";
+ }
+
+ @Override
+ public String getTag() {
+ return "-standardsMode";
+ }
+
+ @Override
+ public boolean setFlag() {
+ setStandardsMode(true);
+ return true;
+ }
+ });
registerHandler(new ArgHandlerString() {
@Override
@@ -605,6 +623,8 @@
private RunStyle runStyle = null;
private boolean shouldAutoGenerateResources = true;
+
+ private boolean standardsMode = false;
/**
* The time the test actually began.
@@ -638,7 +658,8 @@
try {
String localhost = InetAddress.getLocalHost().getHostAddress();
String url = "http://" + localhost + ":" + getPort() + "/"
- + moduleName + "/junit.html";
+ + moduleName
+ + (standardsMode ? "/junit-standards.html" : "/junit.html");
if (developmentMode) {
// CHECKSTYLE_OFF
url += "?gwt.hosted=" + localhost + ":" + codeServerPort;
@@ -812,6 +833,10 @@
void setNumClients(int numClients) {
this.numClients = numClients;
}
+
+ void setStandardsMode(boolean standardsMode) {
+ this.standardsMode = standardsMode;
+ }
/**
* Create the specified (or default) runStyle.
diff --git a/user/src/com/google/gwt/junit/public/junit-standards.html b/user/src/com/google/gwt/junit/public/junit-standards.html
new file mode 100644
index 0000000..6e6eae0
--- /dev/null
+++ b/user/src/com/google/gwt/junit/public/junit-standards.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/DTD/strict.dtd">
+<!--
+Copyright 2008 Google Inc.
+
+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.
+-->
+<html>
+<head>
+<meta name='gwt:onLoadErrorFn' content='junitOnLoadErrorFn'>
+<meta name='gwt:onPropertyErrorFn' content='junitOnPropertyErrorFn'>
+</head>
+<body>
+<script language='javascript'>
+<!--
+function junitOnLoadErrorFn(moduleName) {
+ junitError('Failed to load module "' + moduleName +
+ '".\nPlease see the log for details.');
+}
+
+function junitOnPropertyErrorFn(propName, allowedValues, badValue) {
+ var msg = 'While attempting to load the module, property "' + propName;
+ if (badValue != null) {
+ msg += '" was set to the unexpected value "' + badValue + '"';
+ } else {
+ msg += '" was not specified';
+ }
+ msg += 'Allowed values: ' + allowedValues;
+ junitError(msg);
+}
+
+function junitError(msg) {
+ var xmlHttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
+ xmlHttpRequest.open('POST', 'junithost/loadError', true);
+ xmlHttpRequest.setRequestHeader('Content-Type', 'text/x-gwt-rpc; charset=utf-8');
+ xmlHttpRequest.send(msg);
+}
+
+function loadSelectionScript() {
+ var moduleName = document.location.href;
+ var pos = moduleName.lastIndexOf('/');
+ moduleName = moduleName.substr(0, pos);
+ pos = moduleName.lastIndexOf('/');
+ moduleName = moduleName.substr(pos + 1);
+ document.write("<script language='javascript' src='" + moduleName + ".nocache.js'></script>");
+}
+loadSelectionScript();
+-->
+</script>
+<iframe src="javascript:''" id='__gwt_historyFrame' style='position:absolute;width:0;height:0;border:0'></iframe>
+<noscript>
+ <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
+ Your web browser must have JavaScript enabled
+ in order for this application to display correctly.
+ </div>
+</noscript>
+</body>
+</html>
diff --git a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
index cafa855..d6bc6ad 100644
--- a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
+++ b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
@@ -256,12 +256,16 @@
} else {
/*
* We're being asked to run a test in a different module. We must navigate
- * the browser to a new URL which will run that other module.
+ * the browser to a new URL which will run that other module. We retain
+ * the same path suffix (e.g., '/junit.html') as the current URL.
*/
+ String currentPath = Window.Location.getPath();
+ String pathSuffix = currentPath.substring(currentPath.lastIndexOf('/'));
+
UrlBuilder builder = Window.Location.createUrlBuilder();
builder.setParameter(BLOCKINDEX_QUERY_PARAM,
Integer.toString(currentBlock.getIndex())).setPath(
- newModule + "/junit.html");
+ newModule + pathSuffix);
Window.Location.replace(builder.buildString());
currentBlock = null;
currentTestIndex = 0;
diff --git a/user/test/com/google/gwt/i18n/public_es_AR/junit-standards.html b/user/test/com/google/gwt/i18n/public_es_AR/junit-standards.html
new file mode 100644
index 0000000..e30fb7b
--- /dev/null
+++ b/user/test/com/google/gwt/i18n/public_es_AR/junit-standards.html
@@ -0,0 +1,73 @@
+<!--
+Copyright 2008 Google Inc.
+
+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.
+-->
+<html>
+<head>
+<meta name='gwt:onLoadErrorFn' content='junitOnLoadErrorFn'>
+<meta name='gwt:onPropertyErrorFn' content='junitOnPropertyErrorFn'>
+</head>
+<body>
+<script language='javascript'>
+<!--
+// -- BEGIN CHANGE FROM junit/public/junit.html
+// Set the runtime locale for this test
+// TODO(jat): find a better way to do this that doesn't require duplcating
+// junit.html for each different runtime locale.
+window['__gwt_Locale'] = 'es_AR';
+// -- END CHANGE FROM junit/public/junit.html
+
+function junitOnLoadErrorFn(moduleName) {
+ junitError('Failed to load module "' + moduleName +
+ '".\nPlease see the log for details.');
+}
+
+function junitOnPropertyErrorFn(propName, allowedValues, badValue) {
+ var msg = 'While attempting to load the module, property "' + propName;
+ if (badValue != null) {
+ msg += '" was set to the unexpected value "' + badValue + '"';
+ } else {
+ msg += '" was not specified';
+ }
+ msg += 'Allowed values: ' + allowedValues;
+ junitError(msg);
+}
+
+function junitError(msg) {
+ var xmlHttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
+ xmlHttpRequest.open('POST', 'junithost/loadError', true);
+ xmlHttpRequest.setRequestHeader('Content-Type', 'text/x-gwt-rpc; charset=utf-8');
+ xmlHttpRequest.send(msg);
+}
+
+function loadSelectionScript() {
+ var moduleName = document.location.href;
+ var pos = moduleName.lastIndexOf('/');
+ moduleName = moduleName.substr(0, pos);
+ pos = moduleName.lastIndexOf('/');
+ moduleName = moduleName.substr(pos + 1);
+ document.write("<script language='javascript' src='" + moduleName + ".nocache.js'></script>");
+}
+loadSelectionScript();
+-->
+</script>
+<iframe src="javascript:''" id='__gwt_historyFrame' style='position:absolute;width:0;height:0;border:0'></iframe>
+<noscript>
+ <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
+ Your web browser must have JavaScript enabled
+ in order for this application to display correctly.
+ </div>
+</noscript>
+</body>
+</html>
diff --git a/user/test/com/google/gwt/i18n/public_es_MX/junit-standards.html b/user/test/com/google/gwt/i18n/public_es_MX/junit-standards.html
new file mode 100644
index 0000000..0de069d
--- /dev/null
+++ b/user/test/com/google/gwt/i18n/public_es_MX/junit-standards.html
@@ -0,0 +1,73 @@
+<!--
+Copyright 2008 Google Inc.
+
+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.
+-->
+<html>
+<head>
+<meta name='gwt:onLoadErrorFn' content='junitOnLoadErrorFn'>
+<meta name='gwt:onPropertyErrorFn' content='junitOnPropertyErrorFn'>
+</head>
+<body>
+<script language='javascript'>
+<!--
+// -- BEGIN CHANGE FROM junit/public/junit.html
+// Set the runtime locale for this test
+// TODO(jat): find a better way to do this that doesn't require duplcating
+// junit.html for each different runtime locale.
+window['__gwt_Locale'] = 'es_MX';
+// -- END CHANGE FROM junit/public/junit.html
+
+function junitOnLoadErrorFn(moduleName) {
+ junitError('Failed to load module "' + moduleName +
+ '".\nPlease see the log for details.');
+}
+
+function junitOnPropertyErrorFn(propName, allowedValues, badValue) {
+ var msg = 'While attempting to load the module, property "' + propName;
+ if (badValue != null) {
+ msg += '" was set to the unexpected value "' + badValue + '"';
+ } else {
+ msg += '" was not specified';
+ }
+ msg += 'Allowed values: ' + allowedValues;
+ junitError(msg);
+}
+
+function junitError(msg) {
+ var xmlHttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
+ xmlHttpRequest.open('POST', 'junithost/loadError', true);
+ xmlHttpRequest.setRequestHeader('Content-Type', 'text/x-gwt-rpc; charset=utf-8');
+ xmlHttpRequest.send(msg);
+}
+
+function loadSelectionScript() {
+ var moduleName = document.location.href;
+ var pos = moduleName.lastIndexOf('/');
+ moduleName = moduleName.substr(0, pos);
+ pos = moduleName.lastIndexOf('/');
+ moduleName = moduleName.substr(pos + 1);
+ document.write("<script language='javascript' src='" + moduleName + ".nocache.js'></script>");
+}
+loadSelectionScript();
+-->
+</script>
+<iframe src="javascript:''" id='__gwt_historyFrame' style='position:absolute;width:0;height:0;border:0'></iframe>
+<noscript>
+ <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
+ Your web browser must have JavaScript enabled
+ in order for this application to display correctly.
+ </div>
+</noscript>
+</body>
+</html>