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

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

Issue 2361203002: Remove calls to MessageLoop::Run/RunUntilIdle. (Closed)
Patch Set: CR jochen #6 Created 4 years, 2 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
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 #include "ios/web/net/request_tracker_impl.h" 5 #include "ios/web/net/request_tracker_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 receiver_.get()->value_ = 0.0f; 227 receiver_.get()->value_ = 0.0f;
228 receiver_.get()->max_ = 0.0f; 228 receiver_.get()->max_ = 0.0f;
229 tracker_->StartPageLoad(url, nil); 229 tracker_->StartPageLoad(url, nil);
230 } 230 }
231 231
232 void EndPage(NSString* tab_id, const GURL& url) { 232 void EndPage(NSString* tab_id, const GURL& url) {
233 DCHECK_CURRENTLY_ON(web::WebThread::UI); 233 DCHECK_CURRENTLY_ON(web::WebThread::UI);
234 tracker_->FinishPageLoad(url, false); 234 tracker_->FinishPageLoad(url, false);
235 receiver_.get()->value_ = 0.0f; 235 receiver_.get()->value_ = 0.0f;
236 receiver_.get()->max_ = 0.0f; 236 receiver_.get()->max_ = 0.0f;
237 loop_.RunUntilIdle(); 237 base::RunLoop().RunUntilIdle();
238 } 238 }
239 239
240 net::TestJobInterceptor* AddInterceptorToRequest(size_t i) { 240 net::TestJobInterceptor* AddInterceptorToRequest(size_t i) {
241 // |interceptor| will be deleted from |job_factory_|'s destructor. 241 // |interceptor| will be deleted from |job_factory_|'s destructor.
242 net::TestJobInterceptor* protocol_handler = new net::TestJobInterceptor(); 242 net::TestJobInterceptor* protocol_handler = new net::TestJobInterceptor();
243 job_factory_.SetProtocolHandler("http", base::WrapUnique(protocol_handler)); 243 job_factory_.SetProtocolHandler("http", base::WrapUnique(protocol_handler));
244 contexts_[i]->set_job_factory(&job_factory_); 244 contexts_[i]->set_job_factory(&job_factory_);
245 return protocol_handler; 245 return protocol_handler;
246 } 246 }
247 247
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 const_cast<net::HttpResponseInfo&>(request->response_info()).headers = 443 const_cast<net::HttpResponseInfo&>(request->response_info()).headers =
444 new net::HttpResponseHeaders(headers); 444 new net::HttpResponseHeaders(headers);
445 std::unique_ptr<net::URLRequestTestJob> job(new net::URLRequestTestJob( 445 std::unique_ptr<net::URLRequestTestJob> job(new net::URLRequestTestJob(
446 request, request->context()->network_delegate(), headers, "", false)); 446 request, request->context()->network_delegate(), headers, "", false));
447 AddInterceptorToRequest(0)->set_main_intercept_job(std::move(job)); 447 AddInterceptorToRequest(0)->set_main_intercept_job(std::move(job));
448 request->Start(); 448 request->Start();
449 449
450 tracker_->StartRequest(request); 450 tracker_->StartRequest(request);
451 tracker_->CaptureHeaders(request); 451 tracker_->CaptureHeaders(request);
452 tracker_->StopRequest(request); 452 tracker_->StopRequest(request);
453 loop_.RunUntilIdle(); 453 base::RunLoop().RunUntilIdle();
454 EXPECT_TRUE([receiver_ headers]->HasHeaderValue("X-Auto-Login", 454 EXPECT_TRUE([receiver_ headers]->HasHeaderValue("X-Auto-Login",
455 "Hello World")); 455 "Hello World"));
456 std::string mimeType; 456 std::string mimeType;
457 EXPECT_TRUE([receiver_ headers]->GetMimeType(&mimeType)); 457 EXPECT_TRUE([receiver_ headers]->GetMimeType(&mimeType));
458 EXPECT_EQ("multipart/mixed", mimeType); 458 EXPECT_EQ("multipart/mixed", mimeType);
459 EXPECT_TRUE([receiver_ headers]->HasHeaderValue( 459 EXPECT_TRUE([receiver_ headers]->HasHeaderValue(
460 "Content-Disposition", "attachment; filename=\"name.pdf\"")); 460 "Content-Disposition", "attachment; filename=\"name.pdf\""));
461 } 461 }
462 462
463 // Do-nothing mock CertificatePolicyCache. Allows all certs for all hosts. 463 // Do-nothing mock CertificatePolicyCache. Allows all certs for all hosts.
(...skipping 40 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 | « components/previews/core/previews_ui_service_unittest.cc ('k') | ios/web/public/test/web_test_with_web_state.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698