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 // Unit tests for event trace consumer base class. | 5 // Unit tests for event trace consumer base class. |
6 #include "base/win/event_trace_consumer.h" | 6 #include "base/win/event_trace_consumer.h" |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include <objbase.h> | 10 #include <objbase.h> |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 EtwTraceProperties prop; | 284 EtwTraceProperties prop; |
285 EtwTraceController::Stop(session_name_.c_str(), &prop); | 285 EtwTraceController::Stop(session_name_.c_str(), &prop); |
286 | 286 |
287 // Create a temp dir for this test. | 287 // Create a temp dir for this test. |
288 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 288 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
289 // Construct a temp file name in our dir. | 289 // Construct a temp file name in our dir. |
290 temp_file_ = temp_dir_.path().Append(L"test.etl"); | 290 temp_file_ = temp_dir_.path().Append(L"test.etl"); |
291 } | 291 } |
292 | 292 |
293 virtual void TearDown() { | 293 virtual void TearDown() { |
294 EXPECT_TRUE(base::Delete(temp_file_, false)); | 294 EXPECT_TRUE(base::DeleteFile(temp_file_, false)); |
295 | 295 |
296 EtwTraceConsumerBaseTest::TearDown(); | 296 EtwTraceConsumerBaseTest::TearDown(); |
297 } | 297 } |
298 | 298 |
299 HRESULT LogEventToTempSession(PEVENT_TRACE_HEADER header) { | 299 HRESULT LogEventToTempSession(PEVENT_TRACE_HEADER header) { |
300 EtwTraceController controller; | 300 EtwTraceController controller; |
301 | 301 |
302 // Set up a file session. | 302 // Set up a file session. |
303 HRESULT hr = controller.StartFileSession(session_name_.c_str(), | 303 HRESULT hr = controller.StartFileSession(session_name_.c_str(), |
304 temp_file_.value().c_str()); | 304 temp_file_.value().c_str()); |
(...skipping 23 matching lines...) Expand all Loading... |
328 HRESULT hr = consumer_.OpenFileSession(temp_file_.value().c_str()); | 328 HRESULT hr = consumer_.OpenFileSession(temp_file_.value().c_str()); |
329 if (SUCCEEDED(hr)) | 329 if (SUCCEEDED(hr)) |
330 hr = consumer_.Consume(); | 330 hr = consumer_.Consume(); |
331 consumer_.Close(); | 331 consumer_.Close(); |
332 // And nab the result. | 332 // And nab the result. |
333 events_.swap(TestConsumer::events_); | 333 events_.swap(TestConsumer::events_); |
334 return hr; | 334 return hr; |
335 } | 335 } |
336 | 336 |
337 HRESULT RoundTripEvent(PEVENT_TRACE_HEADER header, PEVENT_TRACE* trace) { | 337 HRESULT RoundTripEvent(PEVENT_TRACE_HEADER header, PEVENT_TRACE* trace) { |
338 base::Delete(temp_file_, false); | 338 base::DeleteFile(temp_file_, false); |
339 | 339 |
340 HRESULT hr = LogEventToTempSession(header); | 340 HRESULT hr = LogEventToTempSession(header); |
341 if (SUCCEEDED(hr)) | 341 if (SUCCEEDED(hr)) |
342 hr = ConsumeEventFromTempSession(); | 342 hr = ConsumeEventFromTempSession(); |
343 | 343 |
344 if (FAILED(hr)) | 344 if (FAILED(hr)) |
345 return hr; | 345 return hr; |
346 | 346 |
347 // We should now have the event in the queue. | 347 // We should now have the event in the queue. |
348 if (events_.empty()) | 348 if (events_.empty()) |
(...skipping 25 matching lines...) Expand all Loading... |
374 return; | 374 return; |
375 } | 375 } |
376 ASSERT_HRESULT_SUCCEEDED(hr) << "RoundTripEvent failed"; | 376 ASSERT_HRESULT_SUCCEEDED(hr) << "RoundTripEvent failed"; |
377 ASSERT_TRUE(NULL != trace); | 377 ASSERT_TRUE(NULL != trace); |
378 ASSERT_EQ(sizeof(kData), trace->MofLength); | 378 ASSERT_EQ(sizeof(kData), trace->MofLength); |
379 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); | 379 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); |
380 } | 380 } |
381 | 381 |
382 } // namespace win | 382 } // namespace win |
383 } // namespace base | 383 } // namespace base |
OLD | NEW |