OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ | 5 #ifndef CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ |
6 #define CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ | 6 #define CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ |
7 | 7 |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/metrics/histogram_base.h" |
| 10 #include "base/metrics/histogram_samples.h" |
9 | 11 |
10 // UMAHistogramHelper provides a simple interface for examining UMA histograms. | 12 // UMAHistogramHelper provides a simple interface for examining UMA histograms. |
11 // Tests can use this interface to verify that UMA data is getting logged as | 13 // Tests can use this interface to verify that UMA data is getting logged as |
12 // intended. | 14 // intended. |
13 class UMAHistogramHelper { | 15 class UMAHistogramHelper { |
14 public: | 16 public: |
15 UMAHistogramHelper(); | 17 UMAHistogramHelper(); |
16 | 18 |
17 // Each child process may have its own histogram data, make sure this data | 19 // Each child process may have its own histogram data, make sure this data |
18 // gets accumulated into the browser process before we examine the histograms. | 20 // gets accumulated into the browser process before we examine the histograms. |
19 void Fetch(); | 21 void Fetch(); |
20 | 22 |
21 // We know the exact number of samples in a bucket, and that no other bucket | 23 // We know the exact number of samples in a bucket, and that no other bucket |
22 // should have samples. | 24 // should have samples. |
23 void ExpectUniqueSample(const std::string& name, size_t bucket_id, | 25 void ExpectUniqueSample(const std::string& name, |
24 base::Histogram::Count expected_count); | 26 base::HistogramBase::Sample sample, |
| 27 base::HistogramBase::Count expected_count); |
25 | 28 |
26 // We don't know the values of the samples, but we know how many there are. | 29 // We don't know the values of the samples, but we know how many there are. |
27 void ExpectTotalCount(const std::string& name, base::Histogram::Count count); | 30 void ExpectTotalCount(const std::string& name, |
| 31 base::HistogramBase::Count count); |
28 | 32 |
29 private: | 33 private: |
30 void FetchCallback(); | 34 void FetchCallback(); |
31 | 35 |
32 void CheckBucketCount(const std::string& name, size_t bucket_id, | 36 void CheckBucketCount(const std::string& name, |
| 37 base::HistogramBase::Sample sample, |
33 base::Histogram::Count expected_count, | 38 base::Histogram::Count expected_count, |
34 base::Histogram::SampleSet& samples); | 39 base::HistogramSamples& samples); |
35 | 40 |
36 void CheckTotalCount(const std::string& name, | 41 void CheckTotalCount(const std::string& name, |
37 base::Histogram::Count expected_count, | 42 base::Histogram::Count expected_count, |
38 base::Histogram::SampleSet& samples); | 43 base::HistogramSamples& samples); |
39 | 44 |
40 DISALLOW_COPY_AND_ASSIGN(UMAHistogramHelper); | 45 DISALLOW_COPY_AND_ASSIGN(UMAHistogramHelper); |
41 }; | 46 }; |
42 | 47 |
43 #endif // CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ | 48 #endif // CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ |
OLD | NEW |