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 <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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ->GetContextSnapshot(); | 55 ->GetContextSnapshot(); |
56 | 56 |
57 ASSERT_EQ(0u, ctx.backtrace.frame_count); | 57 ASSERT_EQ(0u, ctx.backtrace.frame_count); |
58 } | 58 } |
59 | 59 |
60 class AllocationContextTrackerTest : public testing::Test { | 60 class AllocationContextTrackerTest : public testing::Test { |
61 public: | 61 public: |
62 void SetUp() override { | 62 void SetUp() override { |
63 TraceConfig config(""); | 63 TraceConfig config(""); |
64 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); | 64 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); |
65 AllocationContextTracker::SetCaptureMode( | 65 AllocationContextTracker::SetCaptureEnabled(true); |
66 AllocationContextTracker::CaptureMode::PSEUDO_STACK); | |
67 } | 66 } |
68 | 67 |
69 void TearDown() override { | 68 void TearDown() override { |
70 AllocationContextTracker::SetCaptureMode( | 69 AllocationContextTracker::SetCaptureEnabled(false); |
71 AllocationContextTracker::CaptureMode::DISABLED); | |
72 TraceLog::GetInstance()->SetDisabled(); | 70 TraceLog::GetInstance()->SetDisabled(); |
73 } | 71 } |
74 }; | 72 }; |
75 | 73 |
76 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. | 74 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. |
77 TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) { | 75 TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) { |
78 StackFrame c = StackFrame::FromTraceEventName(kCupcake); | 76 StackFrame c = StackFrame::FromTraceEventName(kCupcake); |
79 StackFrame d = StackFrame::FromTraceEventName(kDonut); | 77 StackFrame d = StackFrame::FromTraceEventName(kDonut); |
80 StackFrame e = StackFrame::FromTraceEventName(kEclair); | 78 StackFrame e = StackFrame::FromTraceEventName(kEclair); |
81 StackFrame f = StackFrame::FromTraceEventName(kFroyo); | 79 StackFrame f = StackFrame::FromTraceEventName(kFroyo); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 AllocationContextTracker::GetInstanceForCurrentThread() | 287 AllocationContextTracker::GetInstanceForCurrentThread() |
290 ->GetContextSnapshot(); | 288 ->GetContextSnapshot(); |
291 const StringPiece kTracingOverhead("tracing_overhead"); | 289 const StringPiece kTracingOverhead("tracing_overhead"); |
292 ASSERT_EQ(kTracingOverhead, | 290 ASSERT_EQ(kTracingOverhead, |
293 static_cast<const char*>(ctx.backtrace.frames[0].value)); | 291 static_cast<const char*>(ctx.backtrace.frames[0].value)); |
294 ASSERT_EQ(1u, ctx.backtrace.frame_count); | 292 ASSERT_EQ(1u, ctx.backtrace.frame_count); |
295 } | 293 } |
296 | 294 |
297 } // namespace trace_event | 295 } // namespace trace_event |
298 } // namespace base | 296 } // namespace base |
OLD | NEW |