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

Side by Side Diff: ios/web/net/request_tracker_impl_unittest.mm

Issue 2617243002: Remove ScopedVector from ios/. (Closed)
Patch Set: rebase Created 3 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « ios/web/net/request_tracker_impl.mm ('k') | ios/web/public/webui/web_ui_ios.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #import "ios/web/net/request_tracker_impl.h" 5 #import "ios/web/net/request_tracker_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
10 #include <vector>
11
9 #include "base/logging.h" 12 #include "base/logging.h"
10 #import "base/mac/scoped_nsobject.h" 13 #import "base/mac/scoped_nsobject.h"
11 #include "base/macros.h" 14 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 17 #include "base/run_loop.h"
16 #include "base/strings/sys_string_conversions.h" 18 #include "base/strings/sys_string_conversions.h"
17 #include "ios/web/public/cert_policy.h" 19 #include "ios/web/public/cert_policy.h"
18 #include "ios/web/public/certificate_policy_cache.h" 20 #include "ios/web/public/certificate_policy_cache.h"
19 #include "ios/web/public/ssl_status.h" 21 #include "ios/web/public/ssl_status.h"
20 #include "ios/web/public/test/fakes/test_browser_state.h" 22 #include "ios/web/public/test/fakes/test_browser_state.h"
21 #include "ios/web/public/test/test_web_thread.h" 23 #include "ios/web/public/test/test_web_thread.h"
22 #include "net/cert/x509_certificate.h" 24 #include "net/cert/x509_certificate.h"
23 #include "net/http/http_response_headers.h" 25 #include "net/http/http_response_headers.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 167 }
166 168
167 base::MessageLoop loop_; 169 base::MessageLoop loop_;
168 web::TestWebThread ui_thread_; 170 web::TestWebThread ui_thread_;
169 web::TestWebThread io_thread_; 171 web::TestWebThread io_thread_;
170 172
171 base::scoped_nsobject<RequestTrackerNotificationReceiverTest> receiver_; 173 base::scoped_nsobject<RequestTrackerNotificationReceiverTest> receiver_;
172 scoped_refptr<web::RequestTrackerImpl> tracker_; 174 scoped_refptr<web::RequestTrackerImpl> tracker_;
173 base::scoped_nsobject<NSString> request_group_id_; 175 base::scoped_nsobject<NSString> request_group_id_;
174 web::TestBrowserState browser_state_; 176 web::TestBrowserState browser_state_;
175 ScopedVector<net::URLRequestContext> contexts_; 177 std::vector<std::unique_ptr<net::URLRequestContext>> contexts_;
176 ScopedVector<net::URLRequest> requests_; 178 std::vector<std::unique_ptr<net::URLRequest>> requests_;
177 net::URLRequestJobFactoryImpl job_factory_; 179 net::URLRequestJobFactoryImpl job_factory_;
178 180
179 GURL GetURL(size_t i) { 181 GURL GetURL(size_t i) {
180 std::stringstream ss; 182 std::stringstream ss;
181 ss << "http://www/"; 183 ss << "http://www/";
182 ss << i; 184 ss << i;
183 return GURL(ss.str()); 185 return GURL(ss.str());
184 } 186 }
185 187
186 GURL GetSecureURL(size_t i) { 188 GURL GetSecureURL(size_t i) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 249
248 private: 250 private:
249 net::URLRequest* GetInternalRequest(size_t i, bool secure) { 251 net::URLRequest* GetInternalRequest(size_t i, bool secure) {
250 GURL url; 252 GURL url;
251 if (secure) 253 if (secure)
252 url = GetSecureURL(requests_.size()); 254 url = GetSecureURL(requests_.size());
253 else 255 else
254 url = GetURL(requests_.size()); 256 url = GetURL(requests_.size());
255 257
256 while (i >= requests_.size()) { 258 while (i >= requests_.size()) {
257 contexts_.push_back(new net::URLRequestContext()); 259 contexts_.push_back(base::MakeUnique<net::URLRequestContext>());
258 requests_.push_back( 260 requests_.push_back(contexts_[i]->CreateRequest(
259 contexts_[i] 261 url, net::DEFAULT_PRIORITY, &request_delegate_));
260 ->CreateRequest(url, net::DEFAULT_PRIORITY, &request_delegate_)
261 .release());
262 262
263 if (secure) { 263 if (secure) {
264 // Put a valid SSLInfo inside 264 // Put a valid SSLInfo inside
265 net::HttpResponseInfo* response = 265 net::HttpResponseInfo* response =
266 const_cast<net::HttpResponseInfo*>(&requests_[i]->response_info()); 266 const_cast<net::HttpResponseInfo*>(&requests_[i]->response_info());
267 267
268 response->ssl_info.cert = net::ImportCertFromFile( 268 response->ssl_info.cert = net::ImportCertFromFile(
269 net::GetTestCertsDirectory(), "ok_cert.pem"); 269 net::GetTestCertsDirectory(), "ok_cert.pem");
270 response->ssl_info.cert_status = 0; // No errors. 270 response->ssl_info.cert_status = 0; // No errors.
271 response->ssl_info.security_bits = 128; 271 response->ssl_info.security_bits = 128;
272 272
273 EXPECT_TRUE(requests_[i]->ssl_info().is_valid()); 273 EXPECT_TRUE(requests_[i]->ssl_info().is_valid());
274 } 274 }
275 } 275 }
276 EXPECT_TRUE(!secure == !requests_[i]->url().SchemeIsCryptographic()); 276 EXPECT_TRUE(!secure == !requests_[i]->url().SchemeIsCryptographic());
277 return requests_[i]; 277 return requests_[i].get();
278 } 278 }
279 279
280 DummyURLRequestDelegate request_delegate_; 280 DummyURLRequestDelegate request_delegate_;
281 281
282 DISALLOW_COPY_AND_ASSIGN(RequestTrackerTest); 282 DISALLOW_COPY_AND_ASSIGN(RequestTrackerTest);
283 }; 283 };
284 284
285 TEST_F(RequestTrackerTest, OnePage) { 285 TEST_F(RequestTrackerTest, OnePage) {
286 // Start a request. 286 // Start a request.
287 tracker_->StartRequest(GetRequest(0)); 287 tracker_->StartRequest(GetRequest(0));
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 base::Bind(&TwoStartsSSLCallback, 504 base::Bind(&TwoStartsSSLCallback,
505 &request_0_called)); 505 &request_0_called));
506 tracker_->OnSSLCertificateError(GetSecureRequest(1), ssl_info, true, 506 tracker_->OnSSLCertificateError(GetSecureRequest(1), ssl_info, true,
507 base::Bind(&TwoStartsSSLCallback, 507 base::Bind(&TwoStartsSSLCallback,
508 &request_1_called)); 508 &request_1_called));
509 EXPECT_TRUE(request_0_called); 509 EXPECT_TRUE(request_0_called);
510 EXPECT_TRUE(request_1_called); 510 EXPECT_TRUE(request_1_called);
511 } 511 }
512 512
513 } // namespace 513 } // namespace
OLDNEW
« no previous file with comments | « ios/web/net/request_tracker_impl.mm ('k') | ios/web/public/webui/web_ui_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698