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

Side by Side Diff: base/metrics/histogram_delta_serialization_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_delta_serialization.h" 5 #include "base/metrics/histogram_delta_serialization.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_base.h" 10 #include "base/metrics/histogram_base.h"
11 #include "base/metrics/statistics_recorder.h" 11 #include "base/metrics/statistics_recorder.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 TEST(HistogramDeltaSerializationTest, DeserializeHistogramAndAddSamples) { 16 TEST(HistogramDeltaSerializationTest, DeserializeHistogramAndAddSamples) {
17 StatisticsRecorder statistic_recorder; 17 std::unique_ptr<StatisticsRecorder> statistic_recorder(
18 StatisticsRecorder::CreateTemporaryForTesting());
18 HistogramDeltaSerialization serializer("HistogramDeltaSerializationTest"); 19 HistogramDeltaSerialization serializer("HistogramDeltaSerializationTest");
19 std::vector<std::string> deltas; 20 std::vector<std::string> deltas;
20 // Nothing was changed yet. 21 // Nothing was changed yet.
21 serializer.PrepareAndSerializeDeltas(&deltas, true); 22 serializer.PrepareAndSerializeDeltas(&deltas, true);
22 EXPECT_TRUE(deltas.empty()); 23 EXPECT_TRUE(deltas.empty());
23 24
24 HistogramBase* histogram = Histogram::FactoryGet( 25 HistogramBase* histogram = Histogram::FactoryGet(
25 "TestHistogram", 1, 1000, 10, HistogramBase::kIPCSerializationSourceFlag); 26 "TestHistogram", 1, 1000, 10, HistogramBase::kIPCSerializationSourceFlag);
26 histogram->Add(1); 27 histogram->Add(1);
27 histogram->Add(10); 28 histogram->Add(10);
(...skipping 17 matching lines...) Expand all
45 HistogramDeltaSerialization::DeserializeAndAddSamples(deltas); 46 HistogramDeltaSerialization::DeserializeAndAddSamples(deltas);
46 47
47 std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples()); 48 std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
48 EXPECT_EQ(2, snapshot2->GetCount(1)); 49 EXPECT_EQ(2, snapshot2->GetCount(1));
49 EXPECT_EQ(2, snapshot2->GetCount(10)); 50 EXPECT_EQ(2, snapshot2->GetCount(10));
50 EXPECT_EQ(2, snapshot2->GetCount(100)); 51 EXPECT_EQ(2, snapshot2->GetCount(100));
51 EXPECT_EQ(2, snapshot2->GetCount(1000)); 52 EXPECT_EQ(2, snapshot2->GetCount(1000));
52 } 53 }
53 54
54 } // namespace base 55 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram_base_unittest.cc ('k') | base/metrics/histogram_snapshot_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698