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

Side by Side Diff: base/metrics/statistics_recorder_unittest.cc

Issue 2036643004: Create ForTesting method rather than declaring a dozen "friend" classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/statistics_recorder.h" 5 #include "base/metrics/statistics_recorder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 ~StatisticsRecorderTest() override { 42 ~StatisticsRecorderTest() override {
43 GlobalHistogramAllocator::ReleaseForTesting(); 43 GlobalHistogramAllocator::ReleaseForTesting();
44 UninitializeStatisticsRecorder(); 44 UninitializeStatisticsRecorder();
45 } 45 }
46 46
47 void InitializeStatisticsRecorder() { 47 void InitializeStatisticsRecorder() {
48 DCHECK(!statistics_recorder_); 48 DCHECK(!statistics_recorder_);
49 StatisticsRecorder::UninitializeForTesting(); 49 StatisticsRecorder::UninitializeForTesting();
50 statistics_recorder_.reset(new StatisticsRecorder()); 50 statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting();
51 } 51 }
52 52
53 void UninitializeStatisticsRecorder() { 53 void UninitializeStatisticsRecorder() {
54 statistics_recorder_.reset(); 54 statistics_recorder_.reset();
55 StatisticsRecorder::UninitializeForTesting(); 55 StatisticsRecorder::UninitializeForTesting();
56 } 56 }
57 57
58 Histogram* CreateHistogram(const std::string& name, 58 Histogram* CreateHistogram(const std::string& name,
59 HistogramBase::Sample min, 59 HistogramBase::Sample min,
60 HistogramBase::Sample max, 60 HistogramBase::Sample max,
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 HistogramBase* histogram = Histogram::FactoryGet("TestHistogram", 1, 1000, 10, 586 HistogramBase* histogram = Histogram::FactoryGet("TestHistogram", 1, 1000, 10,
587 HistogramBase::kNoFlags); 587 HistogramBase::kNoFlags);
588 EXPECT_TRUE(histogram); 588 EXPECT_TRUE(histogram);
589 histogram->Add(1); 589 histogram->Add(1);
590 590
591 EXPECT_TRUE(callback_wrapper.called); 591 EXPECT_TRUE(callback_wrapper.called);
592 EXPECT_EQ(callback_wrapper.last_histogram_value, 1); 592 EXPECT_EQ(callback_wrapper.last_histogram_value, 1);
593 } 593 }
594 594
595 } // namespace base 595 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/statistics_recorder.cc ('k') | chrome/browser/metrics/subprocess_metrics_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698