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.
5 #include "base/test/statistics_delta_reader.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/histogram.h"
9 #include "base/metrics/histogram_samples.h"
10 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(StatisticsDeltaReaderTest
, Scope
) {
15 // Record a histogram before the creation of the recorder.
16 UMA_HISTOGRAM_BOOLEAN("Test", true);
18 StatisticsDeltaReader reader
;
20 // Verify that no histogram is recorded.
21 scoped_ptr
<HistogramSamples
> samples(
22 reader
.GetHistogramSamplesSinceCreation("Test"));
23 EXPECT_FALSE(samples
);
25 // Record a histogram after the creation of the recorder.
26 UMA_HISTOGRAM_BOOLEAN("Test", true);
28 // Verify that one histogram is recorded.
29 samples
= reader
.GetHistogramSamplesSinceCreation("Test");
31 EXPECT_EQ(1, samples
->TotalCount());