| 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 "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/trace_event/memory_allocator_dump_guid.h" | 9 #include "base/trace_event/memory_allocator_dump_guid.h" |
| 10 #include "base/trace_event/memory_dump_provider.h" | 10 #include "base/trace_event/memory_dump_provider.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 const MemoryAllocatorDumpGuid guid_bar_2 = mad->guid(); | 118 const MemoryAllocatorDumpGuid guid_bar_2 = mad->guid(); |
| 119 ASSERT_EQ(guid_bar, guid_bar_2); | 119 ASSERT_EQ(guid_bar, guid_bar_2); |
| 120 | 120 |
| 121 mad.reset(new MemoryAllocatorDump("baz", nullptr)); | 121 mad.reset(new MemoryAllocatorDump("baz", nullptr)); |
| 122 const MemoryAllocatorDumpGuid guid_baz = mad->guid(); | 122 const MemoryAllocatorDumpGuid guid_baz = mad->guid(); |
| 123 ASSERT_NE(guid_bar, guid_baz); | 123 ASSERT_NE(guid_bar, guid_baz); |
| 124 } | 124 } |
| 125 | 125 |
| 126 TEST(MemoryAllocatorDumpTest, DumpIntoProcessMemoryDump) { | 126 TEST(MemoryAllocatorDumpTest, DumpIntoProcessMemoryDump) { |
| 127 FakeMemoryAllocatorDumpProvider fmadp; | 127 FakeMemoryAllocatorDumpProvider fmadp; |
| 128 ProcessMemoryDump pmd(new MemoryDumpSessionState(nullptr)); | 128 ProcessMemoryDump pmd(new MemoryDumpSessionState(nullptr, nullptr)); |
| 129 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; | 129 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; |
| 130 | 130 |
| 131 fmadp.OnMemoryDump(dump_args, &pmd); | 131 fmadp.OnMemoryDump(dump_args, &pmd); |
| 132 | 132 |
| 133 ASSERT_EQ(3u, pmd.allocator_dumps().size()); | 133 ASSERT_EQ(3u, pmd.allocator_dumps().size()); |
| 134 | 134 |
| 135 const MemoryAllocatorDump* root_heap = | 135 const MemoryAllocatorDump* root_heap = |
| 136 pmd.GetAllocatorDump("foobar_allocator"); | 136 pmd.GetAllocatorDump("foobar_allocator"); |
| 137 ASSERT_NE(nullptr, root_heap); | 137 ASSERT_NE(nullptr, root_heap); |
| 138 EXPECT_EQ("foobar_allocator", root_heap->absolute_name()); | 138 EXPECT_EQ("foobar_allocator", root_heap->absolute_name()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 165 | 165 |
| 166 // Check that the AsValueInfo doesn't hit any DCHECK. | 166 // Check that the AsValueInfo doesn't hit any DCHECK. |
| 167 scoped_refptr<TracedValue> traced_value(new TracedValue()); | 167 scoped_refptr<TracedValue> traced_value(new TracedValue()); |
| 168 pmd.AsValueInto(traced_value.get()); | 168 pmd.AsValueInto(traced_value.get()); |
| 169 } | 169 } |
| 170 | 170 |
| 171 // DEATH tests are not supported in Android / iOS. | 171 // DEATH tests are not supported in Android / iOS. |
| 172 #if !defined(NDEBUG) && !defined(OS_ANDROID) && !defined(OS_IOS) | 172 #if !defined(NDEBUG) && !defined(OS_ANDROID) && !defined(OS_IOS) |
| 173 TEST(MemoryAllocatorDumpTest, ForbidDuplicatesDeathTest) { | 173 TEST(MemoryAllocatorDumpTest, ForbidDuplicatesDeathTest) { |
| 174 FakeMemoryAllocatorDumpProvider fmadp; | 174 FakeMemoryAllocatorDumpProvider fmadp; |
| 175 ProcessMemoryDump pmd(new MemoryDumpSessionState(nullptr)); | 175 ProcessMemoryDump pmd(new MemoryDumpSessionState(nullptr, nullptr)); |
| 176 pmd.CreateAllocatorDump("foo_allocator"); | 176 pmd.CreateAllocatorDump("foo_allocator"); |
| 177 pmd.CreateAllocatorDump("bar_allocator/heap"); | 177 pmd.CreateAllocatorDump("bar_allocator/heap"); |
| 178 ASSERT_DEATH(pmd.CreateAllocatorDump("foo_allocator"), ""); | 178 ASSERT_DEATH(pmd.CreateAllocatorDump("foo_allocator"), ""); |
| 179 ASSERT_DEATH(pmd.CreateAllocatorDump("bar_allocator/heap"), ""); | 179 ASSERT_DEATH(pmd.CreateAllocatorDump("bar_allocator/heap"), ""); |
| 180 ASSERT_DEATH(pmd.CreateAllocatorDump(""), ""); | 180 ASSERT_DEATH(pmd.CreateAllocatorDump(""), ""); |
| 181 } | 181 } |
| 182 #endif | 182 #endif |
| 183 | 183 |
| 184 } // namespace trace_event | 184 } // namespace trace_event |
| 185 } // namespace base | 185 } // namespace base |
| OLD | NEW |