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 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/metrics/histogram_base.h" | 8 #include "base/metrics/histogram_base.h" |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 statistics_recorder_.reset(); | 31 statistics_recorder_.reset(); |
32 statistics_recorder_.reset(new StatisticsRecorder()); | 32 statistics_recorder_.reset(new StatisticsRecorder()); |
33 } | 33 } |
34 | 34 |
35 HistogramBase* GetCreationReportHistogram(const std::string& name) { | 35 HistogramBase* GetCreationReportHistogram(const std::string& name) { |
36 HistogramBase::EnableActivityReportHistogram(name); | 36 HistogramBase::EnableActivityReportHistogram(name); |
37 return HistogramBase::report_histogram_; | 37 return HistogramBase::report_histogram_; |
38 } | 38 } |
39 | 39 |
40 private: | 40 private: |
41 scoped_ptr<StatisticsRecorder> statistics_recorder_; | 41 std::unique_ptr<StatisticsRecorder> statistics_recorder_; |
42 | 42 |
43 DISALLOW_COPY_AND_ASSIGN(HistogramBaseTest); | 43 DISALLOW_COPY_AND_ASSIGN(HistogramBaseTest); |
44 }; | 44 }; |
45 | 45 |
46 TEST_F(HistogramBaseTest, DeserializeHistogram) { | 46 TEST_F(HistogramBaseTest, DeserializeHistogram) { |
47 HistogramBase* histogram = Histogram::FactoryGet( | 47 HistogramBase* histogram = Histogram::FactoryGet( |
48 "TestHistogram", 1, 1000, 10, | 48 "TestHistogram", 1, 1000, 10, |
49 (HistogramBase::kUmaTargetedHistogramFlag | | 49 (HistogramBase::kUmaTargetedHistogramFlag | |
50 HistogramBase::kIPCSerializationSourceFlag)); | 50 HistogramBase::kIPCSerializationSourceFlag)); |
51 | 51 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 ranges.push_back(8); | 174 ranges.push_back(8); |
175 ranges.push_back(10); | 175 ranges.push_back(10); |
176 | 176 |
177 // Create all histogram types and verify counts. | 177 // Create all histogram types and verify counts. |
178 Histogram::FactoryGet("CRH-Histogram", 1, 10, 5, 0); | 178 Histogram::FactoryGet("CRH-Histogram", 1, 10, 5, 0); |
179 LinearHistogram::FactoryGet("CRH-Linear", 1, 10, 5, 0); | 179 LinearHistogram::FactoryGet("CRH-Linear", 1, 10, 5, 0); |
180 BooleanHistogram::FactoryGet("CRH-Boolean", 0); | 180 BooleanHistogram::FactoryGet("CRH-Boolean", 0); |
181 CustomHistogram::FactoryGet("CRH-Custom", ranges, 0); | 181 CustomHistogram::FactoryGet("CRH-Custom", ranges, 0); |
182 SparseHistogram::FactoryGet("CRH-Sparse", 0); | 182 SparseHistogram::FactoryGet("CRH-Sparse", 0); |
183 | 183 |
184 scoped_ptr<HistogramSamples> samples = report->SnapshotSamples(); | 184 std::unique_ptr<HistogramSamples> samples = report->SnapshotSamples(); |
185 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_CREATED)); | 185 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_CREATED)); |
186 EXPECT_EQ(5, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_CREATED)); | 186 EXPECT_EQ(5, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_CREATED)); |
187 EXPECT_EQ(0, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_LOOKUP)); | 187 EXPECT_EQ(0, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_LOOKUP)); |
188 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_LOGARITHMIC)); | 188 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_LOGARITHMIC)); |
189 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_LINEAR)); | 189 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_LINEAR)); |
190 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_BOOLEAN)); | 190 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_BOOLEAN)); |
191 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_CUSTOM)); | 191 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_CUSTOM)); |
192 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_SPARSE)); | 192 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_TYPE_SPARSE)); |
193 | 193 |
194 // Create all flag types and verify counts. | 194 // Create all flag types and verify counts. |
(...skipping 18 matching lines...) Expand all Loading... |
213 BooleanHistogram::FactoryGet("CRH-Boolean", 0); | 213 BooleanHistogram::FactoryGet("CRH-Boolean", 0); |
214 CustomHistogram::FactoryGet("CRH-Custom", ranges, 0); | 214 CustomHistogram::FactoryGet("CRH-Custom", ranges, 0); |
215 SparseHistogram::FactoryGet("CRH-Sparse", 0); | 215 SparseHistogram::FactoryGet("CRH-Sparse", 0); |
216 samples = report->SnapshotSamples(); | 216 samples = report->SnapshotSamples(); |
217 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_CREATED)); | 217 EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_CREATED)); |
218 EXPECT_EQ(9, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_CREATED)); | 218 EXPECT_EQ(9, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_CREATED)); |
219 EXPECT_EQ(5, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_LOOKUP)); | 219 EXPECT_EQ(5, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_LOOKUP)); |
220 } | 220 } |
221 | 221 |
222 } // namespace base | 222 } // namespace base |
OLD | NEW |