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 // Test of Histogram class | 5 // Test of Histogram class |
6 | 6 |
7 #include <climits> | 7 #include <climits> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/bucket_ranges.h" | 13 #include "base/metrics/bucket_ranges.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/metrics/sample_vector.h" | 15 #include "base/metrics/sample_vector.h" |
16 #include "base/metrics/statistics_recorder.h" | 16 #include "base/metrics/statistics_recorder.h" |
17 #include "base/pickle.h" | 17 #include "base/pickle.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 using std::vector; | 21 using std::vector; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 | 24 |
25 class HistogramTest : public testing::Test { | 25 class HistogramTest : public testing::Test { |
26 protected: | 26 protected: |
27 virtual void SetUp() { | 27 void SetUp() override { |
28 // Each test will have a clean state (no Histogram / BucketRanges | 28 // Each test will have a clean state (no Histogram / BucketRanges |
29 // registered). | 29 // registered). |
30 InitializeStatisticsRecorder(); | 30 InitializeStatisticsRecorder(); |
31 } | 31 } |
32 | 32 |
33 virtual void TearDown() { | 33 void TearDown() override { UninitializeStatisticsRecorder(); } |
34 UninitializeStatisticsRecorder(); | |
35 } | |
36 | 34 |
37 void InitializeStatisticsRecorder() { | 35 void InitializeStatisticsRecorder() { |
38 statistics_recorder_ = new StatisticsRecorder(); | 36 statistics_recorder_ = new StatisticsRecorder(); |
39 } | 37 } |
40 | 38 |
41 void UninitializeStatisticsRecorder() { | 39 void UninitializeStatisticsRecorder() { |
42 delete statistics_recorder_; | 40 delete statistics_recorder_; |
43 statistics_recorder_ = NULL; | 41 statistics_recorder_ = NULL; |
44 } | 42 } |
45 | 43 |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // CustomHistogram needs at least 1 valid range. | 505 // CustomHistogram needs at least 1 valid range. |
508 custom_ranges.clear(); | 506 custom_ranges.clear(); |
509 custom_ranges.push_back(0); | 507 custom_ranges.push_back(0); |
510 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, | 508 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, |
511 HistogramBase::kNoFlags), | 509 HistogramBase::kNoFlags), |
512 ""); | 510 ""); |
513 } | 511 } |
514 #endif | 512 #endif |
515 | 513 |
516 } // namespace base | 514 } // namespace base |
OLD | NEW |