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

Side by Side Diff: chrome/browser/ssl/ssl_error_handler_unittest.cc

Issue 2448943004: Add experimental feature info to certificate reports (Closed)
Patch Set: battre comment Created 4 years, 1 month 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 | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | components/certificate_reporting/BUILD.gn » ('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 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 #include "chrome/browser/ssl/ssl_error_handler.h" 5 #include "chrome/browser/ssl/ssl_error_handler.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 tick_clock_(new base::SimpleTestTickClock), 196 tick_clock_(new base::SimpleTestTickClock),
197 test_server_(new net::EmbeddedTestServer) { 197 test_server_(new net::EmbeddedTestServer) {
198 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD); 198 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD);
199 network_time::NetworkTimeTracker::RegisterPrefs(pref_service_.registry()); 199 network_time::NetworkTimeTracker::RegisterPrefs(pref_service_.registry());
200 } 200 }
201 201
202 void SetUp() override { 202 void SetUp() override {
203 ChromeRenderViewHostTestHarness::SetUp(); 203 ChromeRenderViewHostTestHarness::SetUp();
204 204
205 field_trial_test()->SetNetworkQueriesWithVariationsService( 205 field_trial_test()->SetNetworkQueriesWithVariationsService(
206 false, 0.0, network_time::FieldTrialTest::FETCHES_IN_BACKGROUND_ONLY); 206 false, 0.0,
207 network_time::NetworkTimeTracker::FETCHES_IN_BACKGROUND_ONLY);
207 tracker_.reset(new network_time::NetworkTimeTracker( 208 tracker_.reset(new network_time::NetworkTimeTracker(
208 std::unique_ptr<base::Clock>(clock_), 209 std::unique_ptr<base::Clock>(clock_),
209 std::unique_ptr<base::TickClock>(tick_clock_), &pref_service_, 210 std::unique_ptr<base::TickClock>(tick_clock_), &pref_service_,
210 new net::TestURLRequestContextGetter( 211 new net::TestURLRequestContextGetter(
211 content::BrowserThread::GetTaskRunnerForThread( 212 content::BrowserThread::GetTaskRunnerForThread(
212 content::BrowserThread::IO)))); 213 content::BrowserThread::IO))));
213 214
214 // Do this to be sure that |is_null| returns false. 215 // Do this to be sure that |is_null| returns false.
215 clock_->Advance(base::TimeDelta::FromDays(111)); 216 clock_->Advance(base::TimeDelta::FromDays(111));
216 tick_clock_->Advance(base::TimeDelta::FromDays(222)); 217 tick_clock_->Advance(base::TimeDelta::FromDays(222));
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 EXPECT_EQ(network_time::NetworkTimeTracker::NETWORK_TIME_NO_SYNC_ATTEMPT, 445 EXPECT_EQ(network_time::NetworkTimeTracker::NETWORK_TIME_NO_SYNC_ATTEMPT,
445 tracker()->GetNetworkTime(&network_time, &uncertainty)); 446 tracker()->GetNetworkTime(&network_time, &uncertainty));
446 447
447 // Enable network time queries and handle the error. A bad clock interstitial 448 // Enable network time queries and handle the error. A bad clock interstitial
448 // should be shown. 449 // should be shown.
449 test_server()->RegisterRequestHandler( 450 test_server()->RegisterRequestHandler(
450 base::Bind(&network_time::GoodTimeResponseHandler)); 451 base::Bind(&network_time::GoodTimeResponseHandler));
451 EXPECT_TRUE(test_server()->Start()); 452 EXPECT_TRUE(test_server()->Start());
452 tracker()->SetTimeServerURLForTesting(test_server()->GetURL("/")); 453 tracker()->SetTimeServerURLForTesting(test_server()->GetURL("/"));
453 field_trial_test()->SetNetworkQueriesWithVariationsService( 454 field_trial_test()->SetNetworkQueriesWithVariationsService(
454 true, 0.0, network_time::FieldTrialTest::FETCHES_ON_DEMAND_ONLY); 455 true, 0.0, network_time::NetworkTimeTracker::FETCHES_ON_DEMAND_ONLY);
455 error_handler()->StartHandlingError(); 456 error_handler()->StartHandlingError();
456 457
457 EXPECT_TRUE(error_handler()->IsTimerRunning()); 458 EXPECT_TRUE(error_handler()->IsTimerRunning());
458 tracker()->WaitForFetchForTesting(123123123); 459 tracker()->WaitForFetchForTesting(123123123);
459 base::RunLoop().RunUntilIdle(); 460 base::RunLoop().RunUntilIdle();
460 461
461 EXPECT_TRUE(error_handler()->bad_clock_interstitial_shown()); 462 EXPECT_TRUE(error_handler()->bad_clock_interstitial_shown());
462 EXPECT_FALSE(error_handler()->IsTimerRunning()); 463 EXPECT_FALSE(error_handler()->IsTimerRunning());
463 } 464 }
464 465
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 500
500 // Enable network time queries and handle the error. Because the 501 // Enable network time queries and handle the error. Because the
501 // network time cannot be determined before the timer elapses, an SSL 502 // network time cannot be determined before the timer elapses, an SSL
502 // interstitial should be shown. 503 // interstitial should be shown.
503 base::RunLoop wait_for_time_query_loop; 504 base::RunLoop wait_for_time_query_loop;
504 test_server()->RegisterRequestHandler( 505 test_server()->RegisterRequestHandler(
505 base::Bind(&WaitForRequest, wait_for_time_query_loop.QuitClosure())); 506 base::Bind(&WaitForRequest, wait_for_time_query_loop.QuitClosure()));
506 EXPECT_TRUE(test_server()->Start()); 507 EXPECT_TRUE(test_server()->Start());
507 tracker()->SetTimeServerURLForTesting(test_server()->GetURL("/")); 508 tracker()->SetTimeServerURLForTesting(test_server()->GetURL("/"));
508 field_trial_test()->SetNetworkQueriesWithVariationsService( 509 field_trial_test()->SetNetworkQueriesWithVariationsService(
509 true, 0.0, network_time::FieldTrialTest::FETCHES_ON_DEMAND_ONLY); 510 true, 0.0, network_time::NetworkTimeTracker::FETCHES_ON_DEMAND_ONLY);
510 error_handler()->StartHandlingError(); 511 error_handler()->StartHandlingError();
511 EXPECT_TRUE(error_handler()->IsTimerRunning()); 512 EXPECT_TRUE(error_handler()->IsTimerRunning());
512 wait_for_time_query_loop.Run(); 513 wait_for_time_query_loop.Run();
513 base::RunLoop().RunUntilIdle(); 514 base::RunLoop().RunUntilIdle();
514 515
515 EXPECT_FALSE(error_handler()->bad_clock_interstitial_shown()); 516 EXPECT_FALSE(error_handler()->bad_clock_interstitial_shown());
516 EXPECT_TRUE(error_handler()->ssl_interstitial_shown()); 517 EXPECT_TRUE(error_handler()->ssl_interstitial_shown());
517 EXPECT_FALSE(error_handler()->IsTimerRunning()); 518 EXPECT_FALSE(error_handler()->IsTimerRunning());
518 519
519 // Clear the error handler to test that, when the request completes, 520 // Clear the error handler to test that, when the request completes,
520 // it doesn't try to call a callback on a deleted SSLErrorHandler. 521 // it doesn't try to call a callback on a deleted SSLErrorHandler.
521 ClearErrorHandler(); 522 ClearErrorHandler();
522 523
523 // Shut down the server to cancel the pending request. 524 // Shut down the server to cancel the pending request.
524 ASSERT_TRUE(test_server()->ShutdownAndWaitUntilComplete()); 525 ASSERT_TRUE(test_server()->ShutdownAndWaitUntilComplete());
525 } 526 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | components/certificate_reporting/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698