| Index: components/cronet/android/test/javatests/src/org/chromium/net/ContextInitTest.java
|
| diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/ContextInitTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/ContextInitTest.java
|
| index c8e108f01f69635f728e4380fc28541279540645..56bec51dc182b05af89909792c6e5de6a9929533 100644
|
| --- a/components/cronet/android/test/javatests/src/org/chromium/net/ContextInitTest.java
|
| +++ b/components/cronet/android/test/javatests/src/org/chromium/net/ContextInitTest.java
|
| @@ -24,10 +24,10 @@ public class ContextInitTest extends CronetTestBase {
|
| @SmallTest
|
| @Feature({"Cronet"})
|
| public void testInitFactoryAndStartRequest() {
|
| - CronetTestActivity activity = launchCronetTestAppAndSkipFactoryInit();
|
| + CronetTestFramework testFramework = startCronetTestFrameworkAndSkipFactoryInit();
|
|
|
| // Immediately make a request after initializing the factory.
|
| - HttpUrlRequestFactory factory = activity.initRequestFactory();
|
| + HttpUrlRequestFactory factory = testFramework.initRequestFactory();
|
| TestHttpUrlRequestListener listener = makeRequest(factory, URL);
|
| listener.blockForComplete();
|
| assertEquals(200, listener.mHttpStatusCode);
|
| @@ -36,10 +36,10 @@ public class ContextInitTest extends CronetTestBase {
|
| @SmallTest
|
| @Feature({"Cronet"})
|
| public void testInitFactoryStartRequestAndCancel() {
|
| - CronetTestActivity activity = launchCronetTestAppAndSkipFactoryInit();
|
| + CronetTestFramework testFramework = startCronetTestFrameworkAndSkipFactoryInit();
|
|
|
| // Make a request and cancel it after initializing the factory.
|
| - HttpUrlRequestFactory factory = activity.initRequestFactory();
|
| + HttpUrlRequestFactory factory = testFramework.initRequestFactory();
|
| HashMap<String, String> headers = new HashMap<String, String>();
|
| TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
|
| HttpUrlRequest request = factory.createRequest(
|
| @@ -53,12 +53,12 @@ public class ContextInitTest extends CronetTestBase {
|
| @SmallTest
|
| @Feature({"Cronet"})
|
| public void testInitFactoryStartTwoRequests() throws Exception {
|
| - CronetTestActivity activity = launchCronetTestAppAndSkipFactoryInit();
|
| + CronetTestFramework testFramework = startCronetTestFrameworkAndSkipFactoryInit();
|
|
|
| // Make two request right after initializing the factory.
|
| int[] statusCodes = {0, 0};
|
| String[] urls = {URL, URL_404};
|
| - HttpUrlRequestFactory factory = activity.initRequestFactory();
|
| + HttpUrlRequestFactory factory = testFramework.initRequestFactory();
|
| for (int i = 0; i < 2; i++) {
|
| TestHttpUrlRequestListener listener = makeRequest(factory, urls[i]);
|
| listener.blockForComplete();
|
| @@ -71,17 +71,17 @@ public class ContextInitTest extends CronetTestBase {
|
| class RequestThread extends Thread {
|
| public TestHttpUrlRequestListener mListener;
|
|
|
| - final CronetTestActivity mActivity;
|
| + final CronetTestFramework mTestFramework;
|
| final String mUrl;
|
|
|
| - public RequestThread(CronetTestActivity activity, String url) {
|
| - mActivity = activity;
|
| + public RequestThread(CronetTestFramework testFramework, String url) {
|
| + mTestFramework = testFramework;
|
| mUrl = url;
|
| }
|
|
|
| @Override
|
| public void run() {
|
| - HttpUrlRequestFactory factory = mActivity.initRequestFactory();
|
| + HttpUrlRequestFactory factory = mTestFramework.initRequestFactory();
|
| mListener = makeRequest(factory, mUrl);
|
| mListener.blockForComplete();
|
| }
|
| @@ -90,10 +90,10 @@ public class ContextInitTest extends CronetTestBase {
|
| @SmallTest
|
| @Feature({"Cronet"})
|
| public void testInitTwoFactoriesSimultaneously() throws Exception {
|
| - final CronetTestActivity activity = launchCronetTestAppAndSkipFactoryInit();
|
| + final CronetTestFramework testFramework = startCronetTestFrameworkAndSkipFactoryInit();
|
|
|
| - RequestThread thread1 = new RequestThread(activity, URL);
|
| - RequestThread thread2 = new RequestThread(activity, URL_404);
|
| + RequestThread thread1 = new RequestThread(testFramework, URL);
|
| + RequestThread thread2 = new RequestThread(testFramework, URL_404);
|
|
|
| thread1.start();
|
| thread2.start();
|
| @@ -106,10 +106,10 @@ public class ContextInitTest extends CronetTestBase {
|
| @SmallTest
|
| @Feature({"Cronet"})
|
| public void testInitTwoFactoriesInSequence() throws Exception {
|
| - final CronetTestActivity activity = launchCronetTestAppAndSkipFactoryInit();
|
| + final CronetTestFramework testFramework = startCronetTestFrameworkAndSkipFactoryInit();
|
|
|
| - RequestThread thread1 = new RequestThread(activity, URL);
|
| - RequestThread thread2 = new RequestThread(activity, URL_404);
|
| + RequestThread thread1 = new RequestThread(testFramework, URL);
|
| + RequestThread thread2 = new RequestThread(testFramework, URL_404);
|
|
|
| thread1.start();
|
| thread1.join();
|
| @@ -136,13 +136,13 @@ public class ContextInitTest extends CronetTestBase {
|
| // Test that concurrently instantiating ChromiumUrlRequestContext's upon
|
| // various different versions of the same Android Context does not cause
|
| // crashes like crbug.com/453845
|
| - final CronetTestActivity activity = launchCronetTestApp();
|
| - HttpUrlRequestFactory firstFactory =
|
| - HttpUrlRequestFactory.createFactory(activity, activity.getCronetEngineBuilder());
|
| + final CronetTestFramework testFramework = startCronetTestFramework();
|
| + HttpUrlRequestFactory firstFactory = HttpUrlRequestFactory.createFactory(
|
| + getContext(), testFramework.getCronetEngineBuilder());
|
| HttpUrlRequestFactory secondFactory = HttpUrlRequestFactory.createFactory(
|
| - activity.getApplicationContext(), activity.getCronetEngineBuilder());
|
| + getContext().getApplicationContext(), testFramework.getCronetEngineBuilder());
|
| HttpUrlRequestFactory thirdFactory = HttpUrlRequestFactory.createFactory(
|
| - new ContextWrapper(activity), activity.getCronetEngineBuilder());
|
| + new ContextWrapper(getContext()), testFramework.getCronetEngineBuilder());
|
| // Meager attempt to extend lifetimes to ensure they're concurrently
|
| // alive.
|
| firstFactory.getName();
|
|
|