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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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/test/histogram_tester.cc ('k') | base/test/launcher/test_launcher.h » ('j') | 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 "base/memory/scoped_ptr.h" 7 #include <memory>
8
8 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
9 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using ::testing::ElementsAre; 14 using ::testing::ElementsAre;
14 using ::testing::IsEmpty; 15 using ::testing::IsEmpty;
15 16
16 namespace { 17 namespace {
17 18
(...skipping 15 matching lines...) Expand all
33 34
34 HistogramTester tester; 35 HistogramTester tester;
35 36
36 // Verify that no histogram is recorded. 37 // Verify that no histogram is recorded.
37 tester.ExpectTotalCount(kHistogram1, 0); 38 tester.ExpectTotalCount(kHistogram1, 0);
38 39
39 // Record a histogram after the creation of the recorder. 40 // Record a histogram after the creation of the recorder.
40 UMA_HISTOGRAM_BOOLEAN(kHistogram1, true); 41 UMA_HISTOGRAM_BOOLEAN(kHistogram1, true);
41 42
42 // Verify that one histogram is recorded. 43 // Verify that one histogram is recorded.
43 scoped_ptr<HistogramSamples> samples( 44 std::unique_ptr<HistogramSamples> samples(
44 tester.GetHistogramSamplesSinceCreation(kHistogram1)); 45 tester.GetHistogramSamplesSinceCreation(kHistogram1));
45 EXPECT_TRUE(samples); 46 EXPECT_TRUE(samples);
46 EXPECT_EQ(1, samples->TotalCount()); 47 EXPECT_EQ(1, samples->TotalCount());
47 } 48 }
48 49
49 TEST_F(HistogramTesterTest, GetHistogramSamplesSinceCreationNotNull) { 50 TEST_F(HistogramTesterTest, GetHistogramSamplesSinceCreationNotNull) {
50 // Chose the histogram name uniquely, to ensure nothing was recorded for it so 51 // Chose the histogram name uniquely, to ensure nothing was recorded for it so
51 // far. 52 // far.
52 static const char kHistogram[] = 53 static const char kHistogram[] =
53 "GetHistogramSamplesSinceCreationNotNullHistogram"; 54 "GetHistogramSamplesSinceCreationNotNullHistogram";
54 HistogramTester tester; 55 HistogramTester tester;
55 56
56 // Verify that the returned samples are empty but not null. 57 // Verify that the returned samples are empty but not null.
57 scoped_ptr<HistogramSamples> samples( 58 std::unique_ptr<HistogramSamples> samples(
58 tester.GetHistogramSamplesSinceCreation(kHistogram1)); 59 tester.GetHistogramSamplesSinceCreation(kHistogram1));
59 EXPECT_TRUE(samples); 60 EXPECT_TRUE(samples);
60 tester.ExpectTotalCount(kHistogram, 0); 61 tester.ExpectTotalCount(kHistogram, 0);
61 } 62 }
62 63
63 TEST_F(HistogramTesterTest, TestUniqueSample) { 64 TEST_F(HistogramTesterTest, TestUniqueSample) {
64 HistogramTester tester; 65 HistogramTester tester;
65 66
66 // Record into a sample thrice 67 // Record into a sample thrice
67 UMA_HISTOGRAM_COUNTS_100(kHistogram2, 2); 68 UMA_HISTOGRAM_COUNTS_100(kHistogram2, 2);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 EXPECT_THAT(tester.GetAllSamples(kHistogram5), 111 EXPECT_THAT(tester.GetAllSamples(kHistogram5),
111 ElementsAre(Bucket(2, 1), Bucket(3, 2), Bucket(5, 1))); 112 ElementsAre(Bucket(2, 1), Bucket(3, 2), Bucket(5, 1)));
112 } 113 }
113 114
114 TEST_F(HistogramTesterTest, TestGetAllSamples_NoSamples) { 115 TEST_F(HistogramTesterTest, TestGetAllSamples_NoSamples) {
115 HistogramTester tester; 116 HistogramTester tester;
116 EXPECT_THAT(tester.GetAllSamples(kHistogram5), IsEmpty()); 117 EXPECT_THAT(tester.GetAllSamples(kHistogram5), IsEmpty());
117 } 118 }
118 119
119 } // namespace base 120 } // namespace base
OLDNEW
« no previous file with comments | « base/test/histogram_tester.cc ('k') | base/test/launcher/test_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698