| 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 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 const int32_t kLargerMaxAllocatedBytes = kMaxAllocatedBytes * 2; | 339 const int32_t kLargerMaxAllocatedBytes = kMaxAllocatedBytes * 2; |
| 340 data->RecordAllocations(kAllocOps, kFreeOps, kAllocatedBytes, kFreedBytes, | 340 data->RecordAllocations(kAllocOps, kFreeOps, kAllocatedBytes, kFreedBytes, |
| 341 kAllocOverheadBytes, kLargerMaxAllocatedBytes); | 341 kAllocOverheadBytes, kLargerMaxAllocatedBytes); |
| 342 EXPECT_EQ(data->alloc_ops(), 3 * kAllocOps); | 342 EXPECT_EQ(data->alloc_ops(), 3 * kAllocOps); |
| 343 EXPECT_EQ(data->free_ops(), 3 * kFreeOps); | 343 EXPECT_EQ(data->free_ops(), 3 * kFreeOps); |
| 344 EXPECT_EQ(data->allocated_bytes(), 3 * kAllocatedBytes); | 344 EXPECT_EQ(data->allocated_bytes(), 3 * kAllocatedBytes); |
| 345 EXPECT_EQ(data->freed_bytes(), 3 * kFreedBytes); | 345 EXPECT_EQ(data->freed_bytes(), 3 * kFreedBytes); |
| 346 EXPECT_EQ(data->alloc_overhead_bytes(), 3 * kAllocOverheadBytes); | 346 EXPECT_EQ(data->alloc_overhead_bytes(), 3 * kAllocOverheadBytes); |
| 347 EXPECT_EQ(data->max_allocated_bytes(), kLargerMaxAllocatedBytes); | 347 EXPECT_EQ(data->max_allocated_bytes(), kLargerMaxAllocatedBytes); |
| 348 | 348 |
| 349 // Saturate everything. | 349 // Saturate everything but aggregate byte counts. The byte counts will be |
| 350 // pushed past the 32 bit value range. |
| 351 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); |
| 350 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); | 352 data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX); |
| 351 EXPECT_EQ(data->alloc_ops(), INT_MAX); | 353 EXPECT_EQ(data->alloc_ops(), INT_MAX); |
| 352 EXPECT_EQ(data->free_ops(), INT_MAX); | 354 EXPECT_EQ(data->free_ops(), INT_MAX); |
| 353 EXPECT_EQ(data->allocated_bytes(), INT_MAX); | 355 // The cumulative byte counts are 64 bit wide, and won't saturate easily. |
| 354 EXPECT_EQ(data->freed_bytes(), INT_MAX); | 356 EXPECT_EQ(data->allocated_bytes(), |
| 355 EXPECT_EQ(data->alloc_overhead_bytes(), INT_MAX); | 357 2 * static_cast<int64_t>(INT_MAX) + |
| 358 static_cast<int64_t>(3 * kAllocatedBytes)); |
| 359 EXPECT_EQ(data->freed_bytes(), |
| 360 2 * static_cast<int64_t>(INT_MAX) + 3 * kFreedBytes); |
| 361 EXPECT_EQ(data->alloc_overhead_bytes(), |
| 362 2 * static_cast<int64_t>(INT_MAX) + 3 * kAllocOverheadBytes); |
| 356 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); | 363 EXPECT_EQ(data->max_allocated_bytes(), INT_MAX); |
| 357 } | 364 } |
| 358 | 365 |
| 359 TEST_F(TrackedObjectsTest, DeathDataTest2Phases) { | 366 TEST_F(TrackedObjectsTest, DeathDataTest2Phases) { |
| 360 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); | 367 ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); |
| 361 | 368 |
| 362 std::unique_ptr<DeathData> data(new DeathData()); | 369 std::unique_ptr<DeathData> data(new DeathData()); |
| 363 ASSERT_NE(data, nullptr); | 370 ASSERT_NE(data, nullptr); |
| 364 | 371 |
| 365 const int32_t run_ms = 42; | 372 const int32_t run_ms = 42; |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 EXPECT_TRUE(thread.Start()); | 1373 EXPECT_TRUE(thread.Start()); |
| 1367 } | 1374 } |
| 1368 } | 1375 } |
| 1369 | 1376 |
| 1370 // Expect one ThreadData instance for each element in |kThreadNames| and one | 1377 // Expect one ThreadData instance for each element in |kThreadNames| and one |
| 1371 // ThreadData instance for the main thread. | 1378 // ThreadData instance for the main thread. |
| 1372 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); | 1379 EXPECT_EQ(static_cast<int>(arraysize(kThreadNames) + 1), GetNumThreadData()); |
| 1373 } | 1380 } |
| 1374 | 1381 |
| 1375 } // namespace tracked_objects | 1382 } // namespace tracked_objects |
| OLD | NEW |