Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1400)

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java

Issue 2708243004: Auto convert content shell tests to JUnit4 (Closed)
Patch Set: New test added from WebContentsTest Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java
index e1cb4b2159bddd2b1a65611877224cdd8f689d2f..d717eb5a4901990232bdd4f5b76db8026d4e68e8 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java
@@ -1,4 +1,4 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,7 +6,14 @@ package org.chromium.content.browser;
import android.support.test.filters.SmallTest;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import org.chromium.base.annotations.SuppressFBWarnings;
+import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeTestCommon.Controller;
@@ -14,7 +21,11 @@ import org.chromium.content.browser.JavaBridgeTestCommon.Controller;
* Part of the test suite for the Java Bridge. This test tests the
* use of fields.
*/
-public class JavaBridgeFieldsTest extends JavaBridgeTestBase {
+@RunWith(BaseJUnit4ClassRunner.class)
+public class JavaBridgeFieldsTest {
+ @Rule
+ public JavaBridgeActivityTestRule mActivityTestRule = new JavaBridgeActivityTestRule();
+
@SuppressFBWarnings({"CHROMIUM_SYNCHRONIZED_METHOD", "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"})
private static class TestObject extends Controller {
private String mStringValue;
@@ -48,45 +59,45 @@ public class JavaBridgeFieldsTest extends JavaBridgeTestBase {
TestObject mTestObject;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
mTestObject = new TestObject();
- injectObjectAndReload(mTestObject, "testObject");
+ mActivityTestRule.injectObjectAndReload(mTestObject, "testObject");
}
// Note that this requires that we can pass a JavaScript string to Java.
protected String executeJavaScriptAndGetStringResult(String script) throws Throwable {
- executeJavaScript("testObject.setStringValue(" + script + ");");
+ mActivityTestRule.executeJavaScript("testObject.setStringValue(" + script + ");");
return mTestObject.waitForStringValue();
}
// The Java bridge does not provide access to fields.
// FIXME: Consider providing support for this. See See b/4408210.
+ @Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
public void testFieldTypes() throws Throwable {
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.booleanField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.byteField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.charField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.shortField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.intField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.longField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.floatField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.doubleField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.objectField"));
- assertEquals("undefined",
- executeJavaScriptAndGetStringResult("typeof testObject.stringField"));
- assertEquals("undefined",
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.booleanField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.byteField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.charField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.shortField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.intField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.longField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.floatField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.doubleField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.objectField"));
+ Assert.assertEquals(
+ "undefined", executeJavaScriptAndGetStringResult("typeof testObject.stringField"));
+ Assert.assertEquals("undefined",
executeJavaScriptAndGetStringResult("typeof testObject.customTypeField"));
}
}

Powered by Google App Engine
This is Rietveld 408576698