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 controller. | 5 // Unit tests for event trace controller. |
6 | 6 |
7 #include <objbase.h> | 7 #include <objbase.h> |
8 #include <initguid.h> | 8 #include <initguid.h> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 : EtwTraceProvider(provider_name) { | 35 : EtwTraceProvider(provider_name) { |
36 callback_event_.Set(::CreateEvent(NULL, TRUE, FALSE, NULL)); | 36 callback_event_.Set(::CreateEvent(NULL, TRUE, FALSE, NULL)); |
37 } | 37 } |
38 | 38 |
39 void WaitForCallback() { | 39 void WaitForCallback() { |
40 ::WaitForSingleObject(callback_event_.Get(), INFINITE); | 40 ::WaitForSingleObject(callback_event_.Get(), INFINITE); |
41 ::ResetEvent(callback_event_.Get()); | 41 ::ResetEvent(callback_event_.Get()); |
42 } | 42 } |
43 | 43 |
44 private: | 44 private: |
45 virtual void OnEventsEnabled() { | 45 void OnEventsEnabled() override { ::SetEvent(callback_event_.Get()); } |
46 ::SetEvent(callback_event_.Get()); | 46 void PostEventsDisabled() override { ::SetEvent(callback_event_.Get()); } |
47 } | |
48 virtual void PostEventsDisabled() { | |
49 ::SetEvent(callback_event_.Get()); | |
50 } | |
51 | 47 |
52 ScopedHandle callback_event_; | 48 ScopedHandle callback_event_; |
53 | 49 |
54 DISALLOW_COPY_AND_ASSIGN(TestingProvider); | 50 DISALLOW_COPY_AND_ASSIGN(TestingProvider); |
55 }; | 51 }; |
56 | 52 |
57 } // namespace | 53 } // namespace |
58 | 54 |
59 TEST(EtwTracePropertiesTest, Initialization) { | 55 TEST(EtwTracePropertiesTest, Initialization) { |
60 EtwTraceProperties prop; | 56 EtwTraceProperties prop; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 102 } |
107 | 103 |
108 namespace { | 104 namespace { |
109 | 105 |
110 class EtwTraceControllerTest : public testing::Test { | 106 class EtwTraceControllerTest : public testing::Test { |
111 public: | 107 public: |
112 EtwTraceControllerTest() | 108 EtwTraceControllerTest() |
113 : session_name_(StringPrintf(L"TestSession-%d", GetCurrentProcId())) { | 109 : session_name_(StringPrintf(L"TestSession-%d", GetCurrentProcId())) { |
114 } | 110 } |
115 | 111 |
116 virtual void SetUp() { | 112 void SetUp() override { |
117 EtwTraceProperties ignore; | 113 EtwTraceProperties ignore; |
118 EtwTraceController::Stop(session_name_.c_str(), &ignore); | 114 EtwTraceController::Stop(session_name_.c_str(), &ignore); |
119 | 115 |
120 // Allocate a new provider name GUID for each test. | 116 // Allocate a new provider name GUID for each test. |
121 ASSERT_HRESULT_SUCCEEDED(::CoCreateGuid(&test_provider_)); | 117 ASSERT_HRESULT_SUCCEEDED(::CoCreateGuid(&test_provider_)); |
122 } | 118 } |
123 | 119 |
124 virtual void TearDown() { | 120 void TearDown() override { |
125 EtwTraceProperties prop; | 121 EtwTraceProperties prop; |
126 EtwTraceController::Stop(session_name_.c_str(), &prop); | 122 EtwTraceController::Stop(session_name_.c_str(), &prop); |
127 } | 123 } |
128 | 124 |
129 protected: | 125 protected: |
130 GUID test_provider_; | 126 GUID test_provider_; |
131 std::wstring session_name_; | 127 std::wstring session_name_; |
132 }; | 128 }; |
133 | 129 |
134 } // namespace | 130 } // namespace |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 225 |
230 provider.WaitForCallback(); | 226 provider.WaitForCallback(); |
231 | 227 |
232 // Session should have wound down. | 228 // Session should have wound down. |
233 EXPECT_EQ(0, provider.enable_level()); | 229 EXPECT_EQ(0, provider.enable_level()); |
234 EXPECT_EQ(0, provider.enable_flags()); | 230 EXPECT_EQ(0, provider.enable_flags()); |
235 } | 231 } |
236 | 232 |
237 } // namespace win | 233 } // namespace win |
238 } // namespace base | 234 } // namespace base |
OLD | NEW |