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

Side by Side Diff: base/metrics/statistics_recorder_unittest.cc

Issue 1780993002: Break global impact of PersistentHistogramAllocator into a separate class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-hp
Patch Set: fixed bad formatting from upstream scoped_ptr change 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/statistics_recorder.h" 5 #include "base/metrics/statistics_recorder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 14 matching lines...) Expand all
25 // Get this first so it never gets created in persistent storage and will 25 // Get this first so it never gets created in persistent storage and will
26 // not appear in the StatisticsRecorder after it is re-initialized. 26 // not appear in the StatisticsRecorder after it is re-initialized.
27 PersistentHistogramAllocator::GetCreateHistogramResultHistogram(); 27 PersistentHistogramAllocator::GetCreateHistogramResultHistogram();
28 // Each test will have a clean state (no Histogram / BucketRanges 28 // Each test will have a clean state (no Histogram / BucketRanges
29 // registered). 29 // registered).
30 InitializeStatisticsRecorder(); 30 InitializeStatisticsRecorder();
31 } 31 }
32 32
33 void TearDown() override { 33 void TearDown() override {
34 UninitializeStatisticsRecorder(); 34 UninitializeStatisticsRecorder();
35 PersistentHistogramAllocator::ReleaseGlobalAllocatorForTesting(); 35 GlobalHistogramAllocator::ReleaseForTesting();
36 } 36 }
37 37
38 void InitializeStatisticsRecorder() { 38 void InitializeStatisticsRecorder() {
39 statistics_recorder_ = new StatisticsRecorder(); 39 statistics_recorder_ = new StatisticsRecorder();
40 } 40 }
41 41
42 void UninitializeStatisticsRecorder() { 42 void UninitializeStatisticsRecorder() {
43 delete statistics_recorder_; 43 delete statistics_recorder_;
44 statistics_recorder_ = NULL; 44 statistics_recorder_ = NULL;
45 } 45 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 UninitializeStatisticsRecorder(); 319 UninitializeStatisticsRecorder();
320 320
321 // No data should be returned. 321 // No data should be returned.
322 json = StatisticsRecorder::ToJSON(query); 322 json = StatisticsRecorder::ToJSON(query);
323 EXPECT_TRUE(json.empty()); 323 EXPECT_TRUE(json.empty());
324 } 324 }
325 325
326 TEST_F(StatisticsRecorderTest, IterationTest) { 326 TEST_F(StatisticsRecorderTest, IterationTest) {
327 StatisticsRecorder::Histograms registered_histograms; 327 StatisticsRecorder::Histograms registered_histograms;
328 LOCAL_HISTOGRAM_COUNTS("TestHistogram.IterationTest1", 30); 328 LOCAL_HISTOGRAM_COUNTS("TestHistogram.IterationTest1", 30);
329 PersistentHistogramAllocator::CreateGlobalAllocatorOnLocalMemory( 329 GlobalHistogramAllocator::CreateWithLocalMemory(64 << 10 /* 64 KiB */, 0, "");
330 64 << 10 /* 64 KiB */, 0, "");
331 LOCAL_HISTOGRAM_COUNTS("TestHistogram.IterationTest2", 30); 330 LOCAL_HISTOGRAM_COUNTS("TestHistogram.IterationTest2", 30);
332 331
333 StatisticsRecorder::HistogramIterator i1 = StatisticsRecorder::begin(true); 332 StatisticsRecorder::HistogramIterator i1 = StatisticsRecorder::begin(true);
334 EXPECT_NE(StatisticsRecorder::end(), i1); 333 EXPECT_NE(StatisticsRecorder::end(), i1);
335 EXPECT_NE(StatisticsRecorder::end(), ++i1); 334 EXPECT_NE(StatisticsRecorder::end(), ++i1);
336 EXPECT_EQ(StatisticsRecorder::end(), ++i1); 335 EXPECT_EQ(StatisticsRecorder::end(), ++i1);
337 336
338 StatisticsRecorder::HistogramIterator i2 = StatisticsRecorder::begin(false); 337 StatisticsRecorder::HistogramIterator i2 = StatisticsRecorder::begin(false);
339 EXPECT_NE(StatisticsRecorder::end(), i2); 338 EXPECT_NE(StatisticsRecorder::end(), i2);
340 EXPECT_EQ(StatisticsRecorder::end(), ++i2); 339 EXPECT_EQ(StatisticsRecorder::end(), ++i2);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 HistogramBase* histogram = Histogram::FactoryGet("TestHistogram", 1, 1000, 10, 507 HistogramBase* histogram = Histogram::FactoryGet("TestHistogram", 1, 1000, 10,
509 HistogramBase::kNoFlags); 508 HistogramBase::kNoFlags);
510 EXPECT_TRUE(histogram); 509 EXPECT_TRUE(histogram);
511 histogram->Add(1); 510 histogram->Add(1);
512 511
513 EXPECT_TRUE(callback_wrapper.called); 512 EXPECT_TRUE(callback_wrapper.called);
514 EXPECT_EQ(callback_wrapper.last_histogram_value, 1); 513 EXPECT_EQ(callback_wrapper.last_histogram_value, 1);
515 } 514 }
516 515
517 } // namespace base 516 } // namespace base
OLDNEW
« 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