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 controller. | 5 // Unit tests for event trace controller. |
6 #include "base/event_trace_controller_win.h" | 6 #include "base/event_trace_controller_win.h" |
7 #include "base/event_trace_provider_win.h" | 7 #include "base/event_trace_provider_win.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 EXPECT_EQ(NULL, controller.session()); | 113 EXPECT_EQ(NULL, controller.session()); |
114 EXPECT_STREQ(L"", controller.session_name()); | 114 EXPECT_STREQ(L"", controller.session_name()); |
115 } | 115 } |
116 | 116 |
117 TEST(EtwTraceControllerTest, StartRealTimeSession) { | 117 TEST(EtwTraceControllerTest, StartRealTimeSession) { |
118 EtwTraceController controller; | 118 EtwTraceController controller; |
119 | 119 |
120 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); | 120 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); |
121 if (hr == E_ACCESSDENIED) { | 121 if (hr == E_ACCESSDENIED) { |
122 LOG(INFO) << "You must be an administrator to run this test on Vista"; | 122 VLOG(1) << "You must be an administrator to run this test on Vista"; |
123 return; | 123 return; |
124 } | 124 } |
125 | 125 |
126 EXPECT_TRUE(NULL != controller.session()); | 126 EXPECT_TRUE(NULL != controller.session()); |
127 EXPECT_STREQ(kTestSessionName, controller.session_name()); | 127 EXPECT_STREQ(kTestSessionName, controller.session_name()); |
128 | 128 |
129 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 129 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
130 EXPECT_EQ(NULL, controller.session()); | 130 EXPECT_EQ(NULL, controller.session()); |
131 EXPECT_STREQ(L"", controller.session_name()); | 131 EXPECT_STREQ(L"", controller.session_name()); |
132 } | 132 } |
133 | 133 |
134 TEST(EtwTraceControllerTest, StartFileSession) { | 134 TEST(EtwTraceControllerTest, StartFileSession) { |
135 FilePath temp; | 135 FilePath temp; |
136 | 136 |
137 ASSERT_HRESULT_SUCCEEDED(file_util::CreateTemporaryFile(&temp)); | 137 ASSERT_HRESULT_SUCCEEDED(file_util::CreateTemporaryFile(&temp)); |
138 | 138 |
139 EtwTraceController controller; | 139 EtwTraceController controller; |
140 HRESULT hr = controller.StartFileSession(kTestSessionName, | 140 HRESULT hr = controller.StartFileSession(kTestSessionName, |
141 temp.value().c_str()); | 141 temp.value().c_str()); |
142 if (hr == E_ACCESSDENIED) { | 142 if (hr == E_ACCESSDENIED) { |
143 LOG(INFO) << "You must be an administrator to run this test on Vista"; | 143 VLOG(1) << "You must be an administrator to run this test on Vista"; |
144 return; | 144 return; |
145 } | 145 } |
146 | 146 |
147 EXPECT_TRUE(NULL != controller.session()); | 147 EXPECT_TRUE(NULL != controller.session()); |
148 EXPECT_STREQ(kTestSessionName, controller.session_name()); | 148 EXPECT_STREQ(kTestSessionName, controller.session_name()); |
149 | 149 |
150 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 150 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
151 EXPECT_EQ(NULL, controller.session()); | 151 EXPECT_EQ(NULL, controller.session()); |
152 EXPECT_STREQ(L"", controller.session_name()); | 152 EXPECT_STREQ(L"", controller.session_name()); |
153 } | 153 } |
154 | 154 |
155 // Flaky, http://crbug.com/59328. | 155 // Flaky, http://crbug.com/59328. |
156 TEST(EtwTraceControllerTest, FLAKY_EnableDisable) { | 156 TEST(EtwTraceControllerTest, FLAKY_EnableDisable) { |
157 TestingProvider provider(kTestProvider); | 157 TestingProvider provider(kTestProvider); |
158 | 158 |
159 EXPECT_EQ(ERROR_SUCCESS, provider.Register()); | 159 EXPECT_EQ(ERROR_SUCCESS, provider.Register()); |
160 EXPECT_EQ(NULL, provider.session_handle()); | 160 EXPECT_EQ(NULL, provider.session_handle()); |
161 | 161 |
162 EtwTraceController controller; | 162 EtwTraceController controller; |
163 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); | 163 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); |
164 if (hr == E_ACCESSDENIED) { | 164 if (hr == E_ACCESSDENIED) { |
165 LOG(INFO) << "You must be an administrator to run this test on Vista"; | 165 VLOG(1) << "You must be an administrator to run this test on Vista"; |
166 return; | 166 return; |
167 } | 167 } |
168 | 168 |
169 EXPECT_HRESULT_SUCCEEDED(controller.EnableProvider(kTestProvider, | 169 EXPECT_HRESULT_SUCCEEDED(controller.EnableProvider(kTestProvider, |
170 TRACE_LEVEL_VERBOSE, kTestProviderFlags)); | 170 TRACE_LEVEL_VERBOSE, kTestProviderFlags)); |
171 | 171 |
172 provider.WaitForCallback(); | 172 provider.WaitForCallback(); |
173 | 173 |
174 EXPECT_EQ(TRACE_LEVEL_VERBOSE, provider.enable_level()); | 174 EXPECT_EQ(TRACE_LEVEL_VERBOSE, provider.enable_level()); |
175 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); | 175 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); |
(...skipping 19 matching lines...) Expand all Loading... |
195 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); | 195 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); |
196 | 196 |
197 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 197 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
198 | 198 |
199 provider.WaitForCallback(); | 199 provider.WaitForCallback(); |
200 | 200 |
201 // Session should have wound down. | 201 // Session should have wound down. |
202 EXPECT_EQ(0, provider.enable_level()); | 202 EXPECT_EQ(0, provider.enable_level()); |
203 EXPECT_EQ(0, provider.enable_flags()); | 203 EXPECT_EQ(0, provider.enable_flags()); |
204 } | 204 } |
OLD | NEW |