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

Side by Side Diff: base/metrics/histogram_snapshot_manager_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
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 #include "base/metrics/histogram_snapshot_manager.h" 5 #include "base/metrics/histogram_snapshot_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 private: 61 private:
62 std::vector<std::string> recorded_delta_histogram_names_; 62 std::vector<std::string> recorded_delta_histogram_names_;
63 std::map<std::string, int64_t> recorded_delta_histogram_sum_; 63 std::map<std::string, int64_t> recorded_delta_histogram_sum_;
64 64
65 DISALLOW_COPY_AND_ASSIGN(HistogramFlattenerDeltaRecorder); 65 DISALLOW_COPY_AND_ASSIGN(HistogramFlattenerDeltaRecorder);
66 }; 66 };
67 67
68 class HistogramSnapshotManagerTest : public testing::Test { 68 class HistogramSnapshotManagerTest : public testing::Test {
69 protected: 69 protected:
70 HistogramSnapshotManagerTest() 70 HistogramSnapshotManagerTest()
71 : histogram_snapshot_manager_(&histogram_flattener_delta_recorder_) {} 71 : statistics_recorder_(StatisticsRecorder::CreateTemporaryForTesting()),
72 histogram_snapshot_manager_(&histogram_flattener_delta_recorder_) {}
72 73
73 ~HistogramSnapshotManagerTest() override {} 74 ~HistogramSnapshotManagerTest() override {}
74 75
75 StatisticsRecorder statistics_recorder_; 76 std::unique_ptr<StatisticsRecorder> statistics_recorder_;
76 HistogramFlattenerDeltaRecorder histogram_flattener_delta_recorder_; 77 HistogramFlattenerDeltaRecorder histogram_flattener_delta_recorder_;
77 HistogramSnapshotManager histogram_snapshot_manager_; 78 HistogramSnapshotManager histogram_snapshot_manager_;
78 }; 79 };
79 80
80 TEST_F(HistogramSnapshotManagerTest, PrepareDeltasNoFlagsFilter) { 81 TEST_F(HistogramSnapshotManagerTest, PrepareDeltasNoFlagsFilter) {
81 // kNoFlags filter should record all histograms. 82 // kNoFlags filter should record all histograms.
82 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 4); 83 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 4);
83 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2); 84 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2);
84 85
85 histogram_snapshot_manager_.PrepareDeltas( 86 histogram_snapshot_manager_.PrepareDeltas(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames(); 150 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames();
150 EXPECT_EQ(2U, histograms.size()); 151 EXPECT_EQ(2U, histograms.size());
151 EXPECT_EQ(3, histogram_flattener_delta_recorder_. 152 EXPECT_EQ(3, histogram_flattener_delta_recorder_.
152 GetRecordedDeltaHistogramSum("UmaHistogram")); 153 GetRecordedDeltaHistogramSum("UmaHistogram"));
153 EXPECT_EQ(2, histogram_flattener_delta_recorder_. 154 EXPECT_EQ(2, histogram_flattener_delta_recorder_.
154 GetRecordedDeltaHistogramSum("UmaStabilityHistogram")); 155 GetRecordedDeltaHistogramSum("UmaStabilityHistogram"));
155 } 156 }
156 } 157 }
157 158
158 } // namespace base 159 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram_delta_serialization_unittest.cc ('k') | base/metrics/histogram_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698