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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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) 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.h" 8 #include "base/message_loop.h"
9 #include "base/power_monitor/power_monitor.h" 9 #include "base/power_monitor/power_monitor.h"
10 #include "base/test/thread_test_helper.h" 10 #include "base/test/thread_test_helper.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 profile2_ = profile_manager_.CreateTestingProfile("two"); 107 profile2_ = profile_manager_.CreateTestingProfile("two");
108 } 108 }
109 109
110 TestingProfile* CreateIncognitoProfile(TestingProfile* base) { 110 TestingProfile* CreateIncognitoProfile(TestingProfile* base) {
111 TestingProfile* incognito = new TestingProfile; // Owned by |base|. 111 TestingProfile* incognito = new TestingProfile; // Owned by |base|.
112 incognito->set_incognito(true); 112 incognito->set_incognito(true);
113 base->SetOffTheRecordProfile(incognito); 113 base->SetOffTheRecordProfile(incognito);
114 return incognito; 114 return incognito;
115 } 115 }
116 116
117 MessageLoopForUI message_loop_; 117 base::MessageLoopForUI message_loop_;
118 content::TestBrowserThread ui_thread_; 118 content::TestBrowserThread ui_thread_;
119 content::TestBrowserThread io_thread_; 119 content::TestBrowserThread io_thread_;
120 TestingProfileManager profile_manager_; 120 TestingProfileManager profile_manager_;
121 scoped_ptr<base::PowerMonitor> dummy; 121 scoped_ptr<base::PowerMonitor> dummy;
122 // Profiles are weak pointers, owned by ProfileManager in |browser_process_|. 122 // Profiles are weak pointers, owned by ProfileManager in |browser_process_|.
123 TestingProfile* profile1_; 123 TestingProfile* profile1_;
124 TestingProfile* profile2_; 124 TestingProfile* profile2_;
125 }; 125 };
126 126
127 TEST_F(EventRouterForwarderTest, BroadcastRendererUI) { 127 TEST_F(EventRouterForwarderTest, BroadcastRendererUI) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 base::Bind( 165 base::Bind(
166 &BroadcastEventToRenderers, base::Unretained(event_router.get()), 166 &BroadcastEventToRenderers, base::Unretained(event_router.get()),
167 kEventName, url)); 167 kEventName, url));
168 168
169 // Wait for IO thread's message loop to be processed 169 // Wait for IO thread's message loop to be processed
170 scoped_refptr<base::ThreadTestHelper> helper( 170 scoped_refptr<base::ThreadTestHelper> helper(
171 new base::ThreadTestHelper( 171 new base::ThreadTestHelper(
172 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); 172 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
173 ASSERT_TRUE(helper->Run()); 173 ASSERT_TRUE(helper->Run());
174 174
175 MessageLoop::current()->RunUntilIdle(); 175 base::MessageLoop::current()->RunUntilIdle();
176 } 176 }
177 177
178 TEST_F(EventRouterForwarderTest, UnicastRendererUIRestricted) { 178 TEST_F(EventRouterForwarderTest, UnicastRendererUIRestricted) {
179 scoped_refptr<MockEventRouterForwarder> event_router( 179 scoped_refptr<MockEventRouterForwarder> event_router(
180 new MockEventRouterForwarder); 180 new MockEventRouterForwarder);
181 using ::testing::_; 181 using ::testing::_;
182 GURL url; 182 GURL url;
183 EXPECT_CALL(*event_router, 183 EXPECT_CALL(*event_router,
184 CallEventRouter(profile1_, "", kEventName, profile1_, url)); 184 CallEventRouter(profile1_, "", kEventName, profile1_, url));
185 EXPECT_CALL(*event_router, 185 EXPECT_CALL(*event_router,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 GURL url; 280 GURL url;
281 EXPECT_CALL(*event_router, 281 EXPECT_CALL(*event_router,
282 CallEventRouter(profile1_, kExt, kEventName, NULL, url)); 282 CallEventRouter(profile1_, kExt, kEventName, NULL, url));
283 EXPECT_CALL(*event_router, 283 EXPECT_CALL(*event_router,
284 CallEventRouter(profile2_, _, _, _, _)).Times(0); 284 CallEventRouter(profile2_, _, _, _, _)).Times(0);
285 DispatchEventToExtension(event_router.get(), kExt, kEventName, profile1_, 285 DispatchEventToExtension(event_router.get(), kExt, kEventName, profile1_,
286 false, url); 286 false, url);
287 } 287 }
288 288
289 } // namespace extensions 289 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/event_router.cc ('k') | chrome/browser/extensions/extension_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698