| OLD | NEW |
| 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 // Test of classes in the tracked_objects.h classes. | 5 // Test of classes in the tracked_objects.h classes. |
| 6 | 6 |
| 7 #include "base/tracked_objects.h" | 7 #include "base/tracked_objects.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_sum); | 233 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_sum); |
| 234 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_max); | 234 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_max); |
| 235 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_sample); | 235 EXPECT_EQ(0, process_data_phase.tasks[0].death_data.queue_duration_sample); |
| 236 EXPECT_EQ(kWorkerThreadName, process_data_phase.tasks[0].death_thread_name); | 236 EXPECT_EQ(kWorkerThreadName, process_data_phase.tasks[0].death_thread_name); |
| 237 } | 237 } |
| 238 | 238 |
| 239 TEST_F(TrackedObjectsTest, DeathDataTestRecordDeath) { | 239 TEST_F(TrackedObjectsTest, DeathDataTestRecordDeath) { |
| 240 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 240 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
| 241 | 241 |
| 242 scoped_ptr<DeathData> data(new DeathData()); | 242 scoped_ptr<DeathData> data(new DeathData()); |
| 243 ASSERT_NE(data, reinterpret_cast<DeathData*>(NULL)); | 243 ASSERT_NE(data, nullptr); |
| 244 EXPECT_EQ(data->run_duration_sum(), 0); | 244 EXPECT_EQ(data->run_duration_sum(), 0); |
| 245 EXPECT_EQ(data->run_duration_max(), 0); | 245 EXPECT_EQ(data->run_duration_max(), 0); |
| 246 EXPECT_EQ(data->run_duration_sample(), 0); | 246 EXPECT_EQ(data->run_duration_sample(), 0); |
| 247 EXPECT_EQ(data->queue_duration_sum(), 0); | 247 EXPECT_EQ(data->queue_duration_sum(), 0); |
| 248 EXPECT_EQ(data->queue_duration_max(), 0); | 248 EXPECT_EQ(data->queue_duration_max(), 0); |
| 249 EXPECT_EQ(data->queue_duration_sample(), 0); | 249 EXPECT_EQ(data->queue_duration_sample(), 0); |
| 250 EXPECT_EQ(data->count(), 0); | 250 EXPECT_EQ(data->count(), 0); |
| 251 EXPECT_EQ(nullptr, data->last_phase_snapshot()); | 251 EXPECT_EQ(nullptr, data->last_phase_snapshot()); |
| 252 | 252 |
| 253 int32 run_ms = 42; | 253 int32 run_ms = 42; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 272 EXPECT_EQ(data->queue_duration_max(), queue_ms); | 272 EXPECT_EQ(data->queue_duration_max(), queue_ms); |
| 273 EXPECT_EQ(data->queue_duration_sample(), queue_ms); | 273 EXPECT_EQ(data->queue_duration_sample(), queue_ms); |
| 274 EXPECT_EQ(data->count(), 2); | 274 EXPECT_EQ(data->count(), 2); |
| 275 EXPECT_EQ(nullptr, data->last_phase_snapshot()); | 275 EXPECT_EQ(nullptr, data->last_phase_snapshot()); |
| 276 } | 276 } |
| 277 | 277 |
| 278 TEST_F(TrackedObjectsTest, DeathDataTest2Phases) { | 278 TEST_F(TrackedObjectsTest, DeathDataTest2Phases) { |
| 279 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 279 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
| 280 | 280 |
| 281 scoped_ptr<DeathData> data(new DeathData()); | 281 scoped_ptr<DeathData> data(new DeathData()); |
| 282 ASSERT_NE(data, reinterpret_cast<DeathData*>(NULL)); | 282 ASSERT_NE(data, nullptr); |
| 283 | 283 |
| 284 int32 run_ms = 42; | 284 int32 run_ms = 42; |
| 285 int32 queue_ms = 8; | 285 int32 queue_ms = 8; |
| 286 | 286 |
| 287 const int kUnrandomInt = 0; // Fake random int that ensure we sample data. | 287 const int kUnrandomInt = 0; // Fake random int that ensure we sample data. |
| 288 data->RecordDeath(queue_ms, run_ms, kUnrandomInt); | 288 data->RecordDeath(queue_ms, run_ms, kUnrandomInt); |
| 289 data->RecordDeath(queue_ms, run_ms, kUnrandomInt); | 289 data->RecordDeath(queue_ms, run_ms, kUnrandomInt); |
| 290 | 290 |
| 291 data->OnProfilingPhaseCompleted(123); | 291 data->OnProfilingPhaseCompleted(123); |
| 292 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms); | 292 EXPECT_EQ(data->run_duration_sum(), run_ms + run_ms); |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_max); | 1177 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_max); |
| 1178 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_sample); | 1178 EXPECT_EQ(2, process_data_phase.tasks[t1].death_data.run_duration_sample); |
| 1179 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sum); | 1179 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sum); |
| 1180 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_max); | 1180 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_max); |
| 1181 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sample); | 1181 EXPECT_EQ(1, process_data_phase.tasks[t1].death_data.queue_duration_sample); |
| 1182 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[t1].death_thread_name); | 1182 EXPECT_EQ(kMainThreadName, process_data_phase.tasks[t1].death_thread_name); |
| 1183 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); | 1183 EXPECT_EQ(base::GetCurrentProcId(), process_data.process_id); |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 } // namespace tracked_objects | 1186 } // namespace tracked_objects |
| OLD | NEW |