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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionActivityTestRule.java

Issue 2632043002: Create ContentShellActivityTestRule and BaseJUnitRunner (Closed)
Patch Set: change after mike's commments Created 3 years, 10 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/ContentDetectionActivityTestRule.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionActivityTestRule.java
similarity index 76%
copy from content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java
copy to content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionActivityTestRule.java
index 0c2fac85d8fca07a58ddd3b3d5142304d395dd3b..b0be0f1dd7b664d10a4282eab749341b552b4e5f 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionActivityTestRule.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,8 +6,8 @@ package org.chromium.content.browser;
import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
-import android.app.Activity;
import android.net.Uri;
+import android.support.test.InstrumentationRegistry;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.UrlUtils;
@@ -15,15 +15,14 @@ import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper;
import org.chromium.content_shell.ShellViewAndroidDelegate.ContentIntentHandler;
-import org.chromium.content_shell_apk.ContentShellTestBase;
+import org.chromium.content_shell_apk.ContentShellActivityTestRule;
import java.util.concurrent.TimeUnit;
/**
- * Base class for content detection test suites.
+ * ActivityTestRule for content detection test suites.
*/
-public class ContentDetectionTestBase extends ContentShellTestBase {
-
+public class ContentDetectionActivityTestRule extends ContentShellActivityTestRule {
private static final long WAIT_TIMEOUT_SECONDS = scaleTimeout(10);
private TestCallbackHelperContainer mCallbackHelper;
@@ -67,7 +66,7 @@ public class ContentDetectionTestBase extends ContentShellTestBase {
* Returns the TestCallbackHelperContainer associated with this ContentView,
* or creates it lazily.
*/
- protected TestCallbackHelperContainer getTestCallbackHelperContainer() {
+ public TestCallbackHelperContainer getTestCallbackHelperContainer() {
if (mCallbackHelper == null) {
mCallbackHelper = new TestCallbackHelperContainer(getContentViewCore());
}
@@ -75,14 +74,13 @@ public class ContentDetectionTestBase extends ContentShellTestBase {
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ protected void beforeActivityLaunched() {
+ super.beforeActivityLaunched();
mContentIntentHandler = new TestContentIntentHandler();
}
@Override
- protected void setActivity(Activity activity) {
- super.setActivity(activity);
+ protected void afterActivityLaunched() {
getActivity()
.getShellManager()
.getActiveShell()
@@ -95,7 +93,7 @@ public class ContentDetectionTestBase extends ContentShellTestBase {
* @param content Content to escape into a url.
* @return Escaped url.
*/
- protected static String urlForContent(String content) {
+ public String urlForContent(String content) {
return Uri.encode(content).replaceAll("%20", "+");
}
@@ -104,9 +102,9 @@ public class ContentDetectionTestBase extends ContentShellTestBase {
* @param testUrl Test url to check.
* @return true if the test url is the current one, false otherwise.
*/
- protected boolean isCurrentTestUrl(String testUrl) {
- return UrlUtils.getIsolatedTestFileUrl(testUrl).equals(getContentViewCore()
- .getWebContents().getUrl());
+ public boolean isCurrentTestUrl(String testUrl) {
+ return UrlUtils.getIsolatedTestFileUrl(testUrl).equals(
+ getContentViewCore().getWebContents().getUrl());
}
/**
@@ -114,16 +112,16 @@ public class ContentDetectionTestBase extends ContentShellTestBase {
* @param id Id of the node to scroll and tap.
* @return The content url of the received intent or null if none.
*/
- protected String scrollAndTapExpectingIntent(String id) throws Throwable {
+ public String scrollAndTapExpectingIntent(String id) throws Throwable {
OnStartContentIntentHelper onStartContentIntentHelper =
mContentIntentHandler.getOnStartContentIntentHelper();
int currentCallCount = onStartContentIntentHelper.getCallCount();
DOMUtils.clickNode(getContentViewCore(), id);
- onStartContentIntentHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_SECONDS,
- TimeUnit.SECONDS);
- getInstrumentation().waitForIdleSync();
+ onStartContentIntentHelper.waitForCallback(
+ currentCallCount, 1, WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
return onStartContentIntentHelper.getIntentUrl();
}
@@ -133,7 +131,7 @@ public class ContentDetectionTestBase extends ContentShellTestBase {
* @param id Id of the node to scroll and tap.
* @return The content url of the received intent or null if none.
*/
- protected void scrollAndTapNavigatingOut(String id) throws Throwable {
+ public void scrollAndTapNavigatingOut(String id) throws Throwable {
TestCallbackHelperContainer callbackHelperContainer = getTestCallbackHelperContainer();
OnPageFinishedHelper onPageFinishedHelper =
callbackHelperContainer.getOnPageFinishedHelper();
@@ -141,8 +139,8 @@ public class ContentDetectionTestBase extends ContentShellTestBase {
DOMUtils.clickNode(getContentViewCore(), id);
- onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_SECONDS,
- TimeUnit.SECONDS);
- getInstrumentation().waitForIdleSync();
+ onPageFinishedHelper.waitForCallback(
+ currentCallCount, 1, WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}
-}
+}

Powered by Google App Engine
This is Rietveld 408576698