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

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

Issue 1558633002: Cleanup: Remove double semicolons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Convert CP code to a while loop, fix nit 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/process/launch_win.cc » ('j') | cloud_print/service/win/chrome_launcher.cc » ('J')
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 Histogram* histogram = CreateHistogram("TestHistogram", 1, 1000, 10); 68 Histogram* histogram = CreateHistogram("TestHistogram", 1, 1000, 10);
69 69
70 // When StatisticsRecorder is not initialized, register is a noop. 70 // When StatisticsRecorder is not initialized, register is a noop.
71 EXPECT_EQ(histogram, 71 EXPECT_EQ(histogram,
72 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram)); 72 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram));
73 // Manually delete histogram that was not registered. 73 // Manually delete histogram that was not registered.
74 DeleteHistogram(histogram); 74 DeleteHistogram(histogram);
75 75
76 // RegisterOrDeleteDuplicateRanges is a no-op. 76 // RegisterOrDeleteDuplicateRanges is a no-op.
77 BucketRanges* ranges = new BucketRanges(3);; 77 BucketRanges* ranges = new BucketRanges(3);
78 ranges->ResetChecksum(); 78 ranges->ResetChecksum();
79 EXPECT_EQ(ranges, 79 EXPECT_EQ(ranges,
80 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges)); 80 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges));
81 StatisticsRecorder::GetBucketRanges(&registered_ranges); 81 StatisticsRecorder::GetBucketRanges(&registered_ranges);
82 EXPECT_EQ(0u, registered_ranges.size()); 82 EXPECT_EQ(0u, registered_ranges.size());
83 } 83 }
84 84
85 TEST_F(StatisticsRecorderTest, RegisterBucketRanges) { 85 TEST_F(StatisticsRecorderTest, RegisterBucketRanges) {
86 std::vector<const BucketRanges*> registered_ranges; 86 std::vector<const BucketRanges*> registered_ranges;
87 87
88 BucketRanges* ranges1 = new BucketRanges(3);; 88 BucketRanges* ranges1 = new BucketRanges(3);
89 ranges1->ResetChecksum(); 89 ranges1->ResetChecksum();
90 BucketRanges* ranges2 = new BucketRanges(4);; 90 BucketRanges* ranges2 = new BucketRanges(4);
91 ranges2->ResetChecksum(); 91 ranges2->ResetChecksum();
92 92
93 // Register new ranges. 93 // Register new ranges.
94 EXPECT_EQ(ranges1, 94 EXPECT_EQ(ranges1,
95 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges1)); 95 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges1));
96 EXPECT_EQ(ranges2, 96 EXPECT_EQ(ranges2,
97 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges2)); 97 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges2));
98 StatisticsRecorder::GetBucketRanges(&registered_ranges); 98 StatisticsRecorder::GetBucketRanges(&registered_ranges);
99 ASSERT_EQ(2u, registered_ranges.size()); 99 ASSERT_EQ(2u, registered_ranges.size());
100 100
101 // Register some ranges again. 101 // Register some ranges again.
102 EXPECT_EQ(ranges1, 102 EXPECT_EQ(ranges1,
103 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges1)); 103 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges1));
104 registered_ranges.clear(); 104 registered_ranges.clear();
105 StatisticsRecorder::GetBucketRanges(&registered_ranges); 105 StatisticsRecorder::GetBucketRanges(&registered_ranges);
106 ASSERT_EQ(2u, registered_ranges.size()); 106 ASSERT_EQ(2u, registered_ranges.size());
107 // Make sure the ranges is still the one we know. 107 // Make sure the ranges is still the one we know.
108 ASSERT_EQ(3u, ranges1->size()); 108 ASSERT_EQ(3u, ranges1->size());
109 EXPECT_EQ(0, ranges1->range(0)); 109 EXPECT_EQ(0, ranges1->range(0));
110 EXPECT_EQ(0, ranges1->range(1)); 110 EXPECT_EQ(0, ranges1->range(1));
111 EXPECT_EQ(0, ranges1->range(2)); 111 EXPECT_EQ(0, ranges1->range(2));
112 112
113 // Register ranges with same values. 113 // Register ranges with same values.
114 BucketRanges* ranges3 = new BucketRanges(3);; 114 BucketRanges* ranges3 = new BucketRanges(3);
115 ranges3->ResetChecksum(); 115 ranges3->ResetChecksum();
116 EXPECT_EQ(ranges1, // returning ranges1 116 EXPECT_EQ(ranges1, // returning ranges1
117 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges3)); 117 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges3));
118 registered_ranges.clear(); 118 registered_ranges.clear();
119 StatisticsRecorder::GetBucketRanges(&registered_ranges); 119 StatisticsRecorder::GetBucketRanges(&registered_ranges);
120 ASSERT_EQ(2u, registered_ranges.size()); 120 ASSERT_EQ(2u, registered_ranges.size());
121 } 121 }
122 122
123 TEST_F(StatisticsRecorderTest, RegisterHistogram) { 123 TEST_F(StatisticsRecorderTest, RegisterHistogram) {
124 // Create a Histogram that was not registered. 124 // Create a Histogram that was not registered.
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 HistogramBase* histogram = Histogram::FactoryGet("TestHistogram", 1, 1000, 10, 483 HistogramBase* histogram = Histogram::FactoryGet("TestHistogram", 1, 1000, 10,
484 HistogramBase::kNoFlags); 484 HistogramBase::kNoFlags);
485 EXPECT_TRUE(histogram); 485 EXPECT_TRUE(histogram);
486 histogram->Add(1); 486 histogram->Add(1);
487 487
488 EXPECT_TRUE(callback_wrapper.called); 488 EXPECT_TRUE(callback_wrapper.called);
489 EXPECT_EQ(callback_wrapper.last_histogram_value, 1); 489 EXPECT_EQ(callback_wrapper.last_histogram_value, 1);
490 } 490 }
491 491
492 } // namespace base 492 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/process/launch_win.cc » ('j') | cloud_print/service/win/chrome_launcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698