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 ed8f586d649cda9ae63575581352c43c7655eaba..cb0d8cf888e8ea696742726a9878d0570d7ebd79 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 |
@@ -75,30 +75,44 @@ public class CronetTestBase extends AndroidTestCase { |
@Override |
protected void runTest() throws Throwable { |
- 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. |
- super.runTest(); |
- // Use Cronet's implementation, and run the same test. |
- 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. |
+ super.runTest(); |
+ // Use Cronet's implementation, and run the same test. |
+ 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(); |
} |
} |
@@ -112,4 +126,7 @@ public class CronetTestBase extends AndroidTestCase { |
public @interface OnlyRunCronetHttpURLConnection { |
} |
+ @Target(ElementType.METHOD) |
+ @Retention(RetentionPolicy.RUNTIME) |
+ public @interface OnlyRunNativeCronet {} |
} |