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

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

Issue 10382159: Revert 136990 - Make sure the thread calling CoCreateGuid is CoInitialized. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « no previous file | base/win/event_trace_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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
8 #include <list> 8 #include <list>
9 9
10 #include <objbase.h> 10 #include <objbase.h>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/process.h" 16 #include "base/process.h"
17 #include "base/scoped_temp_dir.h" 17 #include "base/scoped_temp_dir.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/win/event_trace_controller.h" 19 #include "base/win/event_trace_controller.h"
20 #include "base/win/event_trace_provider.h" 20 #include "base/win/event_trace_provider.h"
21 #include "base/win/scoped_com_initializer.h"
22 #include "base/win/scoped_handle.h" 21 #include "base/win/scoped_handle.h"
23 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
24 23
25 #include <initguid.h> // NOLINT - has to be last 24 #include <initguid.h> // NOLINT - has to be last
26 25
27 namespace { 26 namespace {
28 27
29 using base::win::EtwMofEvent; 28 using base::win::EtwMofEvent;
30 using base::win::EtwTraceController; 29 using base::win::EtwTraceController;
31 using base::win::EtwTraceConsumerBase; 30 using base::win::EtwTraceConsumerBase;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ASSERT_HRESULT_SUCCEEDED(::CoCreateGuid(&test_provider_)); 96 ASSERT_HRESULT_SUCCEEDED(::CoCreateGuid(&test_provider_));
98 } 97 }
99 98
100 virtual void TearDown() { 99 virtual void TearDown() {
101 // Cleanup any potentially danging sessions. 100 // Cleanup any potentially danging sessions.
102 EtwTraceProperties ignore; 101 EtwTraceProperties ignore;
103 EtwTraceController::Stop(session_name_.c_str(), &ignore); 102 EtwTraceController::Stop(session_name_.c_str(), &ignore);
104 } 103 }
105 104
106 protected: 105 protected:
107 base::win::ScopedCOMInitializer com_initializer_;
108 GUID test_provider_; 106 GUID test_provider_;
109 std::wstring session_name_; 107 std::wstring session_name_;
110 }; 108 };
111 109
112 } // namespace 110 } // namespace
113 111
114 TEST_F(EtwTraceConsumerBaseTest, Initialize) { 112 TEST_F(EtwTraceConsumerBaseTest, Initialize) {
115 TestConsumer consumer_; 113 TestConsumer consumer_;
116 } 114 }
117 115
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 236 }
239 237
240 namespace { 238 namespace {
241 239
242 // {57E47923-A549-476f-86CA-503D57F59E62} 240 // {57E47923-A549-476f-86CA-503D57F59E62}
243 DEFINE_GUID(kTestEventType, 241 DEFINE_GUID(kTestEventType,
244 0x57e47923, 0xa549, 0x476f, 0x86, 0xca, 0x50, 0x3d, 0x57, 0xf5, 0x9e, 0x62); 242 0x57e47923, 0xa549, 0x476f, 0x86, 0xca, 0x50, 0x3d, 0x57, 0xf5, 0x9e, 0x62);
245 243
246 } // namespace 244 } // namespace
247 245
248 TEST_F(EtwTraceConsumerRealtimeTest, ConsumeEvent) { 246 // Fails consistently on Vista. http://crbug.com/127671
247 TEST_F(EtwTraceConsumerRealtimeTest, DISABLED_ConsumeEvent) {
249 EtwTraceController controller; 248 EtwTraceController controller;
250 HRESULT hr = controller.StartRealtimeSession(session_name_.c_str(), 249 HRESULT hr = controller.StartRealtimeSession(session_name_.c_str(),
251 100 * 1024); 250 100 * 1024);
252 if (hr == E_ACCESSDENIED) { 251 if (hr == E_ACCESSDENIED) {
253 VLOG(1) << "You must be an administrator to run this test on Vista"; 252 VLOG(1) << "You must be an administrator to run this test on Vista";
254 return; 253 return;
255 } 254 }
256 255
257 ASSERT_HRESULT_SUCCEEDED(controller.EnableProvider(test_provider_, 256 ASSERT_HRESULT_SUCCEEDED(controller.EnableProvider(test_provider_,
258 TRACE_LEVEL_VERBOSE, 0xFFFFFFFF)); 257 TRACE_LEVEL_VERBOSE, 0xFFFFFFFF));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 HRESULT hr = RoundTripEvent(&event.header, &trace); 374 HRESULT hr = RoundTripEvent(&event.header, &trace);
376 if (hr == E_ACCESSDENIED) { 375 if (hr == E_ACCESSDENIED) {
377 VLOG(1) << "You must be an administrator to run this test on Vista"; 376 VLOG(1) << "You must be an administrator to run this test on Vista";
378 return; 377 return;
379 } 378 }
380 ASSERT_HRESULT_SUCCEEDED(hr) << "RoundTripEvent failed"; 379 ASSERT_HRESULT_SUCCEEDED(hr) << "RoundTripEvent failed";
381 ASSERT_TRUE(NULL != trace); 380 ASSERT_TRUE(NULL != trace);
382 ASSERT_EQ(sizeof(kData), trace->MofLength); 381 ASSERT_EQ(sizeof(kData), trace->MofLength);
383 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData)); 382 ASSERT_STREQ(kData, reinterpret_cast<const char*>(trace->MofData));
384 } 383 }
OLDNEW
« no previous file with comments | « no previous file | base/win/event_trace_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698