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

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

Issue 1950313005: [tracing] Move and rename TRACE_EVENT_API_TASK_EXECUTION_EVENT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_missing_task
Patch Set: fix unittest. Created 4 years, 7 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/heap_profiler.h ('k') | base/trace_event/trace_event.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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/pending_task.h" 10 #include "base/pending_task.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ->GetContextSnapshot(); 253 ->GetContextSnapshot();
254 ASSERT_EQ(StackFrame::FromThreadName(kThread2), ctx2.backtrace.frames[0]); 254 ASSERT_EQ(StackFrame::FromThreadName(kThread2), ctx2.backtrace.frames[0]);
255 ASSERT_EQ(StackFrame::FromTraceEventName(kCupcake), ctx2.backtrace.frames[1]); 255 ASSERT_EQ(StackFrame::FromTraceEventName(kCupcake), ctx2.backtrace.frames[1]);
256 } 256 }
257 257
258 TEST_F(AllocationContextTrackerTest, TrackTaskContext) { 258 TEST_F(AllocationContextTrackerTest, TrackTaskContext) {
259 const char kContext1[] = "context1"; 259 const char kContext1[] = "context1";
260 const char kContext2[] = "context2"; 260 const char kContext2[] = "context2";
261 { 261 {
262 // The context from the scoped task event should be used as type name. 262 // The context from the scoped task event should be used as type name.
263 TRACE_EVENT_API_SCOPED_TASK_EXECUTION_EVENT event1(kContext1); 263 TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION event1(kContext1);
264 AllocationContext ctx1 = 264 AllocationContext ctx1 =
265 AllocationContextTracker::GetInstanceForCurrentThread() 265 AllocationContextTracker::GetInstanceForCurrentThread()
266 ->GetContextSnapshot(); 266 ->GetContextSnapshot();
267 ASSERT_EQ(kContext1, ctx1.type_name); 267 ASSERT_EQ(kContext1, ctx1.type_name);
268 268
269 // In case of nested events, the last event's context should be used. 269 // In case of nested events, the last event's context should be used.
270 TRACE_EVENT_API_SCOPED_TASK_EXECUTION_EVENT event2(kContext2); 270 TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION event2(kContext2);
271 AllocationContext ctx2 = 271 AllocationContext ctx2 =
272 AllocationContextTracker::GetInstanceForCurrentThread() 272 AllocationContextTracker::GetInstanceForCurrentThread()
273 ->GetContextSnapshot(); 273 ->GetContextSnapshot();
274 ASSERT_EQ(kContext2, ctx2.type_name); 274 ASSERT_EQ(kContext2, ctx2.type_name);
275 } 275 }
276 276
277 // Type should be nullptr without task event. 277 // Type should be nullptr without task event.
278 AllocationContext ctx = 278 AllocationContext ctx =
279 AllocationContextTracker::GetInstanceForCurrentThread() 279 AllocationContextTracker::GetInstanceForCurrentThread()
280 ->GetContextSnapshot(); 280 ->GetContextSnapshot();
281 ASSERT_FALSE(ctx.type_name); 281 ASSERT_FALSE(ctx.type_name);
282 } 282 }
283 283
284 TEST_F(AllocationContextTrackerTest, IgnoreAllocationTest) { 284 TEST_F(AllocationContextTrackerTest, IgnoreAllocationTest) {
285 TRACE_EVENT0("Testing", kCupcake); 285 TRACE_EVENT0("Testing", kCupcake);
286 TRACE_EVENT0("Testing", kDonut); 286 TRACE_EVENT0("Testing", kDonut);
287 HEAP_PROFILER_SCOPED_IGNORE; 287 HEAP_PROFILER_SCOPED_IGNORE;
288 AllocationContext ctx = 288 AllocationContext ctx =
289 AllocationContextTracker::GetInstanceForCurrentThread() 289 AllocationContextTracker::GetInstanceForCurrentThread()
290 ->GetContextSnapshot(); 290 ->GetContextSnapshot();
291 const StringPiece kTracingOverhead("tracing_overhead"); 291 const StringPiece kTracingOverhead("tracing_overhead");
292 ASSERT_EQ(kTracingOverhead, 292 ASSERT_EQ(kTracingOverhead,
293 static_cast<const char*>(ctx.backtrace.frames[0].value)); 293 static_cast<const char*>(ctx.backtrace.frames[0].value));
294 ASSERT_EQ(1u, ctx.backtrace.frame_count); 294 ASSERT_EQ(1u, ctx.backtrace.frame_count);
295 } 295 }
296 296
297 } // namespace trace_event 297 } // namespace trace_event
298 } // namespace base 298 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler.h ('k') | base/trace_event/trace_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698