Revision: 6167 Author: [email protected] Date: Sun Sep 20 11:22:14 2009 Log: Finish restructuring RunStyles. There is a bit more cleanup to do, particularly regarding error handling in argument processing, but the basic functionality intended for 2.0 is there.
http://code.google.com/p/google-web-toolkit/source/detail?r=6167 Deleted: /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleHtmlUnitHosted.java /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleNoServerHosted.java /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleRemote.java Modified: /changes/jat/noswt/user/src/com/google/gwt/junit/JUnitShell.java /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyle.java /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleExternalBrowser.java /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleManual.java /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleSelenium.java ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleHtmlUnitHosted.java Sun Sep 20 08:43:57 2009 +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.TreeLogger; -import com.google.gwt.dev.shell.HostedModePluginObject; -import com.google.gwt.dev.util.log.PrintWriterTreeLogger; - -import com.gargoylesoftware.htmlunit.BrowserVersion; -import com.gargoylesoftware.htmlunit.WebClient; -import com.gargoylesoftware.htmlunit.WebWindow; -import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine; -import com.gargoylesoftware.htmlunit.javascript.host.Window; - -import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; - -/** - * Runstyle for HTMLUnit in hosted mode. - */ -public class RunStyleHtmlUnitHosted extends RunStyleHtmlUnit { - - /** - * Run HMTLUnit in a separate thread, replacing the default JavaScriptEngine - * with one that has the necessary hosted mode hooks. - */ - protected static class HtmlUnitHostedThread extends HtmlUnitThread { - - public HtmlUnitHostedThread(BrowserVersion browser, String url, - TreeLogger treeLogger) { - super(browser, url, treeLogger); - } - - @Override - protected void setupWebClient(WebClient webClient) { - JavaScriptEngine hostedEngine = new HostedJavaScriptEngine(webClient); - webClient.setJavaScriptEngine(hostedEngine); - } - } - - /** - * JavaScriptEngine subclass that provides a hook of initializing the - * __gwt_HostedModePlugin property on any new window, so it acts just like - * Firefox with the XPCOM plugin installed. - */ - private static class HostedJavaScriptEngine extends JavaScriptEngine { - - private static final long serialVersionUID = 3594816610842448691L; - - public HostedJavaScriptEngine(WebClient webClient) { - super(webClient); - } - - @Override - public void initialize(WebWindow webWindow) { - // Hook in the hosted-mode plugin after initializing the JS engine. - super.initialize(webWindow); - Window window = (Window) webWindow.getScriptObject(); - window.defineProperty("__gwt_HostedModePlugin", - new HostedModePluginObject(), ScriptableObject.READONLY); - } - } - - public static HtmlUnitThread createHtmlUnitThread(BrowserVersion browser, - String url, TreeLogger treeLogger) { - return new HtmlUnitHostedThread(browser, url, treeLogger); - } - - public static void startHtmlUnitThread(String url) { - PrintWriterTreeLogger pw = new PrintWriterTreeLogger(); - // TODO(amitmanjhi): get the correct browser emulation - HtmlUnitThread thread = createHtmlUnitThread( - BrowserVersion.FIREFOX_3, url, pw); - thread.start(); - } - - public RunStyleHtmlUnitHosted(JUnitShell unitShell) { - super(unitShell); - } - - public RunStyleHtmlUnitHosted(JUnitShell unitShell, String... targets) { - super(unitShell, targets); - } - - @Override - protected HtmlUnitThread createHtmlUnitThread(BrowserVersion browser, - String url) { - return RunStyleHtmlUnitHosted.createHtmlUnitThread(browser, url, - shell.getTopLogger()); - } -} ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleNoServerHosted.java Wed Sep 16 16:30:53 2009 +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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; - -/** - * <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 RunStyleHtmlUnitHosted { - RunStyleNoServerHosted(JUnitShell shell) { - super(shell); - } - - @Override - public boolean shouldAutoGenerateResources() { - // pretend to be a web server that knows nothing about GWT - return false; - } -} ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleRemote.java Sun Sep 20 08:43:57 2009 +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ -package com.google.gwt.junit; - -/** - * Runs remotely in web mode. This feature is experimental and is not officially - * supported. - */ -abstract class RunStyleRemote extends RunStyle { - - public RunStyleRemote(JUnitShell shell) { - super(shell); - } - - @Override - public boolean isLocal() { - return false; - } -} ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/JUnitShell.java Sun Sep 20 08:43:57 2009 +++ /changes/jat/noswt/user/src/com/google/gwt/junit/JUnitShell.java Sun Sep 20 11:22:14 2009 @@ -35,7 +35,6 @@ import com.google.gwt.junit.client.impl.GWTRunner; import com.google.gwt.junit.client.impl.JUnitResult; import com.google.gwt.junit.client.impl.JUnitHost.TestInfo; -import com.google.gwt.util.tools.ArgHandler; import com.google.gwt.util.tools.ArgHandlerFlag; import com.google.gwt.util.tools.ArgHandlerString; @@ -43,6 +42,8 @@ import junit.framework.TestCase; import junit.framework.TestResult; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.UnknownHostException; @@ -142,8 +143,7 @@ @Override public boolean setFlag() { - // TODO(jat): add back -noserver mode - numClients = 1; + shouldAutoGenerateResources = false; return true; } }); @@ -162,7 +162,6 @@ @Override public boolean setFlag() { developmentMode = false; - numClients = 1; return true; } }); @@ -170,153 +169,68 @@ registerHandler(new ArgHandlerString() { @Override public String getPurpose() { - return "Runs web mode via RMI to a set of BrowserManagerServers; " - + "e.g. rmi://localhost/ie6,rmi://localhost/firefox"; + return "Selects the runstyle to use for this test. The name is " + + "a suffix of com.google.gwt.junit.RunStyle or is a fully " + + "qualified class name, and may be followed with a colon and " + + "an argument for this runstyle."; } @Override public String getTag() { - return "-remoteweb"; + return "-runStyle"; } @Override public String[] getTagArgs() { - return new String[] {"rmiUrl"}; + return new String[] {"runstyle[:args]"}; } @Override public boolean isUndocumented() { - return true; + return false; } @Override - public boolean setString(String str) { - String[] urls = str.split(","); - // TODO(jat): support hosted mode here - developmentMode = false; - runStyle = RunStyleRemoteWeb.create(JUnitShell.this, urls); - numClients = urls.length; - return runStyle != null; - } - }); - - registerHandler(new ArgHandlerString() { - @Override - public String getPurpose() { - return "Runs web mode via HTTP to a set of Selenium servers; " - + "e.g. localhost:4444/*firefox,remotehost:4444/*iexplore"; - } - - @Override - public String getTag() { - return "-selenium"; - } - - @Override - public String[] getTagArgs() { - return new String[] {"seleniumHost"}; - } - - @Override - public boolean setString(String str) { - String[] targets = str.split(","); - numClients = targets.length; - // TODO(jat): support hosted mode here - developmentMode = false; - runStyle = RunStyleSelenium.create(JUnitShell.this, targets); - return runStyle != null; - } - }); - - registerHandler(new ArgHandlerString() { - @Override - public String getPurpose() { - return "Runs hosted mode via HTMLUnit given a list of browsers; " - + "e.g. IE6,IE7,FF2,FF3..."; - } - - @Override - public String getTag() { - return "-htmlunithosted"; - } - - @Override - public String[] getTagArgs() { - return new String[] {"browserNames"}; - } - - @Override - public boolean setString(String str) { - String[] targets = str.split(","); - runStyle = new RunStyleHtmlUnitHosted(JUnitShell.this, targets); - numClients = ((RunStyleHtmlUnit) runStyle).numBrowsers(); - return runStyle != null; - } - }); - - registerHandler(new ArgHandlerString() { - @Override - public String getPurpose() { - return "Runs web mode via HTMLUnit given a list of browsers; " - + "e.g. " + RunStyleHtmlUnit.getBrowserList(); - } - - @Override - public String getTag() { - return "-htmlunit"; - } - - @Override - public String[] getTagArgs() { - return new String[] {"browserNames"}; - } - - @Override - public boolean setString(String str) { - String[] targets = str.split(","); + public boolean setString(String runStyleArg) { + String runStyleName = runStyleArg; + String args = null; + int colon = runStyleArg.indexOf(':'); + if (colon >= 0) { + runStyleName = runStyleArg.substring(0, colon); + args = runStyleArg.substring(colon + 1); + } + if (runStyleName.indexOf('.') < 0) { + runStyleName = RunStyle.class.getName() + runStyleName; + } + Throwable caught = null; try { - // TODO(jat): merge with above - developmentMode = false; - runStyle = new RunStyleHtmlUnit(JUnitShell.this, targets); - numClients = ((RunStyleHtmlUnit) runStyle).numBrowsers(); - return true; - } catch (IllegalArgumentException ex) { - System.err.println(ex.getMessage()); - return false; - } + Class<?> clazz = Class.forName(runStyleName); + Class<? extends RunStyle> runStyleClass = clazz.asSubclass( + RunStyle.class); + Constructor<? extends RunStyle> ctor = runStyleClass.getConstructor( + JUnitShell.class); + runStyle = ctor.newInstance(JUnitShell.this); + return runStyle.initialize(args); + } catch (ClassNotFoundException e) { + caught = e; + } catch (SecurityException e) { + caught = e; + } catch (NoSuchMethodException e) { + caught = e; + } catch (IllegalArgumentException e) { + caught = e; + } catch (InstantiationException e) { + caught = e; + } catch (IllegalAccessException e) { + caught = e; + } catch (InvocationTargetException e) { + caught = e; + } + throw new RuntimeException("Unable to create runStyle " + runStyleArg, + caught); } }); - registerHandler(new ArgHandlerString() { - @Override - public String getPurpose() { - return "Run external browsers in web mode (pass a comma separated list of executables.)"; - } - - @Override - public String getTag() { - return "-externalbrowser"; - } - - @Override - public String[] getTagArgs() { - return new String[] {"browserPaths"}; - } - - @Override - public boolean isUndocumented() { - return true; - } - - @Override - public boolean setString(String str) { - String[] paths = str.split(","); - runStyle = new RunStyleExternalBrowser(JUnitShell.this, paths); - numClients = paths.length; - return runStyle != null; - } - }); - // TODO: currently, only two values but soon may have multiple values. registerHandler(new ArgHandlerString() { @Override @@ -348,53 +262,6 @@ } }); - registerHandler(new ArgHandler() { - @Override - public String[] getDefaultArgs() { - return null; - } - - @Override - public String getPurpose() { - return "Causes the system to wait for a remote browser to connect"; - } - - @Override - public String getTag() { - return "-manual"; - } - - @Override - public String[] getTagArgs() { - return new String[] {"[numClients]"}; - } - - @Override - public int handle(String[] args, int tagIndex) { - int value = 1; - if (tagIndex + 1 < args.length) { - try { - // See if the next item is an integer. - value = Integer.parseInt(args[tagIndex + 1]); - if (value >= 1) { - setInt(value); - return 1; - } - } catch (NumberFormatException e) { - // fall-through - } - } - setInt(1); - return 0; - } - - public void setInt(int value) { - runStyle = new RunStyleManual(JUnitShell.this, value); - developmentMode = false; - numClients = value; - } - }); - registerHandler(new ArgHandlerFlag() { @Override public String getPurpose() { @@ -535,6 +402,7 @@ if (!argProcessor.processArgs(args)) { throw new JUnitFatalLaunchException("Error processing shell arguments"); } + unitTestShell.finalizeArguments(); unitTestShell.messageQueue = new JUnitMessageQueue( unitTestShell.numClients); @@ -599,7 +467,7 @@ /** * What type of test we're running; Local hosted, local web, or remote web. */ - private RunStyle runStyle = new RunStyleHtmlUnitHosted(this); + private RunStyle runStyle = null; /** * True if we are running the test in hosted mode @@ -627,6 +495,8 @@ private Map<TestInfo, Map<String, JUnitResult>> cachedResults = new HashMap<TestInfo, Map<String, JUnitResult>>(); + private boolean shouldAutoGenerateResources = true; + /** * Enforce the singleton pattern. The call to {...@link GWTShell}'s ctor forces * server mode and disables processing extra arguments as URLs to be shown. @@ -675,7 +545,7 @@ if (!super.doStartup()) { return false; } - if (!runStyle.supportsMode(developmentMode)) { + if (!runStyle.setupMode(getTopLogger(), developmentMode)) { getTopLogger().log(TreeLogger.ERROR, "Run style does not support " + (developmentMode ? "development" : "production") + " mode"); return false; @@ -752,9 +622,8 @@ return !messageQueue.hasResult(); } - // TODO (amitmanjhi): GwtShell overlay fix, removed Override. protected boolean shouldAutoGenerateResources() { - return runStyle.shouldAutoGenerateResources(); + return shouldAutoGenerateResources; } void compileForWebMode(String moduleName, String... userAgents) @@ -773,6 +642,17 @@ } super.compile(getTopLogger(), module); } + + /** + * Finish processing command line arguments. + */ + private void finalizeArguments() { + if (runStyle == null) { + // Default to HtmlUnit runstyle with no args + runStyle = new RunStyleHtmlUnit(this); + runStyle.initialize(null); + } + } /** * returns the set of banned {...@code Platform} for a test method. @@ -900,7 +780,7 @@ ConfigurationProperty moduleNameProp = currentModule.getProperties().createConfiguration( "junit.moduleName", false); moduleNameProp.setValue(moduleName); - if (!developmentMode) { + if (!developmentMode || !shouldAutoGenerateResources) { compileForWebMode(syntheticModuleName); } } ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyle.java Sun Sep 20 08:43:57 2009 +++ /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyle.java Sun Sep 20 11:22:14 2009 @@ -29,16 +29,29 @@ protected final JUnitShell shell; /** + * Constructor for RunStyle. Any subclass must provide a constructor with + * the same signature since this will be how the RunStyle is created via + * reflection. + * + * @param logger TreeLogger instance * @param shell the containing shell + * @param args arguments (after the colon in the argument to -runStyle) + * may be null if no argument is supplied */ public RunStyle(JUnitShell shell) { this.shell = shell; } /** - * Returns whether or not the local UI event loop needs to be pumped. + * Initialize the runstyle with any supplied arguments. + * + * @param args arguments passed in -runStyle option, null if none supplied + * @return true if this runstyle is initialized successfully, false if it + * was unsuccessful */ - public abstract boolean isLocal(); + public boolean initialize(String args) { + return true; + } /** * Requests initial launch of the browser. This should only be called once per @@ -51,26 +64,24 @@ 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; - } - - /** - * Return true if this runstyle supports the requested mode. + * Setup this RunStyle for the selected mode. * - * <br>This runstyle should also do any setup work specific to the particular - * mode at this point. - * + * @param logger TreeLogger to use for any messages * @param developmentMode true if we are running in development mode * rather that web/production mode * @return false if we should abort processing due to an unsupported mode * or an error setting up for that mode */ - public boolean supportsMode(boolean developmentMode) { + public boolean setupMode(TreeLogger logger, boolean developmentMode) { + return true; + } + + /** + * 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; } ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleExternalBrowser.java Sun Sep 20 08:43:57 2009 +++ /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleExternalBrowser.java Sun Sep 20 11:22:14 2009 @@ -45,14 +45,24 @@ } } - private final ExternalBrowser[] externalBrowsers; + private ExternalBrowser[] externalBrowsers; /** * @param shell the containing shell * @param browsers an array of path names pointing to browser executables. */ - public RunStyleExternalBrowser(JUnitShell shell, String browsers[]) { + public RunStyleExternalBrowser(JUnitShell shell) { super(shell); + } + + @Override + public boolean initialize(String args) { + if (args == null || args.length() == 0) { + throw new IllegalArgumentException("ExternalBrowser runstyle requires an " + + "argument listing one or more executables of external browsers to " + + "launch"); + } + String browsers[] = args.split(","); synchronized (this) { this.externalBrowsers = new ExternalBrowser[browsers.length]; for (int i = 0; i < browsers.length; ++i) { @@ -60,11 +70,7 @@ } } Runtime.getRuntime().addShutdownHook(new ShutdownCb()); - } - - @Override - public boolean isLocal() { - return false; + return true; } @Override ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java Sun Sep 20 08:43:57 2009 +++ /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java Sun Sep 20 11:22:14 2009 @@ -16,6 +16,7 @@ package com.google.gwt.junit; import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.dev.shell.HostedModePluginObject; import com.gargoylesoftware.htmlunit.AlertHandler; import com.gargoylesoftware.htmlunit.BrowserVersion; @@ -24,7 +25,12 @@ import com.gargoylesoftware.htmlunit.OnbeforeunloadHandler; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine; +import com.gargoylesoftware.htmlunit.javascript.host.Window; + +import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; import java.io.IOException; import java.net.MalformedURLException; @@ -39,7 +45,7 @@ /** * Launches a web-mode test via HTMLUnit. */ -public class RunStyleHtmlUnit extends RunStyleRemote { +public class RunStyleHtmlUnit extends RunStyle { /** * Runs HTMLUnit in a separate thread. @@ -51,13 +57,15 @@ private final String url; private Object waitForUnload = new Object(); private final TreeLogger treeLogger; + private final boolean developmentMode; public HtmlUnitThread(BrowserVersion browser, String url, - TreeLogger treeLogger) { + TreeLogger treeLogger, boolean developmentMode) { this.browser = browser; this.url = url; this.treeLogger = treeLogger; this.setName("htmlUnit client thread"); + this.developmentMode = developmentMode; } public void handleAlert(Page page, String message) { @@ -108,11 +116,34 @@ } } - /** - * Additional setup of the WebClient before starting test. Hook necessary - * for plugging in HtmlUnitHosted. - */ protected void setupWebClient(WebClient webClient) { + if (developmentMode) { + JavaScriptEngine hostedEngine = new HostedJavaScriptEngine(webClient); + webClient.setJavaScriptEngine(hostedEngine); + } + } +} + + /** + * JavaScriptEngine subclass that provides a hook of initializing the + * __gwt_HostedModePlugin property on any new window, so it acts just like + * Firefox with the XPCOM plugin installed. + */ + private static class HostedJavaScriptEngine extends JavaScriptEngine { + + private static final long serialVersionUID = 3594816610842448691L; + + public HostedJavaScriptEngine(WebClient webClient) { + super(webClient); + } + + @Override + public void initialize(WebWindow webWindow) { + // Hook in the hosted-mode plugin after initializing the JS engine. + super.initialize(webWindow); + Window window = (Window) webWindow.getScriptObject(); + window.defineProperty("__gwt_HostedModePlugin", + new HostedModePluginObject(), ScriptableObject.READONLY); } } @@ -143,24 +174,36 @@ return Collections.unmodifiableMap(browserMap); } - private final Set<BrowserVersion> browsers; + private Set<BrowserVersion> browsers = new HashSet<BrowserVersion>(); private final List<Thread> threads = new ArrayList<Thread>(); + private boolean developmentMode; /** * Create a RunStyle instance with the passed-in browser targets. */ public RunStyleHtmlUnit(JUnitShell shell) { - this(shell, "FF3"); + super(shell); } - /** - * Create a RunStyle instance with the passed-in browser targets. - */ - public RunStyleHtmlUnit(JUnitShell shell, String... targetsIn) { - super(shell); - this.browsers = getBrowserSet(targetsIn); - } - + @Override + public boolean initialize(String args) { + if (args == null || args.length() == 0) { + // If no browsers specified, default to Firefox 3. + args = "FF3"; + } + Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>(); + for (String browserName : args.split(",")) { + BrowserVersion browser = BROWSER_MAP.get(browserName); + if (browser == null) { + throw new IllegalArgumentException("Expected browser name: one of " + + BROWSER_MAP.keySet() + ", actual name: " + browserName); + } + browserSet.add(browser); + } + browsers = Collections.unmodifiableSet(browserSet); + return true; + } + @Override public void launchModule(String moduleName) { for (BrowserVersion browser : browsers) { @@ -180,38 +223,16 @@ public int numBrowsers() { return browsers.size(); } + + @Override + public boolean setupMode(TreeLogger logger, boolean developmentMode) { + this.developmentMode = developmentMode; + return true; + } protected HtmlUnitThread createHtmlUnitThread(BrowserVersion browser, String url) { return new HtmlUnitThread(browser, url, shell.getTopLogger().branch( - TreeLogger.SPAM, "logging for HtmlUnit thread")); - } - - private Set<BrowserVersion> getBrowserSet(String[] targetsIn) { - Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>(); - for (String browserName : targetsIn) { - BrowserVersion browser = BROWSER_MAP.get(browserName); - if (browser == null) { - throw new IllegalArgumentException("Expected browser name: one of " - + BROWSER_MAP.keySet() + ", actual name: " + browserName); - } - browserSet.add(browser); - } - return Collections.unmodifiableSet(browserSet); - } - - private String[] getUserAgents() { - Map<BrowserVersion, String> userAgentMap = new HashMap<BrowserVersion, String>(); - userAgentMap.put(BrowserVersion.FIREFOX_2, "gecko1_8"); - userAgentMap.put(BrowserVersion.FIREFOX_3, "gecko"); - userAgentMap.put(BrowserVersion.INTERNET_EXPLORER_6, "ie6"); - userAgentMap.put(BrowserVersion.INTERNET_EXPLORER_7, "ie6"); - - String userAgents[] = new String[numBrowsers()]; - int index = 0; - for (BrowserVersion browser : browsers) { - userAgents[index++] = userAgentMap.get(browser); - } - return userAgents; + TreeLogger.SPAM, "logging for HtmlUnit thread"), developmentMode); } } ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleManual.java Sun Sep 20 08:43:57 2009 +++ /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleManual.java Sun Sep 20 11:22:14 2009 @@ -21,18 +21,26 @@ * Runs in web mode waiting for the user to contact the server with their own * browser. */ -class RunStyleManual extends RunStyleRemote { - - private final int numClients; - - public RunStyleManual(JUnitShell shell, int numClients) { +class RunStyleManual extends RunStyle { + + private int numClients; + + public RunStyleManual(JUnitShell shell) { super(shell); - this.numClients = numClients; } @Override - public boolean isLocal() { - return false; + public boolean initialize(String args) { + numClients = 1; + if (args != null) { + try { + numClients = Integer.parseInt(args); + } catch (NumberFormatException e) { + throw new RuntimeException("Error parsing argument \"" + args + "\"", + e); + } + } + return true; } @Override ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java Sun Sep 20 08:43:57 2009 +++ /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java Sun Sep 20 11:22:14 2009 @@ -32,7 +32,7 @@ * Runs in web mode via browsers managed over RMI. This feature is experimental * and is not officially supported. */ -class RunStyleRemoteWeb extends RunStyleRemote { +class RunStyleRemoteWeb extends RunStyle { static class RMISocketFactoryWithTimeouts extends RMISocketFactory { private static boolean initialized; @@ -195,11 +195,6 @@ } Runtime.getRuntime().addShutdownHook(new ShutdownCb()); } - - @Override - public boolean isLocal() { - return false; - } @Override public synchronized void launchModule(String moduleName) ======================================= --- /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleSelenium.java Sun Sep 20 08:43:57 2009 +++ /changes/jat/noswt/user/src/com/google/gwt/junit/RunStyleSelenium.java Sun Sep 20 11:22:14 2009 @@ -30,7 +30,7 @@ /** * Runs in web mode via browsers managed by Selenium. */ -public class RunStyleSelenium extends RunStyleRemote { +public class RunStyleSelenium extends RunStyle { private static class RCSelenium { final String browser; --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
