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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java

Issue 560153002: Add Cronet Test App that uses libcronet_tests.so with net test utilities. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move existing Cronet Tests to CronetTestInstrumentation. Created 6 years, 3 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: components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java b/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
new file mode 100644
index 0000000000000000000000000000000000000000..1c2e52cdaa65539a39c10ed14a4c021f0bab6071
--- /dev/null
+++ b/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
@@ -0,0 +1,62 @@
+// Copyright 2014 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.cronet_test_apk;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.net.Uri;
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * Base test class for all CronetTest based tests.
+ */
+public class CronetTestBase extends
+ ActivityInstrumentationTestCase2<CronetTestActivity> {
mmenke 2014/09/11 18:05:24 Now that we have this, do we still need CronetSamp
mef 2014/09/11 18:37:54 I'm going to prune that in separate CL. I would l
+ public CronetTestBase() {
+ super(CronetTestActivity.class);
+ }
+
+ /**
+ * Starts the CronetTest activity.
+ */
+ protected CronetTestActivity launchCronetTestApp() {
+ return launchCronetTestAppWithUrlAndCommandLineArgs(null, null);
+ }
+
+
mmenke 2014/09/11 18:05:24 nit: Remove extra blank line.
mef 2014/09/11 18:37:54 Done.
+ /**
+ * Starts the CronetTest activity and loads the given URL. The URL can be
+ * null.
+ */
+ protected CronetTestActivity launchCronetTestAppWithUrl(String url) {
+ return launchCronetTestAppWithUrlAndCommandLineArgs(url, null);
+ }
+
+ /**
+ * Starts the CronetTest activity appending the provided command line
+ * arguments and loads the given URL. The URL can be null.
+ */
+ protected CronetTestActivity launchCronetTestAppWithUrlAndCommandLineArgs(
+ 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(),
+ CronetTestActivity.class));
+ if (commandLineArgs != null) {
+ intent.putExtra(CronetTestActivity.COMMAND_LINE_ARGS_KEY,
+ commandLineArgs);
+ }
+ setActivityIntent(intent);
+ return getActivity();
+ }
+
+ protected boolean waitForActiveShellToBeDoneLoading() {
+ return true;
mmenke 2014/09/11 18:05:25 Why is this different from the old version? Is th
mef 2014/09/11 18:37:54 It *appears* to work fine without it, so I think w
mmenke 2014/09/11 18:54:41 I don't see how testLoadUrl or testPostData aren't
mef 2014/09/11 19:47:50 Done. Excellent point.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698