| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 return scoped_ptr<ClientInfo>(); | 31 return scoped_ptr<ClientInfo>(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 class TestMetricsProvider : public metrics::MetricsProvider { | 34 class TestMetricsProvider : public metrics::MetricsProvider { |
| 35 public: | 35 public: |
| 36 explicit TestMetricsProvider(bool has_stability_metrics) : | 36 explicit TestMetricsProvider(bool has_stability_metrics) : |
| 37 has_stability_metrics_(has_stability_metrics), | 37 has_stability_metrics_(has_stability_metrics), |
| 38 provide_stability_metrics_called_(false) { | 38 provide_stability_metrics_called_(false) { |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual bool HasStabilityMetrics() override { return has_stability_metrics_; } | 41 bool HasStabilityMetrics() override { return has_stability_metrics_; } |
| 42 virtual void ProvideStabilityMetrics( | 42 void ProvideStabilityMetrics( |
| 43 SystemProfileProto* system_profile_proto) override { | 43 SystemProfileProto* system_profile_proto) override { |
| 44 provide_stability_metrics_called_ = true; | 44 provide_stability_metrics_called_ = true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool provide_stability_metrics_called() const { | 47 bool provide_stability_metrics_called() const { |
| 48 return provide_stability_metrics_called_; | 48 return provide_stability_metrics_called_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 bool has_stability_metrics_; | 52 bool has_stability_metrics_; |
| 53 bool provide_stability_metrics_called_; | 53 bool provide_stability_metrics_called_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(TestMetricsProvider); | 55 DISALLOW_COPY_AND_ASSIGN(TestMetricsProvider); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class TestMetricsService : public MetricsService { | 58 class TestMetricsService : public MetricsService { |
| 59 public: | 59 public: |
| 60 TestMetricsService(MetricsStateManager* state_manager, | 60 TestMetricsService(MetricsStateManager* state_manager, |
| 61 MetricsServiceClient* client, | 61 MetricsServiceClient* client, |
| 62 PrefService* local_state) | 62 PrefService* local_state) |
| 63 : MetricsService(state_manager, client, local_state) {} | 63 : MetricsService(state_manager, client, local_state) {} |
| 64 virtual ~TestMetricsService() {} | 64 ~TestMetricsService() override {} |
| 65 | 65 |
| 66 using MetricsService::log_manager; | 66 using MetricsService::log_manager; |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 DISALLOW_COPY_AND_ASSIGN(TestMetricsService); | 69 DISALLOW_COPY_AND_ASSIGN(TestMetricsService); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 class TestMetricsLog : public MetricsLog { | 72 class TestMetricsLog : public MetricsLog { |
| 73 public: | 73 public: |
| 74 TestMetricsLog(const std::string& client_id, | 74 TestMetricsLog(const std::string& client_id, |
| 75 int session_id, | 75 int session_id, |
| 76 MetricsServiceClient* client, | 76 MetricsServiceClient* client, |
| 77 PrefService* local_state) | 77 PrefService* local_state) |
| 78 : MetricsLog(client_id, | 78 : MetricsLog(client_id, |
| 79 session_id, | 79 session_id, |
| 80 MetricsLog::ONGOING_LOG, | 80 MetricsLog::ONGOING_LOG, |
| 81 client, | 81 client, |
| 82 local_state) {} | 82 local_state) {} |
| 83 | 83 |
| 84 virtual ~TestMetricsLog() {} | 84 ~TestMetricsLog() override {} |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); | 87 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class MetricsServiceTest : public testing::Test { | 90 class MetricsServiceTest : public testing::Test { |
| 91 public: | 91 public: |
| 92 MetricsServiceTest() : is_metrics_reporting_enabled_(false) { | 92 MetricsServiceTest() : is_metrics_reporting_enabled_(false) { |
| 93 MetricsService::RegisterPrefs(testing_local_state_.registry()); | 93 MetricsService::RegisterPrefs(testing_local_state_.registry()); |
| 94 metrics_state_manager_ = MetricsStateManager::Create( | 94 metrics_state_manager_ = MetricsStateManager::Create( |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 "clientID", 1, MetricsLog::ONGOING_LOG, &client, GetLocalState()))); | 357 "clientID", 1, MetricsLog::ONGOING_LOG, &client, GetLocalState()))); |
| 358 service.GetCurrentSyntheticFieldTrials(&synthetic_trials); | 358 service.GetCurrentSyntheticFieldTrials(&synthetic_trials); |
| 359 EXPECT_EQ(3U, synthetic_trials.size()); | 359 EXPECT_EQ(3U, synthetic_trials.size()); |
| 360 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial1", "Group2")); | 360 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial1", "Group2")); |
| 361 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); | 361 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); |
| 362 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial3", "Group3")); | 362 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial3", "Group3")); |
| 363 service.log_manager_.FinishCurrentLog(); | 363 service.log_manager_.FinishCurrentLog(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace metrics | 366 } // namespace metrics |
| OLD | NEW |