| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/metrics/histogram_functions.h" | 5 #include "base/metrics/histogram_functions.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 TEST(HistogramFunctionsTest, HistogramEnumeration) { | 40 TEST(HistogramFunctionsTest, HistogramEnumeration) { |
| 41 std::string histogram("Testing.UMA.HistogramEnumeration"); | 41 std::string histogram("Testing.UMA.HistogramEnumeration"); |
| 42 HistogramTester tester; | 42 HistogramTester tester; |
| 43 UmaHistogramEnumeration(histogram, UMA_HISTOGRAM_TESTING_ENUM_FIRST, | 43 UmaHistogramEnumeration(histogram, UMA_HISTOGRAM_TESTING_ENUM_FIRST, |
| 44 UMA_HISTOGRAM_TESTING_ENUM_THIRD); | 44 UMA_HISTOGRAM_TESTING_ENUM_THIRD); |
| 45 tester.ExpectUniqueSample(histogram, UMA_HISTOGRAM_TESTING_ENUM_FIRST, 1); | 45 tester.ExpectUniqueSample(histogram, UMA_HISTOGRAM_TESTING_ENUM_FIRST, 1); |
| 46 | 46 |
| 47 // Verify the overflow & underflow bucket exists. | 47 // Verify the overflow & underflow bucket exists. |
| 48 UMA_HISTOGRAM_ENUMERATION( | 48 UMA_HISTOGRAM_ENUMERATION( |
| 49 histogram, static_cast<int>(UMA_HISTOGRAM_TESTING_ENUM_THIRD) + 10, | 49 histogram, static_cast<int>(UMA_HISTOGRAM_TESTING_ENUM_THIRD) + 10, |
| 50 UMA_HISTOGRAM_TESTING_ENUM_THIRD); | 50 static_cast<int>(UMA_HISTOGRAM_TESTING_ENUM_THIRD)); |
| 51 tester.ExpectBucketCount( | 51 tester.ExpectBucketCount( |
| 52 histogram, static_cast<int>(UMA_HISTOGRAM_TESTING_ENUM_THIRD) + 1, 1); | 52 histogram, static_cast<int>(UMA_HISTOGRAM_TESTING_ENUM_THIRD) + 1, 1); |
| 53 tester.ExpectTotalCount(histogram, 2); | 53 tester.ExpectTotalCount(histogram, 2); |
| 54 } | 54 } |
| 55 | 55 |
| 56 TEST(HistogramFunctionsTest, HistogramBoolean) { | 56 TEST(HistogramFunctionsTest, HistogramBoolean) { |
| 57 std::string histogram("Testing.UMA.HistogramBoolean"); | 57 std::string histogram("Testing.UMA.HistogramBoolean"); |
| 58 HistogramTester tester; | 58 HistogramTester tester; |
| 59 UmaHistogramBoolean(histogram, true); | 59 UmaHistogramBoolean(histogram, true); |
| 60 tester.ExpectUniqueSample(histogram, 1, 1); | 60 tester.ExpectUniqueSample(histogram, 1, 1); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 tester.ExpectTotalCount(histogram, 2); | 100 tester.ExpectTotalCount(histogram, 2); |
| 101 UmaHistogramTimes(histogram, TimeDelta::FromSeconds(10)); // Overflows | 101 UmaHistogramTimes(histogram, TimeDelta::FromSeconds(10)); // Overflows |
| 102 tester.ExpectTimeBucketCount(histogram, TimeDelta::FromSeconds(10), 1); | 102 tester.ExpectTimeBucketCount(histogram, TimeDelta::FromSeconds(10), 1); |
| 103 UmaHistogramTimes(histogram, TimeDelta::FromSeconds(20)); // Overflows. | 103 UmaHistogramTimes(histogram, TimeDelta::FromSeconds(20)); // Overflows. |
| 104 // Check the value by picking any overflow time. | 104 // Check the value by picking any overflow time. |
| 105 tester.ExpectTimeBucketCount(histogram, TimeDelta::FromSeconds(11), 2); | 105 tester.ExpectTimeBucketCount(histogram, TimeDelta::FromSeconds(11), 2); |
| 106 tester.ExpectTotalCount(histogram, 4); | 106 tester.ExpectTotalCount(histogram, 4); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace base. | 109 } // namespace base. |
| OLD | NEW |