Address RunStyle TODO

Review at: http://gwt-code-reviews.appspot.com/1529805/


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10577 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index eb9b112..1911031 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -74,6 +74,7 @@
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
@@ -1220,11 +1221,7 @@
   }
 
   private boolean mustNotExecuteTest(Set<Platform> bannedPlatforms) {
-    // TODO (amitmanjhi): Remove this hard-coding. A RunStyle somehow needs to
-    // specify how it interacts with the platforms.
-    if (runStyle instanceof RunStyleHtmlUnit
-        && (bannedPlatforms.contains(Platform.HtmlUnitUnknown)
-            || bannedPlatforms.contains(Platform.HtmlUnitLayout) || bannedPlatforms.contains(Platform.HtmlUnitBug))) {
+    if (!Collections.disjoint(bannedPlatforms, runStyle.getPlatforms())) {
       return true;
     }
 
diff --git a/user/src/com/google/gwt/junit/RunStyle.java b/user/src/com/google/gwt/junit/RunStyle.java
index a7aaa8d..240c1b2 100644
--- a/user/src/com/google/gwt/junit/RunStyle.java
+++ b/user/src/com/google/gwt/junit/RunStyle.java
@@ -20,6 +20,8 @@
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.Collections;
+import java.util.Set;
 
 /**
  * An abstract class that handles the details of launching a browser.
@@ -69,6 +71,13 @@
   }
 
   /**
+   * Returns the platforms specific to this run style.
+   */
+  public Set<Platform> getPlatforms() {
+    return Collections.emptySet();
+  }
+
+  /**
    * Returns the number of times this test should be tried to run. A test
    * succeeds if it succeeds even once.
    * 
diff --git a/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java b/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
index efc9949..f4eaed2 100644
--- a/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
+++ b/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
@@ -17,6 +17,7 @@
 
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.dev.shell.HostedModePluginObject;
+import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
 
 import com.gargoylesoftware.htmlunit.AlertHandler;
 import com.gargoylesoftware.htmlunit.BrowserVersion;
@@ -180,6 +181,9 @@
    */
   private static final int DEFAULT_TRIES = 1;
 
+  private static final Set<Platform> PLATFORMS = ImmutableSet.of(Platform.HtmlUnitBug,
+      Platform.HtmlUnitLayout, Platform.HtmlUnitUnknown);
+
   /**
    * Returns the list of browsers Htmlunit emulates as a comma separated string.
    */
@@ -217,6 +221,11 @@
   }
 
   @Override
+  public Set<Platform> getPlatforms() {
+    return PLATFORMS;
+  }
+
+  @Override
   public int initialize(String args) {
     if (args == null || args.length() == 0) {
       // If no browsers specified, default to Firefox 3.