| 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 <math.h> | 7 #include <math.h> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 flush_complete_event.Wait(); | 118 flush_complete_event.Wait(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void FlushMonitoring(WaitableEvent* flush_complete_event) { | 121 void FlushMonitoring(WaitableEvent* flush_complete_event) { |
| 122 TraceLog::GetInstance()->FlushButLeaveBufferIntact( | 122 TraceLog::GetInstance()->FlushButLeaveBufferIntact( |
| 123 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, | 123 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, |
| 124 base::Unretained(static_cast<TraceEventTestFixture*>(this)), | 124 base::Unretained(static_cast<TraceEventTestFixture*>(this)), |
| 125 base::Unretained(flush_complete_event))); | 125 base::Unretained(flush_complete_event))); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual void SetUp() override { | 128 void SetUp() override { |
| 129 const char* name = PlatformThread::GetName(); | 129 const char* name = PlatformThread::GetName(); |
| 130 old_thread_name_ = name ? strdup(name) : NULL; | 130 old_thread_name_ = name ? strdup(name) : NULL; |
| 131 | 131 |
| 132 TraceLog::DeleteForTesting(); | 132 TraceLog::DeleteForTesting(); |
| 133 TraceLog* tracelog = TraceLog::GetInstance(); | 133 TraceLog* tracelog = TraceLog::GetInstance(); |
| 134 ASSERT_TRUE(tracelog); | 134 ASSERT_TRUE(tracelog); |
| 135 ASSERT_FALSE(tracelog->IsEnabled()); | 135 ASSERT_FALSE(tracelog->IsEnabled()); |
| 136 trace_buffer_.SetOutputCallback(json_output_.GetCallback()); | 136 trace_buffer_.SetOutputCallback(json_output_.GetCallback()); |
| 137 event_watch_notification_ = 0; | 137 event_watch_notification_ = 0; |
| 138 } | 138 } |
| 139 virtual void TearDown() override { | 139 void TearDown() override { |
| 140 if (TraceLog::GetInstance()) | 140 if (TraceLog::GetInstance()) |
| 141 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); | 141 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); |
| 142 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); | 142 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); |
| 143 free(old_thread_name_); | 143 free(old_thread_name_); |
| 144 old_thread_name_ = NULL; | 144 old_thread_name_ = NULL; |
| 145 // We want our singleton torn down after each test. | 145 // We want our singleton torn down after each test. |
| 146 TraceLog::DeleteForTesting(); | 146 TraceLog::DeleteForTesting(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 char* old_thread_name_; | 149 char* old_thread_name_; |
| (...skipping 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 dict = FindNamePhase("event15", "X"); | 2208 dict = FindNamePhase("event15", "X"); |
| 2209 ASSERT_TRUE(dict); | 2209 ASSERT_TRUE(dict); |
| 2210 dict->GetDictionary("args", &args_dict); | 2210 dict->GetDictionary("args", &args_dict); |
| 2211 ASSERT_TRUE(args_dict); | 2211 ASSERT_TRUE(args_dict); |
| 2212 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value)); | 2212 EXPECT_TRUE(args_dict->GetInteger("timeticks_one", &int_value)); |
| 2213 EXPECT_EQ(1, int_value); | 2213 EXPECT_EQ(1, int_value); |
| 2214 } | 2214 } |
| 2215 | 2215 |
| 2216 class TraceEventCallbackTest : public TraceEventTestFixture { | 2216 class TraceEventCallbackTest : public TraceEventTestFixture { |
| 2217 public: | 2217 public: |
| 2218 virtual void SetUp() override { | 2218 void SetUp() override { |
| 2219 TraceEventTestFixture::SetUp(); | 2219 TraceEventTestFixture::SetUp(); |
| 2220 ASSERT_EQ(NULL, s_instance); | 2220 ASSERT_EQ(NULL, s_instance); |
| 2221 s_instance = this; | 2221 s_instance = this; |
| 2222 } | 2222 } |
| 2223 virtual void TearDown() override { | 2223 void TearDown() override { |
| 2224 TraceLog::GetInstance()->SetDisabled(); | 2224 TraceLog::GetInstance()->SetDisabled(); |
| 2225 ASSERT_TRUE(!!s_instance); | 2225 ASSERT_TRUE(!!s_instance); |
| 2226 s_instance = NULL; | 2226 s_instance = NULL; |
| 2227 TraceEventTestFixture::TearDown(); | 2227 TraceEventTestFixture::TearDown(); |
| 2228 } | 2228 } |
| 2229 | 2229 |
| 2230 protected: | 2230 protected: |
| 2231 // For TraceEventCallbackAndRecordingX tests. | 2231 // For TraceEventCallbackAndRecordingX tests. |
| 2232 void VerifyCallbackAndRecordedEvents(size_t expected_callback_count, | 2232 void VerifyCallbackAndRecordedEvents(size_t expected_callback_count, |
| 2233 size_t expected_recorded_count) { | 2233 size_t expected_recorded_count) { |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3084 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); | 3084 EXPECT_EQ(original_option.enable_sampling, new_options.enable_sampling); |
| 3085 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); | 3085 EXPECT_EQ(original_option.enable_systrace, new_options.enable_systrace); |
| 3086 } | 3086 } |
| 3087 } | 3087 } |
| 3088 } | 3088 } |
| 3089 } | 3089 } |
| 3090 | 3090 |
| 3091 | 3091 |
| 3092 } // namespace debug | 3092 } // namespace debug |
| 3093 } // namespace base | 3093 } // namespace base |
| OLD | NEW |