Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 public: | |
| 15 static void SetUpTestCase() { | |
| 16 HistogramRecorder::Initialize(); | |
| 17 } | |
|
ppi
2013/12/23 16:37:48
I'm afraid we have to follow suit of existing unit
lpromero
2013/12/23 17:22:54
Done.
| |
| 18 }; | |
| 19 | |
| 20 TEST_F(HistogramRecorderTest, Scope) { | |
| 21 // Record a histogram before the creation of the recorder. | |
| 22 UMA_HISTOGRAM_BOOLEAN("Test", true); | |
| 23 | |
| 24 HistogramRecorder recorder; | |
| 25 | |
| 26 // Verify that no histogram is recorded. | |
| 27 scoped_ptr<HistogramSamples> samples( | |
| 28 recorder.GetHistogramSamplesSinceCreation("Test")); | |
| 29 EXPECT_TRUE(samples); | |
| 30 EXPECT_EQ(0, samples->TotalCount()); | |
| 31 | |
| 32 // Record a histogram after the creation of the recorder. | |
| 33 UMA_HISTOGRAM_BOOLEAN("Test", true); | |
| 34 | |
| 35 // Verify that one histogram is recorded. | |
| 36 samples = recorder.GetHistogramSamplesSinceCreation("Test"); | |
| 37 EXPECT_TRUE(samples); | |
| 38 EXPECT_EQ(1, samples->TotalCount()); | |
| 39 } | |
| 40 | |
| 41 } // namespace base | |
| OLD | NEW |