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

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: moved Create-Result histogram to private space and added to histograms.xml Created 4 years, 11 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') | chrome/browser/chrome_browser_field_trials.cc » ('j') | 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 af5c1e7bbc316c2d8cb9b90cb8cac9805217ce07..3e19ec33d5bb051a756cf65631cbeb616c8d7ae9 100644
--- a/base/metrics/statistics_recorder_unittest.cc
+++ b/base/metrics/statistics_recorder_unittest.cc
@@ -10,6 +10,7 @@
#include "base/json/json_reader.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_macros.h"
+#include "base/metrics/histogram_persistence.h"
#include "base/metrics/sparse_histogram.h"
#include "base/metrics/statistics_recorder.h"
#include "base/values.h"
@@ -20,12 +21,18 @@ namespace base {
class StatisticsRecorderTest : public testing::Test {
protected:
void SetUp() override {
+ // Get this first so it never gets created in persistent storage and will
+ // not appear in the StatisticsRecorder after it is re-initialized.
+ GetCreateHistogramResultHistogram();
// Each test will have a clean state (no Histogram / BucketRanges
// registered).
InitializeStatisticsRecorder();
}
- void TearDown() override { UninitializeStatisticsRecorder(); }
+ void TearDown() override {
+ UninitializeStatisticsRecorder();
+ SetPersistentHistogramMemoryAllocator(nullptr);
+ }
void InitializeStatisticsRecorder() {
statistics_recorder_ = new StatisticsRecorder();
@@ -315,6 +322,23 @@ TEST_F(StatisticsRecorderTest, ToJSON) {
EXPECT_TRUE(json.empty());
}
+TEST_F(StatisticsRecorderTest, IterationTest) {
+ StatisticsRecorder::Histograms registered_histograms;
+ LOCAL_HISTOGRAM_COUNTS("TestHistogram.IterationTest1", 30);
+ SetPersistentHistogramMemoryAllocator(
+ new LocalPersistentMemoryAllocator(64 << 10, 0, 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
« no previous file with comments | « base/metrics/statistics_recorder.cc ('k') | chrome/browser/chrome_browser_field_trials.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698