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

Side by Side Diff: chrome/browser/chromeos/resource_reporter/resource_reporter_unittest.cc

Issue 2172023002: chrome/browser/chromeos: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // Manually refresh the task manager. 155 // Manually refresh the task manager.
156 void RefreshTaskManager() { 156 void RefreshTaskManager() {
157 task_manager_.ManualRefresh(); 157 task_manager_.ManualRefresh();
158 } 158 }
159 159
160 // Tests that the task records in |ResourceReporter::task_records_by_cpu_| are 160 // Tests that the task records in |ResourceReporter::task_records_by_cpu_| are
161 // properly sorted by the CPU usage in a descending order. 161 // properly sorted by the CPU usage in a descending order.
162 bool IsCpuRecordsSetSorted() const { 162 bool IsCpuRecordsSetSorted() const {
163 double current_cpu = std::numeric_limits<double>::max(); 163 double current_cpu = std::numeric_limits<double>::max();
164 for (const auto& record : resource_reporter()->task_records_by_cpu_) { 164 for (auto* record : resource_reporter()->task_records_by_cpu_) {
165 if (record->cpu_percent > current_cpu) 165 if (record->cpu_percent > current_cpu)
166 return false; 166 return false;
167 current_cpu = record->cpu_percent; 167 current_cpu = record->cpu_percent;
168 } 168 }
169 169
170 return true; 170 return true;
171 } 171 }
172 172
173 // Tests that the task records in |ResourceReporter::task_records_by_memory_| 173 // Tests that the task records in |ResourceReporter::task_records_by_memory_|
174 // are properly sorted by the memory usage in a descending order. 174 // are properly sorted by the memory usage in a descending order.
175 bool IsMemoryRecordsSetSorted() const { 175 bool IsMemoryRecordsSetSorted() const {
176 int64_t current_memory = std::numeric_limits<int64_t>::max(); 176 int64_t current_memory = std::numeric_limits<int64_t>::max();
177 for (const auto& record : resource_reporter()->task_records_by_memory_) { 177 for (auto* record : resource_reporter()->task_records_by_memory_) {
178 if (record->memory_bytes > current_memory) 178 if (record->memory_bytes > current_memory)
179 return false; 179 return false;
180 current_memory = record->memory_bytes; 180 current_memory = record->memory_bytes;
181 } 181 }
182 182
183 return true; 183 return true;
184 } 184 }
185 185
186 ResourceReporter* resource_reporter() const { 186 ResourceReporter* resource_reporter() const {
187 return ResourceReporter::GetInstance(); 187 return ResourceReporter::GetInstance();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ResourceReporter::kTopConsumersCount); 319 ResourceReporter::kTopConsumersCount);
320 EXPECT_LE(resource_reporter()->task_records_by_memory_.size(), 320 EXPECT_LE(resource_reporter()->task_records_by_memory_.size(),
321 ResourceReporter::kTopConsumersCount); 321 ResourceReporter::kTopConsumersCount);
322 EXPECT_TRUE(IsCpuRecordsSetSorted()); 322 EXPECT_TRUE(IsCpuRecordsSetSorted());
323 EXPECT_TRUE(IsMemoryRecordsSetSorted()); 323 EXPECT_TRUE(IsMemoryRecordsSetSorted());
324 324
325 Stop(); 325 Stop();
326 } 326 }
327 327
328 } // namespace chromeos 328 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698