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

Side by Side Diff: chrome/browser/net/dns_probe_browsertest.cc

Issue 2567623003: Make ERR_ICANN_NAME_COLLISION work for async DNS resolver. (Closed)
Patch Set: address Matt's comments Created 4 years 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 | « no previous file | chrome/browser/net/dns_probe_runner_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <memory> 5 #include <memory>
6 #include <set> 6 #include <set>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 base::Closure delayed_request_destruction_callback_; 312 base::Closure delayed_request_destruction_callback_;
313 }; 313 };
314 314
315 class DnsProbeBrowserTestIOThreadHelper { 315 class DnsProbeBrowserTestIOThreadHelper {
316 public: 316 public:
317 DnsProbeBrowserTestIOThreadHelper(); 317 DnsProbeBrowserTestIOThreadHelper();
318 318
319 void SetUpOnIOThread(IOThread* io_thread); 319 void SetUpOnIOThread(IOThread* io_thread);
320 void CleanUpOnIOThreadAndDeleteHelper(); 320 void CleanUpOnIOThreadAndDeleteHelper();
321 321
322 void SetMockDnsClientRules(MockDnsClientRule::Result system_good_result, 322 void SetMockDnsClientRules(MockDnsClientRule::ResultType system_good_result,
323 MockDnsClientRule::Result public_good_result); 323 MockDnsClientRule::ResultType public_good_result);
324 void SetCorrectionServiceNetError(int net_error); 324 void SetCorrectionServiceNetError(int net_error);
325 void SetCorrectionServiceDelayRequests(bool delay_requests); 325 void SetCorrectionServiceDelayRequests(bool delay_requests);
326 void SetRequestDestructionCallback(const base::Closure& callback); 326 void SetRequestDestructionCallback(const base::Closure& callback);
327 void StartDelayedProbes(int expected_delayed_probe_count); 327 void StartDelayedProbes(int expected_delayed_probe_count);
328 328
329 private: 329 private:
330 IOThread* io_thread_; 330 IOThread* io_thread_;
331 DnsProbeService* original_dns_probe_service_; 331 DnsProbeService* original_dns_probe_service_;
332 DelayingDnsProbeService* delaying_dns_probe_service_; 332 DelayingDnsProbeService* delaying_dns_probe_service_;
333 BreakableCorrectionInterceptor* interceptor_; 333 BreakableCorrectionInterceptor* interceptor_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 std::unique_ptr<DnsProbeService> delaying_dns_probe_service( 375 std::unique_ptr<DnsProbeService> delaying_dns_probe_service(
376 globals->dns_probe_service.release()); 376 globals->dns_probe_service.release());
377 globals->dns_probe_service.reset(original_dns_probe_service_); 377 globals->dns_probe_service.reset(original_dns_probe_service_);
378 378
379 CHECK_EQ(delaying_dns_probe_service_, delaying_dns_probe_service.get()); 379 CHECK_EQ(delaying_dns_probe_service_, delaying_dns_probe_service.get());
380 380
381 delete this; 381 delete this;
382 } 382 }
383 383
384 void DnsProbeBrowserTestIOThreadHelper::SetMockDnsClientRules( 384 void DnsProbeBrowserTestIOThreadHelper::SetMockDnsClientRules(
385 MockDnsClientRule::Result system_result, 385 MockDnsClientRule::ResultType system_result,
386 MockDnsClientRule::Result public_result) { 386 MockDnsClientRule::ResultType public_result) {
387 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 387 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
388 388
389 DnsProbeService* service = io_thread_->globals()->dns_probe_service.get(); 389 DnsProbeService* service = io_thread_->globals()->dns_probe_service.get();
390 service->SetSystemClientForTesting( 390 service->SetSystemClientForTesting(
391 CreateMockDnsClientForProbes(system_result)); 391 CreateMockDnsClientForProbes(system_result));
392 service->SetPublicClientForTesting( 392 service->SetPublicClientForTesting(
393 CreateMockDnsClientForProbes(public_result)); 393 CreateMockDnsClientForProbes(public_result));
394 } 394 }
395 395
396 void DnsProbeBrowserTestIOThreadHelper::SetCorrectionServiceNetError( 396 void DnsProbeBrowserTestIOThreadHelper::SetCorrectionServiceNetError(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 void TearDownOnMainThread() override; 436 void TearDownOnMainThread() override;
437 437
438 protected: 438 protected:
439 // Sets the browser object that other methods apply to, and that has the 439 // Sets the browser object that other methods apply to, and that has the
440 // DnsProbeStatus messages of its currently active tab monitored. 440 // DnsProbeStatus messages of its currently active tab monitored.
441 void SetActiveBrowser(Browser* browser); 441 void SetActiveBrowser(Browser* browser);
442 442
443 void SetCorrectionServiceBroken(bool broken); 443 void SetCorrectionServiceBroken(bool broken);
444 void SetCorrectionServiceDelayRequests(bool delay_requests); 444 void SetCorrectionServiceDelayRequests(bool delay_requests);
445 void WaitForDelayedRequestDestruction(); 445 void WaitForDelayedRequestDestruction();
446 void SetMockDnsClientRules(MockDnsClientRule::Result system_result, 446 void SetMockDnsClientRules(MockDnsClientRule::ResultType system_result,
447 MockDnsClientRule::Result public_result); 447 MockDnsClientRule::ResultType public_result);
448 448
449 // These functions are often used to wait for two navigations because two 449 // These functions are often used to wait for two navigations because two
450 // pages are loaded when navigation corrections are enabled: a blank page, so 450 // pages are loaded when navigation corrections are enabled: a blank page, so
451 // the user stops seeing the previous page, and then the error page, either 451 // the user stops seeing the previous page, and then the error page, either
452 // with navigation corrections or without them (If the request failed). 452 // with navigation corrections or without them (If the request failed).
453 void NavigateToDnsError(int num_navigations); 453 void NavigateToDnsError(int num_navigations);
454 void NavigateToOtherError(int num_navigations); 454 void NavigateToOtherError(int num_navigations);
455 455
456 void StartDelayedProbes(int expected_delayed_probe_count); 456 void StartDelayedProbes(int expected_delayed_probe_count);
457 DnsProbeStatus WaitForSentStatus(); 457 DnsProbeStatus WaitForSentStatus();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 576 }
577 577
578 void DnsProbeBrowserTest::NavigateToOtherError(int num_navigations) { 578 void DnsProbeBrowserTest::NavigateToOtherError(int num_navigations) {
579 NavigateToURLBlockUntilNavigationsComplete( 579 NavigateToURLBlockUntilNavigationsComplete(
580 active_browser_, 580 active_browser_,
581 URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_REFUSED), 581 URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_REFUSED),
582 num_navigations); 582 num_navigations);
583 } 583 }
584 584
585 void DnsProbeBrowserTest::SetMockDnsClientRules( 585 void DnsProbeBrowserTest::SetMockDnsClientRules(
586 MockDnsClientRule::Result system_result, 586 MockDnsClientRule::ResultType system_result,
587 MockDnsClientRule::Result public_result) { 587 MockDnsClientRule::ResultType public_result) {
588 BrowserThread::PostTask( 588 BrowserThread::PostTask(
589 BrowserThread::IO, FROM_HERE, 589 BrowserThread::IO, FROM_HERE,
590 Bind(&DnsProbeBrowserTestIOThreadHelper::SetMockDnsClientRules, 590 Bind(&DnsProbeBrowserTestIOThreadHelper::SetMockDnsClientRules,
591 Unretained(helper_), 591 Unretained(helper_),
592 system_result, 592 system_result,
593 public_result)); 593 public_result));
594 } 594 }
595 595
596 void DnsProbeBrowserTest::StartDelayedProbes( 596 void DnsProbeBrowserTest::StartDelayedProbes(
597 int expected_delayed_probe_count) { 597 int expected_delayed_probe_count) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 984
985 EXPECT_EQ(error_page::DNS_PROBE_FINISHED_INCONCLUSIVE, 985 EXPECT_EQ(error_page::DNS_PROBE_FINISHED_INCONCLUSIVE,
986 WaitForSentStatus()); 986 WaitForSentStatus());
987 EXPECT_EQ(0, pending_status_count()); 987 EXPECT_EQ(0, pending_status_count());
988 ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED"); 988 ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
989 } 989 }
990 990
991 } // namespace 991 } // namespace
992 992
993 } // namespace chrome_browser_net 993 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/dns_probe_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698