OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/debug/trace_event_unittest.h" | 5 #include "base/debug/trace_event_unittest.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 void EndTraceAndFlush() { | 73 void EndTraceAndFlush() { |
74 while (TraceLog::GetInstance()->IsEnabled()) | 74 while (TraceLog::GetInstance()->IsEnabled()) |
75 TraceLog::GetInstance()->SetDisabled(); | 75 TraceLog::GetInstance()->SetDisabled(); |
76 TraceLog::GetInstance()->Flush( | 76 TraceLog::GetInstance()->Flush( |
77 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, | 77 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, |
78 base::Unretained(this))); | 78 base::Unretained(this))); |
79 } | 79 } |
80 | 80 |
81 virtual void SetUp() OVERRIDE { | 81 virtual void SetUp() OVERRIDE { |
82 old_thread_name_ = PlatformThread::GetName(); | 82 const char* name = PlatformThread::GetName(); |
| 83 old_thread_name_ = name ? strdup(name) : NULL; |
83 } | 84 } |
84 virtual void TearDown() OVERRIDE { | 85 virtual void TearDown() OVERRIDE { |
85 if (TraceLog::GetInstance()) | 86 if (TraceLog::GetInstance()) |
86 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); | 87 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); |
87 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); | 88 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); |
| 89 free(old_thread_name_); |
| 90 old_thread_name_ = NULL; |
88 } | 91 } |
89 | 92 |
90 const char* old_thread_name_; | 93 char* old_thread_name_; |
91 ListValue trace_parsed_; | 94 ListValue trace_parsed_; |
92 base::debug::TraceResultBuffer trace_buffer_; | 95 base::debug::TraceResultBuffer trace_buffer_; |
93 base::debug::TraceResultBuffer::SimpleOutput json_output_; | 96 base::debug::TraceResultBuffer::SimpleOutput json_output_; |
94 int event_watch_notification_; | 97 int event_watch_notification_; |
95 | 98 |
96 private: | 99 private: |
97 // We want our singleton torn down after each test. | 100 // We want our singleton torn down after each test. |
98 ShadowingAtExitManager at_exit_manager_; | 101 ShadowingAtExitManager at_exit_manager_; |
99 Lock lock_; | 102 Lock lock_; |
100 }; | 103 }; |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 trace_log->SetEnabled(std::string("moo")); | 1404 trace_log->SetEnabled(std::string("moo")); |
1402 EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz")); | 1405 EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz")); |
1403 EXPECT_TRUE(*trace_log->GetCategoryEnabled("moo")); | 1406 EXPECT_TRUE(*trace_log->GetCategoryEnabled("moo")); |
1404 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo")); | 1407 EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo")); |
1405 trace_log->SetDisabled(); | 1408 trace_log->SetDisabled(); |
1406 trace_log->SetDisabled(); | 1409 trace_log->SetDisabled(); |
1407 } | 1410 } |
1408 | 1411 |
1409 } // namespace debug | 1412 } // namespace debug |
1410 } // namespace base | 1413 } // namespace base |
OLD | NEW |