Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: base/test/histogram_tester_unittest.cc

Issue 2354363002: Call StatisticsRecorder::Initialize in GlobalHistogramAllocator's ctor (Closed)
Patch Set: hack3 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 7 #include <memory>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 //#include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 using ::testing::ElementsAre; 14 //using ::testing::ElementsAre;
15 using ::testing::IsEmpty; 15 //using ::testing::IsEmpty;
16 16
17 namespace { 17 namespace {
18 18
19 const char kHistogram1[] = "Test1"; 19 const char kHistogram1[] = "Test1";
20 const char kHistogram2[] = "Test2"; 20 const char kHistogram2[] = "Test2";
21 const char kHistogram3[] = "Test3"; 21 const char kHistogram3[] = "Test3";
22 const char kHistogram4[] = "Test4"; 22 const char kHistogram4[] = "Test4";
23 #if 0
23 const char kHistogram5[] = "Test5"; 24 const char kHistogram5[] = "Test5";
25 #endif
24 26
25 } // namespace 27 } // namespace
26 28
27 namespace base { 29 namespace base {
28 30
29 typedef testing::Test HistogramTesterTest; 31 typedef testing::Test HistogramTesterTest;
30 32
31 TEST_F(HistogramTesterTest, Scope) { 33 TEST_F(HistogramTesterTest, Scope) {
32 // Record a histogram before the creation of the recorder. 34 // Record a histogram before the creation of the recorder.
33 UMA_HISTOGRAM_BOOLEAN(kHistogram1, true); 35 UMA_HISTOGRAM_BOOLEAN(kHistogram1, true);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 96
95 HistogramTester tester; 97 HistogramTester tester;
96 UMA_HISTOGRAM_COUNTS_100(kHistogram4, 3); 98 UMA_HISTOGRAM_COUNTS_100(kHistogram4, 3);
97 99
98 tester.ExpectBucketCount(kHistogram4, 2, 0); 100 tester.ExpectBucketCount(kHistogram4, 2, 0);
99 tester.ExpectBucketCount(kHistogram4, 3, 1); 101 tester.ExpectBucketCount(kHistogram4, 3, 1);
100 102
101 tester.ExpectTotalCount(kHistogram4, 1); 103 tester.ExpectTotalCount(kHistogram4, 1);
102 } 104 }
103 105
106 #if 0
104 TEST_F(HistogramTesterTest, TestGetAllSamples) { 107 TEST_F(HistogramTesterTest, TestGetAllSamples) {
105 HistogramTester tester; 108 HistogramTester tester;
106 UMA_HISTOGRAM_ENUMERATION(kHistogram5, 2, 5); 109 UMA_HISTOGRAM_ENUMERATION(kHistogram5, 2, 5);
107 UMA_HISTOGRAM_ENUMERATION(kHistogram5, 3, 5); 110 UMA_HISTOGRAM_ENUMERATION(kHistogram5, 3, 5);
108 UMA_HISTOGRAM_ENUMERATION(kHistogram5, 3, 5); 111 UMA_HISTOGRAM_ENUMERATION(kHistogram5, 3, 5);
109 UMA_HISTOGRAM_ENUMERATION(kHistogram5, 5, 5); 112 UMA_HISTOGRAM_ENUMERATION(kHistogram5, 5, 5);
110 113
111 EXPECT_THAT(tester.GetAllSamples(kHistogram5), 114 EXPECT_THAT(tester.GetAllSamples(kHistogram5),
112 ElementsAre(Bucket(2, 1), Bucket(3, 2), Bucket(5, 1))); 115 ElementsAre(Bucket(2, 1), Bucket(3, 2), Bucket(5, 1)));
113 } 116 }
114 117
115 TEST_F(HistogramTesterTest, TestGetAllSamples_NoSamples) { 118 TEST_F(HistogramTesterTest, TestGetAllSamples_NoSamples) {
116 HistogramTester tester; 119 HistogramTester tester;
117 EXPECT_THAT(tester.GetAllSamples(kHistogram5), IsEmpty()); 120 EXPECT_THAT(tester.GetAllSamples(kHistogram5), IsEmpty());
118 } 121 }
122 #endif
119 123
120 } // namespace base 124 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698