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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/metrics/histogram_base.h" | 8 #include "base/metrics/histogram_base.h" |
9 #include "base/metrics/histogram_samples.h" | 9 #include "base/metrics/histogram_samples.h" |
10 #include "base/metrics/sample_map.h" | 10 #include "base/metrics/sample_map.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 histogram->Add(100); | 58 histogram->Add(100); |
59 histogram->Add(101); | 59 histogram->Add(101); |
60 scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples()); | 60 scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples()); |
61 EXPECT_EQ(3, snapshot2->TotalCount()); | 61 EXPECT_EQ(3, snapshot2->TotalCount()); |
62 EXPECT_EQ(2, snapshot2->GetCount(100)); | 62 EXPECT_EQ(2, snapshot2->GetCount(100)); |
63 EXPECT_EQ(1, snapshot2->GetCount(101)); | 63 EXPECT_EQ(1, snapshot2->GetCount(101)); |
64 } | 64 } |
65 | 65 |
66 TEST_F(SparseHistogramTest, MacroBasicTest) { | 66 TEST_F(SparseHistogramTest, MacroBasicTest) { |
67 HISTOGRAM_SPARSE_SLOWLY("Sparse", 100); | 67 LOCAL_HISTOGRAM_SPARSE_SLOWLY("Sparse", 100); |
68 HISTOGRAM_SPARSE_SLOWLY("Sparse", 200); | 68 LOCAL_HISTOGRAM_SPARSE_SLOWLY("Sparse", 200); |
69 HISTOGRAM_SPARSE_SLOWLY("Sparse", 100); | 69 LOCAL_HISTOGRAM_SPARSE_SLOWLY("Sparse", 100); |
70 | 70 |
71 StatisticsRecorder::Histograms histograms; | 71 StatisticsRecorder::Histograms histograms; |
72 StatisticsRecorder::GetHistograms(&histograms); | 72 StatisticsRecorder::GetHistograms(&histograms); |
73 | 73 |
74 ASSERT_EQ(1U, histograms.size()); | 74 ASSERT_EQ(1U, histograms.size()); |
75 HistogramBase* sparse_histogram = histograms[0]; | 75 HistogramBase* sparse_histogram = histograms[0]; |
76 | 76 |
77 EXPECT_EQ(SPARSE_HISTOGRAM, sparse_histogram->GetHistogramType()); | 77 EXPECT_EQ(SPARSE_HISTOGRAM, sparse_histogram->GetHistogramType()); |
78 EXPECT_EQ("Sparse", sparse_histogram->histogram_name()); | 78 EXPECT_EQ("Sparse", sparse_histogram->histogram_name()); |
79 EXPECT_EQ(HistogramBase::kNoFlags, sparse_histogram->flags()); | 79 EXPECT_EQ(HistogramBase::kNoFlags, sparse_histogram->flags()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 int flag; | 136 int flag; |
137 EXPECT_TRUE(iter.ReadInt(&flag)); | 137 EXPECT_TRUE(iter.ReadInt(&flag)); |
138 EXPECT_EQ(HistogramBase::kIPCSerializationSourceFlag, flag); | 138 EXPECT_EQ(HistogramBase::kIPCSerializationSourceFlag, flag); |
139 | 139 |
140 // No more data in the pickle. | 140 // No more data in the pickle. |
141 EXPECT_FALSE(iter.SkipBytes(1)); | 141 EXPECT_FALSE(iter.SkipBytes(1)); |
142 } | 142 } |
143 | 143 |
144 } // namespace base | 144 } // namespace base |
OLD | NEW |