| 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_desktop_capturer.h" |
| 27 #include "remoting/host/fake_mouse_cursor_monitor.h" | 28 #include "remoting/host/fake_mouse_cursor_monitor.h" |
| 28 #include "remoting/host/fake_screen_capturer.h" | |
| 29 #include "remoting/host/host_mock_objects.h" | 29 #include "remoting/host/host_mock_objects.h" |
| 30 #include "remoting/host/ipc_desktop_environment.h" | 30 #include "remoting/host/ipc_desktop_environment.h" |
| 31 #include "remoting/protocol/protocol_mock_objects.h" | 31 #include "remoting/protocol/protocol_mock_objects.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 34 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 35 #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" | 36 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" |
| 37 | 37 |
| 38 using testing::_; | 38 using testing::_; |
| (...skipping 84 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 webrtc::ScreenCapturer, to mock | 133 // Creates a DesktopEnvironment with a fake webrtc::DesktopCapturer, 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 webrtc::ScreenCapturer, to mock | 141 // Creates a fake webrtc::DesktopCapturer, to mock |
| 142 // DesktopEnvironment::CreateVideoCapturer(). | 142 // DesktopEnvironment::CreateVideoCapturer(). |
| 143 webrtc::ScreenCapturer* CreateVideoCapturer(); | 143 webrtc::DesktopCapturer* CreateVideoCapturer(); |
| 144 | 144 |
| 145 // Creates a MockMouseCursorMonitor, to mock | 145 // Creates a MockMouseCursorMonitor, to mock |
| 146 // DesktopEnvironment::CreateMouseCursorMonitor | 146 // DesktopEnvironment::CreateMouseCursorMonitor |
| 147 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor(); | 147 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor(); |
| 148 | 148 |
| 149 void DeleteDesktopEnvironment(); | 149 void DeleteDesktopEnvironment(); |
| 150 | 150 |
| 151 // Forwards |event| to |clipboard_stub_|. | 151 // Forwards |event| to |clipboard_stub_|. |
| 152 void ReflectClipboardEvent(const protocol::ClipboardEvent& event); | 152 void ReflectClipboardEvent(const protocol::ClipboardEvent& event); |
| 153 | 153 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 scoped_ptr<IpcDesktopEnvironmentFactory> desktop_environment_factory_; | 195 scoped_ptr<IpcDesktopEnvironmentFactory> desktop_environment_factory_; |
| 196 scoped_ptr<DesktopEnvironment> desktop_environment_; | 196 scoped_ptr<DesktopEnvironment> desktop_environment_; |
| 197 | 197 |
| 198 // The IPC input injector. | 198 // The IPC input injector. |
| 199 scoped_ptr<InputInjector> input_injector_; | 199 scoped_ptr<InputInjector> input_injector_; |
| 200 | 200 |
| 201 // The IPC screen controls. | 201 // The IPC screen controls. |
| 202 scoped_ptr<ScreenControls> screen_controls_; | 202 scoped_ptr<ScreenControls> screen_controls_; |
| 203 | 203 |
| 204 // The IPC screen capturer. | 204 // The IPC screen capturer. |
| 205 scoped_ptr<webrtc::ScreenCapturer> video_capturer_; | 205 scoped_ptr<webrtc::DesktopCapturer> video_capturer_; |
| 206 | 206 |
| 207 // Represents the desktop process running in a user session. | 207 // Represents the desktop process running in a user session. |
| 208 scoped_ptr<DesktopProcess> desktop_process_; | 208 scoped_ptr<DesktopProcess> desktop_process_; |
| 209 | 209 |
| 210 // Input injector owned by |desktop_process_|. | 210 // Input injector owned by |desktop_process_|. |
| 211 MockInputInjector* remote_input_injector_; | 211 MockInputInjector* remote_input_injector_; |
| 212 | 212 |
| 213 // The last |terminal_id| passed to ConnectTermina(); | 213 // The last |terminal_id| passed to ConnectTermina(); |
| 214 int terminal_id_; | 214 int terminal_id_; |
| 215 | 215 |
| 216 webrtc::MockScreenCapturerCallback screen_capturer_callback_; | 216 webrtc::MockScreenCapturerCallback desktop_capturer_callback_; |
| 217 | 217 |
| 218 MockClientSessionControl client_session_control_; | 218 MockClientSessionControl client_session_control_; |
| 219 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; | 219 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; |
| 220 }; | 220 }; |
| 221 | 221 |
| 222 IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest() | 222 IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest() |
| 223 : client_jid_("user@domain/rest-of-jid"), | 223 : client_jid_("user@domain/rest-of-jid"), |
| 224 clipboard_stub_(NULL), | 224 clipboard_stub_(NULL), |
| 225 remote_input_injector_(NULL), | 225 remote_input_injector_(NULL), |
| 226 terminal_id_(-1), | 226 terminal_id_(-1), |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 345 } |
| 346 | 346 |
| 347 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { | 347 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { |
| 348 EXPECT_TRUE(remote_input_injector_ == NULL); | 348 EXPECT_TRUE(remote_input_injector_ == NULL); |
| 349 remote_input_injector_ = new testing::StrictMock<MockInputInjector>(); | 349 remote_input_injector_ = new testing::StrictMock<MockInputInjector>(); |
| 350 | 350 |
| 351 EXPECT_CALL(*remote_input_injector_, StartPtr(_)); | 351 EXPECT_CALL(*remote_input_injector_, StartPtr(_)); |
| 352 return remote_input_injector_; | 352 return remote_input_injector_; |
| 353 } | 353 } |
| 354 | 354 |
| 355 webrtc::ScreenCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { | 355 webrtc::DesktopCapturer* IpcDesktopEnvironmentTest::CreateVideoCapturer() { |
| 356 return new FakeScreenCapturer(); | 356 return new FakeDesktopCapturer(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 webrtc::MouseCursorMonitor* | 359 webrtc::MouseCursorMonitor* |
| 360 IpcDesktopEnvironmentTest::CreateMouseCursorMonitor() { | 360 IpcDesktopEnvironmentTest::CreateMouseCursorMonitor() { |
| 361 return new FakeMouseCursorMonitor(); | 361 return new FakeMouseCursorMonitor(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { | 364 void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { |
| 365 input_injector_.reset(); | 365 input_injector_.reset(); |
| 366 screen_controls_.reset(); | 366 screen_controls_.reset(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 450 |
| 451 // Tests that the video capturer receives a frame over IPC. | 451 // Tests that the video capturer receives a frame over IPC. |
| 452 TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { | 452 TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { |
| 453 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 453 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 454 new protocol::MockClipboardStub()); | 454 new protocol::MockClipboardStub()); |
| 455 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 455 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 456 .Times(0); | 456 .Times(0); |
| 457 | 457 |
| 458 // Start the input injector and screen capturer. | 458 // Start the input injector and screen capturer. |
| 459 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); | 459 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); |
| 460 video_capturer_->Start(&screen_capturer_callback_); | 460 video_capturer_->Start(&desktop_capturer_callback_); |
| 461 | 461 |
| 462 // Run the message loop until the desktop is attached. | 462 // Run the message loop until the desktop is attached. |
| 463 setup_run_loop_->Run(); | 463 setup_run_loop_->Run(); |
| 464 | 464 |
| 465 // Stop the test when the first frame is captured. | 465 // Stop the test when the first frame is captured. |
| 466 EXPECT_CALL(screen_capturer_callback_, OnCaptureCompleted(_)) | 466 EXPECT_CALL(desktop_capturer_callback_, OnCaptureCompleted(_)) |
| 467 .WillOnce(DoAll( | 467 .WillOnce(DoAll( |
| 468 DeleteArg<0>(), | 468 DeleteArg<0>(), |
| 469 InvokeWithoutArgs( | 469 InvokeWithoutArgs( |
| 470 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment))); | 470 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment))); |
| 471 | 471 |
| 472 // Capture a single frame. | 472 // Capture a single frame. |
| 473 video_capturer_->Capture(webrtc::DesktopRegion()); | 473 video_capturer_->Capture(webrtc::DesktopRegion()); |
| 474 | 474 |
| 475 task_runner_ = NULL; | 475 task_runner_ = NULL; |
| 476 io_task_runner_ = NULL; | 476 io_task_runner_ = NULL; |
| 477 main_run_loop_.Run(); | 477 main_run_loop_.Run(); |
| 478 } | 478 } |
| 479 | 479 |
| 480 // Tests that attaching to a new desktop works. | 480 // Tests that attaching to a new desktop works. |
| 481 TEST_F(IpcDesktopEnvironmentTest, Reattach) { | 481 TEST_F(IpcDesktopEnvironmentTest, Reattach) { |
| 482 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 482 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 483 new protocol::MockClipboardStub()); | 483 new protocol::MockClipboardStub()); |
| 484 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 484 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 485 .Times(0); | 485 .Times(0); |
| 486 | 486 |
| 487 // Start the input injector and screen capturer. | 487 // Start the input injector and screen capturer. |
| 488 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); | 488 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); |
| 489 video_capturer_->Start(&screen_capturer_callback_); | 489 video_capturer_->Start(&desktop_capturer_callback_); |
| 490 | 490 |
| 491 // Run the message loop until the desktop is attached. | 491 // Run the message loop until the desktop is attached. |
| 492 setup_run_loop_->Run(); | 492 setup_run_loop_->Run(); |
| 493 | 493 |
| 494 // Create and start a new desktop process object. | 494 // Create and start a new desktop process object. |
| 495 setup_run_loop_.reset(new base::RunLoop()); | 495 setup_run_loop_.reset(new base::RunLoop()); |
| 496 DestoyDesktopProcess(); | 496 DestoyDesktopProcess(); |
| 497 CreateDesktopProcess(); | 497 CreateDesktopProcess(); |
| 498 setup_run_loop_->Run(); | 498 setup_run_loop_->Run(); |
| 499 | 499 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 512 clipboard_stub_ = clipboard_stub.get(); | 512 clipboard_stub_ = clipboard_stub.get(); |
| 513 | 513 |
| 514 // Stop the test when a clipboard event is received from the desktop process. | 514 // Stop the test when a clipboard event is received from the desktop process. |
| 515 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 515 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 516 .Times(1) | 516 .Times(1) |
| 517 .WillOnce(InvokeWithoutArgs( | 517 .WillOnce(InvokeWithoutArgs( |
| 518 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 518 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 519 | 519 |
| 520 // Start the input injector and screen capturer. | 520 // Start the input injector and screen capturer. |
| 521 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); | 521 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); |
| 522 video_capturer_->Start(&screen_capturer_callback_); | 522 video_capturer_->Start(&desktop_capturer_callback_); |
| 523 | 523 |
| 524 // Run the message loop until the desktop is attached. | 524 // Run the message loop until the desktop is attached. |
| 525 setup_run_loop_->Run(); | 525 setup_run_loop_->Run(); |
| 526 | 526 |
| 527 // Expect a single clipboard event. | 527 // Expect a single clipboard event. |
| 528 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) | 528 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) |
| 529 .Times(1) | 529 .Times(1) |
| 530 .WillOnce(Invoke(this, | 530 .WillOnce(Invoke(this, |
| 531 &IpcDesktopEnvironmentTest::ReflectClipboardEvent)); | 531 &IpcDesktopEnvironmentTest::ReflectClipboardEvent)); |
| 532 | 532 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 543 | 543 |
| 544 // Tests injection of key events. | 544 // Tests injection of key events. |
| 545 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { | 545 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { |
| 546 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 546 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 547 new protocol::MockClipboardStub()); | 547 new protocol::MockClipboardStub()); |
| 548 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 548 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 549 .Times(0); | 549 .Times(0); |
| 550 | 550 |
| 551 // Start the input injector and screen capturer. | 551 // Start the input injector and screen capturer. |
| 552 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); | 552 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); |
| 553 video_capturer_->Start(&screen_capturer_callback_); | 553 video_capturer_->Start(&desktop_capturer_callback_); |
| 554 | 554 |
| 555 // Run the message loop until the desktop is attached. | 555 // Run the message loop until the desktop is attached. |
| 556 setup_run_loop_->Run(); | 556 setup_run_loop_->Run(); |
| 557 | 557 |
| 558 // Expect a single key event. | 558 // Expect a single key event. |
| 559 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) | 559 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) |
| 560 .Times(AtLeast(1)) | 560 .Times(AtLeast(1)) |
| 561 .WillRepeatedly(InvokeWithoutArgs( | 561 .WillRepeatedly(InvokeWithoutArgs( |
| 562 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 562 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 563 | 563 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 574 | 574 |
| 575 // Tests injection of text events. | 575 // Tests injection of text events. |
| 576 TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { | 576 TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { |
| 577 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 577 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 578 new protocol::MockClipboardStub()); | 578 new protocol::MockClipboardStub()); |
| 579 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 579 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 580 .Times(0); | 580 .Times(0); |
| 581 | 581 |
| 582 // Start the input injector and screen capturer. | 582 // Start the input injector and screen capturer. |
| 583 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); | 583 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); |
| 584 video_capturer_->Start(&screen_capturer_callback_); | 584 video_capturer_->Start(&desktop_capturer_callback_); |
| 585 | 585 |
| 586 // Run the message loop until the desktop is attached. | 586 // Run the message loop until the desktop is attached. |
| 587 setup_run_loop_->Run(); | 587 setup_run_loop_->Run(); |
| 588 | 588 |
| 589 // Expect a single text event. | 589 // Expect a single text event. |
| 590 EXPECT_CALL(*remote_input_injector_, InjectTextEvent(_)) | 590 EXPECT_CALL(*remote_input_injector_, InjectTextEvent(_)) |
| 591 .Times(AtLeast(1)) | 591 .Times(AtLeast(1)) |
| 592 .WillRepeatedly(InvokeWithoutArgs( | 592 .WillRepeatedly(InvokeWithoutArgs( |
| 593 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 593 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 594 | 594 |
| 595 // Send a text event. | 595 // Send a text event. |
| 596 protocol::TextEvent event; | 596 protocol::TextEvent event; |
| 597 event.set_text("hello"); | 597 event.set_text("hello"); |
| 598 input_injector_->InjectTextEvent(event); | 598 input_injector_->InjectTextEvent(event); |
| 599 | 599 |
| 600 task_runner_ = NULL; | 600 task_runner_ = NULL; |
| 601 io_task_runner_ = NULL; | 601 io_task_runner_ = NULL; |
| 602 main_run_loop_.Run(); | 602 main_run_loop_.Run(); |
| 603 } | 603 } |
| 604 | 604 |
| 605 // Tests injection of mouse events. | 605 // Tests injection of mouse events. |
| 606 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { | 606 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { |
| 607 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 607 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 608 new protocol::MockClipboardStub()); | 608 new protocol::MockClipboardStub()); |
| 609 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 609 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 610 .Times(0); | 610 .Times(0); |
| 611 | 611 |
| 612 // Start the input injector and screen capturer. | 612 // Start the input injector and screen capturer. |
| 613 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); | 613 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); |
| 614 video_capturer_->Start(&screen_capturer_callback_); | 614 video_capturer_->Start(&desktop_capturer_callback_); |
| 615 | 615 |
| 616 // Run the message loop until the desktop is attached. | 616 // Run the message loop until the desktop is attached. |
| 617 setup_run_loop_->Run(); | 617 setup_run_loop_->Run(); |
| 618 | 618 |
| 619 // Expect a single mouse event. | 619 // Expect a single mouse event. |
| 620 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) | 620 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) |
| 621 .Times(1) | 621 .Times(1) |
| 622 .WillOnce(InvokeWithoutArgs( | 622 .WillOnce(InvokeWithoutArgs( |
| 623 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 623 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 624 | 624 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 635 | 635 |
| 636 // Tests that setting the desktop resolution works. | 636 // Tests that setting the desktop resolution works. |
| 637 TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { | 637 TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { |
| 638 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 638 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 639 new protocol::MockClipboardStub()); | 639 new protocol::MockClipboardStub()); |
| 640 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 640 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 641 .Times(0); | 641 .Times(0); |
| 642 | 642 |
| 643 // Start the input injector and screen capturer. | 643 // Start the input injector and screen capturer. |
| 644 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); | 644 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); |
| 645 video_capturer_->Start(&screen_capturer_callback_); | 645 video_capturer_->Start(&desktop_capturer_callback_); |
| 646 | 646 |
| 647 // Run the message loop until the desktop is attached. | 647 // Run the message loop until the desktop is attached. |
| 648 setup_run_loop_->Run(); | 648 setup_run_loop_->Run(); |
| 649 | 649 |
| 650 EXPECT_CALL(daemon_channel_, SetScreenResolution(_, _)) | 650 EXPECT_CALL(daemon_channel_, SetScreenResolution(_, _)) |
| 651 .Times(1) | 651 .Times(1) |
| 652 .WillOnce(InvokeWithoutArgs( | 652 .WillOnce(InvokeWithoutArgs( |
| 653 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 653 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 654 | 654 |
| 655 // Change the desktop resolution. | 655 // Change the desktop resolution. |
| 656 screen_controls_->SetScreenResolution(ScreenResolution( | 656 screen_controls_->SetScreenResolution(ScreenResolution( |
| 657 webrtc::DesktopSize(100, 100), | 657 webrtc::DesktopSize(100, 100), |
| 658 webrtc::DesktopVector(96, 96))); | 658 webrtc::DesktopVector(96, 96))); |
| 659 | 659 |
| 660 task_runner_ = NULL; | 660 task_runner_ = NULL; |
| 661 io_task_runner_ = NULL; | 661 io_task_runner_ = NULL; |
| 662 main_run_loop_.Run(); | 662 main_run_loop_.Run(); |
| 663 } | 663 } |
| 664 | 664 |
| 665 } // namespace remoting | 665 } // namespace remoting |
| OLD | NEW |