| 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" |
| 11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
| 12 #include "base/metrics/statistics_recorder.h" | 12 #include "base/metrics/statistics_recorder.h" |
| 13 #include "base/pickle.h" | 13 #include "base/pickle.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 | 18 |
| 19 class SparseHistogramTest : public testing::Test { | 19 class SparseHistogramTest : public testing::Test { |
| 20 protected: | 20 protected: |
| 21 virtual void SetUp() { | 21 void SetUp() override { |
| 22 // Each test will have a clean state (no Histogram / BucketRanges | 22 // Each test will have a clean state (no Histogram / BucketRanges |
| 23 // registered). | 23 // registered). |
| 24 InitializeStatisticsRecorder(); | 24 InitializeStatisticsRecorder(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 virtual void TearDown() { | 27 void TearDown() override { UninitializeStatisticsRecorder(); } |
| 28 UninitializeStatisticsRecorder(); | |
| 29 } | |
| 30 | 28 |
| 31 void InitializeStatisticsRecorder() { | 29 void InitializeStatisticsRecorder() { |
| 32 statistics_recorder_ = new StatisticsRecorder(); | 30 statistics_recorder_ = new StatisticsRecorder(); |
| 33 } | 31 } |
| 34 | 32 |
| 35 void UninitializeStatisticsRecorder() { | 33 void UninitializeStatisticsRecorder() { |
| 36 delete statistics_recorder_; | 34 delete statistics_recorder_; |
| 37 statistics_recorder_ = NULL; | 35 statistics_recorder_ = NULL; |
| 38 } | 36 } |
| 39 | 37 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 120 |
| 123 int flag; | 121 int flag; |
| 124 EXPECT_TRUE(iter.ReadInt(&flag)); | 122 EXPECT_TRUE(iter.ReadInt(&flag)); |
| 125 EXPECT_EQ(HistogramBase::kIPCSerializationSourceFlag, flag); | 123 EXPECT_EQ(HistogramBase::kIPCSerializationSourceFlag, flag); |
| 126 | 124 |
| 127 // No more data in the pickle. | 125 // No more data in the pickle. |
| 128 EXPECT_FALSE(iter.SkipBytes(1)); | 126 EXPECT_FALSE(iter.SkipBytes(1)); |
| 129 } | 127 } |
| 130 | 128 |
| 131 } // namespace base | 129 } // namespace base |
| OLD | NEW |