OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.net; | 5 package org.chromium.net; |
6 | 6 |
7 import android.content.ComponentName; | 7 import android.content.ComponentName; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.net.Uri; | 9 import android.net.Uri; |
10 import android.test.ActivityInstrumentationTestCase2; | 10 import android.test.ActivityInstrumentationTestCase2; |
11 import android.text.TextUtils; | 11 import android.text.TextUtils; |
12 | 12 |
13 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 13 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
14 | 14 |
15 import org.chromium.base.PathUtils; | 15 import org.chromium.base.PathUtils; |
16 | 16 |
17 import org.chromium.net.urlconnection.CronetHttpURLConnectionTest; | |
18 | |
19 import java.io.File; | 17 import java.io.File; |
20 import java.lang.annotation.ElementType; | 18 import java.lang.annotation.ElementType; |
21 import java.lang.annotation.Retention; | 19 import java.lang.annotation.Retention; |
22 import java.lang.annotation.RetentionPolicy; | 20 import java.lang.annotation.RetentionPolicy; |
23 import java.lang.annotation.Target; | 21 import java.lang.annotation.Target; |
24 import java.lang.reflect.Method; | 22 import java.lang.reflect.Method; |
25 import java.net.URL; | 23 import java.net.URL; |
26 import java.util.concurrent.atomic.AtomicBoolean; | 24 import java.util.concurrent.atomic.AtomicBoolean; |
27 | 25 |
28 /** | 26 /** |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } catch (Throwable e) { | 137 } catch (Throwable e) { |
140 return false; | 138 return false; |
141 } | 139 } |
142 } | 140 } |
143 }, WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT, | 141 }, WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT, |
144 CriteriaHelper.DEFAULT_POLLING_INTERVAL); | 142 CriteriaHelper.DEFAULT_POLLING_INTERVAL); |
145 } | 143 } |
146 | 144 |
147 @Override | 145 @Override |
148 protected void runTest() throws Throwable { | 146 protected void runTest() throws Throwable { |
149 if (!getClass().getName().equals( | 147 if (!getClass().getPackage().getName().equals( |
150 CronetHttpURLConnectionTest.class.getName())) { | 148 "org.chromium.net.urlconnection")) { |
151 super.runTest(); | 149 super.runTest(); |
152 return; | 150 return; |
153 } | 151 } |
154 try { | 152 try { |
155 Method method = getClass().getMethod(getName(), (Class[]) null); | 153 Method method = getClass().getMethod(getName(), (Class[]) null); |
156 if (method.isAnnotationPresent(CompareDefaultWithCronet.class)) { | 154 if (method.isAnnotationPresent(CompareDefaultWithCronet.class)) { |
157 // Run with the default HttpURLConnection implementation first. | 155 // Run with the default HttpURLConnection implementation first. |
158 super.runTest(); | 156 super.runTest(); |
159 // Use Cronet's implementation, and run the same test. | 157 // Use Cronet's implementation, and run the same test. |
160 URL.setURLStreamHandlerFactory( | 158 URL.setURLStreamHandlerFactory( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 @Retention(RetentionPolicy.RUNTIME) | 202 @Retention(RetentionPolicy.RUNTIME) |
205 public @interface CompareDefaultWithCronet { | 203 public @interface CompareDefaultWithCronet { |
206 } | 204 } |
207 | 205 |
208 @Target(ElementType.METHOD) | 206 @Target(ElementType.METHOD) |
209 @Retention(RetentionPolicy.RUNTIME) | 207 @Retention(RetentionPolicy.RUNTIME) |
210 public @interface OnlyRunCronetHttpURLConnection { | 208 public @interface OnlyRunCronetHttpURLConnection { |
211 } | 209 } |
212 | 210 |
213 } | 211 } |
OLD | NEW |