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

Side by Side Diff: components/ssl_errors/error_classification_unittest.cc

Issue 2449193002: Attempt an on-demand time fetch when encountering a date invalid error (Closed)
Patch Set: meacer nits 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 | « components/network_time/network_time_tracker_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 24 matching lines...) Expand all
35 NetworkErrorResponseHandler(const net::test_server::HttpRequest& request) { 35 NetworkErrorResponseHandler(const net::test_server::HttpRequest& request) {
36 return std::unique_ptr<net::test_server::HttpResponse>( 36 return std::unique_ptr<net::test_server::HttpResponse>(
37 new net::test_server::RawHttpResponse("", "")); 37 new net::test_server::RawHttpResponse("", ""));
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 class SSLErrorClassificationTest : public ::testing::Test { 42 class SSLErrorClassificationTest : public ::testing::Test {
43 public: 43 public:
44 SSLErrorClassificationTest() 44 SSLErrorClassificationTest()
45 : field_trial_test_(new network_time::FieldTrialTest()) {} 45 : field_trial_test_(network_time::FieldTrialTest::CreateForUnitTest()) {}
46 network_time::FieldTrialTest* field_trial_test() { 46 network_time::FieldTrialTest* field_trial_test() {
47 return field_trial_test_.get(); 47 return field_trial_test_.get();
48 } 48 }
49 49
50 private: 50 private:
51 std::unique_ptr<network_time::FieldTrialTest> field_trial_test_; 51 std::unique_ptr<network_time::FieldTrialTest> field_trial_test_;
52 }; 52 };
53 53
54 TEST_F(SSLErrorClassificationTest, TestNameMismatch) { 54 TEST_F(SSLErrorClassificationTest, TestNameMismatch) {
55 scoped_refptr<net::X509Certificate> google_cert( 55 scoped_refptr<net::X509Certificate> google_cert(
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
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));
352 352
353 base::MessageLoop loop; 353 base::MessageLoop loop;
354 network_time::NetworkTimeTracker network_time_tracker( 354 network_time::NetworkTimeTracker network_time_tracker(
355 std::unique_ptr<base::Clock>(clock), 355 std::unique_ptr<base::Clock>(clock),
356 std::unique_ptr<base::TickClock>(tick_clock), &pref_service, 356 std::unique_ptr<base::TickClock>(tick_clock), &pref_service,
357 new net::TestURLRequestContextGetter(io_thread.task_runner())); 357 new net::TestURLRequestContextGetter(io_thread.task_runner()));
358 network_time_tracker.SetTimeServerURLForTesting(test_server.GetURL("/")); 358 network_time_tracker.SetTimeServerURLForTesting(test_server.GetURL("/"));
359 field_trial_test()->SetNetworkQueriesWithVariationsService( 359 field_trial_test()->SetNetworkQueriesWithVariationsService(
360 true, 0.0, network_time::FieldTrialTest::ENABLE_FETCHES_ON_DEMAND); 360 true, 0.0,
361 network_time::FieldTrialTest::FETCHES_IN_BACKGROUND_AND_ON_DEMAND);
361 362
362 // No sync attempt. 363 // No sync attempt.
363 EXPECT_EQ( 364 EXPECT_EQ(
364 ssl_errors::ClockState::CLOCK_STATE_UNKNOWN, 365 ssl_errors::ClockState::CLOCK_STATE_UNKNOWN,
365 ssl_errors::GetClockState(base::Time::Now(), &network_time_tracker)); 366 ssl_errors::GetClockState(base::Time::Now(), &network_time_tracker));
366 histograms.ExpectTotalCount(kNetworkTimeHistogram, 1); 367 histograms.ExpectTotalCount(kNetworkTimeHistogram, 1);
367 histograms.ExpectBucketCount( 368 histograms.ExpectBucketCount(
368 kNetworkTimeHistogram, 369 kNetworkTimeHistogram,
369 ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT, 1); 370 ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT, 1);
370 371
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 clock->Advance(base::TimeDelta::FromDays(1)); 443 clock->Advance(base::TimeDelta::FromDays(1));
443 // GetClockState() will fall back to the build time heuristic. 444 // GetClockState() will fall back to the build time heuristic.
444 ssl_errors::GetClockState(clock->Now(), &network_time_tracker); 445 ssl_errors::GetClockState(clock->Now(), &network_time_tracker);
445 histograms.ExpectTotalCount(kNetworkTimeHistogram, 8); 446 histograms.ExpectTotalCount(kNetworkTimeHistogram, 8);
446 histograms.ExpectBucketCount( 447 histograms.ExpectBucketCount(
447 kNetworkTimeHistogram, ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST, 448 kNetworkTimeHistogram, ssl_errors::NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST,
448 1); 449 1);
449 450
450 io_thread.Stop(); 451 io_thread.Stop();
451 } 452 }
OLDNEW
« no previous file with comments | « components/network_time/network_time_tracker_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698