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

Side by Side Diff: base/metrics/histogram_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/histogram.h" 5 #include "base/metrics/histogram.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 if (allocator_) { 49 if (allocator_) {
50 ASSERT_FALSE(allocator_->IsFull()); 50 ASSERT_FALSE(allocator_->IsFull());
51 ASSERT_FALSE(allocator_->IsCorrupt()); 51 ASSERT_FALSE(allocator_->IsCorrupt());
52 } 52 }
53 UninitializeStatisticsRecorder(); 53 UninitializeStatisticsRecorder();
54 DestroyPersistentHistogramAllocator(); 54 DestroyPersistentHistogramAllocator();
55 } 55 }
56 56
57 void InitializeStatisticsRecorder() { 57 void InitializeStatisticsRecorder() {
58 DCHECK(!statistics_recorder_); 58 DCHECK(!statistics_recorder_);
59 statistics_recorder_.reset(new StatisticsRecorder()); 59 statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting();
60 } 60 }
61 61
62 void UninitializeStatisticsRecorder() { 62 void UninitializeStatisticsRecorder() {
63 statistics_recorder_.reset(); 63 statistics_recorder_.reset();
64 } 64 }
65 65
66 void CreatePersistentHistogramAllocator() { 66 void CreatePersistentHistogramAllocator() {
67 // By getting the results-histogram before any persistent allocator 67 // By getting the results-histogram before any persistent allocator
68 // is attached, that histogram is guaranteed not to be stored in 68 // is attached, that histogram is guaranteed not to be stored in
69 // any persistent memory segment (which simplifies some tests). 69 // any persistent memory segment (which simplifies some tests).
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 // CustomHistogram needs at least 1 valid range. 742 // CustomHistogram needs at least 1 valid range.
743 custom_ranges.clear(); 743 custom_ranges.clear();
744 custom_ranges.push_back(0); 744 custom_ranges.push_back(0);
745 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, 745 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges,
746 HistogramBase::kNoFlags), 746 HistogramBase::kNoFlags),
747 ""); 747 "");
748 } 748 }
749 #endif 749 #endif
750 750
751 } // namespace base 751 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram_snapshot_manager_unittest.cc ('k') | base/metrics/persistent_histogram_allocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698