| 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 has_initial_stability_metrics_called_(false), |
| 22 provide_initial_stability_metrics_called_(false), | 22 provide_initial_stability_metrics_called_(false), |
| 23 provide_stability_metrics_called_(false) {} | 23 provide_stability_metrics_called_(false), |
| 24 provide_system_profile_metrics_called_(false) {} |
| 24 | 25 |
| 25 // MetricsProvider: | 26 // MetricsProvider: |
| 26 void Init() override; | 27 void Init() override; |
| 27 void OnRecordingDisabled() override; | 28 void OnRecordingDisabled() override; |
| 28 bool HasInitialStabilityMetrics() override; | 29 bool HasInitialStabilityMetrics() override; |
| 29 void ProvideInitialStabilityMetrics( | 30 void ProvideInitialStabilityMetrics( |
| 30 SystemProfileProto* system_profile_proto) override; | 31 SystemProfileProto* system_profile_proto) override; |
| 31 void ProvideStabilityMetrics( | 32 void ProvideStabilityMetrics( |
| 32 SystemProfileProto* system_profile_proto) override; | 33 SystemProfileProto* system_profile_proto) override; |
| 34 void ProvideSystemProfileMetrics( |
| 35 SystemProfileProto* system_profile_proto) override; |
| 33 | 36 |
| 34 bool init_called() { return init_called_; } | 37 bool init_called() { return init_called_; } |
| 35 bool on_recording_disabled_called() { return on_recording_disabled_called_; } | 38 bool on_recording_disabled_called() { return on_recording_disabled_called_; } |
| 36 bool has_initial_stability_metrics_called() { | 39 bool has_initial_stability_metrics_called() { |
| 37 return has_initial_stability_metrics_called_; | 40 return has_initial_stability_metrics_called_; |
| 38 } | 41 } |
| 39 void set_has_initial_stability_metrics(bool has_initial_stability_metrics) { | 42 void set_has_initial_stability_metrics(bool has_initial_stability_metrics) { |
| 40 has_initial_stability_metrics_ = has_initial_stability_metrics; | 43 has_initial_stability_metrics_ = has_initial_stability_metrics; |
| 41 } | 44 } |
| 42 bool provide_initial_stability_metrics_called() const { | 45 bool provide_initial_stability_metrics_called() const { |
| 43 return provide_initial_stability_metrics_called_; | 46 return provide_initial_stability_metrics_called_; |
| 44 } | 47 } |
| 45 bool provide_stability_metrics_called() const { | 48 bool provide_stability_metrics_called() const { |
| 46 return provide_stability_metrics_called_; | 49 return provide_stability_metrics_called_; |
| 47 } | 50 } |
| 51 bool provide_system_profile_metrics_called() const { |
| 52 return provide_system_profile_metrics_called_; |
| 53 } |
| 48 | 54 |
| 49 private: | 55 private: |
| 50 bool init_called_; | 56 bool init_called_; |
| 51 bool on_recording_disabled_called_; | 57 bool on_recording_disabled_called_; |
| 52 bool has_initial_stability_metrics_; | 58 bool has_initial_stability_metrics_; |
| 53 bool has_initial_stability_metrics_called_; | 59 bool has_initial_stability_metrics_called_; |
| 54 bool provide_initial_stability_metrics_called_; | 60 bool provide_initial_stability_metrics_called_; |
| 55 bool provide_stability_metrics_called_; | 61 bool provide_stability_metrics_called_; |
| 62 bool provide_system_profile_metrics_called_; |
| 56 | 63 |
| 57 DISALLOW_COPY_AND_ASSIGN(TestMetricsProvider); | 64 DISALLOW_COPY_AND_ASSIGN(TestMetricsProvider); |
| 58 }; | 65 }; |
| 59 | 66 |
| 60 } // namespace metrics | 67 } // namespace metrics |
| 61 | 68 |
| 62 #endif // COMPONENTS_METRICS_TEST_METRICS_PROVIDER_H_ | 69 #endif // COMPONENTS_METRICS_TEST_METRICS_PROVIDER_H_ |
| OLD | NEW |