Chromium Code Reviews| 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.
|
| + } |
| +} |