| 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 "remoting/host/desktop_process.h" | 5 #include "remoting/host/desktop_process.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 void DesktopProcessTest::ConnectNetworkChannel( | 170 void DesktopProcessTest::ConnectNetworkChannel( |
| 171 IPC::PlatformFileForTransit desktop_process) { | 171 IPC::PlatformFileForTransit desktop_process) { |
| 172 | 172 |
| 173 #if defined(OS_POSIX) | 173 #if defined(OS_POSIX) |
| 174 IPC::ChannelHandle channel_handle(std::string(), desktop_process); | 174 IPC::ChannelHandle channel_handle(std::string(), desktop_process); |
| 175 #elif defined(OS_WIN) | 175 #elif defined(OS_WIN) |
| 176 IPC::ChannelHandle channel_handle(desktop_process); | 176 IPC::ChannelHandle channel_handle(desktop_process); |
| 177 #endif // defined(OS_WIN) | 177 #endif // defined(OS_WIN) |
| 178 | 178 |
| 179 network_channel_.reset(new IPC::ChannelProxy( | 179 network_channel_.reset(new IPC::ChannelProxy(channel_handle, |
| 180 channel_handle, | 180 IPC::Channel::MODE_CLIENT, |
| 181 IPC::Channel::MODE_CLIENT, | 181 &network_listener_, |
| 182 &network_listener_, | 182 io_task_runner_.get())); |
| 183 io_task_runner_)); | |
| 184 } | 183 } |
| 185 | 184 |
| 186 void DesktopProcessTest::OnDesktopAttached( | 185 void DesktopProcessTest::OnDesktopAttached( |
| 187 IPC::PlatformFileForTransit desktop_process) { | 186 IPC::PlatformFileForTransit desktop_process) { |
| 188 #if defined(OS_POSIX) | 187 #if defined(OS_POSIX) |
| 189 DCHECK(desktop_process.auto_close); | 188 DCHECK(desktop_process.auto_close); |
| 190 | 189 |
| 191 base::ClosePlatformFile(desktop_process.fd); | 190 base::ClosePlatformFile(desktop_process.fd); |
| 192 #endif // defined(OS_POSIX) | 191 #endif // defined(OS_POSIX) |
| 193 } | 192 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), | 240 base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), |
| 242 message_loop_.message_loop_proxy(), | 241 message_loop_.message_loop_proxy(), |
| 243 FROM_HERE, run_loop.QuitClosure()); | 242 FROM_HERE, run_loop.QuitClosure()); |
| 244 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = new AutoThreadTaskRunner( | 243 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = new AutoThreadTaskRunner( |
| 245 message_loop_.message_loop_proxy(), quit_ui_task_runner); | 244 message_loop_.message_loop_proxy(), quit_ui_task_runner); |
| 246 | 245 |
| 247 io_task_runner_ = AutoThread::CreateWithType( | 246 io_task_runner_ = AutoThread::CreateWithType( |
| 248 "IPC thread", ui_task_runner, base::MessageLoop::TYPE_IO); | 247 "IPC thread", ui_task_runner, base::MessageLoop::TYPE_IO); |
| 249 | 248 |
| 250 std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID(); | 249 std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID(); |
| 251 daemon_channel_.reset(new IPC::ChannelProxy( | 250 daemon_channel_.reset(new IPC::ChannelProxy(IPC::ChannelHandle(channel_name), |
| 252 IPC::ChannelHandle(channel_name), | 251 IPC::Channel::MODE_SERVER, |
| 253 IPC::Channel::MODE_SERVER, | 252 &daemon_listener_, |
| 254 &daemon_listener_, | 253 io_task_runner_.get())); |
| 255 io_task_runner_)); | |
| 256 | 254 |
| 257 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory( | 255 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory( |
| 258 new MockDesktopEnvironmentFactory()); | 256 new MockDesktopEnvironmentFactory()); |
| 259 EXPECT_CALL(*desktop_environment_factory, CreatePtr()) | 257 EXPECT_CALL(*desktop_environment_factory, CreatePtr()) |
| 260 .Times(AnyNumber()) | 258 .Times(AnyNumber()) |
| 261 .WillRepeatedly(Invoke(this, | 259 .WillRepeatedly(Invoke(this, |
| 262 &DesktopProcessTest::CreateDesktopEnvironment)); | 260 &DesktopProcessTest::CreateDesktopEnvironment)); |
| 263 EXPECT_CALL(*desktop_environment_factory, SupportsAudioCapture()) | 261 EXPECT_CALL(*desktop_environment_factory, SupportsAudioCapture()) |
| 264 .Times(AnyNumber()) | 262 .Times(AnyNumber()) |
| 265 .WillRepeatedly(Return(false)); | 263 .WillRepeatedly(Return(false)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 338 } |
| 341 | 339 |
| 342 // Run the desktop process and ask it to crash. | 340 // Run the desktop process and ask it to crash. |
| 343 TEST_F(DesktopProcessTest, DeathTest) { | 341 TEST_F(DesktopProcessTest, DeathTest) { |
| 344 testing::GTEST_FLAG(death_test_style) = "threadsafe"; | 342 testing::GTEST_FLAG(death_test_style) = "threadsafe"; |
| 345 | 343 |
| 346 EXPECT_DEATH(RunDeathTest(), ""); | 344 EXPECT_DEATH(RunDeathTest(), ""); |
| 347 } | 345 } |
| 348 | 346 |
| 349 } // namespace remoting | 347 } // namespace remoting |
| OLD | NEW |