OLD | NEW |
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 "components/network_time/network_time_tracker.h" | 5 #include "components/network_time/network_time_tracker.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 const char kTimeBetweenFetchesHistogram[] = | 41 const char kTimeBetweenFetchesHistogram[] = |
42 "NetworkTimeTracker.TimeBetweenFetches"; | 42 "NetworkTimeTracker.TimeBetweenFetches"; |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 class NetworkTimeTrackerTest : public ::testing::Test { | 45 class NetworkTimeTrackerTest : public ::testing::Test { |
46 public: | 46 public: |
47 ~NetworkTimeTrackerTest() override {} | 47 ~NetworkTimeTrackerTest() override {} |
48 | 48 |
49 NetworkTimeTrackerTest() | 49 NetworkTimeTrackerTest() |
50 : io_thread_("IO thread"), | 50 : io_thread_("IO thread"), |
51 field_trial_test_(FieldTrialTest::CreateForUnitTest()), | 51 field_trial_test_(new FieldTrialTest()), |
52 clock_(new base::SimpleTestClock), | 52 clock_(new base::SimpleTestClock), |
53 tick_clock_(new base::SimpleTestTickClock), | 53 tick_clock_(new base::SimpleTestTickClock), |
54 test_server_(new net::EmbeddedTestServer) { | 54 test_server_(new net::EmbeddedTestServer) { |
55 base::Thread::Options thread_options; | 55 base::Thread::Options thread_options; |
56 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 56 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
57 EXPECT_TRUE(io_thread_.StartWithOptions(thread_options)); | 57 EXPECT_TRUE(io_thread_.StartWithOptions(thread_options)); |
58 NetworkTimeTracker::RegisterPrefs(pref_service_.registry()); | 58 NetworkTimeTracker::RegisterPrefs(pref_service_.registry()); |
59 | 59 |
60 field_trial_test_->SetNetworkQueriesWithVariationsService( | 60 field_trial_test_->SetNetworkQueriesWithVariationsService( |
61 true, 0.0 /* query probability */, | 61 true, 0.0 /* query probability */, |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 tracker_->GetNetworkTime(&out_network_time, nullptr)); | 938 tracker_->GetNetworkTime(&out_network_time, nullptr)); |
939 histograms.ExpectTotalCount(kTimeBetweenFetchesHistogram, 1); | 939 histograms.ExpectTotalCount(kTimeBetweenFetchesHistogram, 1); |
940 histograms.ExpectBucketCount( | 940 histograms.ExpectBucketCount( |
941 kTimeBetweenFetchesHistogram, | 941 kTimeBetweenFetchesHistogram, |
942 (response_handler.GetTimeAtIndex(1) - response_handler.GetTimeAtIndex(0)) | 942 (response_handler.GetTimeAtIndex(1) - response_handler.GetTimeAtIndex(0)) |
943 .InMilliseconds(), | 943 .InMilliseconds(), |
944 1); | 944 1); |
945 } | 945 } |
946 | 946 |
947 } // namespace network_time | 947 } // namespace network_time |
OLD | NEW |