| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/multiprocess_test.h" | 6 #include "base/multiprocess_test.h" |
| 7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/main_function_params.h" | 9 #include "chrome/common/main_function_params.h" |
| 10 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 void OnMessageReceived(const IPC::Message& message) { | 72 void OnMessageReceived(const IPC::Message& message) { |
| 73 // We shouldn't receive any messages | 73 // We shouldn't receive any messages |
| 74 ASSERT_TRUE(false); | 74 ASSERT_TRUE(false); |
| 75 } | 75 } |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 MULTIPROCESS_TEST_MAIN(SimpleRenderer) { | 78 MULTIPROCESS_TEST_MAIN(SimpleRenderer) { |
| 79 SandboxInitWrapper dummy_sandbox_init; | 79 SandboxInitWrapper dummy_sandbox_init; |
| 80 CommandLine cl(*CommandLine::ForCurrentProcess()); | 80 CommandLine cl(*CommandLine::ForCurrentProcess()); |
| 81 cl.AppendSwitchWithValue(switches::kProcessChannelID, | 81 cl.AppendSwitchWithValue(switches::kProcessChannelID, |
| 82 ASCIIToWide(kRendererTestChannelName)); | 82 kRendererTestChannelName); |
| 83 | 83 |
| 84 MainFunctionParams dummy_params(cl, dummy_sandbox_init, NULL); | 84 MainFunctionParams dummy_params(cl, dummy_sandbox_init, NULL); |
| 85 return RendererMain(dummy_params); | 85 return RendererMain(dummy_params); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST_F(RendererMainTest, CreateDestroy) { | 88 TEST_F(RendererMainTest, CreateDestroy) { |
| 89 SuicidalListener listener; | 89 SuicidalListener listener; |
| 90 IPC::Channel control_channel(kRendererTestChannelName, | 90 IPC::Channel control_channel(kRendererTestChannelName, |
| 91 IPC::Channel::MODE_SERVER, | 91 IPC::Channel::MODE_SERVER, |
| 92 &listener); | 92 &listener); |
| 93 base::ProcessHandle renderer_pid = SpawnChild(L"SimpleRenderer", | 93 base::ProcessHandle renderer_pid = SpawnChild(L"SimpleRenderer", |
| 94 &control_channel); | 94 &control_channel); |
| 95 | 95 |
| 96 control_channel.Connect(); | 96 control_channel.Connect(); |
| 97 MessageLoop::current()->Run(); | 97 MessageLoop::current()->Run(); |
| 98 | 98 |
| 99 // The renderer should exit when we close the channel. | 99 // The renderer should exit when we close the channel. |
| 100 control_channel.Close(); | 100 control_channel.Close(); |
| 101 | 101 |
| 102 EXPECT_TRUE(base::WaitForSingleProcess(renderer_pid, 5000)); | 102 EXPECT_TRUE(base::WaitForSingleProcess(renderer_pid, 5000)); |
| 103 } | 103 } |
| 104 #endif // defined(OS_POSIX) | 104 #endif // defined(OS_POSIX) |
| OLD | NEW |