| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 const MemoryAllocatorDumpGuid guid_bar_2 = mad->guid(); | 122 const MemoryAllocatorDumpGuid guid_bar_2 = mad->guid(); |
| 123 ASSERT_EQ(guid_bar, guid_bar_2); | 123 ASSERT_EQ(guid_bar, guid_bar_2); |
| 124 | 124 |
| 125 mad.reset(new MemoryAllocatorDump("baz", nullptr)); | 125 mad.reset(new MemoryAllocatorDump("baz", nullptr)); |
| 126 const MemoryAllocatorDumpGuid guid_baz = mad->guid(); | 126 const MemoryAllocatorDumpGuid guid_baz = mad->guid(); |
| 127 ASSERT_NE(guid_bar, guid_baz); | 127 ASSERT_NE(guid_bar, guid_baz); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST(MemoryAllocatorDumpTest, DumpIntoProcessMemoryDump) { | 130 TEST(MemoryAllocatorDumpTest, DumpIntoProcessMemoryDump) { |
| 131 FakeMemoryAllocatorDumpProvider fmadp; | 131 FakeMemoryAllocatorDumpProvider fmadp; |
| 132 ProcessMemoryDump pmd(new MemoryDumpSessionState); | |
| 133 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; | 132 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; |
| 133 ProcessMemoryDump pmd(new MemoryDumpSessionState, dump_args.level_of_detail); |
| 134 | 134 |
| 135 fmadp.OnMemoryDump(dump_args, &pmd); | 135 fmadp.OnMemoryDump(dump_args, &pmd); |
| 136 | 136 |
| 137 ASSERT_EQ(3u, pmd.allocator_dumps().size()); | 137 ASSERT_EQ(3u, pmd.allocator_dumps().size()); |
| 138 | 138 |
| 139 const MemoryAllocatorDump* root_heap = | 139 const MemoryAllocatorDump* root_heap = |
| 140 pmd.GetAllocatorDump("foobar_allocator"); | 140 pmd.GetAllocatorDump("foobar_allocator"); |
| 141 ASSERT_NE(nullptr, root_heap); | 141 ASSERT_NE(nullptr, root_heap); |
| 142 EXPECT_EQ("foobar_allocator", root_heap->absolute_name()); | 142 EXPECT_EQ("foobar_allocator", root_heap->absolute_name()); |
| 143 CheckScalar(root_heap, MemoryAllocatorDump::kNameSize, | 143 CheckScalar(root_heap, MemoryAllocatorDump::kNameSize, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 pmd.CreateAllocatorDump("foo_allocator"); | 180 pmd.CreateAllocatorDump("foo_allocator"); |
| 181 pmd.CreateAllocatorDump("bar_allocator/heap"); | 181 pmd.CreateAllocatorDump("bar_allocator/heap"); |
| 182 ASSERT_DEATH(pmd.CreateAllocatorDump("foo_allocator"), ""); | 182 ASSERT_DEATH(pmd.CreateAllocatorDump("foo_allocator"), ""); |
| 183 ASSERT_DEATH(pmd.CreateAllocatorDump("bar_allocator/heap"), ""); | 183 ASSERT_DEATH(pmd.CreateAllocatorDump("bar_allocator/heap"), ""); |
| 184 ASSERT_DEATH(pmd.CreateAllocatorDump(""), ""); | 184 ASSERT_DEATH(pmd.CreateAllocatorDump(""), ""); |
| 185 } | 185 } |
| 186 #endif | 186 #endif |
| 187 | 187 |
| 188 } // namespace trace_event | 188 } // namespace trace_event |
| 189 } // namespace base | 189 } // namespace base |
| OLD | NEW |