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

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

Issue 726013002: [Cronet] Hook up library loader, system proxy and network change notifier to async api. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync 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
Index: components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/ContextInitTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/ContextInitTest.java b/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/ContextInitTest.java
index cc2e934bfc693407e28b5ed9f685e6e760b6bbe6..221231be3581bf15d9b43ec5a76efbe0861a49f5 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/ContextInitTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/ContextInitTest.java
@@ -19,15 +19,13 @@ import java.util.HashMap;
public class ContextInitTest extends CronetTestBase {
// URL used for base tests.
private static final String URL = "http://127.0.0.1:8000";
+ // URL used for tests that return HTTP not found (404).
+ private static final String URL_404 = "http://127.0.0.1:8000/notfound404";
@SmallTest
@Feature({"Cronet"})
public void testInitFactoryAndStartRequest() {
CronetTestActivity activity = skipFactoryInitInOnCreate();
- // Make sure the activity was created as expected.
- assertNotNull(activity);
- // Make sure the factory is not created.
- assertNull(activity.mRequestFactory);
// Immediately make a request after initializing the factory.
HttpUrlRequestFactory factory = activity.initRequestFactory();
@@ -40,10 +38,6 @@ public class ContextInitTest extends CronetTestBase {
@Feature({"Cronet"})
public void testInitFactoryStartRequestAndCancel() {
CronetTestActivity activity = skipFactoryInitInOnCreate();
- // Make sure the activity was created as expected.
- assertNotNull(activity);
- // Make sure the factory is not created.
- assertNull(activity.mRequestFactory);
// Make a request and cancel it after initializing the factory.
HttpUrlRequestFactory factory = activity.initRequestFactory();
@@ -61,14 +55,10 @@ public class ContextInitTest extends CronetTestBase {
@Feature({"Cronet"})
public void testInitFactoryStartTwoRequests() throws Exception {
CronetTestActivity activity = skipFactoryInitInOnCreate();
- // Make sure the activity was created as expected.
- assertNotNull(activity);
- // Make sure the factory is not created.
- assertNull(activity.mRequestFactory);
// Make two request right after initializing the factory.
int[] statusCodes = {0, 0};
- String[] urls = {URL, "http://127.0.0.1:8000/test"};
+ String[] urls = {URL, URL_404};
HttpUrlRequestFactory factory = activity.initRequestFactory();
for (int i = 0; i < 2; i++) {
TestHttpUrlRequestListener listener = makeRequest(factory, urls[i]);
@@ -102,14 +92,9 @@ public class ContextInitTest extends CronetTestBase {
@Feature({"Cronet"})
public void testInitTwoFactoriesSimultaneously() throws Exception {
final CronetTestActivity activity = skipFactoryInitInOnCreate();
- // Make sure the activity was created as expected.
- assertNotNull(activity);
- // Make sure the factory is not created.
- assertNull(activity.mRequestFactory);
RequestThread thread1 = new RequestThread(activity, URL);
- RequestThread thread2 = new RequestThread(activity,
- "http://127.0.0.1:8000/notfound");
+ RequestThread thread2 = new RequestThread(activity, URL_404);
thread1.start();
thread2.start();
@@ -123,14 +108,9 @@ public class ContextInitTest extends CronetTestBase {
@Feature({"Cronet"})
public void testInitTwoFactoriesInSequence() throws Exception {
final CronetTestActivity activity = skipFactoryInitInOnCreate();
- // Make sure the activity was created as expected.
- assertNotNull(activity);
- // Make sure the factory is not created.
- assertNull(activity.mRequestFactory);
RequestThread thread1 = new RequestThread(activity, URL);
- RequestThread thread2 = new RequestThread(activity,
- "http://127.0.0.1:8000/notfound");
+ RequestThread thread2 = new RequestThread(activity, URL_404);
thread1.start();
thread1.join();
@@ -140,16 +120,6 @@ public class ContextInitTest extends CronetTestBase {
assertEquals(404, thread2.mListener.mHttpStatusCode);
}
- // Helper method to tell the activity to skip factory init in onCreate().
- private CronetTestActivity skipFactoryInitInOnCreate() {
- String[] commandLineArgs = {
- CronetTestActivity.SKIP_FACTORY_INIT_KEY, "skip" };
- CronetTestActivity activity =
- launchCronetTestAppWithUrlAndCommandLineArgs(null,
- commandLineArgs);
- return activity;
- }
-
// Helper function to make a request.
private TestHttpUrlRequestListener makeRequest(
HttpUrlRequestFactory factory, String url) {

Powered by Google App Engine
This is Rietveld 408576698