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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ScopedTempDir temp_dir; | 164 ScopedTempDir temp_dir; |
165 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 165 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
166 FilePath temp; | 166 FilePath temp; |
167 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir.path(), &temp)); | 167 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir.path(), &temp)); |
168 | 168 |
169 EtwTraceController controller; | 169 EtwTraceController controller; |
170 HRESULT hr = controller.StartFileSession(session_name_.c_str(), | 170 HRESULT hr = controller.StartFileSession(session_name_.c_str(), |
171 temp.value().c_str()); | 171 temp.value().c_str()); |
172 if (hr == E_ACCESSDENIED) { | 172 if (hr == E_ACCESSDENIED) { |
173 VLOG(1) << "You must be an administrator to run this test on Vista"; | 173 VLOG(1) << "You must be an administrator to run this test on Vista"; |
174 base::Delete(temp, false); | 174 base::DeleteFile(temp, false); |
175 return; | 175 return; |
176 } | 176 } |
177 | 177 |
178 EXPECT_TRUE(NULL != controller.session()); | 178 EXPECT_TRUE(NULL != controller.session()); |
179 EXPECT_STREQ(session_name_.c_str(), controller.session_name()); | 179 EXPECT_STREQ(session_name_.c_str(), controller.session_name()); |
180 | 180 |
181 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 181 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
182 EXPECT_EQ(NULL, controller.session()); | 182 EXPECT_EQ(NULL, controller.session()); |
183 EXPECT_STREQ(L"", controller.session_name()); | 183 EXPECT_STREQ(L"", controller.session_name()); |
184 base::Delete(temp, false); | 184 base::DeleteFile(temp, false); |
185 } | 185 } |
186 | 186 |
187 TEST_F(EtwTraceControllerTest, EnableDisable) { | 187 TEST_F(EtwTraceControllerTest, EnableDisable) { |
188 TestingProvider provider(test_provider_); | 188 TestingProvider provider(test_provider_); |
189 | 189 |
190 EXPECT_EQ(ERROR_SUCCESS, provider.Register()); | 190 EXPECT_EQ(ERROR_SUCCESS, provider.Register()); |
191 EXPECT_EQ(NULL, provider.session_handle()); | 191 EXPECT_EQ(NULL, provider.session_handle()); |
192 | 192 |
193 EtwTraceController controller; | 193 EtwTraceController controller; |
194 HRESULT hr = controller.StartRealtimeSession(session_name_.c_str(), | 194 HRESULT hr = controller.StartRealtimeSession(session_name_.c_str(), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 provider.WaitForCallback(); | 231 provider.WaitForCallback(); |
232 | 232 |
233 // Session should have wound down. | 233 // Session should have wound down. |
234 EXPECT_EQ(0, provider.enable_level()); | 234 EXPECT_EQ(0, provider.enable_level()); |
235 EXPECT_EQ(0, provider.enable_flags()); | 235 EXPECT_EQ(0, provider.enable_flags()); |
236 } | 236 } |
237 | 237 |
238 } // namespace win | 238 } // namespace win |
239 } // namespace base | 239 } // namespace base |
OLD | NEW |