| 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 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 EXPECT_TRUE(linear_histogram); | 58 EXPECT_TRUE(linear_histogram); |
| 59 | 59 |
| 60 vector<int> custom_ranges; | 60 vector<int> custom_ranges; |
| 61 custom_ranges.push_back(1); | 61 custom_ranges.push_back(1); |
| 62 custom_ranges.push_back(5); | 62 custom_ranges.push_back(5); |
| 63 HistogramBase* custom_histogram = CustomHistogram::FactoryGet( | 63 HistogramBase* custom_histogram = CustomHistogram::FactoryGet( |
| 64 "TestCustomHistogram", custom_ranges, HistogramBase::kNoFlags); | 64 "TestCustomHistogram", custom_ranges, HistogramBase::kNoFlags); |
| 65 EXPECT_TRUE(custom_histogram); | 65 EXPECT_TRUE(custom_histogram); |
| 66 | 66 |
| 67 // Use standard macros (but with fixed samples) | 67 // Use standard macros (but with fixed samples) |
| 68 HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1)); | 68 LOCAL_HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1)); |
| 69 HISTOGRAM_COUNTS("Test3Histogram", 30); | 69 LOCAL_HISTOGRAM_COUNTS("Test3Histogram", 30); |
| 70 | 70 |
| 71 DHISTOGRAM_TIMES("Test4Histogram", TimeDelta::FromDays(1)); | 71 LOCAL_HISTOGRAM_ENUMERATION("Test6Histogram", 129, 130); |
| 72 DHISTOGRAM_COUNTS("Test5Histogram", 30); | |
| 73 | |
| 74 HISTOGRAM_ENUMERATION("Test6Histogram", 129, 130); | |
| 75 } | 72 } |
| 76 | 73 |
| 77 // Check that the macro correctly matches histograms by name and records their | 74 // Check that the macro correctly matches histograms by name and records their |
| 78 // data together. | 75 // data together. |
| 79 TEST_F(HistogramTest, NameMatchTest) { | 76 TEST_F(HistogramTest, NameMatchTest) { |
| 80 HISTOGRAM_PERCENTAGE("DuplicatedHistogram", 10); | 77 LOCAL_HISTOGRAM_PERCENTAGE("DuplicatedHistogram", 10); |
| 81 HISTOGRAM_PERCENTAGE("DuplicatedHistogram", 10); | 78 LOCAL_HISTOGRAM_PERCENTAGE("DuplicatedHistogram", 10); |
| 82 HistogramBase* histogram = LinearHistogram::FactoryGet( | 79 HistogramBase* histogram = LinearHistogram::FactoryGet( |
| 83 "DuplicatedHistogram", 1, 101, 102, HistogramBase::kNoFlags); | 80 "DuplicatedHistogram", 1, 101, 102, HistogramBase::kNoFlags); |
| 84 | 81 |
| 85 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); | 82 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); |
| 86 EXPECT_EQ(2, samples->TotalCount()); | 83 EXPECT_EQ(2, samples->TotalCount()); |
| 87 EXPECT_EQ(2, samples->GetCount(10)); | 84 EXPECT_EQ(2, samples->GetCount(10)); |
| 88 } | 85 } |
| 89 | 86 |
| 90 TEST_F(HistogramTest, ExponentialRangesTest) { | 87 TEST_F(HistogramTest, ExponentialRangesTest) { |
| 91 // Check that we got a nice exponential when there was enough rooom. | 88 // Check that we got a nice exponential when there was enough rooom. |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 // CustomHistogram needs at least 1 valid range. | 507 // CustomHistogram needs at least 1 valid range. |
| 511 custom_ranges.clear(); | 508 custom_ranges.clear(); |
| 512 custom_ranges.push_back(0); | 509 custom_ranges.push_back(0); |
| 513 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, | 510 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, |
| 514 HistogramBase::kNoFlags), | 511 HistogramBase::kNoFlags), |
| 515 ""); | 512 ""); |
| 516 } | 513 } |
| 517 #endif | 514 #endif |
| 518 | 515 |
| 519 } // namespace base | 516 } // namespace base |
| OLD | NEW |