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/trace_event/heap_profiler_allocation_context.h" | 10 #include "base/trace_event/heap_profiler_allocation_context.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 ->GetContextSnapshot(); | 53 ->GetContextSnapshot(); |
54 | 54 |
55 for (StackFrame frame : ctx.backtrace.frames) | 55 for (StackFrame frame : ctx.backtrace.frames) |
56 ASSERT_EQ(nullptr, frame); | 56 ASSERT_EQ(nullptr, frame); |
57 } | 57 } |
58 | 58 |
59 class AllocationContextTrackerTest : public testing::Test { | 59 class AllocationContextTrackerTest : public testing::Test { |
60 public: | 60 public: |
61 void SetUp() override { | 61 void SetUp() override { |
62 TraceConfig config(""); | 62 TraceConfig config(""); |
| 63 AllocationContextTracker::SetCaptureEnabled(true); |
63 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); | 64 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); |
64 AllocationContextTracker::SetCaptureEnabled(true); | |
65 } | 65 } |
66 | 66 |
67 void TearDown() override { | 67 void TearDown() override { |
68 AllocationContextTracker::SetCaptureEnabled(false); | 68 AllocationContextTracker::SetCaptureEnabled(false); |
69 TraceLog::GetInstance()->SetDisabled(); | 69 TraceLog::GetInstance()->SetDisabled(); |
70 } | 70 } |
71 }; | 71 }; |
72 | 72 |
73 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. | 73 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. |
74 // Also check that |GetContextSnapshot| fills the backtrace with null pointers | 74 // Also check that |GetContextSnapshot| fills the backtrace with null pointers |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 AllocationContext ctx = | 224 AllocationContext ctx = |
225 AllocationContextTracker::GetInstanceForCurrentThread() | 225 AllocationContextTracker::GetInstanceForCurrentThread() |
226 ->GetContextSnapshot(); | 226 ->GetContextSnapshot(); |
227 ASSERT_EQ(kCupcake, ctx.backtrace.frames[0]); | 227 ASSERT_EQ(kCupcake, ctx.backtrace.frames[0]); |
228 ASSERT_EQ(kFroyo, ctx.backtrace.frames[11]); | 228 ASSERT_EQ(kFroyo, ctx.backtrace.frames[11]); |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 } // namespace trace_event | 232 } // namespace trace_event |
233 } // namespace base | 233 } // namespace base |
OLD | NEW |