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" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 DesktopEnvironment* CreateDesktopEnvironment(); | 134 DesktopEnvironment* CreateDesktopEnvironment(); |
135 | 135 |
136 // Creates a dummy InputInjector, to mock | 136 // Creates a dummy InputInjector, to mock |
137 // DesktopEnvironment::CreateInputInjector(). | 137 // DesktopEnvironment::CreateInputInjector(). |
138 InputInjector* CreateInputInjector(); | 138 InputInjector* CreateInputInjector(); |
139 | 139 |
140 // Creates a fake webrtc::ScreenCapturer, to mock | 140 // Creates a fake webrtc::ScreenCapturer, to mock |
141 // DesktopEnvironment::CreateVideoCapturer(). | 141 // DesktopEnvironment::CreateVideoCapturer(). |
142 webrtc::ScreenCapturer* CreateVideoCapturer(); | 142 webrtc::ScreenCapturer* CreateVideoCapturer(); |
143 | 143 |
| 144 // Creates a MockMouseCursorMonitor, to mock |
| 145 // DesktopEnvironment::CreateMouseCursorMonitor |
| 146 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor(); |
| 147 |
144 void DeleteDesktopEnvironment(); | 148 void DeleteDesktopEnvironment(); |
145 | 149 |
146 // Forwards |event| to |clipboard_stub_|. | 150 // Forwards |event| to |clipboard_stub_|. |
147 void ReflectClipboardEvent(const protocol::ClipboardEvent& event); | 151 void ReflectClipboardEvent(const protocol::ClipboardEvent& event); |
148 | 152 |
149 protected: | 153 protected: |
150 // Creates and starts an instance of desktop process object. | 154 // Creates and starts an instance of desktop process object. |
151 void CreateDesktopProcess(); | 155 void CreateDesktopProcess(); |
152 | 156 |
153 // Destroys the desktop process object created by CreateDesktopProcess(). | 157 // 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()) | 321 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) |
318 .Times(AtMost(1)) | 322 .Times(AtMost(1)) |
319 .WillOnce(Invoke( | 323 .WillOnce(Invoke( |
320 this, &IpcDesktopEnvironmentTest::CreateInputInjector)); | 324 this, &IpcDesktopEnvironmentTest::CreateInputInjector)); |
321 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) | 325 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) |
322 .Times(AtMost(1)); | 326 .Times(AtMost(1)); |
323 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) | 327 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) |
324 .Times(AtMost(1)) | 328 .Times(AtMost(1)) |
325 .WillOnce(Invoke( | 329 .WillOnce(Invoke( |
326 this, &IpcDesktopEnvironmentTest::CreateVideoCapturer)); | 330 this, &IpcDesktopEnvironmentTest::CreateVideoCapturer)); |
| 331 EXPECT_CALL(*desktop_environment, CreateMouseCursorMonitorPtr()) |
| 332 .Times(AtMost(1)) |
| 333 .WillOnce(Invoke( |
| 334 this, &IpcDesktopEnvironmentTest::CreateMouseCursorMonitor)); |
327 EXPECT_CALL(*desktop_environment, GetCapabilities()) | 335 EXPECT_CALL(*desktop_environment, GetCapabilities()) |
328 .Times(AtMost(1)); | 336 .Times(AtMost(1)); |
329 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) | 337 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) |
330 .Times(AtMost(1)); | 338 .Times(AtMost(1)); |
331 | 339 |
332 // Let tests know that the remote desktop environment is created. | 340 // Let tests know that the remote desktop environment is created. |
333 message_loop_.PostTask(FROM_HERE, setup_run_loop_->QuitClosure()); | 341 message_loop_.PostTask(FROM_HERE, setup_run_loop_->QuitClosure()); |
334 | 342 |
335 return desktop_environment; | 343 return desktop_environment; |
336 } | 344 } |
337 | 345 |
338 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { | 346 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { |
339 EXPECT_TRUE(remote_input_injector_ == NULL); | 347 EXPECT_TRUE(remote_input_injector_ == NULL); |
340 remote_input_injector_ = new MockInputInjector(); | 348 remote_input_injector_ = new MockInputInjector(); |
341 | 349 |
342 EXPECT_CALL(*remote_input_injector_, StartPtr(_)); | 350 EXPECT_CALL(*remote_input_injector_, StartPtr(_)); |
343 return remote_input_injector_; | 351 return remote_input_injector_; |
344 } | 352 } |
345 | 353 |
346 webrtc::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { | 354 webrtc::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { |
347 return new ScreenCapturerFake(); | 355 return new ScreenCapturerFake(); |
348 } | 356 } |
349 | 357 |
| 358 webrtc::MouseCursorMonitor* |
| 359 IpcDesktopEnvironmentTest::CreateMouseCursorMonitor() { |
| 360 return new MockMouseCursorMonitor(); |
| 361 } |
| 362 |
350 void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { | 363 void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { |
351 input_injector_.reset(); | 364 input_injector_.reset(); |
352 screen_controls_.reset(); | 365 screen_controls_.reset(); |
353 video_capturer_.reset(); | 366 video_capturer_.reset(); |
354 | 367 |
355 // Trigger DisconnectTerminal(). | 368 // Trigger DisconnectTerminal(). |
356 desktop_environment_.reset(); | 369 desktop_environment_.reset(); |
357 } | 370 } |
358 | 371 |
359 void IpcDesktopEnvironmentTest::ReflectClipboardEvent( | 372 void IpcDesktopEnvironmentTest::ReflectClipboardEvent( |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 screen_controls_->SetScreenResolution(ScreenResolution( | 661 screen_controls_->SetScreenResolution(ScreenResolution( |
649 webrtc::DesktopSize(100, 100), | 662 webrtc::DesktopSize(100, 100), |
650 webrtc::DesktopVector(96, 96))); | 663 webrtc::DesktopVector(96, 96))); |
651 | 664 |
652 task_runner_ = NULL; | 665 task_runner_ = NULL; |
653 io_task_runner_ = NULL; | 666 io_task_runner_ = NULL; |
654 main_run_loop_.Run(); | 667 main_run_loop_.Run(); |
655 } | 668 } |
656 | 669 |
657 } // namespace remoting | 670 } // namespace remoting |
OLD | NEW |