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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.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/InterstitialPageTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.java b/content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.java
index 1bdba7b1a5803601ef1d8de4b56891576f72d23e..ce31ffdb3aec5d28130fa1cc63be81d14ce3b177 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.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.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.ThreadUtils;
+import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.base.test.util.UrlUtils;
@@ -16,7 +23,7 @@ import org.chromium.content.browser.test.util.TouchCommon;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver;
import org.chromium.content_shell_apk.ContentShellActivity;
-import org.chromium.content_shell_apk.ContentShellTestBase;
+import org.chromium.content_shell_apk.ContentShellActivityTestRule;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -24,7 +31,10 @@ import java.util.concurrent.ExecutionException;
/**
* Tests for interstitial pages.
*/
-public class InterstitialPageTest extends ContentShellTestBase {
+@RunWith(BaseJUnit4ClassRunner.class)
+public class InterstitialPageTest {
+ @Rule
+ public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule();
private static final String URL = UrlUtils.encodeHtmlDataUri(
"<html><head></head><body>test</body></html>");
@@ -56,12 +66,11 @@ public class InterstitialPageTest extends ContentShellTestBase {
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- ContentShellActivity activity = launchContentShellWithUrl(URL);
- assertNotNull(activity);
- waitForActiveShellToBeDoneLoading();
+ @Before
+ public void setUp() throws Exception {
+ ContentShellActivity activity = mActivityTestRule.launchContentShellWithUrl(URL);
+ Assert.assertNotNull(activity);
+ mActivityTestRule.waitForActiveShellToBeDoneLoading();
}
private void waitForInterstitial(final boolean shouldBeShown) {
@@ -69,7 +78,7 @@ public class InterstitialPageTest extends ContentShellTestBase {
Criteria.equals(shouldBeShown, new Callable<Boolean>() {
@Override
public Boolean call() {
- return getWebContents().isShowingInterstitialPage();
+ return mActivityTestRule.getWebContents().isShowingInterstitialPage();
}
}));
}
@@ -77,6 +86,7 @@ public class InterstitialPageTest extends ContentShellTestBase {
/**
* Tests that showing and hiding an interstitial works.
*/
+ @Test
@LargeTest
@Feature({"Navigation"})
@RetryOnFailure
@@ -100,7 +110,7 @@ public class InterstitialPageTest extends ContentShellTestBase {
new InterstitialPageDelegateAndroid(htmlContent) {
@Override
protected void commandReceived(String command) {
- assertEquals(command, proceedCommand);
+ Assert.assertEquals(command, proceedCommand);
proceed();
}
};
@@ -108,17 +118,19 @@ public class InterstitialPageTest extends ContentShellTestBase {
new Callable<TestWebContentsObserver>() {
@Override
public TestWebContentsObserver call() throws Exception {
- getWebContents().showInterstitialPage(URL, delegate.getNative());
- return new TestWebContentsObserver(getWebContents());
+ mActivityTestRule.getWebContents().showInterstitialPage(
+ URL, delegate.getNative());
+ return new TestWebContentsObserver(mActivityTestRule.getWebContents());
}
});
waitForInterstitial(true);
- assertTrue("WebContentsObserver not notified of interstitial showing",
+ Assert.assertTrue("WebContentsObserver not notified of interstitial showing",
observer.isInterstitialShowing());
- TouchCommon.singleClickView(getContentViewCore().getContainerView(), 10, 10);
+ TouchCommon.singleClickView(
+ mActivityTestRule.getContentViewCore().getContainerView(), 10, 10);
waitForInterstitial(false);
- assertTrue("WebContentsObserver not notified of interstitial hiding",
+ Assert.assertTrue("WebContentsObserver not notified of interstitial hiding",
!observer.isInterstitialShowing());
}
}

Powered by Google App Engine
This is Rietveld 408576698