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

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

Issue 1485763002: Merge multiple histogram snapshots into single one for reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: added merge test Created 5 years 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/metrics/histogram_delta_serialization.h" 10 #include "base/metrics/histogram_delta_serialization.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 histogram_snapshot_manager_.PrepareDeltas( 98 histogram_snapshot_manager_.PrepareDeltas(
99 StatisticsRecorder::begin(false), StatisticsRecorder::end(), 99 StatisticsRecorder::begin(false), StatisticsRecorder::end(),
100 HistogramBase::kNoFlags, HistogramBase::kUmaStabilityHistogramFlag); 100 HistogramBase::kNoFlags, HistogramBase::kUmaStabilityHistogramFlag);
101 101
102 const std::vector<std::string>& histograms = 102 const std::vector<std::string>& histograms =
103 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames(); 103 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames();
104 EXPECT_EQ(1U, histograms.size()); 104 EXPECT_EQ(1U, histograms.size());
105 EXPECT_EQ("UmaStabilityHistogram", histograms[0]); 105 EXPECT_EQ("UmaStabilityHistogram", histograms[0]);
106 } 106 }
107 107
108 TEST_F(HistogramSnapshotManagerTest, CheckMerge) {
109 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2);
110 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2);
111
112 base::HistogramBase* h1 = base::LinearHistogram::FactoryGet(
113 "UmaHistogram", 1, 2, 3, 0);
114 EXPECT_TRUE(h1);
115 base::HistogramBase* h2 = base::LinearHistogram::FactoryGet(
116 "UmaStabilityHistogram", 1, 2, 3, 0);
117 EXPECT_TRUE(h1);
118
119 histogram_snapshot_manager_.StartDeltas();
120 histogram_snapshot_manager_.PrepareDelta(h1);
121 histogram_snapshot_manager_.PrepareDelta(h1);
122 histogram_snapshot_manager_.PrepareDelta(h2);
123 histogram_snapshot_manager_.PrepareDelta(h2);
124 histogram_snapshot_manager_.PrepareDelta(h1);
125 histogram_snapshot_manager_.FinishDeltas();
126
127 const std::vector<std::string>& histograms =
128 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames();
129 EXPECT_EQ(2U, histograms.size());
130 }
131
108 } // namespace base 132 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698