| OLD | NEW |
| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "base/debug/debug_on_start_win.h" | 22 #include "base/debug/debug_on_start_win.h" |
| 23 #include "base/perftimer.h" | 23 #include "base/perftimer.h" |
| 24 #include "base/test/perf_test_suite.h" | 24 #include "base/test/perf_test_suite.h" |
| 25 #include "base/test/test_suite.h" | 25 #include "base/test/test_suite.h" |
| 26 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
| 27 #include "ipc/ipc_descriptors.h" | 27 #include "ipc/ipc_descriptors.h" |
| 28 #include "ipc/ipc_channel.h" | 28 #include "ipc/ipc_channel.h" |
| 29 #include "ipc/ipc_channel_proxy.h" | 29 #include "ipc/ipc_channel_proxy.h" |
| 30 #include "ipc/ipc_message_utils.h" | 30 #include "ipc/ipc_message_utils.h" |
| 31 #include "ipc/ipc_multiprocess_test.h" |
| 31 #include "ipc/ipc_sender.h" | 32 #include "ipc/ipc_sender.h" |
| 32 #include "ipc/ipc_switches.h" | 33 #include "ipc/ipc_switches.h" |
| 33 #include "testing/multiprocess_func_list.h" | 34 #include "testing/multiprocess_func_list.h" |
| 34 | 35 |
| 35 // Define to enable IPC performance testing instead of the regular unit tests | 36 // Define to enable IPC performance testing instead of the regular unit tests |
| 36 // #define PERFORMANCE_TEST | 37 // #define PERFORMANCE_TEST |
| 37 | 38 |
| 38 const char kTestClientChannel[] = "T1"; | 39 const char kTestClientChannel[] = "T1"; |
| 39 const char kReflectorChannel[] = "T2"; | 40 const char kReflectorChannel[] = "T2"; |
| 40 const char kFuzzerChannel[] = "F3"; | 41 const char kFuzzerChannel[] = "F3"; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 MessageLoop::current()->Run(); | 396 MessageLoop::current()->Run(); |
| 396 | 397 |
| 397 // Close Channel so client gets its OnChannelError() callback fired. | 398 // Close Channel so client gets its OnChannelError() callback fired. |
| 398 channel.Close(); | 399 channel.Close(); |
| 399 | 400 |
| 400 // Cleanup child process. | 401 // Cleanup child process. |
| 401 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000)); | 402 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000)); |
| 402 base::CloseProcessHandle(process_handle); | 403 base::CloseProcessHandle(process_handle); |
| 403 } | 404 } |
| 404 | 405 |
| 405 MULTIPROCESS_TEST_MAIN(RunTestClient) { | 406 MULTIPROCESS_IPC_TEST_MAIN(RunTestClient) { |
| 406 MessageLoopForIO main_message_loop; | 407 MessageLoopForIO main_message_loop; |
| 407 MyChannelListener channel_listener; | 408 MyChannelListener channel_listener; |
| 408 | 409 |
| 409 // setup IPC channel | 410 // setup IPC channel |
| 410 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_CLIENT, | 411 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_CLIENT, |
| 411 &channel_listener); | 412 &channel_listener); |
| 412 CHECK(chan.Connect()); | 413 CHECK(chan.Connect()); |
| 413 channel_listener.Init(&chan); | 414 channel_listener.Init(&chan); |
| 414 Send(&chan, "hello from child"); | 415 Send(&chan, "hello from child"); |
| 415 // run message loop | 416 // run message loop |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 | 566 |
| 566 // run message loop | 567 // run message loop |
| 567 MessageLoop::current()->Run(); | 568 MessageLoop::current()->Run(); |
| 568 | 569 |
| 569 // cleanup child process | 570 // cleanup child process |
| 570 WaitForSingleObject(process, 5000); | 571 WaitForSingleObject(process, 5000); |
| 571 CloseHandle(process); | 572 CloseHandle(process); |
| 572 } | 573 } |
| 573 | 574 |
| 574 // This message loop bounces all messages back to the sender | 575 // This message loop bounces all messages back to the sender |
| 575 MULTIPROCESS_TEST_MAIN(RunReflector) { | 576 MULTIPROCESS_IPC_TEST_MAIN(RunReflector) { |
| 576 MessageLoopForIO main_message_loop; | 577 MessageLoopForIO main_message_loop; |
| 577 IPC::Channel chan(kReflectorChannel, IPC::Channel::MODE_CLIENT, NULL); | 578 IPC::Channel chan(kReflectorChannel, IPC::Channel::MODE_CLIENT, NULL); |
| 578 ChannelReflectorListener channel_reflector_listener(&chan); | 579 ChannelReflectorListener channel_reflector_listener(&chan); |
| 579 chan.set_listener(&channel_reflector_listener); | 580 chan.set_listener(&channel_reflector_listener); |
| 580 ASSERT_TRUE(chan.Connect()); | 581 ASSERT_TRUE(chan.Connect()); |
| 581 | 582 |
| 582 MessageLoop::current()->Run(); | 583 MessageLoop::current()->Run(); |
| 583 return true; | 584 return true; |
| 584 } | 585 } |
| 585 | 586 |
| 586 #endif // PERFORMANCE_TEST | 587 #endif // PERFORMANCE_TEST |
| 587 | 588 |
| 588 int main(int argc, char** argv) { | 589 int main(int argc, char** argv) { |
| 589 #ifdef PERFORMANCE_TEST | 590 #ifdef PERFORMANCE_TEST |
| 590 int retval = base::PerfTestSuite(argc, argv).Run(); | 591 int retval = base::PerfTestSuite(argc, argv).Run(); |
| 591 #else | 592 #else |
| 592 int retval = base::TestSuite(argc, argv).Run(); | 593 int retval = base::TestSuite(argc, argv).Run(); |
| 593 #endif | 594 #endif |
| 594 return retval; | 595 return retval; |
| 595 } | 596 } |
| OLD | NEW |