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

Side by Side Diff: base/metrics/histogram_base_unittest.cc

Issue 2036643004: Create ForTesting method rather than declaring a dozen "friend" classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 6 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 | « no previous file | base/metrics/histogram_delta_serialization_unittest.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 (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 11 matching lines...) Expand all
22 } 22 }
23 23
24 ~HistogramBaseTest() override { 24 ~HistogramBaseTest() override {
25 HistogramBase::report_histogram_ = nullptr; 25 HistogramBase::report_histogram_ = nullptr;
26 } 26 }
27 27
28 void ResetStatisticsRecorder() { 28 void ResetStatisticsRecorder() {
29 // It is necessary to fully destruct any existing StatisticsRecorder 29 // It is necessary to fully destruct any existing StatisticsRecorder
30 // before creating a new one. 30 // before creating a new one.
31 statistics_recorder_.reset(); 31 statistics_recorder_.reset();
32 statistics_recorder_.reset(new StatisticsRecorder()); 32 statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting();
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 std::unique_ptr<StatisticsRecorder> statistics_recorder_; 41 std::unique_ptr<StatisticsRecorder> statistics_recorder_;
42 42
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | base/metrics/histogram_delta_serialization_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698