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

Side by Side Diff: chrome/browser/multi_process_notification_unittest.cc

Issue 6246020: Revert 72645 - Multi process notifications on linux (dbus)... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « chrome/browser/multi_process_notification_linux.cc ('k') | chrome/chrome_common.gypi » ('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) 2011 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 #include "chrome/browser/multi_process_notification.h" 5 #include "chrome/browser/multi_process_notification.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/test/multiprocess_test.h" 12 #include "base/test/multiprocess_test.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "testing/multiprocess_func_list.h" 16 #include "testing/multiprocess_func_list.h"
17 17
18 #if defined(OS_POSIX) 18 #if defined(OS_MACOSX)
19 // TODO(ajwong): Remove defined(OS_POSIX) restriction once 19 // TODO(dmaclach): Remove defined(OS_MACOSX) once
20 // MultiProcessNotification is implemented on Win. 20 // MultiProcessNotification is implemented on Win/Linux.
21 21
22 namespace { 22 namespace {
23 23
24 const char kStartedNotificationName[] = "MultiProcessTestStartedNotification"; 24 const char kStartedNotificationName[] = "MultiProcessTestStartedNotification";
25 const char kQuitNotificationName[] = "MultiProcessTestQuitNotification"; 25 const char kQuitNotificationName[] = "MultiProcessTestQuitNotification";
26 26
27 void SpinRunLoop(int milliseconds) { 27 void SpinRunLoop(int milliseconds) {
28 MessageLoop *loop = MessageLoop::current(); 28 MessageLoop *loop = MessageLoop::current();
29 29
30 // Post a quit task so that this loop eventually ends and we don't hang 30 // Post a quit task so that this loop eventually ends and we don't hang
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 case multi_process_notification::SystemDomain: 237 case multi_process_notification::SystemDomain:
238 ASSERT_FALSE(profile_quitter.WasNotificationReceived()); 238 ASSERT_FALSE(profile_quitter.WasNotificationReceived());
239 ASSERT_FALSE(user_quitter.WasNotificationReceived()); 239 ASSERT_FALSE(user_quitter.WasNotificationReceived());
240 ASSERT_TRUE(system_quitter.WasNotificationReceived()); 240 ASSERT_TRUE(system_quitter.WasNotificationReceived());
241 break; 241 break;
242 } 242 }
243 } 243 }
244 244
245 TEST_F(MultiProcessNotificationTest, BasicCreationTest) { 245 TEST_F(MultiProcessNotificationTest, BasicCreationTest) {
246 QuitterDelegate quitter; 246 QuitterDelegate quitter;
247 MessageLoop* message_loop = IOMessageLoop();
248
249 multi_process_notification::Listener profile_listener(
250 "BasicCreationTest", multi_process_notification::ProfileDomain, &quitter);
251 ASSERT_TRUE(profile_listener.Start(message_loop));
252 SpinRunLoop(TestTimeouts::action_max_timeout_ms());
253 ASSERT_TRUE(quitter.WasStartedReceived());
254
255 multi_process_notification::Listener local_listener( 247 multi_process_notification::Listener local_listener(
256 "BasicCreationTest", multi_process_notification::UserDomain, &quitter); 248 "BasicCreationTest", multi_process_notification::UserDomain, &quitter);
249 MessageLoop* message_loop = IOMessageLoop();
257 ASSERT_TRUE(local_listener.Start(message_loop)); 250 ASSERT_TRUE(local_listener.Start(message_loop));
258 SpinRunLoop(TestTimeouts::action_max_timeout_ms()); 251 SpinRunLoop(TestTimeouts::action_max_timeout_ms());
259 ASSERT_TRUE(quitter.WasStartedReceived()); 252 ASSERT_TRUE(quitter.WasStartedReceived());
260
261 multi_process_notification::Listener system_listener( 253 multi_process_notification::Listener system_listener(
262 "BasicCreationTest", multi_process_notification::SystemDomain, &quitter); 254 "BasicCreationTest", multi_process_notification::SystemDomain, &quitter);
263 ASSERT_TRUE(system_listener.Start(message_loop)); 255 ASSERT_TRUE(system_listener.Start(message_loop));
264 SpinRunLoop(TestTimeouts::action_max_timeout_ms()); 256 SpinRunLoop(TestTimeouts::action_max_timeout_ms());
265 ASSERT_TRUE(quitter.WasStartedReceived()); 257 ASSERT_TRUE(quitter.WasStartedReceived());
266 }
267 258
268 TEST_F(MultiProcessNotificationTest, ListenOnNonIoThread) { 259 multi_process_notification::Listener local_listener2(
269 QuitterDelegate quitter; 260 "BasicCreationTest", multi_process_notification::UserDomain, &quitter);
270 multi_process_notification::Listener local_listener(
271 "ListenOnNonIoThread", multi_process_notification::UserDomain, &quitter);
272 // Should fail because current message loop should not be an IOMessageLoop. 261 // Should fail because current message loop should not be an IOMessageLoop.
273 ASSERT_FALSE(local_listener.Start(MessageLoop::current())); 262 ASSERT_FALSE(local_listener2.Start(MessageLoop::current()));
274 } 263 }
275 264
276 TEST_F(MultiProcessNotificationTest, PostInProcessNotification) { 265 TEST_F(MultiProcessNotificationTest, PostInProcessNotification) {
277 std::string local_notification("QuitLocalNotification"); 266 std::string local_notification("QuitLocalNotification");
278 QuitterDelegate quitter; 267 QuitterDelegate quitter;
279 MessageLoop* message_loop = IOMessageLoop();
280
281 multi_process_notification::Listener listener( 268 multi_process_notification::Listener listener(
282 local_notification, multi_process_notification::UserDomain, &quitter); 269 local_notification, multi_process_notification::UserDomain, &quitter);
270 MessageLoop* message_loop = IOMessageLoop();
283 ASSERT_TRUE(listener.Start(message_loop)); 271 ASSERT_TRUE(listener.Start(message_loop));
284 SpinRunLoop(TestTimeouts::action_max_timeout_ms()); 272 SpinRunLoop(TestTimeouts::action_max_timeout_ms());
285 ASSERT_TRUE(quitter.WasStartedReceived()); 273 ASSERT_TRUE(quitter.WasStartedReceived());
286
287 ASSERT_TRUE(multi_process_notification::Post( 274 ASSERT_TRUE(multi_process_notification::Post(
288 local_notification, multi_process_notification::UserDomain)); 275 local_notification, multi_process_notification::UserDomain));
289 SpinRunLoop(TestTimeouts::action_max_timeout_ms()); 276 SpinRunLoop(TestTimeouts::action_max_timeout_ms());
290 ASSERT_TRUE(quitter.WasNotificationReceived()); 277 ASSERT_TRUE(quitter.WasNotificationReceived());
291 } 278 }
292 279
293 TEST_F(MultiProcessNotificationTest, MultiListener) { 280 TEST_F(MultiProcessNotificationTest, MultiListener) {
294 std::string local_notification("LocalNotification"); 281 std::string local_notification("LocalNotification");
295 std::string quit_local_notification("QuitLocalNotification"); 282 std::string quit_local_notification("QuitLocalNotification");
296 283
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 344 }
358 345
359 MULTIPROCESS_TEST_MAIN(MultiProcessUserNotificationMain) { 346 MULTIPROCESS_TEST_MAIN(MultiProcessUserNotificationMain) {
360 return MultiProcessNotificationMain(multi_process_notification::UserDomain); 347 return MultiProcessNotificationMain(multi_process_notification::UserDomain);
361 } 348 }
362 349
363 MULTIPROCESS_TEST_MAIN(MultiProcessSystemNotificationMain) { 350 MULTIPROCESS_TEST_MAIN(MultiProcessSystemNotificationMain) {
364 return MultiProcessNotificationMain(multi_process_notification::SystemDomain); 351 return MultiProcessNotificationMain(multi_process_notification::SystemDomain);
365 } 352 }
366 353
367 #endif // defined(OS_POSIX) 354 #endif // defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « chrome/browser/multi_process_notification_linux.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698