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/metrics/metrics_service.h" | 5 #include "components/metrics/metrics_service.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "components/metrics/metrics_state_manager.h" | 21 #include "components/metrics/metrics_state_manager.h" |
22 #include "components/metrics/test_metrics_provider.h" | 22 #include "components/metrics/test_metrics_provider.h" |
23 #include "components/metrics/test_metrics_service_client.h" | 23 #include "components/metrics/test_metrics_service_client.h" |
24 #include "components/prefs/testing_pref_service.h" | 24 #include "components/prefs/testing_pref_service.h" |
25 #include "components/variations/metrics_util.h" | 25 #include "components/variations/metrics_util.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "third_party/zlib/google/compression_utils.h" | 27 #include "third_party/zlib/google/compression_utils.h" |
28 | 28 |
29 namespace metrics { | 29 namespace metrics { |
30 | 30 |
31 namespace { | 31 namespace { |
Alexei Svitkine (slow)
2016/03/29 16:29:10
Add an empty line below.
gayane -on leave until 09-2017
2016/03/31 01:38:24
Done.
| |
32 bool IsCellularEnabled() { | |
33 return false; | |
34 } | |
35 | |
36 const base::Callback<bool(void)> GetCellularCallback() { | |
37 return base::Bind(&IsCellularEnabled); | |
38 } | |
32 | 39 |
33 void StoreNoClientInfoBackup(const ClientInfo& /* client_info */) { | 40 void StoreNoClientInfoBackup(const ClientInfo& /* client_info */) { |
34 } | 41 } |
35 | 42 |
36 scoped_ptr<ClientInfo> ReturnNoBackup() { | 43 scoped_ptr<ClientInfo> ReturnNoBackup() { |
37 return scoped_ptr<ClientInfo>(); | 44 return scoped_ptr<ClientInfo>(); |
38 } | 45 } |
39 | 46 |
40 class TestMetricsService : public MetricsService { | 47 class TestMetricsService : public MetricsService { |
41 public: | 48 public: |
42 TestMetricsService(MetricsStateManager* state_manager, | 49 TestMetricsService(MetricsStateManager* state_manager, |
43 MetricsServiceClient* client, | 50 MetricsServiceClient* client, |
44 PrefService* local_state) | 51 PrefService* local_state) |
45 : MetricsService(state_manager, client, local_state) {} | 52 : MetricsService(state_manager, |
53 client, | |
54 local_state, | |
55 GetCellularCallback()) {} | |
46 ~TestMetricsService() override {} | 56 ~TestMetricsService() override {} |
47 | 57 |
48 using MetricsService::log_manager; | 58 using MetricsService::log_manager; |
49 | 59 |
50 private: | 60 private: |
51 DISALLOW_COPY_AND_ASSIGN(TestMetricsService); | 61 DISALLOW_COPY_AND_ASSIGN(TestMetricsService); |
52 }; | 62 }; |
53 | 63 |
54 class TestMetricsLog : public MetricsLog { | 64 class TestMetricsLog : public MetricsLog { |
55 public: | 65 public: |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 EXPECT_EQ(0, uma_log.omnibox_event_size()); | 318 EXPECT_EQ(0, uma_log.omnibox_event_size()); |
309 EXPECT_EQ(0, uma_log.profiler_event_size()); | 319 EXPECT_EQ(0, uma_log.profiler_event_size()); |
310 EXPECT_EQ(0, uma_log.perf_data_size()); | 320 EXPECT_EQ(0, uma_log.perf_data_size()); |
311 CheckForNonStabilityHistograms(uma_log); | 321 CheckForNonStabilityHistograms(uma_log); |
312 | 322 |
313 EXPECT_EQ(1, uma_log.system_profile().stability().crash_count()); | 323 EXPECT_EQ(1, uma_log.system_profile().stability().crash_count()); |
314 } | 324 } |
315 | 325 |
316 TEST_F(MetricsServiceTest, RegisterSyntheticTrial) { | 326 TEST_F(MetricsServiceTest, RegisterSyntheticTrial) { |
317 TestMetricsServiceClient client; | 327 TestMetricsServiceClient client; |
318 MetricsService service(GetMetricsStateManager(), &client, GetLocalState()); | 328 MetricsService service(GetMetricsStateManager(), &client, GetLocalState(), |
329 GetCellularCallback()); | |
319 | 330 |
320 // Add two synthetic trials and confirm that they show up in the list. | 331 // Add two synthetic trials and confirm that they show up in the list. |
321 variations::SyntheticTrialGroup trial1(HashName("TestTrial1"), | 332 variations::SyntheticTrialGroup trial1(HashName("TestTrial1"), |
322 HashName("Group1")); | 333 HashName("Group1")); |
323 service.RegisterSyntheticFieldTrial(trial1); | 334 service.RegisterSyntheticFieldTrial(trial1); |
324 | 335 |
325 variations::SyntheticTrialGroup trial2(HashName("TestTrial2"), | 336 variations::SyntheticTrialGroup trial2(HashName("TestTrial2"), |
326 HashName("Group2")); | 337 HashName("Group2")); |
327 service.RegisterSyntheticFieldTrial(trial2); | 338 service.RegisterSyntheticFieldTrial(trial2); |
328 // Ensure that time has advanced by at least a tick before proceeding. | 339 // Ensure that time has advanced by at least a tick before proceeding. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 | 415 |
405 TestMetricsProvider* test_provider = new TestMetricsProvider(); | 416 TestMetricsProvider* test_provider = new TestMetricsProvider(); |
406 service.RegisterMetricsProvider(scoped_ptr<MetricsProvider>(test_provider)); | 417 service.RegisterMetricsProvider(scoped_ptr<MetricsProvider>(test_provider)); |
407 | 418 |
408 service.InitializeMetricsRecordingState(); | 419 service.InitializeMetricsRecordingState(); |
409 | 420 |
410 EXPECT_TRUE(test_provider->init_called()); | 421 EXPECT_TRUE(test_provider->init_called()); |
411 } | 422 } |
412 | 423 |
413 } // namespace metrics | 424 } // namespace metrics |
OLD | NEW |