Revision: 6580
Author: [email protected]
Date: Mon Nov  2 08:50:07 2009
Log: Implement a -standardsMode flag for junit tests, but don't enable the
tests just yet.

Review by: jlabanca


http://code.google.com/p/google-web-toolkit/source/detail?r=6580

Added:
  /trunk/user/src/com/google/gwt/junit/public/junit-standards.html
  /trunk/user/test/com/google/gwt/i18n/public_es_AR/junit-standards.html
  /trunk/user/test/com/google/gwt/i18n/public_es_MX/junit-standards.html
Modified:
  /trunk/user/build.xml
  /trunk/user/src/com/google/gwt/junit/JUnitShell.java
   
/trunk/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java

=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/junit/public/junit-standards.html    Mon  
Nov  2 08:50:07 2009
@@ -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>
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/i18n/public_es_AR/junit-standards.html      
 
Mon Nov  2 08:50:07 2009
@@ -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>
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/i18n/public_es_MX/junit-standards.html      
 
Mon Nov  2 08:50:07 2009
@@ -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>
=======================================
--- /trunk/user/build.xml       Sun Nov  1 08:30:34 2009
+++ /trunk/user/build.xml       Mon Nov  2 08:50:07 2009
@@ -42,6 +42,12 @@
    <property name="gwt.junit.testcase.noserver.includes"  
value="**/IFrameLinkerTest.class" />
    <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>
=======================================
--- /trunk/user/src/com/google/gwt/junit/JUnitShell.java        Fri Oct 30  
14:27:25 2009
+++ /trunk/user/src/com/google/gwt/junit/JUnitShell.java        Mon Nov  2  
08:50:07 2009
@@ -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.
=======================================
---  
/trunk/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
      
Tue Oct 13 16:57:19 2009
+++  
/trunk/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTRunner.java
      
Mon Nov  2 08:50:07 2009
@@ -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;

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to