OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/process.h" | 11 #include "base/process.h" |
12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.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 "ipc/ipc_platform_file.h" | 18 #include "ipc/ipc_platform_file.h" |
19 #include "media/video/capture/screen/screen_capturer_fake.h" | |
20 #include "media/video/capture/screen/screen_capturer_mock_objects.h" | |
21 #include "remoting/base/auto_thread.h" | 19 #include "remoting/base/auto_thread.h" |
22 #include "remoting/base/auto_thread_task_runner.h" | 20 #include "remoting/base/auto_thread_task_runner.h" |
23 #include "remoting/base/constants.h" | 21 #include "remoting/base/constants.h" |
24 #include "remoting/host/chromoting_messages.h" | 22 #include "remoting/host/chromoting_messages.h" |
25 #include "remoting/host/desktop_process.h" | 23 #include "remoting/host/desktop_process.h" |
26 #include "remoting/host/desktop_session.h" | 24 #include "remoting/host/desktop_session.h" |
27 #include "remoting/host/desktop_session_connector.h" | 25 #include "remoting/host/desktop_session_connector.h" |
28 #include "remoting/host/desktop_session_proxy.h" | 26 #include "remoting/host/desktop_session_proxy.h" |
29 #include "remoting/host/host_mock_objects.h" | 27 #include "remoting/host/host_mock_objects.h" |
30 #include "remoting/host/ipc_desktop_environment.h" | 28 #include "remoting/host/ipc_desktop_environment.h" |
| 29 #include "remoting/host/screen_capturer_fake.h" |
31 #include "remoting/protocol/protocol_mock_objects.h" | 30 #include "remoting/protocol/protocol_mock_objects.h" |
32 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
34 #include "third_party/skia/include/core/SkRegion.h" | 33 #include "third_party/skia/include/core/SkRegion.h" |
35 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 34 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
36 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 35 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
| 36 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" |
37 | 37 |
38 using testing::_; | 38 using testing::_; |
39 using testing::AnyNumber; | 39 using testing::AnyNumber; |
40 using testing::AtLeast; | 40 using testing::AtLeast; |
41 using testing::AtMost; | 41 using testing::AtMost; |
42 using testing::DeleteArg; | 42 using testing::DeleteArg; |
43 using testing::DoAll; | 43 using testing::DoAll; |
44 using testing::Return; | 44 using testing::Return; |
45 using testing::ReturnRef; | 45 using testing::ReturnRef; |
46 | 46 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 IpcDesktopEnvironmentTest(); | 123 IpcDesktopEnvironmentTest(); |
124 virtual ~IpcDesktopEnvironmentTest(); | 124 virtual ~IpcDesktopEnvironmentTest(); |
125 | 125 |
126 virtual void SetUp() OVERRIDE; | 126 virtual void SetUp() OVERRIDE; |
127 | 127 |
128 void ConnectTerminal(int terminal_id, | 128 void ConnectTerminal(int terminal_id, |
129 const ScreenResolution& resolution, | 129 const ScreenResolution& resolution, |
130 bool virtual_terminal); | 130 bool virtual_terminal); |
131 void DisconnectTerminal(int terminal_id); | 131 void DisconnectTerminal(int terminal_id); |
132 | 132 |
133 // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock | 133 // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, to mock |
134 // DesktopEnvironmentFactory::Create(). | 134 // DesktopEnvironmentFactory::Create(). |
135 DesktopEnvironment* CreateDesktopEnvironment(); | 135 DesktopEnvironment* CreateDesktopEnvironment(); |
136 | 136 |
137 // Creates a dummy InputInjector, to mock | 137 // Creates a dummy InputInjector, to mock |
138 // DesktopEnvironment::CreateInputInjector(). | 138 // DesktopEnvironment::CreateInputInjector(). |
139 InputInjector* CreateInputInjector(); | 139 InputInjector* CreateInputInjector(); |
140 | 140 |
141 // Creates a fake media::ScreenCapturer, to mock | 141 // Creates a fake webrtc::ScreenCapturer, to mock |
142 // DesktopEnvironment::CreateVideoCapturer(). | 142 // DesktopEnvironment::CreateVideoCapturer(). |
143 media::ScreenCapturer* CreateVideoCapturer(); | 143 webrtc::ScreenCapturer* CreateVideoCapturer(); |
144 | 144 |
145 void DeleteDesktopEnvironment(); | 145 void DeleteDesktopEnvironment(); |
146 | 146 |
147 // Forwards |event| to |clipboard_stub_|. | 147 // Forwards |event| to |clipboard_stub_|. |
148 void ReflectClipboardEvent(const protocol::ClipboardEvent& event); | 148 void ReflectClipboardEvent(const protocol::ClipboardEvent& event); |
149 | 149 |
150 protected: | 150 protected: |
151 // Creates and starts an instance of desktop process object. | 151 // Creates and starts an instance of desktop process object. |
152 void CreateDesktopProcess(); | 152 void CreateDesktopProcess(); |
153 | 153 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 scoped_ptr<IpcDesktopEnvironmentFactory> desktop_environment_factory_; | 191 scoped_ptr<IpcDesktopEnvironmentFactory> desktop_environment_factory_; |
192 scoped_ptr<DesktopEnvironment> desktop_environment_; | 192 scoped_ptr<DesktopEnvironment> desktop_environment_; |
193 | 193 |
194 // The IPC input injector. | 194 // The IPC input injector. |
195 scoped_ptr<InputInjector> input_injector_; | 195 scoped_ptr<InputInjector> input_injector_; |
196 | 196 |
197 // The IPC screen controls. | 197 // The IPC screen controls. |
198 scoped_ptr<ScreenControls> screen_controls_; | 198 scoped_ptr<ScreenControls> screen_controls_; |
199 | 199 |
200 // The IPC screen capturer. | 200 // The IPC screen capturer. |
201 scoped_ptr<media::ScreenCapturer> video_capturer_; | 201 scoped_ptr<webrtc::ScreenCapturer> video_capturer_; |
202 | 202 |
203 // Represents the desktop process running in a user session. | 203 // Represents the desktop process running in a user session. |
204 scoped_ptr<DesktopProcess> desktop_process_; | 204 scoped_ptr<DesktopProcess> desktop_process_; |
205 | 205 |
206 // Input injector owned by |desktop_process_|. | 206 // Input injector owned by |desktop_process_|. |
207 MockInputInjector* remote_input_injector_; | 207 MockInputInjector* remote_input_injector_; |
208 | 208 |
209 // The last |terminal_id| passed to ConnectTermina(); | 209 // The last |terminal_id| passed to ConnectTermina(); |
210 int terminal_id_; | 210 int terminal_id_; |
211 | 211 |
212 media::MockScreenCapturerCallback screen_capturer_callback_; | 212 webrtc::MockScreenCapturerCallback screen_capturer_callback_; |
213 | 213 |
214 MockClientSessionControl client_session_control_; | 214 MockClientSessionControl client_session_control_; |
215 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; | 215 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; |
216 }; | 216 }; |
217 | 217 |
218 IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest() | 218 IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest() |
219 : message_loop_(base::MessageLoop::TYPE_UI), | 219 : message_loop_(base::MessageLoop::TYPE_UI), |
220 client_jid_("user@domain/rest-of-jid"), | 220 client_jid_("user@domain/rest-of-jid"), |
221 clipboard_stub_(NULL), | 221 clipboard_stub_(NULL), |
222 remote_input_injector_(NULL), | 222 remote_input_injector_(NULL), |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 | 339 |
340 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { | 340 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { |
341 EXPECT_TRUE(remote_input_injector_ == NULL); | 341 EXPECT_TRUE(remote_input_injector_ == NULL); |
342 remote_input_injector_ = new MockInputInjector(); | 342 remote_input_injector_ = new MockInputInjector(); |
343 | 343 |
344 EXPECT_CALL(*remote_input_injector_, StartPtr(_)); | 344 EXPECT_CALL(*remote_input_injector_, StartPtr(_)); |
345 return remote_input_injector_; | 345 return remote_input_injector_; |
346 } | 346 } |
347 | 347 |
348 media::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { | 348 webrtc::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { |
349 return new media::ScreenCapturerFake(); | 349 return new ScreenCapturerFake(); |
350 } | 350 } |
351 | 351 |
352 void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { | 352 void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { |
353 input_injector_.reset(); | 353 input_injector_.reset(); |
354 screen_controls_.reset(); | 354 screen_controls_.reset(); |
355 video_capturer_.reset(); | 355 video_capturer_.reset(); |
356 | 356 |
357 // Trigger DisconnectTerminal(). | 357 // Trigger DisconnectTerminal(). |
358 desktop_environment_.reset(); | 358 desktop_environment_.reset(); |
359 } | 359 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 screen_controls_->SetScreenResolution(ScreenResolution( | 650 screen_controls_->SetScreenResolution(ScreenResolution( |
651 webrtc::DesktopSize(100, 100), | 651 webrtc::DesktopSize(100, 100), |
652 webrtc::DesktopVector(96, 96))); | 652 webrtc::DesktopVector(96, 96))); |
653 | 653 |
654 task_runner_ = NULL; | 654 task_runner_ = NULL; |
655 io_task_runner_ = NULL; | 655 io_task_runner_ = NULL; |
656 main_run_loop_.Run(); | 656 main_run_loop_.Run(); |
657 } | 657 } |
658 | 658 |
659 } // namespace remoting | 659 } // namespace remoting |
OLD | NEW |