Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
|
Primiano Tucci (use gerrit)
2016/04/28 07:02:42
Would be nice to cover the code above (and the var
| |
| 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" |
| 11 #include "base/trace_event/heap_profiler.h" | 11 #include "base/trace_event/heap_profiler.h" |
| (...skipping 43 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::SetCaptureEnabled(true); | 65 AllocationContextTracker::SetCaptureMode( |
| 66 AllocationContextTracker::CaptureMode::PSEUDO_STACK); | |
| 66 } | 67 } |
| 67 | 68 |
| 68 void TearDown() override { | 69 void TearDown() override { |
| 69 AllocationContextTracker::SetCaptureEnabled(false); | 70 AllocationContextTracker::SetCaptureMode( |
| 71 AllocationContextTracker::CaptureMode::DISABLED); | |
| 70 TraceLog::GetInstance()->SetDisabled(); | 72 TraceLog::GetInstance()->SetDisabled(); |
| 71 } | 73 } |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. | 76 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. |
| 75 TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) { | 77 TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) { |
| 76 StackFrame c = StackFrame::FromTraceEventName(kCupcake); | 78 StackFrame c = StackFrame::FromTraceEventName(kCupcake); |
| 77 StackFrame d = StackFrame::FromTraceEventName(kDonut); | 79 StackFrame d = StackFrame::FromTraceEventName(kDonut); |
| 78 StackFrame e = StackFrame::FromTraceEventName(kEclair); | 80 StackFrame e = StackFrame::FromTraceEventName(kEclair); |
| 79 StackFrame f = StackFrame::FromTraceEventName(kFroyo); | 81 StackFrame f = StackFrame::FromTraceEventName(kFroyo); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 AllocationContextTracker::GetInstanceForCurrentThread() | 289 AllocationContextTracker::GetInstanceForCurrentThread() |
| 288 ->GetContextSnapshot(); | 290 ->GetContextSnapshot(); |
| 289 const StringPiece kTracingOverhead("tracing_overhead"); | 291 const StringPiece kTracingOverhead("tracing_overhead"); |
| 290 ASSERT_EQ(kTracingOverhead, | 292 ASSERT_EQ(kTracingOverhead, |
| 291 static_cast<const char*>(ctx.backtrace.frames[0].value)); | 293 static_cast<const char*>(ctx.backtrace.frames[0].value)); |
| 292 ASSERT_EQ(1u, ctx.backtrace.frame_count); | 294 ASSERT_EQ(1u, ctx.backtrace.frame_count); |
| 293 } | 295 } |
| 294 | 296 |
| 295 } // namespace trace_event | 297 } // namespace trace_event |
| 296 } // namespace base | 298 } // namespace base |
| OLD | NEW |