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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/process/process.h" | 11 #include "base/process/process.h" |
12 #include "base/process/process_handle.h" | 12 #include "base/process/process_handle.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 "remoting/base/auto_thread.h" | 19 #include "remoting/base/auto_thread.h" |
20 #include "remoting/base/auto_thread_task_runner.h" | 20 #include "remoting/base/auto_thread_task_runner.h" |
21 #include "remoting/base/constants.h" | 21 #include "remoting/base/constants.h" |
22 #include "remoting/host/chromoting_messages.h" | 22 #include "remoting/host/chromoting_messages.h" |
23 #include "remoting/host/desktop_process.h" | 23 #include "remoting/host/desktop_process.h" |
24 #include "remoting/host/desktop_session.h" | 24 #include "remoting/host/desktop_session.h" |
25 #include "remoting/host/desktop_session_connector.h" | 25 #include "remoting/host/desktop_session_connector.h" |
26 #include "remoting/host/desktop_session_proxy.h" | 26 #include "remoting/host/desktop_session_proxy.h" |
| 27 #include "remoting/host/fake_mouse_cursor_monitor.h" |
27 #include "remoting/host/fake_screen_capturer.h" | 28 #include "remoting/host/fake_screen_capturer.h" |
28 #include "remoting/host/host_mock_objects.h" | 29 #include "remoting/host/host_mock_objects.h" |
29 #include "remoting/host/ipc_desktop_environment.h" | 30 #include "remoting/host/ipc_desktop_environment.h" |
30 #include "remoting/protocol/protocol_mock_objects.h" | 31 #include "remoting/protocol/protocol_mock_objects.h" |
31 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
33 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 34 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
34 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 35 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
35 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" | 36 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" |
36 | 37 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 DesktopEnvironment* CreateDesktopEnvironment(); | 135 DesktopEnvironment* CreateDesktopEnvironment(); |
135 | 136 |
136 // Creates a dummy InputInjector, to mock | 137 // Creates a dummy InputInjector, to mock |
137 // DesktopEnvironment::CreateInputInjector(). | 138 // DesktopEnvironment::CreateInputInjector(). |
138 InputInjector* CreateInputInjector(); | 139 InputInjector* CreateInputInjector(); |
139 | 140 |
140 // Creates a fake webrtc::ScreenCapturer, to mock | 141 // Creates a fake webrtc::ScreenCapturer, to mock |
141 // DesktopEnvironment::CreateVideoCapturer(). | 142 // DesktopEnvironment::CreateVideoCapturer(). |
142 webrtc::ScreenCapturer* CreateVideoCapturer(); | 143 webrtc::ScreenCapturer* CreateVideoCapturer(); |
143 | 144 |
| 145 // Creates a MockMouseCursorMonitor, to mock |
| 146 // DesktopEnvironment::CreateMouseCursorMonitor |
| 147 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor(); |
| 148 |
144 void DeleteDesktopEnvironment(); | 149 void DeleteDesktopEnvironment(); |
145 | 150 |
146 // Forwards |event| to |clipboard_stub_|. | 151 // Forwards |event| to |clipboard_stub_|. |
147 void ReflectClipboardEvent(const protocol::ClipboardEvent& event); | 152 void ReflectClipboardEvent(const protocol::ClipboardEvent& event); |
148 | 153 |
149 protected: | 154 protected: |
150 // Creates and starts an instance of desktop process object. | 155 // Creates and starts an instance of desktop process object. |
151 void CreateDesktopProcess(); | 156 void CreateDesktopProcess(); |
152 | 157 |
153 // Destroys the desktop process object created by CreateDesktopProcess(). | 158 // Destroys the desktop process object created by CreateDesktopProcess(). |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) | 322 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) |
318 .Times(AtMost(1)) | 323 .Times(AtMost(1)) |
319 .WillOnce(Invoke( | 324 .WillOnce(Invoke( |
320 this, &IpcDesktopEnvironmentTest::CreateInputInjector)); | 325 this, &IpcDesktopEnvironmentTest::CreateInputInjector)); |
321 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) | 326 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) |
322 .Times(AtMost(1)); | 327 .Times(AtMost(1)); |
323 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) | 328 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) |
324 .Times(AtMost(1)) | 329 .Times(AtMost(1)) |
325 .WillOnce(Invoke( | 330 .WillOnce(Invoke( |
326 this, &IpcDesktopEnvironmentTest::CreateVideoCapturer)); | 331 this, &IpcDesktopEnvironmentTest::CreateVideoCapturer)); |
| 332 EXPECT_CALL(*desktop_environment, CreateMouseCursorMonitorPtr()) |
| 333 .Times(AtMost(1)) |
| 334 .WillOnce(Invoke( |
| 335 this, &IpcDesktopEnvironmentTest::CreateMouseCursorMonitor)); |
327 EXPECT_CALL(*desktop_environment, GetCapabilities()) | 336 EXPECT_CALL(*desktop_environment, GetCapabilities()) |
328 .Times(AtMost(1)); | 337 .Times(AtMost(1)); |
329 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) | 338 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) |
330 .Times(AtMost(1)); | 339 .Times(AtMost(1)); |
331 | 340 |
332 // Let tests know that the remote desktop environment is created. | 341 // Let tests know that the remote desktop environment is created. |
333 message_loop_.PostTask(FROM_HERE, setup_run_loop_->QuitClosure()); | 342 message_loop_.PostTask(FROM_HERE, setup_run_loop_->QuitClosure()); |
334 | 343 |
335 return desktop_environment; | 344 return desktop_environment; |
336 } | 345 } |
337 | 346 |
338 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { | 347 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { |
339 EXPECT_TRUE(remote_input_injector_ == NULL); | 348 EXPECT_TRUE(remote_input_injector_ == NULL); |
340 remote_input_injector_ = new testing::StrictMock<MockInputInjector>(); | 349 remote_input_injector_ = new testing::StrictMock<MockInputInjector>(); |
341 | 350 |
342 EXPECT_CALL(*remote_input_injector_, StartPtr(_)); | 351 EXPECT_CALL(*remote_input_injector_, StartPtr(_)); |
343 return remote_input_injector_; | 352 return remote_input_injector_; |
344 } | 353 } |
345 | 354 |
346 webrtc::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { | 355 webrtc::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { |
347 return new FakeScreenCapturer(); | 356 return new FakeScreenCapturer(); |
348 } | 357 } |
349 | 358 |
| 359 webrtc::MouseCursorMonitor* |
| 360 IpcDesktopEnvironmentTest::CreateMouseCursorMonitor() { |
| 361 return new FakeMouseCursorMonitor(); |
| 362 } |
| 363 |
350 void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { | 364 void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { |
351 input_injector_.reset(); | 365 input_injector_.reset(); |
352 screen_controls_.reset(); | 366 screen_controls_.reset(); |
353 video_capturer_.reset(); | 367 video_capturer_.reset(); |
354 | 368 |
355 // Trigger DisconnectTerminal(). | 369 // Trigger DisconnectTerminal(). |
356 desktop_environment_.reset(); | 370 desktop_environment_.reset(); |
357 } | 371 } |
358 | 372 |
359 void IpcDesktopEnvironmentTest::ReflectClipboardEvent( | 373 void IpcDesktopEnvironmentTest::ReflectClipboardEvent( |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 screen_controls_->SetScreenResolution(ScreenResolution( | 656 screen_controls_->SetScreenResolution(ScreenResolution( |
643 webrtc::DesktopSize(100, 100), | 657 webrtc::DesktopSize(100, 100), |
644 webrtc::DesktopVector(96, 96))); | 658 webrtc::DesktopVector(96, 96))); |
645 | 659 |
646 task_runner_ = NULL; | 660 task_runner_ = NULL; |
647 io_task_runner_ = NULL; | 661 io_task_runner_ = NULL; |
648 main_run_loop_.Run(); | 662 main_run_loop_.Run(); |
649 } | 663 } |
650 | 664 |
651 } // namespace remoting | 665 } // namespace remoting |
OLD | NEW |