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

Unified Diff: base/metrics/statistics_recorder_unittest.cc

Issue 1779503002: Fix StatisticsRecorder to handle re-entry during tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 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/statistics_recorder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/statistics_recorder_unittest.cc
diff --git a/base/metrics/statistics_recorder_unittest.cc b/base/metrics/statistics_recorder_unittest.cc
index 6be7d5bb881a893791f45c83e8ff552ffa69d452..bed1cd9f60727af1d56acfa1a3416beb1cbfee66 100644
--- a/base/metrics/statistics_recorder_unittest.cc
+++ b/base/metrics/statistics_recorder_unittest.cc
@@ -36,12 +36,13 @@ class StatisticsRecorderTest : public testing::Test {
}
void InitializeStatisticsRecorder() {
- statistics_recorder_ = new StatisticsRecorder();
+ DCHECK(!statistics_recorder_);
+ StatisticsRecorder::UninitializeForTesting();
+ statistics_recorder_.reset(new StatisticsRecorder());
}
void UninitializeStatisticsRecorder() {
- delete statistics_recorder_;
- statistics_recorder_ = NULL;
+ statistics_recorder_.reset();
}
Histogram* CreateHistogram(const std::string& name,
@@ -59,11 +60,12 @@ class StatisticsRecorderTest : public testing::Test {
delete histogram;
}
- StatisticsRecorder* statistics_recorder_;
+ std::unique_ptr<StatisticsRecorder> statistics_recorder_;
};
TEST_F(StatisticsRecorderTest, NotInitialized) {
UninitializeStatisticsRecorder();
+ StatisticsRecorder::UninitializeForTesting();
Alexei Svitkine (slow) 2016/04/08 15:04:19 Shouldn't this be part of UninitializeStatisticsRe
bcwhite 2016/04/08 16:06:33 It's not generally important since it's just a sta
ASSERT_FALSE(StatisticsRecorder::IsActive());
« no previous file with comments | « base/metrics/statistics_recorder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698