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_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/process.h" | 14 #include "base/process.h" |
14 #include "base/scoped_temp_dir.h" | |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
17 #include "base/win/event_trace_controller.h" | 17 #include "base/win/event_trace_controller.h" |
18 #include "base/win/event_trace_provider.h" | 18 #include "base/win/event_trace_provider.h" |
19 #include "base/win/scoped_handle.h" | 19 #include "base/win/scoped_handle.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 using base::win::EtwTraceController; | 24 using base::win::EtwTraceController; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 EXPECT_TRUE(NULL != controller.session()); | 155 EXPECT_TRUE(NULL != controller.session()); |
156 EXPECT_STREQ(session_name_.c_str(), controller.session_name()); | 156 EXPECT_STREQ(session_name_.c_str(), controller.session_name()); |
157 | 157 |
158 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 158 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
159 EXPECT_EQ(NULL, controller.session()); | 159 EXPECT_EQ(NULL, controller.session()); |
160 EXPECT_STREQ(L"", controller.session_name()); | 160 EXPECT_STREQ(L"", controller.session_name()); |
161 } | 161 } |
162 | 162 |
163 TEST_F(EtwTraceControllerTest, StartFileSession) { | 163 TEST_F(EtwTraceControllerTest, StartFileSession) { |
164 ScopedTempDir temp_dir; | 164 base::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 file_util::Delete(temp, false); | 174 file_util::Delete(temp, false); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); | 227 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); |
228 | 228 |
229 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 229 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
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 } |
OLD | NEW |