| OLD | NEW |
| 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 #ifndef COMPONENTS_METRICS_TEST_METRICS_PROVIDER_H_ | 5 #ifndef COMPONENTS_METRICS_TEST_METRICS_PROVIDER_H_ |
| 6 #define COMPONENTS_METRICS_TEST_METRICS_PROVIDER_H_ | 6 #define COMPONENTS_METRICS_TEST_METRICS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/metrics/metrics_provider.h" | 9 #include "components/metrics/metrics_provider.h" |
| 10 | 10 |
| 11 namespace metrics { | 11 namespace metrics { |
| 12 | 12 |
| 13 // A simple implementation of MetricsProvider that checks that its providing | 13 // A simple implementation of MetricsProvider that checks that its providing |
| 14 // functions are called, for use in tests. | 14 // functions are called, for use in tests. |
| 15 class TestMetricsProvider : public MetricsProvider { | 15 class TestMetricsProvider : public MetricsProvider { |
| 16 public: | 16 public: |
| 17 TestMetricsProvider() | 17 TestMetricsProvider() |
| 18 : init_called_(false), | 18 : init_called_(false), |
| 19 on_recording_disabled_called_(false), | 19 on_recording_disabled_called_(false), |
| 20 has_initial_stability_metrics_(false), | 20 has_initial_stability_metrics_(false), |
| 21 has_initial_stability_metrics_called_(false), |
| 21 provide_initial_stability_metrics_called_(false), | 22 provide_initial_stability_metrics_called_(false), |
| 22 provide_stability_metrics_called_(false) {} | 23 provide_stability_metrics_called_(false) {} |
| 23 | 24 |
| 24 // MetricsProvider: | 25 // MetricsProvider: |
| 25 void Init() override; | 26 void Init() override; |
| 26 void OnRecordingDisabled() override; | 27 void OnRecordingDisabled() override; |
| 27 bool HasInitialStabilityMetrics() override; | 28 bool HasInitialStabilityMetrics() override; |
| 28 void ProvideInitialStabilityMetrics( | 29 void ProvideInitialStabilityMetrics( |
| 29 SystemProfileProto* system_profile_proto) override; | 30 SystemProfileProto* system_profile_proto) override; |
| 30 void ProvideStabilityMetrics( | 31 void ProvideStabilityMetrics( |
| 31 SystemProfileProto* system_profile_proto) override; | 32 SystemProfileProto* system_profile_proto) override; |
| 32 | 33 |
| 33 bool init_called() { return init_called_; } | 34 bool init_called() { return init_called_; } |
| 34 bool on_recording_disabled_called() { return on_recording_disabled_called_; } | 35 bool on_recording_disabled_called() { return on_recording_disabled_called_; } |
| 36 bool has_initial_stability_metrics_called() { |
| 37 return has_initial_stability_metrics_called_; |
| 38 } |
| 35 void set_has_initial_stability_metrics(bool has_initial_stability_metrics) { | 39 void set_has_initial_stability_metrics(bool has_initial_stability_metrics) { |
| 36 has_initial_stability_metrics_ = has_initial_stability_metrics; | 40 has_initial_stability_metrics_ = has_initial_stability_metrics; |
| 37 } | 41 } |
| 38 bool provide_initial_stability_metrics_called() const { | 42 bool provide_initial_stability_metrics_called() const { |
| 39 return provide_initial_stability_metrics_called_; | 43 return provide_initial_stability_metrics_called_; |
| 40 } | 44 } |
| 41 bool provide_stability_metrics_called() const { | 45 bool provide_stability_metrics_called() const { |
| 42 return provide_stability_metrics_called_; | 46 return provide_stability_metrics_called_; |
| 43 } | 47 } |
| 44 | 48 |
| 45 private: | 49 private: |
| 46 bool init_called_; | 50 bool init_called_; |
| 47 bool on_recording_disabled_called_; | 51 bool on_recording_disabled_called_; |
| 48 bool has_initial_stability_metrics_; | 52 bool has_initial_stability_metrics_; |
| 53 bool has_initial_stability_metrics_called_; |
| 49 bool provide_initial_stability_metrics_called_; | 54 bool provide_initial_stability_metrics_called_; |
| 50 bool provide_stability_metrics_called_; | 55 bool provide_stability_metrics_called_; |
| 51 | 56 |
| 52 DISALLOW_COPY_AND_ASSIGN(TestMetricsProvider); | 57 DISALLOW_COPY_AND_ASSIGN(TestMetricsProvider); |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 } // namespace metrics | 60 } // namespace metrics |
| 56 | 61 |
| 57 #endif // COMPONENTS_METRICS_TEST_METRICS_PROVIDER_H_ | 62 #endif // COMPONENTS_METRICS_TEST_METRICS_PROVIDER_H_ |
| OLD | NEW |