Adds additional JsExport tests and some test cleanup

Change-Id: Ib6820d2ecaf03a325b31a0dc0f6da098e91bf9ba
diff --git a/user/test/com/google/gwt/core/client/interop/JsExportTest.java b/user/test/com/google/gwt/core/client/interop/JsExportTest.java
index afaf108..5cdd00e 100644
--- a/user/test/com/google/gwt/core/client/interop/JsExportTest.java
+++ b/user/test/com/google/gwt/core/client/interop/JsExportTest.java
@@ -18,7 +18,6 @@
 import static com.google.gwt.core.client.ScriptInjector.TOP_WINDOW;
 
 import com.google.gwt.core.client.ScriptInjector;
-import com.google.gwt.core.client.interop.subpackage.MyNestedExportedClassSansPackageNamespace;
 import com.google.gwt.junit.client.GWTTestCase;
 
 /**
@@ -231,36 +230,54 @@
   }-*/;
 
   public static void testInheritClassNamespace() {
-    assertEquals(MyExportedClassWithNamespace.BAR, getFooBAR());
+    assertEquals(42, getBAR());
   }
 
-  private static native int getFooBAR() /*-{
-    return $wnd.foo.MyExportedClassWithNamespace.BAR || 0;
+  private static native int getBAR() /*-{
+    return $wnd.foo.MyExportedClassWithNamespace.BAR;
+  }-*/;
+
+  public static void testInheritClassNamespace_noExport() {
+    assertEquals(99, getBAZ());
+  }
+
+  private static native int getBAZ() /*-{
+    return $wnd.foobaz.MyClassWithNamespace.BAZ;
   }-*/;
 
   public void testInheritPackageNamespace() {
-    assertEquals(MyExportedClassWithPackageNamespace.WOO, getWOO());
+    assertEquals(1001, getWOO());
   }
 
   private static native int getWOO() /*-{
-    return $wnd.woo.MyExportedClassWithPackageNamespace.WOO || 0;
+    return $wnd.woo.MyExportedClassWithPackageNamespace.WOO;
   }-*/;
 
-  public void testNotInheritNestedPackageNamespace() {
-    assertFalse(MyNestedExportedClassSansPackageNamespace.WOO == getNestedWOO());
+  public void testInheritPackageNamespace_nestedClass() {
+    assertEquals(99, getNestedWOO());
+    assertNotNull(createNestedExportedClass());
   }
 
   private static native int getNestedWOO() /*-{
-    return $wnd['woo.subpackage.MyNestedExportedClassSansPackageNamespace.WOO'] || 0;
+    return $wnd.woo.MyClassWithNestedExportedClass.Inner.WOO;
   }-*/;
 
-  public void testNestedEnum() {
-    assertEquals(MyClassWithNestedEnum.NestedEnum.FOO.name(),
-        getEnumNameViaJs(MyClassWithNestedEnum.NestedEnum.FOO));
+  private static native Object createNestedExportedClass() /*-{
+    return new $wnd.woo.MyClassWithNestedExportedClass.Inner();
+  }-*/;
+
+  public void testInheritPackageNamespace_subpackage() {
+    assertNull(getNestedSubpackage());
+    assertNotNull(getNestedSubpackageCorrect());
   }
 
-  private static native String getEnumNameViaJs(MyClassWithNestedEnum.NestedEnum ref) /*-{
-    return ref.name2();
+  private static native Object getNestedSubpackage() /*-{
+    return $wnd.woo.subpackage;
+  }-*/;
+
+  private static native Object getNestedSubpackageCorrect() /*-{
+    return $wnd.com.google.gwt.core.client.interop.subpackage.
+        MyNestedExportedClassSansPackageNamespace;
   }-*/;
 
   public void testEnum_enumerations() {
@@ -269,11 +286,11 @@
   }
 
   private static native Object getEnumerationTEST1() /*-{
-    return $wnd.woo.MyEnumWithJsExport.TEST1;
+    return $wnd.woo.MyExportedEnum.TEST1;
   }-*/;
 
   private static native Object getEnumerationTEST2() /*-{
-    return $wnd.woo.MyEnumWithJsExport.TEST2;
+    return $wnd.woo.MyExportedEnum.TEST2;
   }-*/;
 
   public void testEnum_exportedMethods() {
@@ -281,7 +298,7 @@
   }
 
   private static native Object getPublicStaticMethodInEnum() /*-{
-    return $wnd.woo.MyEnumWithJsExport.publicStaticMethod();
+    return $wnd.woo.MyExportedEnum.publicStaticMethod();
   }-*/;
 
   public void testEnum_exportedFields() {
@@ -293,11 +310,11 @@
   }
 
   private static native int getPublicStaticFinalFieldInEnum() /*-{
-    return $wnd.woo.MyEnumWithJsExport.publicStaticFinalField;
+    return $wnd.woo.MyExportedEnum.publicStaticFinalField;
   }-*/;
 
   private static native int getPublicStaticFieldInEnum() /*-{
-    return $wnd.woo.MyEnumWithJsExport.publicStaticField;
+    return $wnd.woo.MyExportedEnum.publicStaticField;
   }-*/;
 
   public void testEnum_notExported() {
@@ -306,17 +323,17 @@
   }
 
   private native Object getNotExportedFieldsInEnum() /*-{
-    return $wnd.woo.MyEnumWithJsExport.publicFinalField
-        || $wnd.woo.MyEnumWithJsExport.privateStaticFinalField
-        || $wnd.woo.MyEnumWithJsExport.protectedStaticFinalField
-        || $wnd.woo.MyEnumWithJsExport.defaultStaticFinalField;
+    return $wnd.woo.MyExportedEnum.publicFinalField
+        || $wnd.woo.MyExportedEnum.privateStaticFinalField
+        || $wnd.woo.MyExportedEnum.protectedStaticFinalField
+        || $wnd.woo.MyExportedEnum.defaultStaticFinalField;
   }-*/;
 
   private native Object getNotExportedMethodsInEnum() /*-{
-    return $wnd.woo.MyEnumWithJsExport.publicMethod
-        || $wnd.woo.MyEnumWithJsExport.protectedStaticMethod
-        || $wnd.woo.MyEnumWithJsExport.privateStaticMethod
-        || $wnd.woo.MyEnumWithJsExport.defaultStaticMethod;
+    return $wnd.woo.MyExportedEnum.publicMethod
+        || $wnd.woo.MyExportedEnum.protectedStaticMethod
+        || $wnd.woo.MyExportedEnum.privateStaticMethod
+        || $wnd.woo.MyExportedEnum.defaultStaticMethod;
   }-*/;
 
   public void testEnum_subclassEnumerations() {
diff --git a/user/test/com/google/gwt/core/client/interop/JsTypeTest.java b/user/test/com/google/gwt/core/client/interop/JsTypeTest.java
index 6eac110..be01e4e 100644
--- a/user/test/com/google/gwt/core/client/interop/JsTypeTest.java
+++ b/user/test/com/google/gwt/core/client/interop/JsTypeTest.java
@@ -68,11 +68,6 @@
     listNoExport.add("Tight");
     assertEquals("TightCollectionBaseFooImpl", listNoExport.x);
 
-    // TODO: fix me
-    if (isIE8()) {
-      return;
-    }
-
     // Calls through a bridge method.
     listWithExport.add("Tight");
     assertEquals("TightListImpl", listWithExport.x);
@@ -81,9 +76,10 @@
   public void testConcreteJsTypeAccess() {
     ConcreteJsType concreteJsType = new ConcreteJsType();
 
-    testJsTypeHasFields(concreteJsType, "publicMethod", "publicField");
-    testJsTypeHasNoFields(concreteJsType, "publicStaticMethod", "privateMethod", "protectedMethod",
-        "packageMethod", "publicStaticField", "privateField", "protectedField", "packageField");
+    assertJsTypeHasFields(concreteJsType, "publicMethod", "publicField");
+    assertJsTypeDoesntHaveFields(concreteJsType, "publicStaticMethod", "privateMethod",
+        "protectedMethod", "packageMethod", "publicStaticField", "privateField", "protectedField",
+        "packageField");
   }
 
   public void testConcreteJsTypeSubclassAccess() {
@@ -91,14 +87,14 @@
     ConcreteJsTypeSubclass concreteJsTypeSubclass = new ConcreteJsTypeSubclass();
 
     // A subclass of a JsType is not itself a JsType.
-    testJsTypeHasNoFields(concreteJsTypeSubclass, "publicSubclassMethod", "publicSubclassField",
-        "publicStaticSubclassMethod", "privateSubclassMethod", "protectedSubclassMethod",
-        "packageSubclassMethod", "publicStaticSubclassField", "privateSubclassField",
-        "protectedSubclassField", "packageSubclassField");
+    assertJsTypeDoesntHaveFields(concreteJsTypeSubclass, "publicSubclassMethod",
+        "publicSubclassField", "publicStaticSubclassMethod", "privateSubclassMethod",
+        "protectedSubclassMethod", "packageSubclassMethod", "publicStaticSubclassField",
+        "privateSubclassField", "protectedSubclassField", "packageSubclassField");
 
     // But if it overrides an exported method then the overriding method will be exported.
-    testJsTypeHasFields(concreteJsType, "publicMethod");
-    testJsTypeHasFields(concreteJsTypeSubclass, "publicMethod");
+    assertJsTypeHasFields(concreteJsType, "publicMethod");
+    assertJsTypeHasFields(concreteJsTypeSubclass, "publicMethod");
     assertFalse(
         areSameFunction(concreteJsType, "publicMethod", concreteJsTypeSubclass, "publicMethod"));
     assertFalse(callIntFunction(concreteJsType, "publicMethod")
@@ -264,8 +260,8 @@
   }
 
   public void testEnumJsTypeAccess() {
-    testJsTypeHasFields(MyEnumWithJsType.TEST2, "publicMethod", "publicField");
-    testJsTypeHasNoFields(MyEnumWithJsType.TEST2, "publicStaticMethod", "privateMethod",
+    assertJsTypeHasFields(MyEnumWithJsType.TEST2, "publicMethod", "publicField");
+    assertJsTypeDoesntHaveFields(MyEnumWithJsType.TEST2, "publicStaticMethod", "privateMethod",
         "protectedMethod", "packageMethod", "publicStaticField", "privateField", "protectedField",
         "packageField");
   }
@@ -317,14 +313,6 @@
     return object[fieldName] != undefined;
   }-*/;
 
-  private static native boolean isIE8() /*-{
-    return $wnd.navigator.userAgent.toLowerCase().indexOf('msie') != -1 && $doc.documentMode == 8;
-  }-*/;
-
-  private static native boolean isFirefox40OrEarlier() /*-{
-    return @com.google.gwt.dom.client.DOMImplMozilla::isGecko2OrBefore()();
-  }-*/;
-
   private static native int callPublicMethodFromEnumeration(MyEnumWithJsType enumeration) /*-{
     return enumeration.idxAddOne();
   }-*/;
@@ -334,13 +322,13 @@
     return enumeration.foo();
   }-*/;
 
-  private static void testJsTypeHasFields(Object obj, String... fields) {
+  private static void assertJsTypeHasFields(Object obj, String... fields) {
     for (String field : fields) {
       assertTrue("Field '" + field + "' should be exported", hasField(obj, field));
     }
   }
 
-  private static void testJsTypeHasNoFields(Object obj, String... fields) {
+  private static void assertJsTypeDoesntHaveFields(Object obj, String... fields) {
     for (String field : fields) {
       assertFalse("Field '" + field + "' should not be exported", hasField(obj, field));
     }
diff --git a/user/test/com/google/gwt/core/client/interop/MyClassWithNestedEnum.java b/user/test/com/google/gwt/core/client/interop/MyClassWithNamespace.java
similarity index 78%
rename from user/test/com/google/gwt/core/client/interop/MyClassWithNestedEnum.java
rename to user/test/com/google/gwt/core/client/interop/MyClassWithNamespace.java
index 369383b..ab4fa57 100644
--- a/user/test/com/google/gwt/core/client/interop/MyClassWithNestedEnum.java
+++ b/user/test/com/google/gwt/core/client/interop/MyClassWithNamespace.java
@@ -16,16 +16,13 @@
 package com.google.gwt.core.client.interop;
 
 import com.google.gwt.core.client.js.JsExport;
-import com.google.gwt.core.client.js.JsType;
+import com.google.gwt.core.client.js.JsNamespace;
 
-class MyClassWithNestedEnum {
-  @JsType
+/**
+ * Class with a namespace.
+ */
+@JsNamespace("foobaz")
+public class MyClassWithNamespace {
   @JsExport
-  public enum NestedEnum {
-    FOO, BAR;
-
-    public String name2() {
-      return name();
-    }
-  }
+  public static final int BAZ = 99;
 }
diff --git a/user/test/com/google/gwt/core/client/interop/MyClassWithNamespaceNested.java b/user/test/com/google/gwt/core/client/interop/MyClassWithNestedExportedClass.java
similarity index 77%
rename from user/test/com/google/gwt/core/client/interop/MyClassWithNamespaceNested.java
rename to user/test/com/google/gwt/core/client/interop/MyClassWithNestedExportedClass.java
index f14e35d..419a273 100644
--- a/user/test/com/google/gwt/core/client/interop/MyClassWithNamespaceNested.java
+++ b/user/test/com/google/gwt/core/client/interop/MyClassWithNestedExportedClass.java
@@ -16,18 +16,16 @@
 package com.google.gwt.core.client.interop;
 
 import com.google.gwt.core.client.js.JsExport;
-import com.google.gwt.core.client.js.JsNamespace;
 
 /**
- * Test namespace inherited from outer class.
+ * Class with a nested exported class.
  */
-@JsNamespace("foo")
-public class MyClassWithNamespaceNested {
+public class MyClassWithNestedExportedClass {
   /**
-   * Exported field.
+   * Exported nested class.
    */
   @JsExport
   public static class Inner {
-    public static final int BAZ = 99;
+    public static final int WOO = 99;
   }
 }
diff --git a/user/test/com/google/gwt/core/client/interop/MyEnumWithJsExport.java b/user/test/com/google/gwt/core/client/interop/MyExportedEnum.java
similarity index 97%
rename from user/test/com/google/gwt/core/client/interop/MyEnumWithJsExport.java
rename to user/test/com/google/gwt/core/client/interop/MyExportedEnum.java
index 1dfd841..9cffb76 100644
--- a/user/test/com/google/gwt/core/client/interop/MyEnumWithJsExport.java
+++ b/user/test/com/google/gwt/core/client/interop/MyExportedEnum.java
@@ -21,7 +21,7 @@
  * This enum is annotated as @JsExport.
  */
 @JsExport
-public enum MyEnumWithJsExport {
+public enum MyExportedEnum {
   TEST1, TEST2;
 
   public static int publicStaticMethod() {