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 <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" |
11 #include "base/pickle.h" | 11 #include "base/pickle.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 class HistogramBaseTest : public testing::Test { | 16 class HistogramBaseTest : public testing::Test { |
17 protected: | 17 protected: |
18 HistogramBaseTest() { | 18 HistogramBaseTest() { |
19 // Each test will have a clean state (no Histogram / BucketRanges | 19 // Each test will have a clean state (no Histogram / BucketRanges |
20 // registered). | 20 // registered). |
21 statistics_recorder_ = NULL; | 21 statistics_recorder_ = NULL; |
22 ResetStatisticsRecorder(); | 22 ResetStatisticsRecorder(); |
23 } | 23 } |
24 | 24 |
25 virtual ~HistogramBaseTest() { | 25 ~HistogramBaseTest() override { delete statistics_recorder_; } |
26 delete statistics_recorder_; | |
27 } | |
28 | 26 |
29 void ResetStatisticsRecorder() { | 27 void ResetStatisticsRecorder() { |
30 delete statistics_recorder_; | 28 delete statistics_recorder_; |
31 statistics_recorder_ = new StatisticsRecorder(); | 29 statistics_recorder_ = new StatisticsRecorder(); |
32 } | 30 } |
33 | 31 |
34 private: | 32 private: |
35 StatisticsRecorder* statistics_recorder_; | 33 StatisticsRecorder* statistics_recorder_; |
36 }; | 34 }; |
37 | 35 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 146 |
149 PickleIterator iter2(pickle); | 147 PickleIterator iter2(pickle); |
150 deserialized = DeserializeHistogramInfo(&iter2); | 148 deserialized = DeserializeHistogramInfo(&iter2); |
151 EXPECT_TRUE(deserialized); | 149 EXPECT_TRUE(deserialized); |
152 EXPECT_NE(histogram, deserialized); | 150 EXPECT_NE(histogram, deserialized); |
153 EXPECT_EQ("TestHistogram", deserialized->histogram_name()); | 151 EXPECT_EQ("TestHistogram", deserialized->histogram_name()); |
154 EXPECT_EQ(0, deserialized->flags()); | 152 EXPECT_EQ(0, deserialized->flags()); |
155 } | 153 } |
156 | 154 |
157 } // namespace base | 155 } // namespace base |
OLD | NEW |