Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: base/trace_event/memory_allocator_dump_unittest.cc

Issue 2760253005: memory-infra: Fill the memory dump callback result (1/2) (Closed)
Patch Set: fix nits Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/trace_event/memory_allocator_dump.cc ('k') | base/trace_event/memory_dump_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 DictionaryValue* attrs = nullptr; 165 DictionaryValue* attrs = nullptr;
166 ASSERT_TRUE(raw_attrs->GetAsDictionary(&attrs)); 166 ASSERT_TRUE(raw_attrs->GetAsDictionary(&attrs));
167 ASSERT_FALSE(attrs->HasKey(MemoryAllocatorDump::kNameSize)); 167 ASSERT_FALSE(attrs->HasKey(MemoryAllocatorDump::kNameSize));
168 ASSERT_FALSE(attrs->HasKey(MemoryAllocatorDump::kNameObjectCount)); 168 ASSERT_FALSE(attrs->HasKey(MemoryAllocatorDump::kNameObjectCount));
169 169
170 // Check that the AsValueInfo doesn't hit any DCHECK. 170 // Check that the AsValueInfo doesn't hit any DCHECK.
171 std::unique_ptr<TracedValue> traced_value(new TracedValue); 171 std::unique_ptr<TracedValue> traced_value(new TracedValue);
172 pmd.AsValueInto(traced_value.get()); 172 pmd.AsValueInto(traced_value.get());
173 } 173 }
174 174
175 TEST(MemoryAllocatorDumpTest, GetSize) {
176 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
177 ProcessMemoryDump pmd(new MemoryDumpSessionState, dump_args);
178 MemoryAllocatorDump* dump = pmd.CreateAllocatorDump("allocator_for_size");
179 dump->AddScalar(MemoryAllocatorDump::kNameSize,
180 MemoryAllocatorDump::kUnitsBytes, 1);
181 dump->AddScalar("foo", MemoryAllocatorDump::kUnitsBytes, 2);
182 EXPECT_EQ(1u, dump->GetSize());
183 }
184
175 // DEATH tests are not supported in Android / iOS. 185 // DEATH tests are not supported in Android / iOS.
176 #if !defined(NDEBUG) && !defined(OS_ANDROID) && !defined(OS_IOS) 186 #if !defined(NDEBUG) && !defined(OS_ANDROID) && !defined(OS_IOS)
177 TEST(MemoryAllocatorDumpTest, ForbidDuplicatesDeathTest) { 187 TEST(MemoryAllocatorDumpTest, ForbidDuplicatesDeathTest) {
178 FakeMemoryAllocatorDumpProvider fmadp; 188 FakeMemoryAllocatorDumpProvider fmadp;
179 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED}; 189 MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
180 ProcessMemoryDump pmd(new MemoryDumpSessionState, dump_args); 190 ProcessMemoryDump pmd(new MemoryDumpSessionState, dump_args);
181 pmd.CreateAllocatorDump("foo_allocator"); 191 pmd.CreateAllocatorDump("foo_allocator");
182 pmd.CreateAllocatorDump("bar_allocator/heap"); 192 pmd.CreateAllocatorDump("bar_allocator/heap");
183 ASSERT_DEATH(pmd.CreateAllocatorDump("foo_allocator"), ""); 193 ASSERT_DEATH(pmd.CreateAllocatorDump("foo_allocator"), "");
184 ASSERT_DEATH(pmd.CreateAllocatorDump("bar_allocator/heap"), ""); 194 ASSERT_DEATH(pmd.CreateAllocatorDump("bar_allocator/heap"), "");
185 ASSERT_DEATH(pmd.CreateAllocatorDump(""), ""); 195 ASSERT_DEATH(pmd.CreateAllocatorDump(""), "");
186 } 196 }
187 #endif 197 #endif
188 198
189 } // namespace trace_event 199 } // namespace trace_event
190 } // namespace base 200 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_allocator_dump.cc ('k') | base/trace_event/memory_dump_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698