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

Side by Side Diff: components/ssl_errors/error_classification_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 | « chrome/browser/ssl/ssl_error_handler_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/ssl_errors/error_classification.h" 5 #include "components/ssl_errors/error_classification.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 // Tests that all possible NetworkClockState histogram values are recorded 332 // Tests that all possible NetworkClockState histogram values are recorded
333 // appropriately. 333 // appropriately.
334 TEST_F(SSLErrorClassificationTest, NetworkClockStateHistogram) { 334 TEST_F(SSLErrorClassificationTest, NetworkClockStateHistogram) {
335 base::Thread io_thread("IO thread"); 335 base::Thread io_thread("IO thread");
336 base::Thread::Options thread_options; 336 base::Thread::Options thread_options;
337 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 337 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
338 EXPECT_TRUE(io_thread.StartWithOptions(thread_options)); 338 EXPECT_TRUE(io_thread.StartWithOptions(thread_options));
339 339
340 net::EmbeddedTestServer test_server; 340 net::EmbeddedTestServer test_server;
341 ASSERT_TRUE(test_server.Start()); 341 ASSERT_TRUE(test_server.InitializeAndListen());
342 342
343 base::HistogramTester histograms; 343 base::HistogramTester histograms;
344 histograms.ExpectTotalCount(kNetworkTimeHistogram, 0); 344 histograms.ExpectTotalCount(kNetworkTimeHistogram, 0);
345 TestingPrefServiceSimple pref_service; 345 TestingPrefServiceSimple pref_service;
346 network_time::NetworkTimeTracker::RegisterPrefs(pref_service.registry()); 346 network_time::NetworkTimeTracker::RegisterPrefs(pref_service.registry());
347 base::SimpleTestTickClock* tick_clock = new base::SimpleTestTickClock; 347 base::SimpleTestTickClock* tick_clock = new base::SimpleTestTickClock;
348 base::SimpleTestClock* clock = new base::SimpleTestClock; 348 base::SimpleTestClock* clock = new base::SimpleTestClock;
349 // Do this to be sure that |is_null| returns false. 349 // Do this to be sure that |is_null| returns false.
350 clock->Advance(base::TimeDelta::FromDays(111)); 350 clock->Advance(base::TimeDelta::FromDays(111));
351 tick_clock->Advance(base::TimeDelta::FromDays(222)); 351 tick_clock->Advance(base::TimeDelta::FromDays(222));
(...skipping 12 matching lines...) Expand all
364 EXPECT_EQ( 364 EXPECT_EQ(
365 ssl_errors::ClockState::CLOCK_STATE_UNKNOWN, 365 ssl_errors::ClockState::CLOCK_STATE_UNKNOWN,
366 ssl_errors::GetClockState(base::Time::Now(), &network_time_tracker)); 366 ssl_errors::GetClockState(base::Time::Now(), &network_time_tracker));
367 histograms.ExpectTotalCount(kNetworkTimeHistogram, 1); 367 histograms.ExpectTotalCount(kNetworkTimeHistogram, 1);
368 histograms.ExpectBucketCount( 368 histograms.ExpectBucketCount(
369 kNetworkTimeHistogram, 369 kNetworkTimeHistogram,
370 ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT, 1); 370 ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT, 1);
371 371
372 // First sync attempt is pending. 372 // First sync attempt is pending.
373 test_server.RegisterRequestHandler(base::Bind(&NetworkErrorResponseHandler)); 373 test_server.RegisterRequestHandler(base::Bind(&NetworkErrorResponseHandler));
374 test_server.StartAcceptingConnections();
374 EXPECT_TRUE(network_time_tracker.QueryTimeServiceForTesting()); 375 EXPECT_TRUE(network_time_tracker.QueryTimeServiceForTesting());
375 EXPECT_EQ( 376 EXPECT_EQ(
376 ssl_errors::ClockState::CLOCK_STATE_UNKNOWN, 377 ssl_errors::ClockState::CLOCK_STATE_UNKNOWN,
377 ssl_errors::GetClockState(base::Time::Now(), &network_time_tracker)); 378 ssl_errors::GetClockState(base::Time::Now(), &network_time_tracker));
378 histograms.ExpectTotalCount(kNetworkTimeHistogram, 2); 379 histograms.ExpectTotalCount(kNetworkTimeHistogram, 2);
379 histograms.ExpectBucketCount( 380 histograms.ExpectBucketCount(
380 kNetworkTimeHistogram, 381 kNetworkTimeHistogram,
381 ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_FIRST_SYNC_PENDING, 1); 382 ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_FIRST_SYNC_PENDING, 1);
382 network_time_tracker.WaitForFetchForTesting(123123123); 383 network_time_tracker.WaitForFetchForTesting(123123123);
383 384
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 clock->Advance(base::TimeDelta::FromDays(1)); 444 clock->Advance(base::TimeDelta::FromDays(1));
444 // GetClockState() will fall back to the build time heuristic. 445 // GetClockState() will fall back to the build time heuristic.
445 ssl_errors::GetClockState(clock->Now(), &network_time_tracker); 446 ssl_errors::GetClockState(clock->Now(), &network_time_tracker);
446 histograms.ExpectTotalCount(kNetworkTimeHistogram, 8); 447 histograms.ExpectTotalCount(kNetworkTimeHistogram, 8);
447 histograms.ExpectBucketCount( 448 histograms.ExpectBucketCount(
448 kNetworkTimeHistogram, ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST, 449 kNetworkTimeHistogram, ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST,
449 1); 450 1);
450 451
451 io_thread.Stop(); 452 io_thread.Stop();
452 } 453 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_error_handler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698