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

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

Issue 725683002: [Cronet] Initial implementation of HttpURLConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix findbug warnings Created 6 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/cronet_test_apk/CronetTestBase.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java b/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
index eac0754468de0e7cf98454d0111e85fd51532e7f..94dd133429e691e5cd99ba9f4615186c1b61f5c7 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/CronetTestBase.java
@@ -12,6 +12,14 @@ import android.text.TextUtils;
import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
+import org.chromium.cronet_test_apk.urlconnection.CronetHttpURLConnectionTest;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Method;
+import java.net.URL;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -123,4 +131,46 @@ public class CronetTestBase extends
}, WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT,
CriteriaHelper.DEFAULT_POLLING_INTERVAL);
}
+
+ @Override
+ protected void runTest() throws Throwable {
+ if (!getClass().getName().equals(
+ CronetHttpURLConnectionTest.class.getName())) {
+ 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(
+ getActivity().mStreamHandlerFactory);
+ super.runTest();
+ } else if (method.isAnnotationPresent(
+ OnlyRunCronetHttpURLConnection.class)) {
+ // Run only with Cronet's implementation.
+ URL.setURLStreamHandlerFactory(
+ getActivity().mStreamHandlerFactory);
+ super.runTest();
+ } else {
+ // For all other tests.
+ super.runTest();
+ }
+ } catch (Throwable e) {
+ throw new Throwable("CronetTestBase#runTest failed.", e);
+ }
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface CompareDefaultWithCronet {
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface OnlyRunCronetHttpURLConnection {
+ }
+
}

Powered by Google App Engine
This is Rietveld 408576698