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

Unified Diff: base/metrics/statistics_recorder_unittest.cc

Issue 1425533011: Support "shared" histograms between processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: added a couple tests (and fixed related issues) Created 5 years, 1 month 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
Index: base/metrics/statistics_recorder_unittest.cc
diff --git a/base/metrics/statistics_recorder_unittest.cc b/base/metrics/statistics_recorder_unittest.cc
index 29caf49110d9c799a944f587a055a7b23b7da2c4..5c457d103916183773098b0af52aac24bcb394e6 100644
--- a/base/metrics/statistics_recorder_unittest.cc
+++ b/base/metrics/statistics_recorder_unittest.cc
@@ -23,7 +23,10 @@ class StatisticsRecorderTest : public testing::Test {
InitializeStatisticsRecorder();
}
- void TearDown() override { UninitializeStatisticsRecorder(); }
+ void TearDown() override {
+ UninitializeStatisticsRecorder();
+ HistogramBase::SetDefaultPersistentMemoryAllocator(nullptr);
+ }
void InitializeStatisticsRecorder() {
statistics_recorder_ = new StatisticsRecorder();
@@ -313,6 +316,23 @@ TEST_F(StatisticsRecorderTest, ToJSON) {
EXPECT_TRUE(json.empty());
}
+TEST_F(StatisticsRecorderTest, IterationTest) {
+ StatisticsRecorder::Histograms registered_histograms;
+ LOCAL_HISTOGRAM_COUNTS("TestHistogram.IterationTest1", 30);
+ HistogramBase::SetDefaultPersistentMemoryAllocator(
+ new LocalPersistentMemoryAllocator(64 << 10, std::string()));
+ LOCAL_HISTOGRAM_COUNTS("TestHistogram.IterationTest2", 30);
+
+ StatisticsRecorder::HistogramIterator i1 = StatisticsRecorder::begin(true);
+ EXPECT_NE(StatisticsRecorder::end(), i1);
+ EXPECT_NE(StatisticsRecorder::end(), ++i1);
+ EXPECT_EQ(StatisticsRecorder::end(), ++i1);
+
+ StatisticsRecorder::HistogramIterator i2 = StatisticsRecorder::begin(false);
+ EXPECT_NE(StatisticsRecorder::end(), i2);
+ EXPECT_EQ(StatisticsRecorder::end(), ++i2);
+}
+
namespace {
// CallbackCheckWrapper is simply a convenient way to check and store that

Powered by Google App Engine
This is Rietveld 408576698