Chromium Code Reviews| Index: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java |
| diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java |
| index b74554520b83b940556ad479154f3a2af83a136c..94b173868a8ee88941c05d3376a0116713a02ef0 100644 |
| --- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java |
| +++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java |
| @@ -122,6 +122,45 @@ public class CronetUrlRequestContextTest extends CronetTestBase { |
| @SmallTest |
| @Feature({"Cronet"}) |
| + public void testDataReductionProxyEnabled() throws Exception { |
| + UrlRequestContextConfig config = new UrlRequestContextConfig(); |
| + config.enableDataReductionProxy(false, "test-key"); |
| + config.setLibraryName("cronet_tests"); |
| + String[] commandLineArgs = { |
| + CronetTestActivity.CONFIG_KEY, config.toString() |
| + }; |
| + mActivity = launchCronetTestAppWithUrlAndCommandLineArgs(null, |
| + commandLineArgs); |
| + assertTrue(NativeTestServer.startNativeTestServer( |
| + getInstrumentation().getTargetContext())); |
| + |
| + String serverHostPort = "127.0.0.1:" + NativeTestServer.getPort(); |
|
mmenke
2015/04/01 16:48:53
Can we just use getHostPortPair instead of getPort
bengr
2015/04/24 02:30:43
NativeTestServer doesn't hold onto the host.
mmenke
2015/04/24 15:54:59
It does. That's how the other NativeTestServer me
bengr
2015/04/24 21:13:50
Done.
|
| + // Shutdown the original context and create a new context that uses the |
| + // NativeTestServer as the data reduction proxy. |
| + mActivity.mUrlRequestContext.shutdown(); |
|
mmenke
2015/04/01 16:48:53
Why can't we just start the test server first, and
bengr
2015/04/24 02:30:43
This was a chicken and egg problem. The server nee
mmenke
2015/04/24 15:54:59
See skipFactoryInitInOnCreate.
|
| + UrlRequestContextConfig config2 = new UrlRequestContextConfig(); |
| + config2.enableDataReductionProxy(true, "test-key"); |
| + config2.setDataReductionProxyOptions( |
| + serverHostPort + "," |
| + + "unused.net:9999" + "," |
| + + NativeTestServer.getFileURL("/secureproxychecksuccess.txt")); |
| + config2.setLibraryName("cronet_tests"); |
| + mActivity.mUrlRequestContext = |
| + mActivity.mUrlRequestContext.createContext( |
| + getInstrumentation().getTargetContext(), config2); |
| + TestUrlRequestListener listener = new TestUrlRequestListener(); |
| + UrlRequest urlRequest = mActivity.mUrlRequestContext.createRequest( |
| + "http://google.com/datareductionproxysuccess.txt", |
| + listener, listener.getExecutor()); |
| + |
| + urlRequest.start(); |
| + listener.blockForDone(); |
| + assertEquals(200, listener.mResponseInfo.getHttpStatusCode()); |
| + assertEquals(serverHostPort, listener.mResponseInfo.getProxyServer()); |
|
mmenke
2015/04/01 16:48:53
Should we check that the other parameters work as
mmenke
2015/04/01 16:48:53
Check the URL as well? (http://google.com/datared
bengr
2015/04/24 02:30:43
What other parameters? The race doesn't matter. Th
bengr
2015/04/24 02:30:43
Done.
mmenke
2015/04/24 15:54:59
Other parameters -> The second proxy and the proxy
bengr
2015/04/24 21:13:50
These aren't exposed easily. setDataReductionProxy
|
| + } |
| + |
| + @SmallTest |
| + @Feature({"Cronet"}) |
| public void testShutdown() throws Exception { |
| mActivity = launchCronetTestApp(); |
| TestUrlRequestListener listener = new ShutdownTestUrlRequestListener(); |