| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/win/event_trace_controller.h" | 6 |
| 7 #include "base/win/event_trace_provider.h" | 7 #include <initguid.h> // NOLINT. |
| 8 |
| 8 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/scoped_handle.h" | |
| 12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 13 #include "base/win/event_trace_controller.h" |
| 14 #include "base/win/event_trace_provider.h" |
| 15 #include "base/win/scoped_handle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include <initguid.h> // NOLINT - must be last. | |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 using base::win::EtwTraceController; | 20 using base::win::EtwTraceController; |
| 19 using base::win::EtwTraceProvider; | 21 using base::win::EtwTraceProvider; |
| 20 using base::win::EtwTraceProperties; | 22 using base::win::EtwTraceProperties; |
| 21 | 23 |
| 22 const wchar_t kTestSessionName[] = L"TestLogSession"; | 24 const wchar_t kTestSessionName[] = L"TestLogSession"; |
| 23 | 25 |
| 24 // {0D236A42-CD18-4e3d-9975-DCEEA2106E05} | 26 // {0D236A42-CD18-4e3d-9975-DCEEA2106E05} |
| (...skipping 18 matching lines...) Expand all Loading... |
| 43 } | 45 } |
| 44 | 46 |
| 45 private: | 47 private: |
| 46 virtual void OnEventsEnabled() { | 48 virtual void OnEventsEnabled() { |
| 47 ::SetEvent(callback_event_.Get()); | 49 ::SetEvent(callback_event_.Get()); |
| 48 } | 50 } |
| 49 virtual void PostEventsDisabled() { | 51 virtual void PostEventsDisabled() { |
| 50 ::SetEvent(callback_event_.Get()); | 52 ::SetEvent(callback_event_.Get()); |
| 51 } | 53 } |
| 52 | 54 |
| 53 ScopedHandle callback_event_; | 55 base::win::ScopedHandle callback_event_; |
| 54 | 56 |
| 55 DISALLOW_COPY_AND_ASSIGN(TestingProvider); | 57 DISALLOW_COPY_AND_ASSIGN(TestingProvider); |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 } // namespace | 60 } // namespace |
| 59 | 61 |
| 60 TEST(EtwTraceTest, Cleanup) { | 62 TEST(EtwTraceTest, Cleanup) { |
| 61 // Clean up potential leftover sessions from previous unsuccessful runs. | 63 // Clean up potential leftover sessions from previous unsuccessful runs. |
| 62 EtwTraceProperties ignore; | 64 EtwTraceProperties ignore; |
| 63 EtwTraceController::Stop(kTestSessionName, &ignore); | 65 EtwTraceController::Stop(kTestSessionName, &ignore); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); | 201 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); |
| 200 | 202 |
| 201 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 203 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
| 202 | 204 |
| 203 provider.WaitForCallback(); | 205 provider.WaitForCallback(); |
| 204 | 206 |
| 205 // Session should have wound down. | 207 // Session should have wound down. |
| 206 EXPECT_EQ(0, provider.enable_level()); | 208 EXPECT_EQ(0, provider.enable_level()); |
| 207 EXPECT_EQ(0, provider.enable_flags()); | 209 EXPECT_EQ(0, provider.enable_flags()); |
| 208 } | 210 } |
| OLD | NEW |