| Index: components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
|
| diff --git a/components/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTestBase.java b/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
|
| similarity index 57%
|
| copy from components/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTestBase.java
|
| copy to components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
|
| index eb44b56edd1666b5e3ea2ab8f43a17b95eb56e77..9b0e28381eb282329c7008f3d086ae13d1f050bf 100644
|
| --- a/components/cronet/android/sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTestBase.java
|
| +++ b/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -package org.chromium.cronet_sample_apk;
|
| +package org.chromium.cronet_test_apk;
|
|
|
| import android.content.ComponentName;
|
| import android.content.Intent;
|
| @@ -12,16 +12,13 @@ import android.text.TextUtils;
|
|
|
| import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
|
|
|
| -import org.chromium.base.test.util.UrlUtils;
|
| -
|
| import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
| /**
|
| - * Base test class for all CronetSample based tests.
|
| + * Base test class for all CronetTest based tests.
|
| */
|
| -public class CronetSampleTestBase extends
|
| - ActivityInstrumentationTestCase2<CronetSampleActivity> {
|
| -
|
| +public class CronetTestBase extends
|
| + ActivityInstrumentationTestCase2<CronetTestActivity> {
|
| /**
|
| * The maximum time the waitForActiveShellToBeDoneLoading method will wait.
|
| */
|
| @@ -31,25 +28,30 @@ public class CronetSampleTestBase extends
|
| protected static final long
|
| WAIT_PAGE_LOADING_TIMEOUT_SECONDS = scaleTimeout(15);
|
|
|
| - public CronetSampleTestBase() {
|
| - super(CronetSampleActivity.class);
|
| + public CronetTestBase() {
|
| + super(CronetTestActivity.class);
|
| + }
|
| +
|
| + /**
|
| + * Starts the CronetTest activity.
|
| + */
|
| + protected CronetTestActivity launchCronetTestApp() {
|
| + return launchCronetTestAppWithUrlAndCommandLineArgs(null, null);
|
| }
|
|
|
| /**
|
| - * Starts the CronetSample activity and loads the given URL. The URL can be
|
| - * null, in which case will default to
|
| - * CronetSampleActivity.DEFAULT_SHELL_URL.
|
| + * Starts the CronetTest activity and loads the given URL. The URL can be
|
| + * null.
|
| */
|
| - protected CronetSampleActivity launchCronetSampleWithUrl(String url) {
|
| - return launchCronetSampleWithUrlAndCommandLineArgs(url, null);
|
| + protected CronetTestActivity launchCronetTestAppWithUrl(String url) {
|
| + return launchCronetTestAppWithUrlAndCommandLineArgs(url, null);
|
| }
|
|
|
| /**
|
| - * Starts the CronetSample activity appending the provided command line
|
| - * arguments and loads the given URL. The URL can be null, in which case
|
| - * will default to CronetSampleActivity.DEFAULT_SHELL_URL.
|
| + * Starts the CronetTest activity appending the provided command line
|
| + * arguments and loads the given URL. The URL can be null.
|
| */
|
| - protected CronetSampleActivity launchCronetSampleWithUrlAndCommandLineArgs(
|
| + protected CronetTestActivity launchCronetTestAppWithUrlAndCommandLineArgs(
|
| String url, String[] commandLineArgs) {
|
| Intent intent = new Intent(Intent.ACTION_MAIN);
|
| intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
| @@ -58,48 +60,15 @@ public class CronetSampleTestBase extends
|
| intent.setData(Uri.parse(url));
|
| intent.setComponent(new ComponentName(
|
| getInstrumentation().getTargetContext(),
|
| - CronetSampleActivity.class));
|
| + CronetTestActivity.class));
|
| if (commandLineArgs != null) {
|
| - intent.putExtra(CronetSampleActivity.COMMAND_LINE_ARGS_KEY,
|
| + intent.putExtra(CronetTestActivity.COMMAND_LINE_ARGS_KEY,
|
| commandLineArgs);
|
| }
|
| setActivityIntent(intent);
|
| return getActivity();
|
| }
|
|
|
| - // TODO(cjhopman): These functions are inconsistent with
|
| - // launchCronetSample***. Should be startCronetSample*** and should use the
|
| - // url exactly without the getTestFileUrl call. Possibly these two ways of
|
| - // starting the activity (launch* and start*) should be merged into one.
|
| - /**
|
| - * Starts the content shell activity with the provided test url. The url is
|
| - * synchronously loaded.
|
| - *
|
| - * @param url Test url to load.
|
| - */
|
| - protected void startActivityWithTestUrl(String url) throws Throwable {
|
| - launchCronetSampleWithUrl(UrlUtils.getTestFileUrl(url));
|
| - assertNotNull(getActivity());
|
| - assertTrue(waitForActiveShellToBeDoneLoading());
|
| - assertEquals(UrlUtils.getTestFileUrl(url), getActivity().getUrl());
|
| - }
|
| -
|
| - /**
|
| - * 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 {
|
| - launchCronetSampleWithUrlAndCommandLineArgs(
|
| - UrlUtils.getTestFileUrl(url), commandLineArgs);
|
| - assertNotNull(getActivity());
|
| - assertTrue(waitForActiveShellToBeDoneLoading());
|
| - }
|
| -
|
| /**
|
| * Waits for the Active shell to finish loading. This times out after
|
| * WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT milliseconds and it shouldn't be
|
| @@ -112,7 +81,7 @@ public class CronetSampleTestBase extends
|
| */
|
| protected boolean waitForActiveShellToBeDoneLoading()
|
| throws InterruptedException {
|
| - final CronetSampleActivity activity = getActivity();
|
| + final CronetTestActivity activity = getActivity();
|
|
|
| // Wait for the Content Shell to be initialized.
|
| return CriteriaHelper.pollForCriteria(new Criteria() {
|
|
|