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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.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/WebContentsObserverAndroidTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.java b/content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.java
index b89d1d2cfb1ea11b2861b357ec41034a5385a6f8..5ea1bba6e5603ede655ce261532861504845e042 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/WebContentsObserverAndroidTest.java
@@ -1,10 +1,19 @@
-// Copyright 2014 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.
package org.chromium.content.browser;
+import android.support.test.InstrumentationRegistry;
+
+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.CallbackHelper;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.UrlUtils;
@@ -12,14 +21,18 @@ import org.chromium.content_public.browser.LoadUrlParams;
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;
/**
* Tests for the WebContentsObserver APIs.
*/
-public class WebContentsObserverAndroidTest extends ContentShellTestBase {
+@RunWith(BaseJUnit4ClassRunner.class)
+public class WebContentsObserverAndroidTest {
+ @Rule
+ public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule();
+
private static final String URL = UrlUtils.encodeHtmlDataUri(
"<html><head></head><body>didFirstVisuallyNonEmptyPaint test</body></html>");
@@ -40,33 +53,36 @@ public class WebContentsObserverAndroidTest extends ContentShellTestBase {
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- ContentShellActivity activity = launchContentShellWithUrl(null);
- assertNotNull(activity);
- waitForActiveShellToBeDoneLoading();
+ @Before
+ public void setUp() throws Exception {
+ ContentShellActivity activity = mActivityTestRule.launchContentShellWithUrl(null);
+ Assert.assertNotNull(activity);
+ mActivityTestRule.waitForActiveShellToBeDoneLoading();
}
/*
@SmallTest
@Feature({"Navigation"})
*/
+ @Test
@DisabledTest(message = "crbug.com/411931")
public void testDidFirstVisuallyNonEmptyPaint() throws Throwable {
TestWebContentsObserver observer = ThreadUtils.runOnUiThreadBlocking(
new Callable<TestWebContentsObserver>() {
@Override
public TestWebContentsObserver call() throws Exception {
- return new TestWebContentsObserver(getContentViewCore().getWebContents());
+ return new TestWebContentsObserver(
+ mActivityTestRule.getContentViewCore().getWebContents());
}
});
int callCount = observer.getDidFirstVisuallyNonEmptyPaintCallbackHelper().getCallCount();
- getInstrumentation().runOnMainSync(new Runnable() {
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- getContentViewCore().getWebContents().getNavigationController()
+ mActivityTestRule.getContentViewCore()
+ .getWebContents()
+ .getNavigationController()
.loadUrl(new LoadUrlParams(URL));
}
});

Powered by Google App Engine
This is Rietveld 408576698