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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/process/process.h" | 17 #include "base/process/process_handle.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/win/event_trace_controller.h" | 19 #include "base/win/event_trace_controller.h" |
20 #include "base/win/event_trace_provider.h" | 20 #include "base/win/event_trace_provider.h" |
21 #include "base/win/scoped_handle.h" | 21 #include "base/win/scoped_handle.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
24 #include <initguid.h> // NOLINT - has to be last | 24 #include <initguid.h> // NOLINT - has to be last |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 namespace win { | 27 namespace win { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 private: | 72 private: |
73 DISALLOW_COPY_AND_ASSIGN(TestConsumer); | 73 DISALLOW_COPY_AND_ASSIGN(TestConsumer); |
74 }; | 74 }; |
75 | 75 |
76 ScopedHandle TestConsumer::sank_event_; | 76 ScopedHandle TestConsumer::sank_event_; |
77 EventQueue TestConsumer::events_; | 77 EventQueue TestConsumer::events_; |
78 | 78 |
79 class EtwTraceConsumerBaseTest: public testing::Test { | 79 class EtwTraceConsumerBaseTest: public testing::Test { |
80 public: | 80 public: |
81 EtwTraceConsumerBaseTest() | 81 EtwTraceConsumerBaseTest() |
82 : session_name_(StringPrintf(L"TestSession-%d", | 82 : session_name_(StringPrintf(L"TestSession-%d", GetCurrentProcId())) { |
83 Process::Current().pid())) { | |
84 } | 83 } |
85 | 84 |
86 virtual void SetUp() { | 85 virtual void SetUp() { |
87 // Cleanup any potentially dangling sessions. | 86 // Cleanup any potentially dangling sessions. |
88 EtwTraceProperties ignore; | 87 EtwTraceProperties ignore; |
89 EtwTraceController::Stop(session_name_.c_str(), &ignore); | 88 EtwTraceController::Stop(session_name_.c_str(), &ignore); |
90 | 89 |
91 // Allocate a new GUID for each provider test. | 90 // Allocate a new GUID for each provider test. |
92 ASSERT_HRESULT_SUCCEEDED(::CoCreateGuid(&test_provider_)); | 91 ASSERT_HRESULT_SUCCEEDED(::CoCreateGuid(&test_provider_)); |
93 } | 92 } |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 return; | 357 return; |
359 } | 358 } |
360 ASSERT_HRESULT_SUCCEEDED(hr) << "RoundTripEvent failed"; | 359 ASSERT_HRESULT_SUCCEEDED(hr) << "RoundTripEvent failed"; |
361 ASSERT_TRUE(trace != NULL); | 360 ASSERT_TRUE(trace != NULL); |
362 ASSERT_EQ(sizeof(kData), trace->MofLength); | 361 ASSERT_EQ(sizeof(kData), trace->MofLength); |
363 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); | 362 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); |
364 } | 363 } |
365 | 364 |
366 } // namespace win | 365 } // namespace win |
367 } // namespace base | 366 } // namespace base |
OLD | NEW |