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 |
| 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 |
OLD | NEW |