Commit 4cd5d8a5 authored by Sky Malice's avatar Sky Malice Committed by Commit Bot

Revert "[remoteobjects] Use new codepath for Java bridge in instrumentation tests"

This reverts commit 2ea849e2.

Reason for revert: Flakes on Android, see crbug.com/1117003 and crbug.com/1116744

Original change's description:
> [remoteobjects] Use new codepath for Java bridge in instrumentation tests
> 
> This CL is parameterizing the Java bridge instrumentation tests to
> run with and without using Mojo in JavascriptInjector, running all
> the relevant tests and using
> JavaBridgeActivityTestRule#MojoTestParams for the ones that pass
> and JavaBridgeActivityTestRule#LegacyTestParams for the ones that
> fails. So, all tests still run for the old codepath.
> 
> Bug: 1105928
> Change-Id: Idb3ee3ed4d1cb49fa0fc37d7609ac2e8ef166177
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348488
> Reviewed-by: Bo <boliu@chromium.org>
> Reviewed-by: Oksana Zhuravlova <oksamyt@chromium.org>
> Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
> Cr-Commit-Position: refs/heads/master@{#798370}

TBR=boliu@chromium.org,oksamyt@chromium.org,myid.shin@igalia.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1105928
Change-Id: I348787f3ca85c778a1ad9ebfb6ec0e97dada5dbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359738Reviewed-by: default avatarSky Malice <skym@chromium.org>
Commit-Queue: Sky Malice <skym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798786}
parent caad51c8
......@@ -11,8 +11,6 @@ import org.junit.runners.model.Statement;
import org.chromium.base.Log;
import org.chromium.base.test.SetUpStatement;
import org.chromium.base.test.SetUpTestRule;
import org.chromium.base.test.params.ParameterProvider;
import org.chromium.base.test.params.ParameterSet;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content_public.browser.JavascriptInjector;
import org.chromium.content_public.browser.LoadUrlParams;
......@@ -22,44 +20,14 @@ import org.chromium.content_shell_apk.ContentShellActivity;
import org.chromium.content_shell_apk.ContentShellActivityTestRule;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.List;
/**
* ActivityTestRule with common functionality for testing the Java Bridge.
*/
public class JavaBridgeActivityTestRule
extends ContentShellActivityTestRule implements SetUpTestRule<JavaBridgeActivityTestRule> {
/**
* {@link ParameterProvider} used for parameterized test that provides the Mojo usage state.
*/
public static class MojoTestParams implements ParameterProvider {
private static List<ParameterSet> sMojoTestParams =
Arrays.asList(new ParameterSet().value(false).name("MojoUnused"),
new ParameterSet().value(true).name("MojoUsed"));
@Override
public List<ParameterSet> getParameters() {
return sMojoTestParams;
}
}
/**
* {@link ParameterProvider} used for parameterized test that keeps the legacy tests.
*/
public static class LegacyTestParams implements ParameterProvider {
private static List<ParameterSet> sLegacyTestParams =
Arrays.asList(new ParameterSet().value(false));
@Override
public List<ParameterSet> getParameters() {
return sLegacyTestParams;
}
}
private TestCallbackHelperContainer mTestCallbackHelperContainer;
private boolean mSetup;
private boolean mUseMojo;
public static class Controller {
private static final int RESULT_WAIT_TIME = 5000;
......@@ -148,8 +116,7 @@ public class JavaBridgeActivityTestRule
@Override
public void run() {
WebContents webContents = getWebContents();
JavascriptInjector injector =
JavascriptInjector.fromWebContents(webContents, mUseMojo);
JavascriptInjector injector = JavascriptInjector.fromWebContents(webContents);
injector.addPossiblyUnsafeInterface(object1, name1, requiredAnnotation);
if (object2 != null && name2 != null) {
injector.addPossiblyUnsafeInterface(object2, name2, requiredAnnotation);
......@@ -163,9 +130,6 @@ public class JavaBridgeActivityTestRule
"Failed to injectObjectsAndReload: " + Log.getStackTraceString(e));
}
}
public void setupMojoTest(boolean useMojo) {
mUseMojo = useMojo;
}
public void synchronousPageReload() throws Throwable {
TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper =
......
......@@ -12,11 +12,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
......@@ -31,8 +27,7 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
* FIXME: Consider making our implementation more compliant, if it will not
* break backwards-compatibility. See b/4408210.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
@RunWith(BaseJUnit4ClassRunner.class)
public class JavaBridgeArrayCoercionTest {
private static final double ASSERTION_DELTA = 0;
......@@ -163,11 +158,6 @@ public class JavaBridgeArrayCoercionTest {
private static class CustomType {
}
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
private TestObject mTestObject;
@Before
......@@ -184,8 +174,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberInt32(boolean useMojo) throws Throwable {
public void testPassNumberInt32() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([0]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
// LIVECONNECT_COMPLIANCE: Should convert to boolean.
......@@ -231,8 +220,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberDouble(boolean useMojo) throws Throwable {
public void testPassNumberDouble() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should convert to boolean.
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([42.1]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
......@@ -277,8 +265,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberNaN(boolean useMojo) throws Throwable {
public void testPassNumberNaN() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([Number.NaN]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
......@@ -321,8 +308,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberInfinity(boolean useMojo) throws Throwable {
public void testPassNumberInfinity() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([Infinity]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
......@@ -368,8 +354,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassBoolean(boolean useMojo) throws Throwable {
public void testPassBoolean() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([true]);");
Assert.assertTrue(mTestObject.waitForBooleanArray()[0]);
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([false]);");
......@@ -435,8 +420,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassString(boolean useMojo) throws Throwable {
public void testPassString() throws Throwable {
// LIVECONNECT_COMPLIANCE: Non-empty string should convert to true.
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([\"+042.10\"]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
......@@ -486,8 +470,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassJavaScriptObject(boolean useMojo) throws Throwable {
public void testPassJavaScriptObject() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setBooleanArray([{foo: 42}]);");
Assert.assertFalse(mTestObject.waitForBooleanArray()[0]);
......@@ -538,8 +521,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassJavaObject(boolean useMojo) throws Throwable {
public void testPassJavaObject() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception.
mActivityTestRule.executeJavaScript(
"testObject.setBooleanArray([testObject.getObjectInstance()]);");
......@@ -604,8 +586,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNull(boolean useMojo) throws Throwable {
public void testPassNull() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteArray([null]);");
Assert.assertEquals(0, mTestObject.waitForByteArray()[0]);
......@@ -647,8 +628,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassUndefined(boolean useMojo) throws Throwable {
public void testPassUndefined() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteArray([undefined]);");
Assert.assertEquals(0, mTestObject.waitForByteArray()[0]);
......@@ -689,8 +669,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassInt8Array(boolean useMojo) throws Throwable {
public void testPassInt8Array() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(1);");
mActivityTestRule.executeJavaScript("int8_array = new Int8Array(buffer);");
mActivityTestRule.executeJavaScript("int8_array[0] = 42;");
......@@ -733,8 +712,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassUint8Array(boolean useMojo) throws Throwable {
public void testPassUint8Array() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(1);");
mActivityTestRule.executeJavaScript("uint8_array = new Uint8Array(buffer);");
mActivityTestRule.executeJavaScript("uint8_array[0] = 42;");
......@@ -777,8 +755,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassInt16Array(boolean useMojo) throws Throwable {
public void testPassInt16Array() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(2);");
mActivityTestRule.executeJavaScript("int16_array = new Int16Array(buffer);");
mActivityTestRule.executeJavaScript("int16_array[0] = 42;");
......@@ -821,8 +798,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassUint16Array(boolean useMojo) throws Throwable {
public void testPassUint16Array() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(2);");
mActivityTestRule.executeJavaScript("uint16_array = new Uint16Array(buffer);");
mActivityTestRule.executeJavaScript("uint16_array[0] = 42;");
......@@ -865,8 +841,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassInt32Array(boolean useMojo) throws Throwable {
public void testPassInt32Array() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);");
mActivityTestRule.executeJavaScript("int32_array = new Int32Array(buffer);");
mActivityTestRule.executeJavaScript("int32_array[0] = 42;");
......@@ -909,8 +884,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassUint32Array(boolean useMojo) throws Throwable {
public void testPassUint32Array() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);");
mActivityTestRule.executeJavaScript("uint32_array = new Uint32Array(buffer);");
mActivityTestRule.executeJavaScript("uint32_array[0] = 42;");
......@@ -953,8 +927,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassFloat32Array(boolean useMojo) throws Throwable {
public void testPassFloat32Array() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(4);");
mActivityTestRule.executeJavaScript("float32_array = new Float32Array(buffer);");
mActivityTestRule.executeJavaScript("float32_array[0] = 42.0;");
......@@ -997,8 +970,7 @@ public class JavaBridgeArrayCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassFloat64Array(boolean useMojo) throws Throwable {
public void testPassFloat64Array() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(8);");
mActivityTestRule.executeJavaScript("float64_array = new Float64Array(buffer);");
mActivityTestRule.executeJavaScript("float64_array[0] = 42.0;");
......
......@@ -12,11 +12,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
......@@ -30,8 +26,7 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
* FIXME: Consider making our implementation more compliant, if it will not
* break backwards-compatibility. See b/4408210.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
@RunWith(BaseJUnit4ClassRunner.class)
public class JavaBridgeArrayTest {
@Rule
public JavaBridgeActivityTestRule mActivityTestRule =
......@@ -101,11 +96,6 @@ public class JavaBridgeArrayTest {
}
}
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
private TestObject mTestObject;
@Before
......@@ -117,8 +107,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testArrayLength(boolean useMojo) throws Throwable {
public void testArrayLength() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray([42, 43, 44]);");
int[] result = mTestObject.waitForIntArray();
Assert.assertEquals(3, result.length);
......@@ -130,8 +119,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNull(boolean useMojo) throws Throwable {
public void testPassNull() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray(null);");
Assert.assertNull(mTestObject.waitForIntArray());
}
......@@ -139,8 +127,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassUndefined(boolean useMojo) throws Throwable {
public void testPassUndefined() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray(undefined);");
Assert.assertNull(mTestObject.waitForIntArray());
}
......@@ -148,8 +135,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassEmptyArray(boolean useMojo) throws Throwable {
public void testPassEmptyArray() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray([]);");
Assert.assertEquals(0, mTestObject.waitForIntArray().length);
}
......@@ -159,8 +145,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassArrayToStringMethod(boolean useMojo) throws Throwable {
public void testPassArrayToStringMethod() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should call toString() on array.
mActivityTestRule.executeJavaScript("testObject.setStringValue([42, 42, 42]);");
Assert.assertEquals("undefined", mTestObject.waitForStringValue());
......@@ -171,8 +156,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassArrayToNonStringNonArrayMethod(boolean useMojo) throws Throwable {
public void testPassArrayToNonStringNonArrayMethod() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setIntValue([42, 42, 42]);");
Assert.assertEquals(0, mTestObject.waitForIntValue());
......@@ -181,8 +165,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNonArrayToArrayMethod(boolean useMojo) throws Throwable {
public void testPassNonArrayToArrayMethod() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setIntArray(42);");
Assert.assertNull(mTestObject.waitForIntArray());
......@@ -191,8 +174,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testObjectWithLengthProperty(boolean useMojo) throws Throwable {
public void testObjectWithLengthProperty() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setIntArray({length: 3, 1: 42});");
int[] result = mTestObject.waitForIntArray();
Assert.assertEquals(3, result.length);
......@@ -204,8 +186,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testNonNumericLengthProperty(boolean useMojo) throws Throwable {
public void testNonNumericLengthProperty() throws Throwable {
// LIVECONNECT_COMPLIANCE: This should not count as an array, so we
// should raise a JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setIntArray({length: \"foo\"});");
......@@ -215,8 +196,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testLengthOutOfBounds(boolean useMojo) throws Throwable {
public void testLengthOutOfBounds() throws Throwable {
// LIVECONNECT_COMPLIANCE: This should not count as an array, so we
// should raise a JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setIntArray({length: -1});");
......@@ -238,8 +218,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testSparseArray(boolean useMojo) throws Throwable {
public void testSparseArray() throws Throwable {
mActivityTestRule.executeJavaScript(
"var x = [42, 43]; x[3] = 45; testObject.setIntArray(x);");
int[] result = mTestObject.waitForIntArray();
......@@ -255,8 +234,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMethodReturningArrayNotCalled(boolean useMojo) throws Throwable {
public void testMethodReturningArrayNotCalled() throws Throwable {
// We don't invoke methods which return arrays, but note that no
// exception is raised.
// LIVECONNECT_COMPLIANCE: Should call method and convert result to
......@@ -270,8 +248,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMultiDimensionalArrayMethod(boolean useMojo) throws Throwable {
public void testMultiDimensionalArrayMethod() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should handle multi-dimensional arrays.
mActivityTestRule.executeJavaScript("testObject.setIntIntArray([ [42, 43], [44, 45] ]);");
Assert.assertNull(mTestObject.waitForIntIntArray());
......@@ -280,8 +257,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassMultiDimensionalArray(boolean useMojo) throws Throwable {
public void testPassMultiDimensionalArray() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should handle multi-dimensional arrays.
mActivityTestRule.executeJavaScript("testObject.setIntArray([ [42, 43], [44, 45] ]);");
int[] result = mTestObject.waitForIntArray();
......@@ -296,8 +272,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassArrayBuffer(boolean useMojo) throws Throwable {
public void testPassArrayBuffer() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);");
mActivityTestRule.executeJavaScript("testObject.setIntArray(buffer);");
Assert.assertNull(mTestObject.waitForIntArray());
......@@ -312,8 +287,7 @@ public class JavaBridgeArrayTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassDataView(boolean useMojo) throws Throwable {
public void testPassDataView() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);");
mActivityTestRule.executeJavaScript("testObject.setIntArray(new DataView(buffer));");
Assert.assertNull(mTestObject.waitForIntArray());
......
......@@ -12,11 +12,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer;
......@@ -26,21 +22,13 @@ import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer
/**
* Common functionality for testing the Java Bridge.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
@RunWith(BaseJUnit4ClassRunner.class)
public class JavaBridgeBareboneTest {
@Rule
public JavaBridgeActivityTestRule mActivityTestRule =
new JavaBridgeActivityTestRule().shouldSetUp(false);
private TestCallbackHelperContainer mTestCallbackHelperContainer;
private boolean mUseMojo;
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mUseMojo = useMojo;
mActivityTestRule.setupMojoTest(useMojo);
}
@Before
public void setUp() {
......@@ -55,7 +43,7 @@ public class JavaBridgeBareboneTest {
mActivityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
mActivityTestRule.getJavascriptInjector(mUseMojo).addPossiblyUnsafeInterface(
mActivityTestRule.getJavascriptInjector().addPossiblyUnsafeInterface(
new Object(), name, null);
}
});
......@@ -95,8 +83,7 @@ public class JavaBridgeBareboneTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testImmediateAddition(boolean useMojo) throws Throwable {
public void testImmediateAddition() throws Throwable {
injectDummyObject("testObject");
Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject"));
}
......@@ -106,8 +93,7 @@ public class JavaBridgeBareboneTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testNoImmediateAdditionAfterJSEvaluation(boolean useMojo) throws Throwable {
public void testNoImmediateAdditionAfterJSEvaluation() throws Throwable {
evaluateJsSync("true");
injectDummyObject("testObject");
Assert.assertEquals("\"undefined\"", evaluateJsSync("typeof testObject"));
......@@ -116,8 +102,7 @@ public class JavaBridgeBareboneTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testImmediateAdditionAfterReload(boolean useMojo) throws Throwable {
public void testImmediateAdditionAfterReload() throws Throwable {
reloadSync();
injectDummyObject("testObject");
Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject"));
......@@ -126,8 +111,7 @@ public class JavaBridgeBareboneTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testReloadAfterAddition(boolean useMojo) throws Throwable {
public void testReloadAfterAddition() throws Throwable {
injectDummyObject("testObject");
reloadSync();
Assert.assertEquals("\"object\"", evaluateJsSync("typeof testObject"));
......
......@@ -16,16 +16,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.test.ContentJUnit4RunnerDelegate;
import org.chromium.content_public.browser.test.ContentJUnit4ClassRunner;
import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer;
import java.lang.annotation.ElementType;
......@@ -47,8 +43,7 @@ import java.util.concurrent.CountDownLatch;
* - Threading
* - Inheritance
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(ContentJUnit4RunnerDelegate.class)
@RunWith(ContentJUnit4ClassRunner.class)
public class JavaBridgeBasicsTest {
@Rule
public JavaBridgeActivityTestRule mActivityTestRule =
......@@ -105,11 +100,6 @@ public class JavaBridgeBasicsTest {
}
}
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
TestController mTestController;
@Before
......@@ -147,21 +137,19 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testTypeOfInjectedObject(boolean useMojo) throws Throwable {
public void testTypeOfInjectedObject() throws Throwable {
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
}
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testAdditionNotReflectedUntilReload(boolean useMojo) throws Throwable {
public void testAdditionNotReflectedUntilReload() throws Throwable {
Assert.assertEquals("undefined", executeJavaScriptAndGetStringResult("typeof testObject"));
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
mActivityTestRule.getJavascriptInjector(useMojo).addPossiblyUnsafeInterface(
mActivityTestRule.getJavascriptInjector().addPossiblyUnsafeInterface(
new Object(), "testObject", null);
}
});
......@@ -173,8 +161,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testRemovalNotReflectedUntilReload(boolean useMojo) throws Throwable {
public void testRemovalNotReflectedUntilReload() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public void method() {
mTestController.setStringValue("I'm here");
......@@ -186,7 +173,7 @@ public class JavaBridgeBasicsTest {
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
mActivityTestRule.getJavascriptInjector(useMojo).removeInterface("testObject");
mActivityTestRule.getJavascriptInjector().removeInterface("testObject");
}
});
// Check that the Java object is being held by the Java bridge, thus it's not
......@@ -203,15 +190,14 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testRemoveObjectNotAdded(boolean useMojo) throws Throwable {
public void testRemoveObjectNotAdded() throws Throwable {
TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper =
mActivityTestRule.getTestCallBackHelperContainer().getOnPageFinishedHelper();
int currentCallCount = onPageFinishedHelper.getCallCount();
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
mActivityTestRule.getJavascriptInjector(useMojo).removeInterface("foo");
mActivityTestRule.getJavascriptInjector().removeInterface("foo");
mActivityTestRule.getWebContents().getNavigationController().reload(true);
}
});
......@@ -222,8 +208,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testTypeOfMethod(boolean useMojo) throws Throwable {
public void testTypeOfMethod() throws Throwable {
Assert.assertEquals("function",
executeJavaScriptAndGetStringResult("typeof testController.setStringValue"));
}
......@@ -231,8 +216,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testTypeOfInvalidMethod(boolean useMojo) throws Throwable {
public void testTypeOfInvalidMethod() throws Throwable {
Assert.assertEquals(
"undefined", executeJavaScriptAndGetStringResult("typeof testController.foo"));
}
......@@ -240,17 +224,14 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallingInvalidMethodRaisesException(boolean useMojo) throws Throwable {
public void testCallingInvalidMethodRaisesException() throws Throwable {
assertRaisesException("testController.foo()");
}
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testUncaughtJavaExceptionRaisesJavaScriptException(boolean useMojo)
throws Throwable {
public void testUncaughtJavaExceptionRaisesJavaScriptException() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public void method() {
throw new RuntimeException("foo");
......@@ -262,24 +243,21 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallingAsConstructorRaisesException(boolean useMojo) throws Throwable {
public void testCallingAsConstructorRaisesException() throws Throwable {
assertRaisesException("new testController.setStringValue('foo')");
}
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallingOnNonInjectedObjectRaisesException(boolean useMojo) throws Throwable {
public void testCallingOnNonInjectedObjectRaisesException() throws Throwable {
assertRaisesException("testController.setStringValue.call({}, 'foo')");
}
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallingOnInstanceOfOtherClassRaisesException(boolean useMojo) throws Throwable {
public void testCallingOnInstanceOfOtherClassRaisesException() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object(), "testObject");
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testObject"));
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
......@@ -292,8 +270,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testTypeOfStaticMethod(boolean useMojo) throws Throwable {
public void testTypeOfStaticMethod() throws Throwable {
mActivityTestRule.injectObjectAndReload(new ObjectWithStaticMethod(), "testObject");
mActivityTestRule.executeJavaScript(
"testController.setStringValue(typeof testObject.staticMethod)");
......@@ -304,8 +281,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallStaticMethod(boolean useMojo) throws Throwable {
public void testCallStaticMethod() throws Throwable {
mActivityTestRule.injectObjectAndReload(new ObjectWithStaticMethod(), "testObject");
mActivityTestRule.executeJavaScript(
"testController.setStringValue(testObject.staticMethod())");
......@@ -315,8 +291,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPrivateMethodNotExposed(boolean useMojo) throws Throwable {
public void testPrivateMethodNotExposed() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
private void method() {}
protected void method2() {}
......@@ -330,8 +305,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReplaceInjectedObject(boolean useMojo) throws Throwable {
public void testReplaceInjectedObject() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public void method() {
mTestController.setStringValue("object 1");
......@@ -352,8 +326,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testInjectNullObjectIsIgnored(boolean useMojo) throws Throwable {
public void testInjectNullObjectIsIgnored() throws Throwable {
mActivityTestRule.injectObjectAndReload(null, "testObject");
Assert.assertEquals("undefined", executeJavaScriptAndGetStringResult("typeof testObject"));
}
......@@ -361,8 +334,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReplaceInjectedObjectWithNullObjectIsIgnored(boolean useMojo) throws Throwable {
public void testReplaceInjectedObjectWithNullObjectIsIgnored() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object(), "testObject");
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testObject"));
mActivityTestRule.injectObjectAndReload(null, "testObject");
......@@ -372,9 +344,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallOverloadedMethodWithDifferentNumberOfArguments(boolean useMojo)
throws Throwable {
public void testCallOverloadedMethodWithDifferentNumberOfArguments() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public void method() {
mTestController.setStringValue("0 args");
......@@ -403,9 +373,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallMethodWithWrongNumberOfArgumentsRaisesException(boolean useMojo)
throws Throwable {
public void testCallMethodWithWrongNumberOfArgumentsRaisesException() throws Throwable {
assertRaisesException("testController.setIntValue()");
assertRaisesException("testController.setIntValue(42, 42)");
}
......@@ -413,8 +381,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testObjectPersistsAcrossPageLoads(boolean useMojo) throws Throwable {
public void testObjectPersistsAcrossPageLoads() throws Throwable {
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
mActivityTestRule.synchronousPageReload();
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
......@@ -423,8 +390,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCustomPropertiesCleanedUpOnPageReloads(boolean useMojo) throws Throwable {
public void testCustomPropertiesCleanedUpOnPageReloads() throws Throwable {
Assert.assertEquals("object", executeJavaScriptAndGetStringResult("typeof testController"));
mActivityTestRule.executeJavaScript("testController.myProperty = 42;");
Assert.assertEquals("42", executeJavaScriptAndGetStringResult("testController.myProperty"));
......@@ -437,8 +403,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testSameObjectInjectedMultipleTimes(boolean useMojo) throws Throwable {
public void testSameObjectInjectedMultipleTimes() throws Throwable {
class TestObject {
private int mNumMethodInvocations;
......@@ -458,8 +423,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testCallMethodOnReturnedObject(boolean useMojo) throws Throwable {
public void testCallMethodOnReturnedObject() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public Object getInnerObject() {
return new Object() {
......@@ -476,8 +440,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testReturnedObjectInjectedElsewhere(boolean useMojo) throws Throwable {
public void testReturnedObjectInjectedElsewhere() throws Throwable {
class InnerObject {
private int mNumMethodInvocations;
......@@ -507,8 +470,7 @@ public class JavaBridgeBasicsTest {
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@CommandLineFlags.Add("js-flags=--expose-gc")
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testReturnedObjectIsGarbageCollected(boolean useMojo) throws Throwable {
public void testReturnedObjectIsGarbageCollected() throws Throwable {
Assert.assertEquals("function", executeJavaScriptAndGetStringResult("typeof gc"));
class InnerObject {
}
......@@ -549,8 +511,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testSameReturnedObjectUsesSameWrapper(boolean useMojo) throws Throwable {
public void testSameReturnedObjectUsesSameWrapper() throws Throwable {
class InnerObject {
}
final InnerObject innerObject = new InnerObject();
......@@ -570,8 +531,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testMethodInvokedOnBackgroundThread(boolean useMojo) throws Throwable {
public void testMethodInvokedOnBackgroundThread() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public void captureThreadId() {
mTestController.setLongValue(Thread.currentThread().getId());
......@@ -591,8 +551,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testBlockingUiThreadDoesNotBlockCallsFromJs(boolean useMojo) {
public void testBlockingUiThreadDoesNotBlockCallsFromJs() {
class TestObject {
private CountDownLatch mLatch;
public TestObject() {
......@@ -635,8 +594,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPublicInheritedMethod(boolean useMojo) throws Throwable {
public void testPublicInheritedMethod() throws Throwable {
class Base {
public void method(int x) {
mTestController.setIntValue(x);
......@@ -654,8 +612,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPrivateInheritedMethod(boolean useMojo) throws Throwable {
public void testPrivateInheritedMethod() throws Throwable {
class Base {
private void method() {}
}
......@@ -669,8 +626,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testOverriddenMethod(boolean useMojo) throws Throwable {
public void testOverriddenMethod() throws Throwable {
class Base {
public void method() {
mTestController.setStringValue("base");
......@@ -690,8 +646,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testEnumerateMembers(boolean useMojo) throws Throwable {
public void testEnumerateMembers() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public void method() {}
private void privateMethod() {}
......@@ -708,8 +663,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReflectPublicMethod(boolean useMojo) throws Throwable {
public void testReflectPublicMethod() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public Class<?> myGetClass() {
return getClass();
......@@ -728,8 +682,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReflectPublicField(boolean useMojo) throws Throwable {
public void testReflectPublicField() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public Class<?> myGetClass() {
return getClass();
......@@ -745,8 +698,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReflectPrivateMethodRaisesException(boolean useMojo) throws Throwable {
public void testReflectPrivateMethodRaisesException() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public Class<?> myGetClass() {
return getClass();
......@@ -766,8 +718,7 @@ public class JavaBridgeBasicsTest {
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@DisabledTest(message = "https://crbug.com/795378")
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testReflectPrivateFieldRaisesException(boolean useMojo) throws Throwable {
public void testReflectPrivateFieldRaisesException() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public Class<?> myGetClass() {
return getClass();
......@@ -787,8 +738,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testAllowNonAnnotatedMethods(boolean useMojo) throws Throwable {
public void testAllowNonAnnotatedMethods() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
public String allowed() {
return "foo";
......@@ -806,8 +756,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testAllowOnlyAnnotatedMethods(boolean useMojo) throws Throwable {
public void testAllowOnlyAnnotatedMethods() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object() {
@JavascriptInterface
public String allowed() {
......@@ -839,9 +788,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testAnnotationRequirementRetainsPropertyAcrossObjects(boolean useMojo)
throws Throwable {
public void testAnnotationRequirementRetainsPropertyAcrossObjects() throws Throwable {
class Test {
@JavascriptInterface
public String safe() {
......@@ -891,8 +838,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testAnnotationDoesNotGetInherited(boolean useMojo) throws Throwable {
public void testAnnotationDoesNotGetInherited() throws Throwable {
class Base {
@JavascriptInterface
public void base() { }
......@@ -922,8 +868,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testCustomAnnotationRestriction(boolean useMojo) throws Throwable {
public void testCustomAnnotationRestriction() throws Throwable {
class Test {
@TestAnnotation
public String checkTestAnnotationFoo() {
......@@ -969,8 +914,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testObjectsInspection(boolean useMojo) throws Throwable {
public void testObjectsInspection() throws Throwable {
class Test {
@JavascriptInterface
public String m1() {
......@@ -1010,7 +954,7 @@ public class JavaBridgeBasicsTest {
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
mActivityTestRule.getJavascriptInjector(useMojo).setAllowInspection(false);
mActivityTestRule.getJavascriptInjector().setAllowInspection(false);
}
});
......@@ -1028,8 +972,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testAccessToObjectGetClassIsBlocked(boolean useMojo) throws Throwable {
public void testAccessToObjectGetClassIsBlocked() throws Throwable {
mActivityTestRule.injectObjectAndReload(new Object(), "testObject");
Assert.assertEquals(
"function", executeJavaScriptAndGetStringResult("typeof testObject.getClass"));
......@@ -1039,8 +982,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testReplaceJavascriptInterface(boolean useMojo) throws Throwable {
public void testReplaceJavascriptInterface() throws Throwable {
class Test {
public Test(int value) {
mValue = value;
......@@ -1063,8 +1005,7 @@ public class JavaBridgeBasicsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMethodCalledOnAnotherInstance(boolean useMojo) throws Throwable {
public void testMethodCalledOnAnotherInstance() throws Throwable {
class TestObject {
private int mIndex;
TestObject(int index) {
......
......@@ -14,10 +14,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
......@@ -26,7 +22,7 @@ import org.chromium.content_public.browser.JavaScriptCallback;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.test.ContentJUnit4RunnerDelegate;
import org.chromium.content_public.browser.test.ContentJUnit4ClassRunner;
import java.lang.ref.WeakReference;
import java.util.concurrent.CountDownLatch;
......@@ -39,8 +35,7 @@ import java.util.concurrent.TimeoutException;
* Ensures that injected objects are exposed to child frames as well as the
* main frame.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(ContentJUnit4RunnerDelegate.class)
@RunWith(ContentJUnit4ClassRunner.class)
public class JavaBridgeChildFrameTest {
@Rule
public JavaBridgeActivityTestRule mActivityTestRule =
......@@ -61,11 +56,6 @@ public class JavaBridgeChildFrameTest {
}
}
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
TestController mTestController;
@Before
......@@ -77,8 +67,7 @@ public class JavaBridgeChildFrameTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testInjectedObjectPresentInChildFrame(boolean useMojo) throws Throwable {
public void testInjectedObjectPresentInChildFrame() throws Throwable {
loadDataSync(mActivityTestRule.getWebContents().getNavigationController(),
"<html><body><iframe></iframe></body></html>", "text/html", false);
// We are not executing this code as a part of page loading routine to avoid races
......@@ -96,8 +85,7 @@ public class JavaBridgeChildFrameTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMainPageWrapperIsNotBrokenByChildFrame(boolean useMojo) throws Throwable {
public void testMainPageWrapperIsNotBrokenByChildFrame() throws Throwable {
loadDataSync(mActivityTestRule.getWebContents().getNavigationController(),
"<html><body><iframe></iframe></body></html>", "text/html", false);
// In case there is anything wrong with the JS wrapper, an attempt
......@@ -120,8 +108,7 @@ public class JavaBridgeChildFrameTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testWrapperIsNotSharedWithChildFrame(boolean useMojo) throws Throwable {
public void testWrapperIsNotSharedWithChildFrame() throws Throwable {
// Test by setting a custom property on the parent page's injected
// object and then checking that child frame doesn't see the property.
loadDataSync(mActivityTestRule.getWebContents().getNavigationController(),
......@@ -150,8 +137,7 @@ public class JavaBridgeChildFrameTest {
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@DisabledTest(message = "https://crbug.com/677182")
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testRemovingTransientObjectHolders(boolean useMojo) throws Throwable {
public void testRemovingTransientObjectHolders() throws Throwable {
class Test {
private Object mInner = new Object();
// Expecting the inner object to be retrieved twice.
......@@ -213,8 +199,7 @@ public class JavaBridgeChildFrameTest {
@Feature({"AndroidWebView", "Android-JavaBridge"})
@CommandLineFlags.Add("js-flags=--expose-gc")
@DisabledTest(message = "https://crbug.com/646843")
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testHolderFrame(boolean useMojo) throws Throwable {
public void testHolderFrame() throws Throwable {
class Test {
WeakReference<Object> mWeakRefForInner;
private CountDownLatch mLatch = new CountDownLatch(1);
......
......@@ -14,11 +14,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
......@@ -37,8 +33,7 @@ import java.io.File;
* FIXME: Consider making our implementation more compliant, if it will not
* break backwards-compatibility. See b/4408210.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
@RunWith(BaseJUnit4ClassRunner.class)
public class JavaBridgeCoercionTest {
private static final double ASSERTION_DELTA = 0;
......@@ -176,11 +171,6 @@ public class JavaBridgeCoercionTest {
private static class CustomType2 {
}
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
private TestObject mTestObject;
private static class TestController extends Controller {
......@@ -223,8 +213,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberInt32(boolean useMojo) throws Throwable {
public void testPassNumberInt32() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteValue(42);");
Assert.assertEquals(42, mTestObject.waitForByteValue());
mActivityTestRule.executeJavaScript(
......@@ -277,8 +266,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassNumberDouble(boolean useMojo) throws Throwable {
public void testPassNumberDouble() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteValue(42.1);");
Assert.assertEquals(42, mTestObject.waitForByteValue());
mActivityTestRule.executeJavaScript(
......@@ -359,8 +347,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberNaN(boolean useMojo) throws Throwable {
public void testPassNumberNaN() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteValue(Number.NaN);");
Assert.assertEquals(0, mTestObject.waitForByteValue());
......@@ -401,8 +388,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNumberInfinity(boolean useMojo) throws Throwable {
public void testPassNumberInfinity() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setByteValue(Infinity);");
Assert.assertEquals(-1, mTestObject.waitForByteValue());
......@@ -446,8 +432,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassBoolean(boolean useMojo) throws Throwable {
public void testPassBoolean() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setBooleanValue(true);");
Assert.assertTrue(mTestObject.waitForBooleanValue());
mActivityTestRule.executeJavaScript("testObject.setBooleanValue(false);");
......@@ -513,8 +498,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassString(boolean useMojo) throws Throwable {
public void testPassString() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setStringValue(\"+042.10\");");
Assert.assertEquals("+042.10", mTestObject.waitForStringValue());
......@@ -567,8 +551,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassJavaScriptObject(boolean useMojo) throws Throwable {
public void testPassJavaScriptObject() throws Throwable {
// LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception.
mActivityTestRule.executeJavaScript("testObject.setObjectValue({foo: 42});");
Assert.assertNull(mTestObject.waitForObjectValue());
......@@ -620,8 +603,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassJavaObject(boolean useMojo) throws Throwable {
public void testPassJavaObject() throws Throwable {
mActivityTestRule.executeJavaScript(
"testObject.setObjectValue(testObject.getObjectInstance());");
Assert.assertTrue(mTestObject.getObjectInstance() == mTestObject.waitForObjectValue());
......@@ -700,8 +682,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassJavaObjectFromCustomClassLoader(boolean useMojo) throws Throwable {
public void testPassJavaObjectFromCustomClassLoader() throws Throwable {
// Compiled bytecode (dex) for the following class:
//
// package org.example;
......@@ -725,7 +706,7 @@ public class JavaBridgeCoercionTest {
mActivityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
mActivityTestRule.getJavascriptInjector(useMojo).addPossiblyUnsafeInterface(
mActivityTestRule.getJavascriptInjector().addPossiblyUnsafeInterface(
selfConsuming, "selfConsuming", null);
}
});
......@@ -739,8 +720,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassNull(boolean useMojo) throws Throwable {
public void testPassNull() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setObjectValue(null);");
Assert.assertNull(mTestObject.waitForObjectValue());
......@@ -779,8 +759,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testPassUndefined(boolean useMojo) throws Throwable {
public void testPassUndefined() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setObjectValue(undefined);");
Assert.assertNull(mTestObject.waitForObjectValue());
......@@ -821,8 +800,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassArrayBuffer(boolean useMojo) throws Throwable {
public void testPassArrayBuffer() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);");
mActivityTestRule.executeJavaScript("testObject.setObjectValue(buffer);");
......@@ -839,8 +817,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassDataView(boolean useMojo) throws Throwable {
public void testPassDataView() throws Throwable {
mActivityTestRule.executeJavaScript("buffer = new ArrayBuffer(16);");
mActivityTestRule.executeJavaScript("testObject.setObjectValue(new DataView(buffer));");
......@@ -854,8 +831,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassDateObject(boolean useMojo) throws Throwable {
public void testPassDateObject() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setDoubleValue(new Date(2000, 0, 1));");
Assert.assertEquals(0.0, mTestObject.waitForDoubleValue(), ASSERTION_DELTA);
......@@ -870,8 +846,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassRegExpObject(boolean useMojo) throws Throwable {
public void testPassRegExpObject() throws Throwable {
mActivityTestRule.executeJavaScript("testObject.setStringValue(/abc/);");
Assert.assertEquals("undefined", mTestObject.waitForStringValue());
......@@ -883,8 +858,7 @@ public class JavaBridgeCoercionTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.LegacyTestParams.class)
public void testPassFunctionObject(boolean useMojo) throws Throwable {
public void testPassFunctionObject() throws Throwable {
mActivityTestRule.executeJavaScript("func = new Function('a', 'b', 'return a + b');");
mActivityTestRule.executeJavaScript("testObject.setStringValue(func);");
......
......@@ -12,11 +12,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
......@@ -24,8 +20,7 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
* Part of the test suite for the Java Bridge. This test tests the
* use of fields.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
@RunWith(BaseJUnit4ClassRunner.class)
public class JavaBridgeFieldsTest {
@Rule
public JavaBridgeActivityTestRule mActivityTestRule =
......@@ -61,11 +56,6 @@ public class JavaBridgeFieldsTest {
private static class CustomType {
}
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
TestObject mTestObject;
@Before
......@@ -85,8 +75,7 @@ public class JavaBridgeFieldsTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testFieldTypes(boolean useMojo) throws Throwable {
public void testFieldTypes() throws Throwable {
Assert.assertEquals(
"undefined", executeJavaScriptAndGetStringResult("typeof testObject.booleanField"));
Assert.assertEquals(
......
......@@ -12,11 +12,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameter;
import org.chromium.base.test.params.ParameterAnnotations.UseMethodParameterBefore;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
......@@ -31,8 +27,7 @@ import org.chromium.content.browser.JavaBridgeActivityTestRule.Controller;
* FIXME: Consider making our implementation more compliant, if it will not
* break backwards-compatibility. See b/4408210.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
@RunWith(BaseJUnit4ClassRunner.class)
public class JavaBridgeReturnValuesTest {
@Rule
public JavaBridgeActivityTestRule mActivityTestRule =
......@@ -118,11 +113,6 @@ public class JavaBridgeReturnValuesTest {
private static class CustomType {
}
@UseMethodParameterBefore(JavaBridgeActivityTestRule.MojoTestParams.class)
public void setupMojoTest(boolean useMojo) {
mActivityTestRule.setupMojoTest(useMojo);
}
TestObject mTestObject;
@Before
......@@ -146,8 +136,7 @@ public class JavaBridgeReturnValuesTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMethodReturnTypes(boolean useMojo) throws Throwable {
public void testMethodReturnTypes() throws Throwable {
Assert.assertEquals("boolean",
executeJavaScriptAndGetStringResult("typeof testObject.getBooleanValue()"));
Assert.assertEquals(
......@@ -189,8 +178,7 @@ public class JavaBridgeReturnValuesTest {
@Test
@SmallTest
@Feature({"AndroidWebView", "Android-JavaBridge"})
@UseMethodParameter(JavaBridgeActivityTestRule.MojoTestParams.class)
public void testMethodReturnValues(boolean useMojo) throws Throwable {
public void testMethodReturnValues() throws Throwable {
// We do the string comparison in JavaScript, to avoid relying on the
// coercion algorithm from JavaScript to Java.
Assert.assertTrue(executeJavaScriptAndGetBooleanResult("testObject.getBooleanValue()"));
......
......@@ -34,7 +34,6 @@ android_library("content_java_test_support") {
"javatests/src/org/chromium/content_public/browser/test/ChildProcessAllocatorSettings.java",
"javatests/src/org/chromium/content_public/browser/test/ChildProcessAllocatorSettingsHook.java",
"javatests/src/org/chromium/content_public/browser/test/ContentJUnit4ClassRunner.java",
"javatests/src/org/chromium/content_public/browser/test/ContentJUnit4RunnerDelegate.java",
"javatests/src/org/chromium/content_public/browser/test/NativeLibraryTestUtils.java",
"javatests/src/org/chromium/content_public/browser/test/RenderFrameHostTestExt.java",
"javatests/src/org/chromium/content_public/browser/test/mock/MockNavigationController.java",
......
// Copyright 2020 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.
package org.chromium.content_public.browser.test;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.chromium.base.test.params.ParameterizedRunner.ParameterizedTestInstantiationException;
import org.chromium.base.test.params.ParameterizedRunnerDelegate;
import org.chromium.base.test.params.ParameterizedRunnerDelegateCommon;
import java.util.List;
/**
* A custom runner delegate for running //content JUnit4 parameterized tests.
*/
public final class ContentJUnit4RunnerDelegate
extends ContentJUnit4ClassRunner implements ParameterizedRunnerDelegate {
private final ParameterizedRunnerDelegateCommon mDelegateCommon;
public ContentJUnit4RunnerDelegate(Class<?> klass,
ParameterizedRunnerDelegateCommon delegateCommon) throws InitializationError {
super(klass);
mDelegateCommon = delegateCommon;
}
@Override
public void collectInitializationErrors(List<Throwable> errors) {
ParameterizedRunnerDelegateCommon.collectInitializationErrors(errors);
}
@Override
public List<FrameworkMethod> computeTestMethods() {
return mDelegateCommon.computeTestMethods();
}
@Override
public Object createTest() throws ParameterizedTestInstantiationException {
return mDelegateCommon.createTest();
}
}
......@@ -226,11 +226,7 @@ public class ContentShellActivityTestRule extends ActivityTestRule<ContentShellA
}
public JavascriptInjector getJavascriptInjector() {
return getJavascriptInjector(false);
}
public JavascriptInjector getJavascriptInjector(boolean useMojo) {
return JavascriptInjector.fromWebContents(getWebContents(), useMojo);
return JavascriptInjector.fromWebContents(getWebContents());
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment