| OLD | NEW |
| 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 "base/trace_event/memory_allocator_dump.h" | 5 #include "base/trace_event/memory_allocator_dump.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 TEST(MemoryAllocatorDumpTest, GetSize) { | 175 TEST(MemoryAllocatorDumpTest, GetSize) { |
| 176 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; | 176 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; |
| 177 ProcessMemoryDump pmd(new HeapProfilerSerializationState, dump_args); | 177 ProcessMemoryDump pmd(new HeapProfilerSerializationState, dump_args); |
| 178 MemoryAllocatorDump* dump = pmd.CreateAllocatorDump("allocator_for_size"); | 178 MemoryAllocatorDump* dump = pmd.CreateAllocatorDump("allocator_for_size"); |
| 179 dump->AddScalar(MemoryAllocatorDump::kNameSize, | 179 dump->AddScalar(MemoryAllocatorDump::kNameSize, |
| 180 MemoryAllocatorDump::kUnitsBytes, 1); | 180 MemoryAllocatorDump::kUnitsBytes, 1); |
| 181 dump->AddScalar("foo", MemoryAllocatorDump::kUnitsBytes, 2); | 181 dump->AddScalar("foo", MemoryAllocatorDump::kUnitsBytes, 2); |
| 182 EXPECT_EQ(1u, dump->GetSize()); | 182 EXPECT_EQ(1u, dump->GetSize()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // DEATH tests are not supported in Android / iOS. | 185 // DEATH tests are not supported in Android/iOS/Fuchsia. |
| 186 #if !defined(NDEBUG) && !defined(OS_ANDROID) && !defined(OS_IOS) | 186 #if !defined(NDEBUG) && !defined(OS_ANDROID) && !defined(OS_IOS) && \ |
| 187 !defined(OS_FUCHSIA) |
| 187 TEST(MemoryAllocatorDumpTest, ForbidDuplicatesDeathTest) { | 188 TEST(MemoryAllocatorDumpTest, ForbidDuplicatesDeathTest) { |
| 188 FakeMemoryAllocatorDumpProvider fmadp; | 189 FakeMemoryAllocatorDumpProvider fmadp; |
| 189 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; | 190 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; |
| 190 ProcessMemoryDump pmd(new HeapProfilerSerializationState, dump_args); | 191 ProcessMemoryDump pmd(new HeapProfilerSerializationState, dump_args); |
| 191 pmd.CreateAllocatorDump("foo_allocator"); | 192 pmd.CreateAllocatorDump("foo_allocator"); |
| 192 pmd.CreateAllocatorDump("bar_allocator/heap"); | 193 pmd.CreateAllocatorDump("bar_allocator/heap"); |
| 193 ASSERT_DEATH(pmd.CreateAllocatorDump("foo_allocator"), ""); | 194 ASSERT_DEATH(pmd.CreateAllocatorDump("foo_allocator"), ""); |
| 194 ASSERT_DEATH(pmd.CreateAllocatorDump("bar_allocator/heap"), ""); | 195 ASSERT_DEATH(pmd.CreateAllocatorDump("bar_allocator/heap"), ""); |
| 195 ASSERT_DEATH(pmd.CreateAllocatorDump(""), ""); | 196 ASSERT_DEATH(pmd.CreateAllocatorDump(""), ""); |
| 196 } | 197 } |
| 197 #endif | 198 #endif |
| 198 | 199 |
| 199 } // namespace trace_event | 200 } // namespace trace_event |
| 200 } // namespace base | 201 } // namespace base |
| OLD | NEW |