Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: base/win/event_trace_consumer_unittest.cc

Issue 6126002: Remove base/scoped_handle_win.h stub and fix up all callers to use the new location and namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 consumer_ base class. 5 // Unit tests for event trace consumer_ base class.
6 #include "base/win/event_trace_consumer.h" 6 #include "base/win/event_trace_consumer.h"
7
7 #include <list> 8 #include <list>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/win/event_trace_controller.h"
10 #include "base/win/event_trace_provider.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/scoped_handle.h" 14 #include "base/win/event_trace_controller.h"
15 #include "base/win/event_trace_provider.h"
16 #include "base/win/scoped_handle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 #include <initguid.h> // NOLINT - has to be last 19 #include <initguid.h> // NOLINT - has to be last
18 20
19 namespace { 21 namespace {
20 22
21 using base::win::EtwMofEvent; 23 using base::win::EtwMofEvent;
22 using base::win::EtwTraceController; 24 using base::win::EtwTraceController;
23 using base::win::EtwTraceConsumerBase; 25 using base::win::EtwTraceConsumerBase;
24 using base::win::EtwTraceProperties; 26 using base::win::EtwTraceProperties;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 back.MofData = new char[event->MofLength]; 58 back.MofData = new char[event->MofLength];
57 memcpy(back.MofData, event->MofData, event->MofLength); 59 memcpy(back.MofData, event->MofData, event->MofLength);
58 } 60 }
59 } 61 }
60 62
61 static void ProcessEvent(EVENT_TRACE* event) { 63 static void ProcessEvent(EVENT_TRACE* event) {
62 EnqueueEvent(event); 64 EnqueueEvent(event);
63 ::SetEvent(sank_event_.Get()); 65 ::SetEvent(sank_event_.Get());
64 } 66 }
65 67
66 static ScopedHandle sank_event_; 68 static base::win::ScopedHandle sank_event_;
67 static EventQueue events_; 69 static EventQueue events_;
68 70
69 private: 71 private:
70 DISALLOW_COPY_AND_ASSIGN(TestConsumer); 72 DISALLOW_COPY_AND_ASSIGN(TestConsumer);
71 }; 73 };
72 74
73 ScopedHandle TestConsumer::sank_event_; 75 base::win::ScopedHandle TestConsumer::sank_event_;
74 EventQueue TestConsumer::events_; 76 EventQueue TestConsumer::events_;
75 77
76 const wchar_t* const kTestSessionName = L"TestLogSession"; 78 const wchar_t* const kTestSessionName = L"TestLogSession";
77 79
78 class EtwTraceConsumerBaseTest: public testing::Test { 80 class EtwTraceConsumerBaseTest: public testing::Test {
79 public: 81 public:
80 virtual void SetUp() { 82 virtual void SetUp() {
81 EtwTraceProperties ignore; 83 EtwTraceProperties ignore;
82 EtwTraceController::Stop(kTestSessionName, &ignore); 84 EtwTraceController::Stop(kTestSessionName, &ignore);
83 } 85 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return HRESULT_FROM_WIN32(::GetLastError()); 170 return HRESULT_FROM_WIN32(::GetLastError());
169 171
170 DWORD exit_code = 0; 172 DWORD exit_code = 0;
171 if (::GetExitCodeThread(consumer_thread_, &exit_code)) 173 if (::GetExitCodeThread(consumer_thread_, &exit_code))
172 return exit_code; 174 return exit_code;
173 175
174 return HRESULT_FROM_WIN32(::GetLastError()); 176 return HRESULT_FROM_WIN32(::GetLastError());
175 } 177 }
176 178
177 TestConsumer consumer_; 179 TestConsumer consumer_;
178 ScopedHandle consumer_ready_; 180 base::win::ScopedHandle consumer_ready_;
179 ScopedHandle consumer_thread_; 181 base::win::ScopedHandle consumer_thread_;
180 }; 182 };
181 } // namespace 183 } // namespace
182 184
183 TEST_F(EtwTraceConsumerRealtimeTest, ConsumerReturnsWhenSessionClosed) { 185 TEST_F(EtwTraceConsumerRealtimeTest, ConsumerReturnsWhenSessionClosed) {
184 EtwTraceController controller; 186 EtwTraceController controller;
185 187
186 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024); 188 HRESULT hr = controller.StartRealtimeSession(kTestSessionName, 100 * 1024);
187 if (hr == E_ACCESSDENIED) { 189 if (hr == E_ACCESSDENIED) {
188 VLOG(1) << "You must be an administrator to run this test on Vista"; 190 VLOG(1) << "You must be an administrator to run this test on Vista";
189 return; 191 return;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 PEVENT_TRACE trace = NULL; 339 PEVENT_TRACE trace = NULL;
338 HRESULT hr = RoundTripEvent(&event.header, &trace); 340 HRESULT hr = RoundTripEvent(&event.header, &trace);
339 if (hr == E_ACCESSDENIED) { 341 if (hr == E_ACCESSDENIED) {
340 VLOG(1) << "You must be an administrator to run this test on Vista"; 342 VLOG(1) << "You must be an administrator to run this test on Vista";
341 return; 343 return;
342 } 344 }
343 ASSERT_TRUE(NULL != trace); 345 ASSERT_TRUE(NULL != trace);
344 ASSERT_EQ(sizeof(kData), trace->MofLength); 346 ASSERT_EQ(sizeof(kData), trace->MofLength);
345 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); 347 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData));
346 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698