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

Side by Side Diff: chrome/browser/extensions/event_router_forwarder_unittest.cc

Issue 179923006: Attempting to resolve a race condition with PowerMonitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win64 fixes Created 6 years, 8 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 | « base/timer/hi_res_timer_manager_win.cc ('k') | components/nacl/loader/nacl_helper_win_64.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 #include "chrome/browser/extensions/event_router_forwarder.h" 5 #include "chrome/browser/extensions/event_router_forwarder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/power_monitor/power_monitor.h" 9 #include "base/power_monitor/power_monitor.h"
10 #include "base/power_monitor/power_monitor_device_source.h" 10 #include "base/power_monitor/power_monitor_device_source.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 EventRouterForwarderTest() 90 EventRouterForwarderTest()
91 : ui_thread_(BrowserThread::UI, &message_loop_), 91 : ui_thread_(BrowserThread::UI, &message_loop_),
92 io_thread_(BrowserThread::IO), 92 io_thread_(BrowserThread::IO),
93 profile_manager_( 93 profile_manager_(
94 TestingBrowserProcess::GetGlobal()) { 94 TestingBrowserProcess::GetGlobal()) {
95 #if defined(OS_MACOSX) 95 #if defined(OS_MACOSX)
96 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); 96 base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
97 #endif 97 #endif
98 scoped_ptr<base::PowerMonitorSource> power_monitor_source( 98 scoped_ptr<base::PowerMonitorSource> power_monitor_source(
99 new base::PowerMonitorDeviceSource()); 99 new base::PowerMonitorDeviceSource());
100 dummy.reset(new base::PowerMonitor(power_monitor_source.Pass())); 100 base::PowerMonitor::Initialize(power_monitor_source.Pass());
101 }
102
103 virtual ~EventRouterForwarderTest() {
104 base::PowerMonitor::ShutdownForTesting();
101 } 105 }
102 106
103 virtual void SetUp() { 107 virtual void SetUp() {
104 ASSERT_TRUE(profile_manager_.SetUp()); 108 ASSERT_TRUE(profile_manager_.SetUp());
105 109
106 // Inject a BrowserProcess with a ProfileManager. 110 // Inject a BrowserProcess with a ProfileManager.
107 ASSERT_TRUE(io_thread_.Start()); 111 ASSERT_TRUE(io_thread_.Start());
108 112
109 profile1_ = profile_manager_.CreateTestingProfile("one"); 113 profile1_ = profile_manager_.CreateTestingProfile("one");
110 profile2_ = profile_manager_.CreateTestingProfile("two"); 114 profile2_ = profile_manager_.CreateTestingProfile("two");
111 } 115 }
112 116
113 base::MessageLoopForUI message_loop_; 117 base::MessageLoopForUI message_loop_;
114 content::TestBrowserThread ui_thread_; 118 content::TestBrowserThread ui_thread_;
115 content::TestBrowserThread io_thread_; 119 content::TestBrowserThread io_thread_;
116 TestingProfileManager profile_manager_; 120 TestingProfileManager profile_manager_;
117 scoped_ptr<base::PowerMonitor> dummy;
118 // Profiles are weak pointers, owned by ProfileManager in |browser_process_|. 121 // Profiles are weak pointers, owned by ProfileManager in |browser_process_|.
119 TestingProfile* profile1_; 122 TestingProfile* profile1_;
120 TestingProfile* profile2_; 123 TestingProfile* profile2_;
121 }; 124 };
122 125
123 TEST_F(EventRouterForwarderTest, BroadcastRendererUI) { 126 TEST_F(EventRouterForwarderTest, BroadcastRendererUI) {
124 scoped_refptr<MockEventRouterForwarder> event_router( 127 scoped_refptr<MockEventRouterForwarder> event_router(
125 new MockEventRouterForwarder); 128 new MockEventRouterForwarder);
126 GURL url; 129 GURL url;
127 EXPECT_CALL(*event_router.get(), 130 EXPECT_CALL(*event_router.get(),
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 GURL url; 278 GURL url;
276 EXPECT_CALL(*event_router.get(), 279 EXPECT_CALL(*event_router.get(),
277 CallEventRouter(profile1_, kExt, kEventName, NULL, url)); 280 CallEventRouter(profile1_, kExt, kEventName, NULL, url));
278 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _)) 281 EXPECT_CALL(*event_router.get(), CallEventRouter(profile2_, _, _, _, _))
279 .Times(0); 282 .Times(0);
280 DispatchEventToExtension(event_router.get(), kExt, kEventName, profile1_, 283 DispatchEventToExtension(event_router.get(), kExt, kEventName, profile1_,
281 false, url); 284 false, url);
282 } 285 }
283 286
284 } // namespace extensions 287 } // namespace extensions
OLDNEW
« no previous file with comments | « base/timer/hi_res_timer_manager_win.cc ('k') | components/nacl/loader/nacl_helper_win_64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698