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

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

Issue 120753002: Add a StatisticsDeltaReader class and use cases (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address isherman's feedback (and bump copyright year). Created 6 years, 11 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 2014 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/metrics/statistics_recorder.h"
9 #include "base/test/statistics_delta_reader.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace base {
13
14 class StatisticsDeltaReaderTest : public testing::Test {
15 protected:
16 virtual void SetUp() OVERRIDE {
17 // Each test will have a clean state (no Histogram / BucketRanges
18 // registered).
19 statistics_recorder_ = new StatisticsRecorder();
20 }
21
22 virtual void TearDown() OVERRIDE {
23 delete statistics_recorder_;
24 statistics_recorder_ = NULL;
25 }
26
27 StatisticsRecorder* statistics_recorder_;
28 };
29
30 TEST_F(StatisticsDeltaReaderTest, Scope) {
31 // Record a histogram before the creation of the recorder.
32 UMA_HISTOGRAM_BOOLEAN("Test", true);
33
34 StatisticsDeltaReader reader;
35
36 // Verify that no histogram is recorded.
37 scoped_ptr<HistogramSamples> samples(
38 reader.GetHistogramSamplesSinceCreation("Test"));
39 EXPECT_TRUE(samples);
40 EXPECT_EQ(0, samples->TotalCount());
41
42 // Record a histogram after the creation of the recorder.
43 UMA_HISTOGRAM_BOOLEAN("Test", true);
44
45 // Verify that one histogram is recorded.
46 samples = reader.GetHistogramSamplesSinceCreation("Test");
47 EXPECT_TRUE(samples);
48 EXPECT_EQ(1, samples->TotalCount());
49 }
50
51 } // namespace base
OLDNEW
« no previous file with comments | « base/test/statistics_delta_reader.cc ('k') | chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698