Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java |
| index 8a780b43b9239574c31ae5a61b8ad806d50b6d3a..245cc44721b79cf0231a5e92f99b3158ee59a350 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java |
| @@ -4,15 +4,24 @@ |
| package org.chromium.chrome.browser.dom_distiller; |
| +import android.support.test.InstrumentationRegistry; |
| import android.support.test.filters.MediumTest; |
| +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.test.util.CommandLineFlags; |
| import org.chromium.base.test.util.DisabledTest; |
| 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.compositor.bottombar.readermode.ReaderModePanel; |
| -import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| +import org.chromium.chrome.test.ChromeActivityTestRule; |
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| import org.chromium.chrome.test.util.ChromeRestriction; |
| import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper; |
| import org.chromium.content.browser.test.util.TestWebContentsObserver; |
| @@ -23,49 +32,51 @@ import java.util.concurrent.TimeoutException; |
| /** |
| * Tests for making sure the distillability service is communicating correctly. |
| */ |
| -@CommandLineFlags.Add({"enable-dom-distiller", "reader-mode-heuristics=alwaystrue"}) |
| -public class DistillabilityServiceTest extends ChromeActivityTestCaseBase<ChromeActivity> { |
| +@RunWith(ChromeJUnit4ClassRunner.class) |
| +@CommandLineFlags.Add({"enable-dom-distiller", "reader-mode-heuristics=alwaystrue", |
|
Ted C
2017/04/27 18:05:27
for cases like this if we have a default set of co
the real yoland
2017/04/28 02:03:29
this would work with this CL to enable the annotat
|
| + ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
| +public class DistillabilityServiceTest { |
| + @Rule |
| + public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = |
| + new ChromeActivityTestRule<>(ChromeActivity.class); |
| private static final String TEST_PAGE = "/chrome/test/data/android/simple.html"; |
| - public DistillabilityServiceTest() { |
| - super(ChromeActivity.class); |
| - } |
| - |
| - @Override |
| - public void startMainActivity() throws InterruptedException { |
| - startMainActivityOnBlankPage(); |
| + @Before |
| + public void setUp() throws InterruptedException { |
| + mActivityTestRule.startMainActivityOnBlankPage(); |
| } |
| /** |
| * Make sure that Reader Mode appears after navigating from a native page. |
| */ |
| + @Test |
| @Feature({"Distillability-Service"}) |
| @MediumTest |
| @Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE) |
| @DisabledTest |
| - public void testServiceAliveAfterNativePage() |
| - throws InterruptedException, TimeoutException { |
| - |
| + public void testServiceAliveAfterNativePage() throws InterruptedException, TimeoutException { |
| EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartServer( |
| - getInstrumentation().getContext()); |
| + InstrumentationRegistry.getInstrumentation().getContext()); |
| - final ReaderModePanel panel = getActivity().getReaderModeManager().getPanelForTesting(); |
| + final ReaderModePanel panel = |
| + mActivityTestRule.getActivity().getReaderModeManager().getPanelForTesting(); |
| - TestWebContentsObserver observer = |
| - new TestWebContentsObserver(getActivity().getActivityTab().getWebContents()); |
| + TestWebContentsObserver observer = new TestWebContentsObserver( |
| + mActivityTestRule.getActivity().getActivityTab().getWebContents()); |
| OnPageFinishedHelper finishHelper = observer.getOnPageFinishedHelper(); |
| // Navigate to a native page. |
| int curCallCount = finishHelper.getCallCount(); |
| - loadUrl("chrome://history"); |
| + mActivityTestRule.loadUrl("chrome://history"); |
| finishHelper.waitForCallback(curCallCount, 1); |
| - assertFalse(panel.isShowing()); |
| + Assert.assertFalse(panel.isShowing()); |
| // Navigate to a normal page. |
| curCallCount = finishHelper.getCallCount(); |
| - loadUrl(testServer.getURL(TEST_PAGE)); |
| + mActivityTestRule.loadUrl(testServer.getURL(TEST_PAGE)); |
| finishHelper.waitForCallback(curCallCount, 1); |
| - assertTrue(panel.isShowing()); |
| + Assert.assertTrue(panel.isShowing()); |
| } |
| } |