Remove connection_history.js from remoting's JS tests.
[chromium-blink-merge.git] / base / test / statistics_delta_reader_unittest.cc
blobacf8d5ad470c0bb1d5210483028f4c14660e8bd7
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/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"
12 namespace base {
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();
22 virtual void TearDown() OVERRIDE {
23 delete statistics_recorder_;
24 statistics_recorder_ = NULL;
27 StatisticsRecorder* statistics_recorder_;
30 TEST_F(StatisticsDeltaReaderTest, Scope) {
31 // Record a histogram before the creation of the recorder.
32 UMA_HISTOGRAM_BOOLEAN("Test", true);
34 StatisticsDeltaReader reader;
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());
42 // Record a histogram after the creation of the recorder.
43 UMA_HISTOGRAM_BOOLEAN("Test", true);
45 // Verify that one histogram is recorded.
46 samples = reader.GetHistogramSamplesSinceCreation("Test");
47 EXPECT_TRUE(samples);
48 EXPECT_EQ(1, samples->TotalCount());
51 } // namespace base