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 #ifndef BASE_TEST_HISTOGRAM_TESTER_H_ | 5 #ifndef BASE_TEST_HISTOGRAM_TESTER_H_ |
6 #define BASE_TEST_HISTOGRAM_TESTER_H_ | 6 #define BASE_TEST_HISTOGRAM_TESTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 scoped_ptr<HistogramSamples> GetHistogramSamplesSinceCreation( | 52 scoped_ptr<HistogramSamples> GetHistogramSamplesSinceCreation( |
53 const std::string& histogram_name); | 53 const std::string& histogram_name); |
54 | 54 |
55 private: | 55 private: |
56 // Verifies and asserts that value in the |sample| bucket matches the | 56 // Verifies and asserts that value in the |sample| bucket matches the |
57 // |expected_count|. The bucket's current value is determined from |samples| | 57 // |expected_count|. The bucket's current value is determined from |samples| |
58 // and is modified based on the snapshot stored for histogram |name|. | 58 // and is modified based on the snapshot stored for histogram |name|. |
59 void CheckBucketCount(const std::string& name, | 59 void CheckBucketCount(const std::string& name, |
60 base::HistogramBase::Sample sample, | 60 base::HistogramBase::Sample sample, |
61 base::Histogram::Count expected_count, | 61 base::Histogram::Count expected_count, |
62 base::HistogramSamples& samples) const; | 62 const base::HistogramSamples& samples) const; |
63 | 63 |
64 // Verifies that the total number of values recorded for the histogram |name| | 64 // Verifies that the total number of values recorded for the histogram |name| |
65 // is |expected_count|. This is checked against |samples| minus the snapshot | 65 // is |expected_count|. This is checked against |samples| minus the snapshot |
66 // that was taken for |name|. | 66 // that was taken for |name|. |
67 void CheckTotalCount(const std::string& name, | 67 void CheckTotalCount(const std::string& name, |
68 base::Histogram::Count expected_count, | 68 base::Histogram::Count expected_count, |
69 base::HistogramSamples& samples) const; | 69 const base::HistogramSamples& samples) const; |
70 | 70 |
71 // Used to determine the histogram changes made during this instance's | 71 // Used to determine the histogram changes made during this instance's |
72 // lifecycle. This instance takes ownership of the samples, which are deleted | 72 // lifecycle. This instance takes ownership of the samples, which are deleted |
73 // when the instance is destroyed. | 73 // when the instance is destroyed. |
74 std::map<std::string, HistogramSamples*> histograms_snapshot_; | 74 std::map<std::string, HistogramSamples*> histograms_snapshot_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(HistogramTester); | 76 DISALLOW_COPY_AND_ASSIGN(HistogramTester); |
77 }; | 77 }; |
78 | 78 |
79 } // namespace base | 79 } // namespace base |
80 | 80 |
81 #endif // BASE_TEST_HISTOGRAM_TESTER_H_ | 81 #endif // BASE_TEST_HISTOGRAM_TESTER_H_ |
OLD | NEW |