Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/histogram_tester.h" | 5 #include "base/test/histogram_tester.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/metrics/histogram_samples.h" | 9 #include "base/metrics/histogram_samples.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 | 14 |
| 15 using ::testing::ElementsAre; | |
| 16 | |
| 14 const std::string kHistogram1 = "Test1"; | 17 const std::string kHistogram1 = "Test1"; |
| 15 const std::string kHistogram2 = "Test2"; | 18 const std::string kHistogram2 = "Test2"; |
| 16 const std::string kHistogram3 = "Test3"; | 19 const std::string kHistogram3 = "Test3"; |
| 17 const std::string kHistogram4 = "Test4"; | 20 const std::string kHistogram4 = "Test4"; |
| 18 | 21 |
| 19 typedef testing::Test HistogramTesterTest; | 22 typedef testing::Test HistogramTesterTest; |
| 20 | 23 |
| 21 TEST_F(HistogramTesterTest, Scope) { | 24 TEST_F(HistogramTesterTest, Scope) { |
| 22 // Record a histogram before the creation of the recorder. | 25 // Record a histogram before the creation of the recorder. |
| 23 UMA_HISTOGRAM_BOOLEAN(kHistogram1, true); | 26 UMA_HISTOGRAM_BOOLEAN(kHistogram1, true); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 | 74 |
| 72 HistogramTester tester; | 75 HistogramTester tester; |
| 73 UMA_HISTOGRAM_COUNTS_100(kHistogram4, 3); | 76 UMA_HISTOGRAM_COUNTS_100(kHistogram4, 3); |
| 74 | 77 |
| 75 tester.ExpectBucketCount(kHistogram4, 2, 0); | 78 tester.ExpectBucketCount(kHistogram4, 2, 0); |
| 76 tester.ExpectBucketCount(kHistogram4, 3, 1); | 79 tester.ExpectBucketCount(kHistogram4, 3, 1); |
| 77 | 80 |
| 78 tester.ExpectTotalCount(kHistogram4, 1); | 81 tester.ExpectTotalCount(kHistogram4, 1); |
| 79 } | 82 } |
| 80 | 83 |
| 84 TEST_F(HistogramTesterTest, TestGetAllSamples) { | |
| 85 HistogramTester tester; | |
| 86 UMA_HISTOGRAM_COUNTS_100(kHistogram2, 2); | |
| 87 UMA_HISTOGRAM_COUNTS_100(kHistogram2, 3); | |
| 88 UMA_HISTOGRAM_COUNTS_100(kHistogram2, 3); | |
| 89 UMA_HISTOGRAM_COUNTS_100(kHistogram2, 5); | |
| 90 | |
| 91 EXPECT_THAT(tester.GetAllSamples(kHistogram2), | |
| 92 ElementsAre(std::make_pair(2, 1), std::make_pair(3, 2), | |
| 93 std::make_pair(5, 1))); | |
|
ncarter (slow)
2015/06/24 17:28:44
I patched this in and played around with it. I thi
twifkak
2015/06/25 20:21:38
Okay, sounds good!
Do you want me to implement Ge
| |
| 94 } | |
| 95 | |
| 81 } // namespace base | 96 } // namespace base |
| OLD | NEW |