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

Unified Diff: base/metrics/persistent_histogram_allocator_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/histogram_unittest.cc ('k') | base/metrics/sparse_histogram_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/persistent_histogram_allocator_unittest.cc
diff --git a/base/metrics/persistent_histogram_allocator_unittest.cc b/base/metrics/persistent_histogram_allocator_unittest.cc
index a8743d2a393032330cd59a2965bd5f36d8a40f11..eee6756f7412c802c9b645900b6d3d473761a5d4 100644
--- a/base/metrics/persistent_histogram_allocator_unittest.cc
+++ b/base/metrics/persistent_histogram_allocator_unittest.cc
@@ -18,7 +18,10 @@ class PersistentHistogramAllocatorTest : public testing::Test {
protected:
const int32_t kAllocatorMemorySize = 64 << 10; // 64 KiB
- PersistentHistogramAllocatorTest() { CreatePersistentHistogramAllocator(); }
+ PersistentHistogramAllocatorTest()
+ : statistics_recorder_(StatisticsRecorder::CreateTemporaryForTesting()) {
+ CreatePersistentHistogramAllocator();
+ }
~PersistentHistogramAllocatorTest() override {
DestroyPersistentHistogramAllocator();
}
@@ -40,11 +43,7 @@ class PersistentHistogramAllocatorTest : public testing::Test {
GlobalHistogramAllocator::ReleaseForTesting();
}
- std::unique_ptr<StatisticsRecorder> CreateLocalStatisticsRecorder() {
- return WrapUnique(new StatisticsRecorder());
- }
-
- StatisticsRecorder statistics_recorder_;
+ std::unique_ptr<StatisticsRecorder> statistics_recorder_;
std::unique_ptr<char[]> allocator_memory_;
PersistentMemoryAllocator* allocator_ = nullptr;
@@ -133,7 +132,7 @@ TEST_F(PersistentHistogramAllocatorTest, StatisticsRecorderTest) {
// Create a local StatisticsRecorder in which the newly created histogram
// will be recorded.
std::unique_ptr<StatisticsRecorder> local_sr =
- CreateLocalStatisticsRecorder();
+ StatisticsRecorder::CreateTemporaryForTesting();
EXPECT_EQ(0U, StatisticsRecorder::GetHistogramCount());
HistogramBase* histogram = LinearHistogram::FactoryGet(
« no previous file with comments | « base/metrics/histogram_unittest.cc ('k') | base/metrics/sparse_histogram_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698