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

Unified Diff: content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java

Issue 879993002: [Android] Add support for command-line flags via annotation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add @VisibleForTesting Created 5 years, 11 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
« no previous file with comments | « content/public/android/javatests/src/org/chromium/content/browser/PhoneNumberDetectionTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java
diff --git a/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java b/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java
index 49a8d1343492d6719d318574fe76502e98bfe1f1..a4c8b3aba52f7349ec95c3ae0f369a0d5c07e259 100644
--- a/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java
+++ b/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java
@@ -9,11 +9,12 @@ import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
-import android.test.ActivityInstrumentationTestCase2;
import android.text.TextUtils;
import android.view.ViewGroup;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.test.BaseActivityInstrumentationTestCase;
+import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewCore;
@@ -21,6 +22,7 @@ import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
+import org.chromium.content.common.ContentSwitches;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.WebContents;
@@ -37,8 +39,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
* Base test class for all ContentShell based tests.
*/
-public class ContentShellTestBase extends ActivityInstrumentationTestCase2<ContentShellActivity> {
-
+@CommandLineFlags.Add(ContentSwitches.ENABLE_TEST_INTENTS)
+public class ContentShellTestBase
+ extends BaseActivityInstrumentationTestCase<ContentShellActivity> {
/** The maximum time the waitForActiveShellToBeDoneLoading method will wait. */
private static final long WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT = scaleTimeout(10000);
@@ -53,25 +56,12 @@ public class ContentShellTestBase extends ActivityInstrumentationTestCase2<Conte
* The URL can be null, in which case will default to ContentShellActivity.DEFAULT_SHELL_URL.
*/
protected ContentShellActivity launchContentShellWithUrl(String url) {
- return launchContentShellWithUrlAndCommandLineArgs(url, null);
- }
-
- /**
- * Starts the ContentShell activity appending the provided command line arguments
- * and loads the given URL. The URL can be null, in which case will default to
- * ContentShellActivity.DEFAULT_SHELL_URL.
- */
- protected ContentShellActivity launchContentShellWithUrlAndCommandLineArgs(String url,
- String[] commandLineArgs) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (url != null) intent.setData(Uri.parse(url));
intent.setComponent(new ComponentName(getInstrumentation().getTargetContext(),
ContentShellActivity.class));
- if (commandLineArgs != null) {
- intent.putExtra(ContentShellActivity.COMMAND_LINE_ARGS_KEY, commandLineArgs);
- }
setActivityIntent(intent);
return getActivity();
}
@@ -92,21 +82,6 @@ public class ContentShellTestBase extends ActivityInstrumentationTestCase2<Conte
}
/**
- * Starts the content shell activity with the provided test url and optional command line
- * arguments to append.
- * The url is synchronously loaded.
- * @param url Test url to load.
- * @param commandLineArgs Optional command line args to append when launching the activity.
- */
- protected void startActivityWithTestUrlAndCommandLineArgs(
- String url, String[] commandLineArgs) throws Throwable {
- launchContentShellWithUrlAndCommandLineArgs(
- UrlUtils.getTestFileUrl(url), commandLineArgs);
- assertNotNull(getActivity());
- assertTrue(waitForActiveShellToBeDoneLoading());
- }
-
- /**
* Returns the current ContentViewCore or null if there is no ContentView.
*/
protected ContentViewCore getContentViewCore() {
« no previous file with comments | « content/public/android/javatests/src/org/chromium/content/browser/PhoneNumberDetectionTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698