| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
| 15 #include "ipc/ipc_channel_proxy.h" | 15 #include "ipc/ipc_channel_proxy.h" |
| 16 #include "ipc/ipc_listener.h" | 16 #include "ipc/ipc_listener.h" |
| 17 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
| 18 #include "remoting/base/auto_thread.h" | 18 #include "remoting/base/auto_thread.h" |
| 19 #include "remoting/base/auto_thread_task_runner.h" | 19 #include "remoting/base/auto_thread_task_runner.h" |
| 20 #include "remoting/host/chromoting_messages.h" | 20 #include "remoting/host/chromoting_messages.h" |
| 21 #include "remoting/host/desktop_process.h" | 21 #include "remoting/host/desktop_process.h" |
| 22 #include "remoting/host/fake_screen_capturer.h" | 22 #include "remoting/host/fake_desktop_capturer.h" |
| 23 #include "remoting/host/host_exit_codes.h" | 23 #include "remoting/host/host_exit_codes.h" |
| 24 #include "remoting/host/host_mock_objects.h" | 24 #include "remoting/host/host_mock_objects.h" |
| 25 #include "remoting/host/screen_resolution.h" | 25 #include "remoting/host/screen_resolution.h" |
| 26 #include "remoting/protocol/protocol_mock_objects.h" | 26 #include "remoting/protocol/protocol_mock_objects.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gmock_mutant.h" | 28 #include "testing/gmock_mutant.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 30 |
| 31 using testing::_; | 31 using testing::_; |
| 32 using testing::AnyNumber; | 32 using testing::AnyNumber; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 virtual ~DesktopProcessTest(); | 98 virtual ~DesktopProcessTest(); |
| 99 | 99 |
| 100 // testing::Test overrides | 100 // testing::Test overrides |
| 101 virtual void SetUp() OVERRIDE; | 101 virtual void SetUp() OVERRIDE; |
| 102 virtual void TearDown() OVERRIDE; | 102 virtual void TearDown() OVERRIDE; |
| 103 | 103 |
| 104 // MockDaemonListener mocks | 104 // MockDaemonListener mocks |
| 105 void ConnectNetworkChannel(IPC::PlatformFileForTransit desktop_process); | 105 void ConnectNetworkChannel(IPC::PlatformFileForTransit desktop_process); |
| 106 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_process); | 106 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_process); |
| 107 | 107 |
| 108 // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, to mock | 108 // Creates a DesktopEnvironment with a fake webrtc::DesktopCapturer, to mock |
| 109 // DesktopEnvironmentFactory::Create(). | 109 // DesktopEnvironmentFactory::Create(). |
| 110 DesktopEnvironment* CreateDesktopEnvironment(); | 110 DesktopEnvironment* CreateDesktopEnvironment(); |
| 111 | 111 |
| 112 // Creates a dummy InputInjector, to mock | 112 // Creates a dummy InputInjector, to mock |
| 113 // DesktopEnvironment::CreateInputInjector(). | 113 // DesktopEnvironment::CreateInputInjector(). |
| 114 InputInjector* CreateInputInjector(); | 114 InputInjector* CreateInputInjector(); |
| 115 | 115 |
| 116 // Creates a fake webrtc::ScreenCapturer, to mock | 116 // Creates a fake webrtc::DesktopCapturer, to mock |
| 117 // DesktopEnvironment::CreateVideoCapturer(). | 117 // DesktopEnvironment::CreateVideoCapturer(). |
| 118 webrtc::ScreenCapturer* CreateVideoCapturer(); | 118 webrtc::DesktopCapturer* CreateVideoCapturer(); |
| 119 | 119 |
| 120 // Disconnects the daemon-to-desktop channel causing the desktop process to | 120 // Disconnects the daemon-to-desktop channel causing the desktop process to |
| 121 // exit. | 121 // exit. |
| 122 void DisconnectChannels(); | 122 void DisconnectChannels(); |
| 123 | 123 |
| 124 // Posts DisconnectChannels() to |message_loop_|. | 124 // Posts DisconnectChannels() to |message_loop_|. |
| 125 void PostDisconnectChannels(); | 125 void PostDisconnectChannels(); |
| 126 | 126 |
| 127 // Runs the desktop process code in a separate thread. | 127 // Runs the desktop process code in a separate thread. |
| 128 void RunDesktopProcess(); | 128 void RunDesktopProcess(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 network_listener_.OnDesktopEnvironmentCreated(); | 211 network_listener_.OnDesktopEnvironmentCreated(); |
| 212 return desktop_environment; | 212 return desktop_environment; |
| 213 } | 213 } |
| 214 | 214 |
| 215 InputInjector* DesktopProcessTest::CreateInputInjector() { | 215 InputInjector* DesktopProcessTest::CreateInputInjector() { |
| 216 MockInputInjector* input_injector = new MockInputInjector(); | 216 MockInputInjector* input_injector = new MockInputInjector(); |
| 217 EXPECT_CALL(*input_injector, StartPtr(_)); | 217 EXPECT_CALL(*input_injector, StartPtr(_)); |
| 218 return input_injector; | 218 return input_injector; |
| 219 } | 219 } |
| 220 | 220 |
| 221 webrtc::ScreenCapturer* DesktopProcessTest::CreateVideoCapturer() { | 221 webrtc::DesktopCapturer* DesktopProcessTest::CreateVideoCapturer() { |
| 222 return new FakeScreenCapturer(); | 222 return new FakeDesktopCapturer(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void DesktopProcessTest::DisconnectChannels() { | 225 void DesktopProcessTest::DisconnectChannels() { |
| 226 daemon_channel_.reset(); | 226 daemon_channel_.reset(); |
| 227 network_channel_.reset(); | 227 network_channel_.reset(); |
| 228 io_task_runner_ = NULL; | 228 io_task_runner_ = NULL; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void DesktopProcessTest::PostDisconnectChannels() { | 231 void DesktopProcessTest::PostDisconnectChannels() { |
| 232 message_loop_.PostTask(FROM_HERE, base::Bind( | 232 message_loop_.PostTask(FROM_HERE, base::Bind( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 337 } |
| 338 | 338 |
| 339 // Run the desktop process and ask it to crash. | 339 // Run the desktop process and ask it to crash. |
| 340 TEST_F(DesktopProcessTest, DeathTest) { | 340 TEST_F(DesktopProcessTest, DeathTest) { |
| 341 testing::GTEST_FLAG(death_test_style) = "threadsafe"; | 341 testing::GTEST_FLAG(death_test_style) = "threadsafe"; |
| 342 | 342 |
| 343 EXPECT_DEATH(RunDeathTest(), ""); | 343 EXPECT_DEATH(RunDeathTest(), ""); |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace remoting | 346 } // namespace remoting |
| OLD | NEW |