Author: sp...@google.com
Date: Fri Mar 27 07:58:53 2009
New Revision: 5094

Added:
    trunk/user/src/com/google/gwt/junit/RunStyleNoServerHosted.java    
(contents, props changed)
Modified:
    trunk/user/build.xml
    trunk/user/src/com/google/gwt/junit/JUnitShell.java
    trunk/user/src/com/google/gwt/junit/RunStyle.java

Log:
Adds a test for -noserver hosted mode.

Review by: jat



Modified: trunk/user/build.xml
==============================================================================
--- trunk/user/build.xml        (original)
+++ trunk/user/build.xml        Fri Mar 27 07:58:53 2009
@@ -13,11 +13,14 @@

    <fileset id="default.emma.tests" dir="${javac.junit.out}"
         includes="**/EmmaClassLoadingTest.class" />
-
+
    <fileset id="default.hosted.emma.tests" dir="${javac.junit.out}"
        excludes="**/CoverageTest.class,**/CompilerSuite.class"  
includes="${gwt.junit.emmatestcase.includes}" />
    <!-- everything succeeds except CoverageTest.java. It fails due to a  
javac bug in sun/OpenJDK's Java. See the file contents for details -->
-
+
+  <fileset id="default.noserver.tests" dir="${javac.junit.out}"  
includes="**/IFrameLinkerTest.class" />
+  <!-- Only IFrameLinker actually supports -noserver mode; run the other  
linker tests if and when they are supported -->
+
    <!--
      Default web mode test cases
    -->
@@ -49,11 +52,11 @@

    <!--
      Compile test code for dev/core to pick up TypeOracleTestUtils and  
others.
-  -->  
+  -->
    <target name="compile.dev.core.tests" description="Compiles test  
dependencies in dev/core">
      <gwt.ant dir="../dev/core" target="compile.tests" />
    </target>
-
+
    <target name="compile.tests" depends="compile.dev.core.tests"  
description="Compiles the test code for this project">
      <mkdir dir="${javac.junit.out}" />
      <gwt.javac srcdir="test" excludes="com/google/gwt/langtest/**"  
destdir="${javac.junit.out}">
@@ -126,11 +129,19 @@
          <pathelement location="${gwt.build}/out/dev/core/bin-test" />
          <pathelement location="${gwt.tools.redist}/emma/emma.jar" />
        </extraclasspaths>
-    </gwt.junit>
+    </gwt.junit>
+  </target>
+
+  <target name="test.noserver" depends="compile, compile.tests"  
description="Run noserver hosted-mode tests for this project.">
+    <gwt.junit test.args="${test.args}"  
test.out="${junit.out}/${build.host.platform}-noserver-mode"  
test.cases="default.noserver.tests">
+      <extraclasspaths>
+        <pathelement location="${gwt.build}/out/dev/core/bin-test" />
+      </extraclasspaths>
+    </gwt.junit>
    </target>

    <target name="test.web" depends="compile, compile.tests"  
description="Run only web-mode tests for this project.">
-    <gwt.junit test.args="${test.args} -out www -web"  
test.out="${junit.out}/${build.host.platform}-web-mode"  
test.cases="default.web.tests" >
+    <gwt.junit test.args="${test.args} -out www -web"  
test.out="${junit.out}/${build.host.platform}-web-mode"  
test.cases="default.web.tests">
        <extraclasspaths>
          <pathelement location="${gwt.build}/out/dev/core/bin-test" />
        </extraclasspaths>
@@ -167,6 +178,7 @@
        <!-- remoteweb-test is a no-op unless gwt.remote.browsers is defined  
-->
        <antcall target="remoteweb-test"/>
        <antcall target="test.hosted"/>
+      <antcall target="test.noserver"/>
        <antcall target="test.web"/>
        <antcall target="test.web.disableClassMetadata"/>
        <antcall target="test.web.draft"/>
@@ -179,6 +191,6 @@
      <delete file="${project.lib}" />
    </target>
    <target name="presubmit" depends="test, checkstyle" description="runs  
the gwt api checker, user checkstyle, and user tests">
-   <gwt.ant dir=".." target="apicheck-nobuild"/>
+    <gwt.ant dir=".." target="apicheck-nobuild"/>
    </target>
  </project>

Modified: trunk/user/src/com/google/gwt/junit/JUnitShell.java
==============================================================================
--- trunk/user/src/com/google/gwt/junit/JUnitShell.java (original)
+++ trunk/user/src/com/google/gwt/junit/JUnitShell.java Fri Mar 27 07:58:53  
2009
@@ -116,6 +116,25 @@
        registerHandler(new ArgHandlerFlag() {
          @Override
          public String getPurpose() {
+          return "Causes your test to run in -noserver hosted mode  
(defaults to hosted mode)";
+        }
+
+        @Override
+        public String getTag() {
+          return "-noserver";
+        }
+
+        @Override
+        public boolean setFlag() {
+          runStyle = new RunStyleNoServerHosted(JUnitShell.this);
+          numClients = 1;
+          return true;
+        }
+      });
+
+      registerHandler(new ArgHandlerFlag() {
+        @Override
+        public String getPurpose() {
            return "Causes your test to run in web (compiled) mode (defaults  
to hosted mode)";
          }

@@ -587,6 +606,11 @@
      }

      return !messageQueue.hasResult();
+  }
+
+  @Override
+  protected boolean shouldAutoGenerateResources() {
+    return runStyle.shouldAutoGenerateResources();
    }

    @Override

Modified: trunk/user/src/com/google/gwt/junit/RunStyle.java
==============================================================================
--- trunk/user/src/com/google/gwt/junit/RunStyle.java   (original)
+++ trunk/user/src/com/google/gwt/junit/RunStyle.java   Fri Mar 27 07:58:53  
2009
@@ -60,6 +60,15 @@
        throws UnableToCompleteException;

    /**
+   * Whether the embedded server should ever generate resources.  Hosted  
mode
+   * needs this, but not noserver hosted.  TODO(spoon) does web mode get
+   * simpler if this is turned on?
+   */
+  public boolean shouldAutoGenerateResources() {
+    return true;
+  }
+
+  /**
     * Tests whether the test was interrupted.
     *
     * @return <code>true</code> if the test has been interrupted.

Added: trunk/user/src/com/google/gwt/junit/RunStyleNoServerHosted.java
==============================================================================
--- (empty file)
+++ trunk/user/src/com/google/gwt/junit/RunStyleNoServerHosted.java     Fri Mar 
 
27 07:58:53 2009
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 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.
+ */
+package com.google.gwt.junit;
+
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.shell.BrowserWidget;
+
+/**
+ * <p>
+ * This run style simulates -noserver hosted mode. It is the same as  
hosted mode
+ * except for two differences:
+ * </p>
+ *
+ * <ol>
+ * <li>The program is compiled for web mode.
+ * <li>The embedded server does not do any GWT-specific resource  
generation.
+ * </ol>
+ *
+ * <p>
+ * In effect, the built-in web server gets used as a dumb web server to  
serve up
+ * the compiled files.
+ * </p>
+ */
+public class RunStyleNoServerHosted extends RunStyleLocalHosted {
+  RunStyleNoServerHosted(JUnitShell shell) {
+    super(shell);
+  }
+
+  @Override
+  public void maybeCompileModule(String moduleName)
+      throws UnableToCompleteException {
+    BrowserWidget browserWindow = getBrowserWindow();
+    shell.compileForWebMode(moduleName, browserWindow.getUserAgent());
+  }
+
+  @Override
+  public boolean shouldAutoGenerateResources() {
+    // pretend to be a web server that knows nothing about GWT
+    return false;
+  }
+}

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

Reply via email to