| Index: chrome/android/javatests/src/org/chromium/chrome/browser/shape_detection/ShapeDetectionTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/shape_detection/ShapeDetectionTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/shape_detection/ShapeDetectionTest.java
|
| index 98836948c46a557fb993dcb73804d81b6c45c2d1..3f64ccba1ef842f0fa2c270999966dc2fe0eab01 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/shape_detection/ShapeDetectionTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/shape_detection/ShapeDetectionTest.java
|
| @@ -5,25 +5,15 @@
|
| package org.chromium.chrome.browser.shape_detection;
|
|
|
| import android.os.StrictMode;
|
| -import android.support.test.InstrumentationRegistry;
|
| import android.support.test.filters.LargeTest;
|
| -
|
| -import org.junit.After;
|
| -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.ThreadUtils;
|
| import org.chromium.base.test.util.CommandLineFlags;
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.Restriction;
|
| import org.chromium.chrome.browser.ChromeActivity;
|
| -import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.tab.Tab;
|
| -import org.chromium.chrome.test.ChromeActivityTestRule;
|
| -import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| +import org.chromium.chrome.test.ChromeActivityTestCaseBase;
|
| import org.chromium.chrome.test.util.ChromeRestriction;
|
| import org.chromium.chrome.test.util.browser.TabTitleObserver;
|
| import org.chromium.net.test.EmbeddedTestServer;
|
| @@ -36,39 +26,34 @@
|
| * is based on android.media.FaceDetector and doesn't need special treatment,
|
| * hence is tested via content_browsertests.
|
| */
|
| -@RunWith(ChromeJUnit4ClassRunner.class)
|
| -@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
|
| - ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
|
| -public class ShapeDetectionTest {
|
| - @Rule
|
| - public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
|
| - new ChromeActivityTestRule<>(ChromeActivity.class);
|
| -
|
| +public class ShapeDetectionTest extends ChromeActivityTestCaseBase<ChromeActivity> {
|
| private static final String BARCODE_TEST_EXPECTED_TAB_TITLE = "https://chromium.org";
|
| private static final String TEXT_TEST_EXPECTED_TAB_TITLE =
|
| "The quick brown fox jumped over the lazy dog. Helvetica Neue 36.";
|
| private StrictMode.ThreadPolicy mOldPolicy;
|
|
|
| + public ShapeDetectionTest() {
|
| + super(ChromeActivity.class);
|
| + }
|
| +
|
| /**
|
| * Verifies that QR codes are detected correctly.
|
| */
|
| - @Test
|
| @CommandLineFlags.Add("enable-experimental-web-platform-features")
|
| @Feature({"ShapeDetection"})
|
| @LargeTest
|
| @Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES)
|
| public void testBarcodeDetection() throws InterruptedException, TimeoutException {
|
| - EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartServer(
|
| - InstrumentationRegistry.getInstrumentation().getContext());
|
| + EmbeddedTestServer testServer =
|
| + EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
|
| try {
|
| - Tab tab = mActivityTestRule.getActivity().getActivityTab();
|
| + Tab tab = getActivity().getActivityTab();
|
| TabTitleObserver titleObserver =
|
| new TabTitleObserver(tab, BARCODE_TEST_EXPECTED_TAB_TITLE);
|
| - mActivityTestRule.loadUrl(
|
| - testServer.getURL("/chrome/test/data/android/barcode_detection.html"));
|
| + loadUrl(testServer.getURL("/chrome/test/data/android/barcode_detection.html"));
|
| titleObserver.waitForTitleUpdate(10);
|
|
|
| - Assert.assertEquals(BARCODE_TEST_EXPECTED_TAB_TITLE, tab.getTitle());
|
| + assertEquals(BARCODE_TEST_EXPECTED_TAB_TITLE, tab.getTitle());
|
| } finally {
|
| testServer.stopAndDestroyServer();
|
| }
|
| @@ -77,23 +62,21 @@
|
| /**
|
| * Verifies that text is detected correctly.
|
| */
|
| - @Test
|
| @CommandLineFlags.Add("enable-experimental-web-platform-features")
|
| @Feature({"ShapeDetection"})
|
| @LargeTest
|
| @Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES)
|
| public void testTextDetection() throws InterruptedException, TimeoutException {
|
| - EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartServer(
|
| - InstrumentationRegistry.getInstrumentation().getContext());
|
| + EmbeddedTestServer testServer =
|
| + EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
|
| try {
|
| - Tab tab = mActivityTestRule.getActivity().getActivityTab();
|
| + Tab tab = getActivity().getActivityTab();
|
| TabTitleObserver titleObserver =
|
| new TabTitleObserver(tab, TEXT_TEST_EXPECTED_TAB_TITLE);
|
| - mActivityTestRule.loadUrl(
|
| - testServer.getURL("/chrome/test/data/android/text_detection.html"));
|
| + loadUrl(testServer.getURL("/chrome/test/data/android/text_detection.html"));
|
| titleObserver.waitForTitleUpdate(10);
|
|
|
| - Assert.assertEquals(TEXT_TEST_EXPECTED_TAB_TITLE, tab.getTitle());
|
| + assertEquals(TEXT_TEST_EXPECTED_TAB_TITLE, tab.getTitle());
|
| } finally {
|
| testServer.stopAndDestroyServer();
|
| }
|
| @@ -102,9 +85,9 @@
|
| /**
|
| * We need to allow a looser policy due to the Google Play Services internals.
|
| */
|
| - @Before
|
| - public void setUp() throws Exception {
|
| - mActivityTestRule.startMainActivityOnBlankPage();
|
| + @Override
|
| + protected void setUp() throws Exception {
|
| + super.setUp();
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| @@ -113,13 +96,19 @@
|
| });
|
| }
|
|
|
| - @After
|
| - public void tearDown() throws Exception {
|
| + @Override
|
| + protected void tearDown() throws Exception {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| StrictMode.setThreadPolicy(mOldPolicy);
|
| }
|
| });
|
| + super.tearDown();
|
| + }
|
| +
|
| + @Override
|
| + public void startMainActivity() throws InterruptedException {
|
| + startMainActivityOnBlankPage();
|
| }
|
| }
|
|
|