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

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

Issue 18337014: Add a HistogramRecorder class and use cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "base/metrics/histogram.h"
7 #include "base/metrics/histogram_samples.h"
8 #include "base/test/histogram_recorder.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace base {
12
13 class HistogramRecorderTest : public testing::Test {};
14
15 TEST_F(HistogramRecorderTest, Scope) {
16 // Send a histogram before the creation of the recorder.
17 UMA_HISTOGRAM_BOOLEAN("Test", true);
18
19 HistogramRecorder recorder;
20
21 // Verify that no histogram is recorded.
22 EXPECT_FALSE(recorder.GetHistogramSamplesSinceCreation("Test"));
23
24 // Send a histogram after the creation of the recorder.
25 UMA_HISTOGRAM_BOOLEAN("Test", true);
26
27 // Verify that one histogram is recorded.
28 scoped_ptr<HistogramSamples> samples(
29 recorder.GetHistogramSamplesSinceCreation("Test"));
30 EXPECT_TRUE(samples);
31 EXPECT_EQ(1, samples->TotalCount());
32 }
33
34 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698