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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
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.AppendSwitchASCII(switches::kProcessChannelID, kRendererTestChannelName); |
82 kRendererTestChannelName); | |
83 | 82 |
84 MainFunctionParams dummy_params(cl, dummy_sandbox_init, NULL); | 83 MainFunctionParams dummy_params(cl, dummy_sandbox_init, NULL); |
85 return RendererMain(dummy_params); | 84 return RendererMain(dummy_params); |
86 } | 85 } |
87 | 86 |
88 TEST_F(RendererMainTest, CreateDestroy) { | 87 TEST_F(RendererMainTest, CreateDestroy) { |
89 SuicidalListener listener; | 88 SuicidalListener listener; |
90 IPC::Channel control_channel(kRendererTestChannelName, | 89 IPC::Channel control_channel(kRendererTestChannelName, |
91 IPC::Channel::MODE_SERVER, | 90 IPC::Channel::MODE_SERVER, |
92 &listener); | 91 &listener); |
93 base::ProcessHandle renderer_pid = SpawnChild("SimpleRenderer", | 92 base::ProcessHandle renderer_pid = SpawnChild("SimpleRenderer", |
94 &control_channel); | 93 &control_channel); |
95 | 94 |
96 control_channel.Connect(); | 95 control_channel.Connect(); |
97 MessageLoop::current()->Run(); | 96 MessageLoop::current()->Run(); |
98 | 97 |
99 // The renderer should exit when we close the channel. | 98 // The renderer should exit when we close the channel. |
100 control_channel.Close(); | 99 control_channel.Close(); |
101 | 100 |
102 EXPECT_TRUE(base::WaitForSingleProcess(renderer_pid, 5000)); | 101 EXPECT_TRUE(base::WaitForSingleProcess(renderer_pid, 5000)); |
103 } | 102 } |
104 #endif // defined(OS_POSIX) | 103 #endif // defined(OS_POSIX) |
OLD | NEW |