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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/CronetTestBase.java

Issue 1492583002: Add HttpUrlConnection backed implementation of CronetEngine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 5 years 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/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 {}
}

Powered by Google App Engine
This is Rietveld 408576698