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.Context; | 7 import android.content.Context; |
8 import android.content.ContextWrapper; | 8 import android.content.ContextWrapper; |
9 import android.os.ConditionVariable; | 9 import android.os.ConditionVariable; |
10 import android.os.Handler; | 10 import android.os.Handler; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 config.setLibraryName("cronet_tests"); | 132 config.setLibraryName("cronet_tests"); |
133 mActivity.mUrlRequestContext = | 133 mActivity.mUrlRequestContext = |
134 mActivity.mUrlRequestContext.createContext( | 134 mActivity.mUrlRequestContext.createContext( |
135 getInstrumentation().getTargetContext(), config); | 135 getInstrumentation().getTargetContext(), config); |
136 TestUrlRequestListener listener = new TestUrlRequestListener(); | 136 TestUrlRequestListener listener = new TestUrlRequestListener(); |
137 | 137 |
138 // Construct and start a request that can only be returned by the test | 138 // Construct and start a request that can only be returned by the test |
139 // server. This request will fail if the configuration logic for the | 139 // server. This request will fail if the configuration logic for the |
140 // Data Reduction Proxy is not used. | 140 // Data Reduction Proxy is not used. |
141 UrlRequest urlRequest = mActivity.mUrlRequestContext.createRequest( | 141 UrlRequest urlRequest = mActivity.mUrlRequestContext.createRequest( |
142 "http://google.com/datareductionproxysuccess.txt", | 142 "http://DomainThatDoesnt.Resolve/datareductionproxysuccess.txt", |
143 listener, listener.getExecutor()); | 143 listener, listener.getExecutor()); |
144 urlRequest.start(); | 144 urlRequest.start(); |
145 listener.blockForDone(); | 145 listener.blockForDone(); |
146 | 146 |
147 // Verify that the request is successful and that the Data Reduction | 147 // Verify that the request is successful and that the Data Reduction |
148 // Proxy logic configured to use the test server as its proxy. | 148 // Proxy logic configured to use the test server as its proxy. |
149 assertEquals(200, listener.mResponseInfo.getHttpStatusCode()); | 149 assertEquals(200, listener.mResponseInfo.getHttpStatusCode()); |
150 assertEquals(serverHostPort, listener.mResponseInfo.getProxyServer()); | 150 assertEquals(serverHostPort, listener.mResponseInfo.getProxyServer()); |
151 assertEquals("http://www.google.com/datareductionproxysuccess.txt", | 151 assertEquals( |
| 152 "http://DomainThatDoesnt.Resolve/datareductionproxysuccess.txt", |
152 listener.mResponseInfo.getUrl()); | 153 listener.mResponseInfo.getUrl()); |
153 } | 154 } |
154 | 155 |
155 @SmallTest | 156 @SmallTest |
156 @Feature({"Cronet"}) | 157 @Feature({"Cronet"}) |
157 public void testShutdown() throws Exception { | 158 public void testShutdown() throws Exception { |
158 mActivity = launchCronetTestApp(); | 159 mActivity = launchCronetTestApp(); |
159 TestUrlRequestListener listener = new ShutdownTestUrlRequestListener(); | 160 TestUrlRequestListener listener = new ShutdownTestUrlRequestListener(); |
160 // Block listener when response starts to verify that shutdown fails | 161 // Block listener when response starts to verify that shutdown fails |
161 // if there are active requests. | 162 // if there are active requests. |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 new CronetUrlRequestContext(mActivity, mActivity.getContextConfi
g()); | 670 new CronetUrlRequestContext(mActivity, mActivity.getContextConfi
g()); |
670 CronetUrlRequestContext secondContext = new CronetUrlRequestContext( | 671 CronetUrlRequestContext secondContext = new CronetUrlRequestContext( |
671 mActivity.getApplicationContext(), mActivity.getContextConfig())
; | 672 mActivity.getApplicationContext(), mActivity.getContextConfig())
; |
672 CronetUrlRequestContext thirdContext = new CronetUrlRequestContext( | 673 CronetUrlRequestContext thirdContext = new CronetUrlRequestContext( |
673 new ContextWrapper(mActivity), mActivity.getContextConfig()); | 674 new ContextWrapper(mActivity), mActivity.getContextConfig()); |
674 firstContext.shutdown(); | 675 firstContext.shutdown(); |
675 secondContext.shutdown(); | 676 secondContext.shutdown(); |
676 thirdContext.shutdown(); | 677 thirdContext.shutdown(); |
677 } | 678 } |
678 } | 679 } |
OLD | NEW |