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.h" | 11 #include "base/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 "media/video/capture/screen/screen_capturer_fake.h" | |
19 #include "remoting/base/auto_thread.h" | 18 #include "remoting/base/auto_thread.h" |
20 #include "remoting/base/auto_thread_task_runner.h" | 19 #include "remoting/base/auto_thread_task_runner.h" |
21 #include "remoting/host/chromoting_messages.h" | 20 #include "remoting/host/chromoting_messages.h" |
22 #include "remoting/host/desktop_process.h" | 21 #include "remoting/host/desktop_process.h" |
23 #include "remoting/host/host_exit_codes.h" | 22 #include "remoting/host/host_exit_codes.h" |
24 #include "remoting/host/host_mock_objects.h" | 23 #include "remoting/host/host_mock_objects.h" |
| 24 #include "remoting/host/screen_capturer_fake.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_mutant.h" | 28 #include "testing/gmock_mutant.h" |
28 #include "testing/gmock/include/gmock/gmock.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; |
33 using testing::AtMost; | 33 using testing::AtMost; |
34 using testing::InSequence; | 34 using testing::InSequence; |
35 using testing::Return; | 35 using testing::Return; |
36 | 36 |
37 namespace remoting { | 37 namespace remoting { |
38 | 38 |
(...skipping 59 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 media::ScreenCapturer, to mock | 108 // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, 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 media::ScreenCapturer, to mock | 116 // Creates a fake webrtc::ScreenCapturer, to mock |
117 // DesktopEnvironment::CreateVideoCapturer(). | 117 // DesktopEnvironment::CreateVideoCapturer(). |
118 media::ScreenCapturer* CreateVideoCapturer(); | 118 webrtc::ScreenCapturer* 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 network_listener_.OnDesktopEnvironmentCreated(); | 212 network_listener_.OnDesktopEnvironmentCreated(); |
213 return desktop_environment; | 213 return desktop_environment; |
214 } | 214 } |
215 | 215 |
216 InputInjector* DesktopProcessTest::CreateInputInjector() { | 216 InputInjector* DesktopProcessTest::CreateInputInjector() { |
217 MockInputInjector* input_injector = new MockInputInjector(); | 217 MockInputInjector* input_injector = new MockInputInjector(); |
218 EXPECT_CALL(*input_injector, StartPtr(_)); | 218 EXPECT_CALL(*input_injector, StartPtr(_)); |
219 return input_injector; | 219 return input_injector; |
220 } | 220 } |
221 | 221 |
222 media::ScreenCapturer* DesktopProcessTest::CreateVideoCapturer() { | 222 webrtc::ScreenCapturer* DesktopProcessTest::CreateVideoCapturer() { |
223 return new media::ScreenCapturerFake(); | 223 return new ScreenCapturerFake(); |
224 } | 224 } |
225 | 225 |
226 void DesktopProcessTest::DisconnectChannels() { | 226 void DesktopProcessTest::DisconnectChannels() { |
227 daemon_channel_.reset(); | 227 daemon_channel_.reset(); |
228 network_channel_.reset(); | 228 network_channel_.reset(); |
229 io_task_runner_ = NULL; | 229 io_task_runner_ = NULL; |
230 } | 230 } |
231 | 231 |
232 void DesktopProcessTest::PostDisconnectChannels() { | 232 void DesktopProcessTest::PostDisconnectChannels() { |
233 message_loop_.PostTask(FROM_HERE, base::Bind( | 233 message_loop_.PostTask(FROM_HERE, base::Bind( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 | 339 |
340 // Run the desktop process and ask it to crash. | 340 // Run the desktop process and ask it to crash. |
341 TEST_F(DesktopProcessTest, DeathTest) { | 341 TEST_F(DesktopProcessTest, DeathTest) { |
342 testing::GTEST_FLAG(death_test_style) = "threadsafe"; | 342 testing::GTEST_FLAG(death_test_style) = "threadsafe"; |
343 | 343 |
344 EXPECT_DEATH(RunDeathTest(), ""); | 344 EXPECT_DEATH(RunDeathTest(), ""); |
345 } | 345 } |
346 | 346 |
347 } // namespace remoting | 347 } // namespace remoting |
OLD | NEW |