OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Unit tests for event trace consumer_ base class. | 5 // Unit tests for event trace consumer_ base class. |
6 #include "base/event_trace_consumer_win.h" | 6 #include "base/event_trace_consumer_win.h" |
7 #include <list> | 7 #include <list> |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/event_trace_controller_win.h" | 9 #include "base/event_trace_controller_win.h" |
10 #include "base/event_trace_provider_win.h" | 10 #include "base/event_trace_provider_win.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 }; | 65 }; |
66 | 66 |
67 ScopedHandle TestConsumer::sank_event_; | 67 ScopedHandle TestConsumer::sank_event_; |
68 EventQueue TestConsumer::events_; | 68 EventQueue TestConsumer::events_; |
69 | 69 |
70 const wchar_t* const kTestSessionName = L"TestLogSession"; | 70 const wchar_t* const kTestSessionName = L"TestLogSession"; |
71 | 71 |
72 class EtwTraceConsumerBaseTest: public testing::Test { | 72 class EtwTraceConsumerBaseTest: public testing::Test { |
73 public: | 73 public: |
74 virtual void SetUp() { | 74 virtual void SetUp() { |
75 EtwTraceController::Stop(kTestSessionName, NULL); | 75 EtwTraceProperties ignore; |
| 76 EtwTraceController::Stop(kTestSessionName, &ignore); |
76 } | 77 } |
77 }; | 78 }; |
78 | 79 |
79 } // namespace | 80 } // namespace |
80 | 81 |
81 TEST_F(EtwTraceConsumerBaseTest, Initialize) { | 82 TEST_F(EtwTraceConsumerBaseTest, Initialize) { |
82 TestConsumer consumer_; | 83 TestConsumer consumer_; |
83 } | 84 } |
84 | 85 |
85 TEST_F(EtwTraceConsumerBaseTest, OpenRealtimeSucceedsWhenNoSession) { | 86 TEST_F(EtwTraceConsumerBaseTest, OpenRealtimeSucceedsWhenNoSession) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 namespace { | 239 namespace { |
239 | 240 |
240 // We run events through a file session to assert that | 241 // We run events through a file session to assert that |
241 // the content comes through. | 242 // the content comes through. |
242 class EtwTraceConsumerDataTest: public testing::Test { | 243 class EtwTraceConsumerDataTest: public testing::Test { |
243 public: | 244 public: |
244 EtwTraceConsumerDataTest() { | 245 EtwTraceConsumerDataTest() { |
245 } | 246 } |
246 | 247 |
247 virtual void SetUp() { | 248 virtual void SetUp() { |
248 EtwTraceController::Stop(kTestSessionName, NULL); | 249 EtwTraceProperties prop; |
| 250 EtwTraceController::Stop(kTestSessionName, &prop); |
249 // Construct a temp file name. | 251 // Construct a temp file name. |
250 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_)); | 252 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_)); |
251 } | 253 } |
252 | 254 |
253 virtual void TearDown() { | 255 virtual void TearDown() { |
254 EXPECT_TRUE(file_util::Delete(temp_file_, false)); | 256 EXPECT_TRUE(file_util::Delete(temp_file_, false)); |
255 EtwTraceController::Stop(kTestSessionName, NULL); | 257 EtwTraceProperties ignore; |
| 258 EtwTraceController::Stop(kTestSessionName, &ignore); |
256 } | 259 } |
257 | 260 |
258 HRESULT LogEventToTempSession(PEVENT_TRACE_HEADER header) { | 261 HRESULT LogEventToTempSession(PEVENT_TRACE_HEADER header) { |
259 EtwTraceController controller; | 262 EtwTraceController controller; |
260 | 263 |
261 // Set up a file session. | 264 // Set up a file session. |
262 HRESULT hr = controller.StartFileSession(kTestSessionName, | 265 HRESULT hr = controller.StartFileSession(kTestSessionName, |
263 temp_file_.value().c_str()); | 266 temp_file_.value().c_str()); |
264 if (FAILED(hr)) | 267 if (FAILED(hr)) |
265 return hr; | 268 return hr; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 PEVENT_TRACE trace = NULL; | 331 PEVENT_TRACE trace = NULL; |
329 HRESULT hr = RoundTripEvent(&event.header, &trace); | 332 HRESULT hr = RoundTripEvent(&event.header, &trace); |
330 if (hr == E_ACCESSDENIED) { | 333 if (hr == E_ACCESSDENIED) { |
331 LOG(INFO) << "You must be an administrator to run this test on Vista"; | 334 LOG(INFO) << "You must be an administrator to run this test on Vista"; |
332 return; | 335 return; |
333 } | 336 } |
334 ASSERT_TRUE(NULL != trace); | 337 ASSERT_TRUE(NULL != trace); |
335 ASSERT_EQ(sizeof(kData), trace->MofLength); | 338 ASSERT_EQ(sizeof(kData), trace->MofLength); |
336 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); | 339 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); |
337 } | 340 } |
OLD | NEW |