Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: base/test/histogram_tester.h

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/gtest_util.cc ('k') | base/test/histogram_tester.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory>
9 #include <ostream> 10 #include <ostream>
10 #include <string> 11 #include <string>
11 #include <utility> 12 #include <utility>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/metrics/histogram_base.h" 17 #include "base/metrics/histogram_base.h"
18 18
19 namespace base { 19 namespace base {
20 20
21 struct Bucket; 21 struct Bucket;
22 class HistogramSamples; 22 class HistogramSamples;
23 23
24 // HistogramTester provides a simple interface for examining histograms, UMA 24 // HistogramTester provides a simple interface for examining histograms, UMA
25 // or otherwise. Tests can use this interface to verify that histogram data is 25 // or otherwise. Tests can use this interface to verify that histogram data is
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // ... 86 // ...
87 // base::HistogramTester::CountsMap expected_counts; 87 // base::HistogramTester::CountsMap expected_counts;
88 // expected_counts["MyMetric.A"] = 1; 88 // expected_counts["MyMetric.A"] = 1;
89 // expected_counts["MyMetric.B"] = 1; 89 // expected_counts["MyMetric.B"] = 1;
90 // EXPECT_THAT(histogram_tester.GetTotalCountsForPrefix("MyMetric."), 90 // EXPECT_THAT(histogram_tester.GetTotalCountsForPrefix("MyMetric."),
91 // testing::ContainerEq(expected_counts)); 91 // testing::ContainerEq(expected_counts));
92 CountsMap GetTotalCountsForPrefix(const std::string& query) const; 92 CountsMap GetTotalCountsForPrefix(const std::string& query) const;
93 93
94 // Access a modified HistogramSamples containing only what has been logged 94 // Access a modified HistogramSamples containing only what has been logged
95 // to the histogram since the creation of this object. 95 // to the histogram since the creation of this object.
96 scoped_ptr<HistogramSamples> GetHistogramSamplesSinceCreation( 96 std::unique_ptr<HistogramSamples> GetHistogramSamplesSinceCreation(
97 const std::string& histogram_name) const; 97 const std::string& histogram_name) const;
98 98
99 private: 99 private:
100 // Verifies and asserts that value in the |sample| bucket matches the 100 // Verifies and asserts that value in the |sample| bucket matches the
101 // |expected_count|. The bucket's current value is determined from |samples| 101 // |expected_count|. The bucket's current value is determined from |samples|
102 // and is modified based on the snapshot stored for histogram |name|. 102 // and is modified based on the snapshot stored for histogram |name|.
103 void CheckBucketCount(const std::string& name, 103 void CheckBucketCount(const std::string& name,
104 base::HistogramBase::Sample sample, 104 base::HistogramBase::Sample sample,
105 base::Histogram::Count expected_count, 105 base::Histogram::Count expected_count,
106 const base::HistogramSamples& samples) const; 106 const base::HistogramSamples& samples) const;
(...skipping 21 matching lines...) Expand all
128 128
129 base::HistogramBase::Sample min; 129 base::HistogramBase::Sample min;
130 base::HistogramBase::Count count; 130 base::HistogramBase::Count count;
131 }; 131 };
132 132
133 void PrintTo(const Bucket& value, std::ostream* os); 133 void PrintTo(const Bucket& value, std::ostream* os);
134 134
135 } // namespace base 135 } // namespace base
136 136
137 #endif // BASE_TEST_HISTOGRAM_TESTER_H_ 137 #endif // BASE_TEST_HISTOGRAM_TESTER_H_
OLDNEW
« no previous file with comments | « base/test/gtest_util.cc ('k') | base/test/histogram_tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698