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

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

Issue 2486313002: Correct net::EmbeddedTestServer usage in some SSL related tests. (Closed)
Patch Set: 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 | « no previous file | components/ssl_errors/error_classification_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 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } 439 }
440 440
441 TEST_F(SSLErrorHandlerDateInvalidTest, TimeQueryStarted) { 441 TEST_F(SSLErrorHandlerDateInvalidTest, TimeQueryStarted) {
442 base::Time network_time; 442 base::Time network_time;
443 base::TimeDelta uncertainty; 443 base::TimeDelta uncertainty;
444 EXPECT_EQ(network_time::NetworkTimeTracker::NETWORK_TIME_NO_SYNC_ATTEMPT, 444 EXPECT_EQ(network_time::NetworkTimeTracker::NETWORK_TIME_NO_SYNC_ATTEMPT,
445 tracker()->GetNetworkTime(&network_time, &uncertainty)); 445 tracker()->GetNetworkTime(&network_time, &uncertainty));
446 446
447 // Enable network time queries and handle the error. A bad clock interstitial 447 // Enable network time queries and handle the error. A bad clock interstitial
448 // should be shown. 448 // should be shown.
449 EXPECT_TRUE(test_server()->Start());
450 test_server()->RegisterRequestHandler( 449 test_server()->RegisterRequestHandler(
451 base::Bind(&network_time::GoodTimeResponseHandler)); 450 base::Bind(&network_time::GoodTimeResponseHandler));
451 EXPECT_TRUE(test_server()->Start());
452 tracker()->SetTimeServerURLForTesting(test_server()->GetURL("/")); 452 tracker()->SetTimeServerURLForTesting(test_server()->GetURL("/"));
453 field_trial_test()->SetNetworkQueriesWithVariationsService( 453 field_trial_test()->SetNetworkQueriesWithVariationsService(
454 true, 0.0, network_time::FieldTrialTest::FETCHES_ON_DEMAND_ONLY); 454 true, 0.0, network_time::FieldTrialTest::FETCHES_ON_DEMAND_ONLY);
455 error_handler()->StartHandlingError(); 455 error_handler()->StartHandlingError();
456 456
457 EXPECT_TRUE(error_handler()->IsTimerRunning()); 457 EXPECT_TRUE(error_handler()->IsTimerRunning());
458 tracker()->WaitForFetchForTesting(123123123); 458 tracker()->WaitForFetchForTesting(123123123);
459 base::RunLoop().RunUntilIdle(); 459 base::RunLoop().RunUntilIdle();
460 460
461 EXPECT_TRUE(error_handler()->bad_clock_interstitial_shown()); 461 EXPECT_TRUE(error_handler()->bad_clock_interstitial_shown());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // the system clock times out (e.g. because a network time query hangs). 493 // the system clock times out (e.g. because a network time query hangs).
494 TEST_F(SSLErrorHandlerDateInvalidTest, TimeQueryHangs) { 494 TEST_F(SSLErrorHandlerDateInvalidTest, TimeQueryHangs) {
495 base::Time network_time; 495 base::Time network_time;
496 base::TimeDelta uncertainty; 496 base::TimeDelta uncertainty;
497 EXPECT_EQ(network_time::NetworkTimeTracker::NETWORK_TIME_NO_SYNC_ATTEMPT, 497 EXPECT_EQ(network_time::NetworkTimeTracker::NETWORK_TIME_NO_SYNC_ATTEMPT,
498 tracker()->GetNetworkTime(&network_time, &uncertainty)); 498 tracker()->GetNetworkTime(&network_time, &uncertainty));
499 499
500 // Enable network time queries and handle the error. Because the 500 // Enable network time queries and handle the error. Because the
501 // network time cannot be determined before the timer elapses, an SSL 501 // network time cannot be determined before the timer elapses, an SSL
502 // interstitial should be shown. 502 // interstitial should be shown.
503 EXPECT_TRUE(test_server()->Start());
504 base::RunLoop wait_for_time_query_loop; 503 base::RunLoop wait_for_time_query_loop;
505 test_server()->RegisterRequestHandler( 504 test_server()->RegisterRequestHandler(
506 base::Bind(&WaitForRequest, wait_for_time_query_loop.QuitClosure())); 505 base::Bind(&WaitForRequest, wait_for_time_query_loop.QuitClosure()));
506 EXPECT_TRUE(test_server()->Start());
507 tracker()->SetTimeServerURLForTesting(test_server()->GetURL("/")); 507 tracker()->SetTimeServerURLForTesting(test_server()->GetURL("/"));
508 field_trial_test()->SetNetworkQueriesWithVariationsService( 508 field_trial_test()->SetNetworkQueriesWithVariationsService(
509 true, 0.0, network_time::FieldTrialTest::FETCHES_ON_DEMAND_ONLY); 509 true, 0.0, network_time::FieldTrialTest::FETCHES_ON_DEMAND_ONLY);
510 error_handler()->StartHandlingError(); 510 error_handler()->StartHandlingError();
511 EXPECT_TRUE(error_handler()->IsTimerRunning()); 511 EXPECT_TRUE(error_handler()->IsTimerRunning());
512 wait_for_time_query_loop.Run(); 512 wait_for_time_query_loop.Run();
513 base::RunLoop().RunUntilIdle(); 513 base::RunLoop().RunUntilIdle();
514 514
515 EXPECT_FALSE(error_handler()->bad_clock_interstitial_shown()); 515 EXPECT_FALSE(error_handler()->bad_clock_interstitial_shown());
516 EXPECT_TRUE(error_handler()->ssl_interstitial_shown()); 516 EXPECT_TRUE(error_handler()->ssl_interstitial_shown());
517 EXPECT_FALSE(error_handler()->IsTimerRunning()); 517 EXPECT_FALSE(error_handler()->IsTimerRunning());
518 518
519 // Clear the error handler to test that, when the request completes, 519 // Clear the error handler to test that, when the request completes,
520 // it doesn't try to call a callback on a deleted SSLErrorHandler. 520 // it doesn't try to call a callback on a deleted SSLErrorHandler.
521 ClearErrorHandler(); 521 ClearErrorHandler();
522 522
523 // Shut down the server to cancel the pending request. 523 // Shut down the server to cancel the pending request.
524 ASSERT_TRUE(test_server()->ShutdownAndWaitUntilComplete()); 524 ASSERT_TRUE(test_server()->ShutdownAndWaitUntilComplete());
525 tracker()->WaitForFetchForTesting(123123123); 525 tracker()->WaitForFetchForTesting(123123123);
526 } 526 }
OLDNEW
« no previous file with comments | « no previous file | components/ssl_errors/error_classification_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698