Index: components/cronet/android/test/javatests/src/org/chromium/net/CronetTestBase.java |
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetTestBase.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetTestBase.java |
index 59aad24329b928e7d5d1bf57ad6db0a2357413fc..c4bdc039fc7495bdf2cf48fcc95e0336722dd04c 100644 |
--- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetTestBase.java |
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetTestBase.java |
@@ -98,32 +98,46 @@ public class CronetTestBase extends AndroidTestCase { |
@Override |
protected void runTest() throws Throwable { |
mTestingSystemHttpURLConnection = false; |
- if (!getClass().getPackage().getName().equals( |
- "org.chromium.net.urlconnection")) { |
- super.runTest(); |
- return; |
- } |
- try { |
- Method method = getClass().getMethod(getName(), (Class[]) null); |
- if (method.isAnnotationPresent(CompareDefaultWithCronet.class)) { |
- // Run with the default HttpURLConnection implementation first. |
- mTestingSystemHttpURLConnection = true; |
- super.runTest(); |
- // Use Cronet's implementation, and run the same test. |
- mTestingSystemHttpURLConnection = false; |
- URL.setURLStreamHandlerFactory(mCronetTestFramework.mStreamHandlerFactory); |
- super.runTest(); |
- } else if (method.isAnnotationPresent( |
- OnlyRunCronetHttpURLConnection.class)) { |
- // Run only with Cronet's implementation. |
- URL.setURLStreamHandlerFactory(mCronetTestFramework.mStreamHandlerFactory); |
- super.runTest(); |
- } else { |
- // For all other tests. |
+ String packageName = getClass().getPackage().getName(); |
+ if (packageName.equals("org.chromium.net.urlconnection")) { |
+ try { |
+ Method method = getClass().getMethod(getName(), (Class[]) null); |
+ if (method.isAnnotationPresent(CompareDefaultWithCronet.class)) { |
+ // Run with the default HttpURLConnection implementation first. |
+ mTestingSystemHttpURLConnection = true; |
+ super.runTest(); |
+ // Use Cronet's implementation, and run the same test. |
+ mTestingSystemHttpURLConnection = false; |
+ URL.setURLStreamHandlerFactory(mCronetTestFramework.mStreamHandlerFactory); |
+ super.runTest(); |
+ } else if (method.isAnnotationPresent(OnlyRunCronetHttpURLConnection.class)) { |
+ // Run only with Cronet's implementation. |
+ URL.setURLStreamHandlerFactory(mCronetTestFramework.mStreamHandlerFactory); |
+ super.runTest(); |
+ } else { |
+ // For all other tests. |
+ super.runTest(); |
+ } |
+ } catch (Throwable e) { |
+ throw new Throwable("CronetTestBase#runTest failed.", e); |
+ } |
+ } else if (packageName.equals("org.chromium.net")) { |
+ try { |
+ Method method = getClass().getMethod(getName(), (Class[]) null); |
super.runTest(); |
+ if (!method.isAnnotationPresent(OnlyRunNativeCronet.class)) { |
+ if (mCronetTestFramework != null) { |
+ mCronetTestFramework.mCronetEngine = |
+ new JavaCronetEngine(UserAgent.from(getContext())); |
+ } |
+ super.runTest(); |
+ } |
+ } catch (Throwable e) { |
+ throw new Throwable("CronetTestBase#runTest failed.", e); |
} |
- } catch (Throwable e) { |
- throw new Throwable("CronetTestBase#runTest failed.", e); |
+ return; |
+ } else { |
+ super.runTest(); |
} |
} |
@@ -162,4 +176,7 @@ public class CronetTestBase extends AndroidTestCase { |
public @interface OnlyRunCronetHttpURLConnection { |
} |
+ @Target(ElementType.METHOD) |
+ @Retention(RetentionPolicy.RUNTIME) |
+ public @interface OnlyRunNativeCronet {} |
} |