| Index: chrome/android/javatests/src/org/chromium/chrome/browser/video/VideoTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/video/VideoTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/video/VideoTest.java
|
| index 75169f35d6609cd62e5ad1ad57e2272bc1442bb9..1a0fee36c1688a137730592db839b0833f6a682e 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/video/VideoTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/video/VideoTest.java
|
| @@ -4,14 +4,24 @@
|
|
|
| package org.chromium.chrome.browser.video;
|
|
|
| +import android.support.test.InstrumentationRegistry;
|
| import android.support.test.filters.LargeTest;
|
|
|
| +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.DisableIf;
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.RetryOnFailure;
|
| import org.chromium.chrome.browser.ChromeActivity;
|
| +import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.tab.Tab;
|
| -import org.chromium.chrome.test.ChromeActivityTestCaseBase;
|
| +import org.chromium.chrome.test.ChromeActivityTestRule;
|
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| import org.chromium.chrome.test.util.browser.TabTitleObserver;
|
| import org.chromium.content.browser.test.util.DOMUtils;
|
| import org.chromium.net.test.EmbeddedTestServer;
|
| @@ -21,39 +31,43 @@ import java.util.concurrent.TimeoutException;
|
| /**
|
| * Simple tests of html5 video.
|
| */
|
| -public class VideoTest extends ChromeActivityTestCaseBase<ChromeActivity> {
|
| -
|
| - public VideoTest() {
|
| - super(ChromeActivity.class);
|
| - }
|
| +@RunWith(ChromeJUnit4ClassRunner.class)
|
| +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
|
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
|
| +public class VideoTest {
|
| + @Rule
|
| + public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
|
| + new ChromeActivityTestRule<>(ChromeActivity.class);
|
|
|
| + @Test
|
| @DisableIf.Build(sdk_is_less_than = 19, message = "crbug.com/582067")
|
| @Feature({"Media", "Media-Video", "Main"})
|
| @LargeTest
|
| @RetryOnFailure
|
| public void testLoadMediaUrl() throws InterruptedException, TimeoutException {
|
| EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartServer(
|
| - getInstrumentation().getContext());
|
| + InstrumentationRegistry.getInstrumentation().getContext());
|
| try {
|
| - Tab tab = getActivity().getActivityTab();
|
| + Tab tab = mActivityTestRule.getActivity().getActivityTab();
|
| TabTitleObserver titleObserver = new TabTitleObserver(tab, "ready_to_play");
|
| - loadUrl(testServer.getURL("/chrome/test/data/android/media/video-play.html"));
|
| + mActivityTestRule.loadUrl(
|
| + testServer.getURL("/chrome/test/data/android/media/video-play.html"));
|
| titleObserver.waitForTitleUpdate(5);
|
| - assertEquals("ready_to_play", tab.getTitle());
|
| + Assert.assertEquals("ready_to_play", tab.getTitle());
|
|
|
| titleObserver = new TabTitleObserver(tab, "ended");
|
| DOMUtils.clickNode(tab.getContentViewCore(), "button1");
|
| // Now the video will play for 5 secs.
|
| // Makes sure that the video ends and title was changed.
|
| titleObserver.waitForTitleUpdate(15);
|
| - assertEquals("ended", tab.getTitle());
|
| + Assert.assertEquals("ended", tab.getTitle());
|
| } finally {
|
| testServer.stopAndDestroyServer();
|
| }
|
| }
|
|
|
| - @Override
|
| - public void startMainActivity() throws InterruptedException {
|
| - startMainActivityOnBlankPage();
|
| + @Before
|
| + public void setUp() throws InterruptedException {
|
| + mActivityTestRule.startMainActivityOnBlankPage();
|
| }
|
| }
|
|
|