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 "remoting/host/ipc_desktop_environment.h" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | 8 |
| 9 #include <memory> |
7 #include <utility> | 10 #include <utility> |
8 | 11 |
9 #include "base/bind.h" | 12 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 14 #include "base/callback.h" |
12 #include "base/macros.h" | 15 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
16 #include "base/process/process.h" | 18 #include "base/process/process.h" |
17 #include "base/process/process_handle.h" | 19 #include "base/process/process_handle.h" |
18 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
19 #include "build/build_config.h" | 21 #include "build/build_config.h" |
20 #include "ipc/attachment_broker_privileged.h" | 22 #include "ipc/attachment_broker_privileged.h" |
21 #include "ipc/ipc_channel.h" | 23 #include "ipc/ipc_channel.h" |
22 #include "ipc/ipc_channel_proxy.h" | 24 #include "ipc/ipc_channel_proxy.h" |
23 #include "ipc/ipc_listener.h" | 25 #include "ipc/ipc_listener.h" |
24 #include "ipc/ipc_message.h" | 26 #include "ipc/ipc_message.h" |
25 #include "ipc/ipc_platform_file.h" | 27 #include "ipc/ipc_platform_file.h" |
26 #include "remoting/base/auto_thread.h" | 28 #include "remoting/base/auto_thread.h" |
27 #include "remoting/base/auto_thread_task_runner.h" | 29 #include "remoting/base/auto_thread_task_runner.h" |
28 #include "remoting/base/constants.h" | 30 #include "remoting/base/constants.h" |
29 #include "remoting/host/chromoting_messages.h" | 31 #include "remoting/host/chromoting_messages.h" |
30 #include "remoting/host/desktop_process.h" | 32 #include "remoting/host/desktop_process.h" |
31 #include "remoting/host/desktop_session.h" | 33 #include "remoting/host/desktop_session.h" |
32 #include "remoting/host/desktop_session_connector.h" | 34 #include "remoting/host/desktop_session_connector.h" |
33 #include "remoting/host/desktop_session_proxy.h" | 35 #include "remoting/host/desktop_session_proxy.h" |
34 #include "remoting/host/fake_mouse_cursor_monitor.h" | 36 #include "remoting/host/fake_mouse_cursor_monitor.h" |
35 #include "remoting/host/host_mock_objects.h" | 37 #include "remoting/host/host_mock_objects.h" |
36 #include "remoting/host/ipc_desktop_environment.h" | |
37 #include "remoting/protocol/fake_desktop_capturer.h" | 38 #include "remoting/protocol/fake_desktop_capturer.h" |
38 #include "remoting/protocol/protocol_mock_objects.h" | 39 #include "remoting/protocol/protocol_mock_objects.h" |
39 #include "remoting/protocol/test_event_matchers.h" | 40 #include "remoting/protocol/test_event_matchers.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
42 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 43 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
43 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 44 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
44 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" | 45 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" |
45 | 46 |
46 using testing::_; | 47 using testing::_; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Invoked when ChromotingDesktopDaemonMsg_DesktopAttached message is | 177 // Invoked when ChromotingDesktopDaemonMsg_DesktopAttached message is |
177 // received. | 178 // received. |
178 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_pipe); | 179 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_pipe); |
179 | 180 |
180 void RunMainLoopUntilDone(); | 181 void RunMainLoopUntilDone(); |
181 | 182 |
182 // The main message loop. | 183 // The main message loop. |
183 base::MessageLoopForUI message_loop_; | 184 base::MessageLoopForUI message_loop_; |
184 | 185 |
185 // Runs until |desktop_session_proxy_| is connected to the desktop. | 186 // Runs until |desktop_session_proxy_| is connected to the desktop. |
186 scoped_ptr<base::RunLoop> setup_run_loop_; | 187 std::unique_ptr<base::RunLoop> setup_run_loop_; |
187 | 188 |
188 scoped_refptr<AutoThreadTaskRunner> task_runner_; | 189 scoped_refptr<AutoThreadTaskRunner> task_runner_; |
189 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; | 190 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; |
190 | 191 |
191 std::string client_jid_; | 192 std::string client_jid_; |
192 | 193 |
193 // Clipboard stub that receives clipboard events from the desktop process. | 194 // Clipboard stub that receives clipboard events from the desktop process. |
194 protocol::ClipboardStub* clipboard_stub_; | 195 protocol::ClipboardStub* clipboard_stub_; |
195 | 196 |
196 // The daemons's end of the daemon-to-desktop channel. | 197 // The daemons's end of the daemon-to-desktop channel. |
197 scoped_ptr<IPC::ChannelProxy> desktop_channel_; | 198 std::unique_ptr<IPC::ChannelProxy> desktop_channel_; |
198 | 199 |
199 // Name of the daemon-to-desktop channel. | 200 // Name of the daemon-to-desktop channel. |
200 std::string desktop_channel_name_; | 201 std::string desktop_channel_name_; |
201 | 202 |
202 // Delegate that is passed to |desktop_channel_|. | 203 // Delegate that is passed to |desktop_channel_|. |
203 MockDaemonListener desktop_listener_; | 204 MockDaemonListener desktop_listener_; |
204 | 205 |
205 FakeDaemonSender daemon_channel_; | 206 FakeDaemonSender daemon_channel_; |
206 | 207 |
207 scoped_ptr<IpcDesktopEnvironmentFactory> desktop_environment_factory_; | 208 std::unique_ptr<IpcDesktopEnvironmentFactory> desktop_environment_factory_; |
208 scoped_ptr<DesktopEnvironment> desktop_environment_; | 209 std::unique_ptr<DesktopEnvironment> desktop_environment_; |
209 | 210 |
210 // The IPC input injector. | 211 // The IPC input injector. |
211 scoped_ptr<InputInjector> input_injector_; | 212 std::unique_ptr<InputInjector> input_injector_; |
212 | 213 |
213 // The IPC screen controls. | 214 // The IPC screen controls. |
214 scoped_ptr<ScreenControls> screen_controls_; | 215 std::unique_ptr<ScreenControls> screen_controls_; |
215 | 216 |
216 // The IPC screen capturer. | 217 // The IPC screen capturer. |
217 scoped_ptr<webrtc::DesktopCapturer> video_capturer_; | 218 std::unique_ptr<webrtc::DesktopCapturer> video_capturer_; |
218 | 219 |
219 // Represents the desktop process running in a user session. | 220 // Represents the desktop process running in a user session. |
220 scoped_ptr<DesktopProcess> desktop_process_; | 221 std::unique_ptr<DesktopProcess> desktop_process_; |
221 | 222 |
222 // Input injector owned by |desktop_process_|. | 223 // Input injector owned by |desktop_process_|. |
223 MockInputInjector* remote_input_injector_; | 224 MockInputInjector* remote_input_injector_; |
224 | 225 |
225 // The last |terminal_id| passed to ConnectTermina(); | 226 // The last |terminal_id| passed to ConnectTermina(); |
226 int terminal_id_; | 227 int terminal_id_; |
227 | 228 |
228 webrtc::MockScreenCapturerCallback desktop_capturer_callback_; | 229 webrtc::MockScreenCapturerCallback desktop_capturer_callback_; |
229 | 230 |
230 MockClientSessionControl client_session_control_; | 231 MockClientSessionControl client_session_control_; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 desktop_channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); | 401 desktop_channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); |
401 desktop_channel_ = IPC::ChannelProxy::Create( | 402 desktop_channel_ = IPC::ChannelProxy::Create( |
402 IPC::ChannelHandle(desktop_channel_name_), IPC::Channel::MODE_SERVER, | 403 IPC::ChannelHandle(desktop_channel_name_), IPC::Channel::MODE_SERVER, |
403 &desktop_listener_, io_task_runner_.get()); | 404 &desktop_listener_, io_task_runner_.get()); |
404 | 405 |
405 // Create and start the desktop process. | 406 // Create and start the desktop process. |
406 desktop_process_.reset(new DesktopProcess(task_runner_, | 407 desktop_process_.reset(new DesktopProcess(task_runner_, |
407 io_task_runner_, | 408 io_task_runner_, |
408 desktop_channel_name_)); | 409 desktop_channel_name_)); |
409 | 410 |
410 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory( | 411 std::unique_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory( |
411 new MockDesktopEnvironmentFactory()); | 412 new MockDesktopEnvironmentFactory()); |
412 EXPECT_CALL(*desktop_environment_factory, CreatePtr()) | 413 EXPECT_CALL(*desktop_environment_factory, CreatePtr()) |
413 .Times(AnyNumber()) | 414 .Times(AnyNumber()) |
414 .WillRepeatedly(Invoke( | 415 .WillRepeatedly(Invoke( |
415 this, &IpcDesktopEnvironmentTest::CreateDesktopEnvironment)); | 416 this, &IpcDesktopEnvironmentTest::CreateDesktopEnvironment)); |
416 EXPECT_CALL(*desktop_environment_factory, SupportsAudioCapture()) | 417 EXPECT_CALL(*desktop_environment_factory, SupportsAudioCapture()) |
417 .Times(AnyNumber()) | 418 .Times(AnyNumber()) |
418 .WillRepeatedly(Return(false)); | 419 .WillRepeatedly(Return(false)); |
419 | 420 |
420 EXPECT_TRUE(desktop_process_->Start(std::move(desktop_environment_factory))); | 421 EXPECT_TRUE(desktop_process_->Start(std::move(desktop_environment_factory))); |
(...skipping 28 matching lines...) Expand all Loading... |
449 } | 450 } |
450 | 451 |
451 void IpcDesktopEnvironmentTest::RunMainLoopUntilDone() { | 452 void IpcDesktopEnvironmentTest::RunMainLoopUntilDone() { |
452 task_runner_ = nullptr; | 453 task_runner_ = nullptr; |
453 io_task_runner_ = nullptr; | 454 io_task_runner_ = nullptr; |
454 main_run_loop_.Run(); | 455 main_run_loop_.Run(); |
455 } | 456 } |
456 | 457 |
457 // Runs until the desktop is attached and exits immediately after that. | 458 // Runs until the desktop is attached and exits immediately after that. |
458 TEST_F(IpcDesktopEnvironmentTest, Basic) { | 459 TEST_F(IpcDesktopEnvironmentTest, Basic) { |
459 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 460 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
460 new protocol::MockClipboardStub()); | 461 new protocol::MockClipboardStub()); |
461 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 462 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
462 .Times(0); | 463 .Times(0); |
463 | 464 |
464 // Start the input injector and screen capturer. | 465 // Start the input injector and screen capturer. |
465 input_injector_->Start(std::move(clipboard_stub)); | 466 input_injector_->Start(std::move(clipboard_stub)); |
466 | 467 |
467 // Run the message loop until the desktop is attached. | 468 // Run the message loop until the desktop is attached. |
468 setup_run_loop_->Run(); | 469 setup_run_loop_->Run(); |
469 | 470 |
470 // Stop the test. | 471 // Stop the test. |
471 DeleteDesktopEnvironment(); | 472 DeleteDesktopEnvironment(); |
472 } | 473 } |
473 | 474 |
474 // Check Capabilities. | 475 // Check Capabilities. |
475 TEST_F(IpcDesktopEnvironmentTest, CapabilitiesNoTouch) { | 476 TEST_F(IpcDesktopEnvironmentTest, CapabilitiesNoTouch) { |
476 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 477 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
477 new protocol::MockClipboardStub()); | 478 new protocol::MockClipboardStub()); |
478 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 479 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
479 .Times(0); | 480 .Times(0); |
480 | 481 |
481 EXPECT_EQ("rateLimitResizeRequests", desktop_environment_->GetCapabilities()); | 482 EXPECT_EQ("rateLimitResizeRequests", desktop_environment_->GetCapabilities()); |
482 | 483 |
483 // Start the input injector and screen capturer. | 484 // Start the input injector and screen capturer. |
484 input_injector_->Start(std::move(clipboard_stub)); | 485 input_injector_->Start(std::move(clipboard_stub)); |
485 | 486 |
486 // Run the message loop until the desktop is attached. | 487 // Run the message loop until the desktop is attached. |
487 setup_run_loop_->Run(); | 488 setup_run_loop_->Run(); |
488 | 489 |
489 // Stop the test. | 490 // Stop the test. |
490 DeleteDesktopEnvironment(); | 491 DeleteDesktopEnvironment(); |
491 } | 492 } |
492 | 493 |
493 // Check touchEvents capability is set when the desktop environment can | 494 // Check touchEvents capability is set when the desktop environment can |
494 // inject touch events. | 495 // inject touch events. |
495 TEST_F(IpcDesktopEnvironmentTest, TouchEventsCapabilities) { | 496 TEST_F(IpcDesktopEnvironmentTest, TouchEventsCapabilities) { |
496 // Create an environment with multi touch enabled. | 497 // Create an environment with multi touch enabled. |
497 desktop_environment_factory_->set_supports_touch_events(true); | 498 desktop_environment_factory_->set_supports_touch_events(true); |
498 desktop_environment_ = desktop_environment_factory_->Create( | 499 desktop_environment_ = desktop_environment_factory_->Create( |
499 client_session_control_factory_.GetWeakPtr()); | 500 client_session_control_factory_.GetWeakPtr()); |
500 | 501 |
501 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 502 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
502 new protocol::MockClipboardStub()); | 503 new protocol::MockClipboardStub()); |
503 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 504 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
504 .Times(0); | 505 .Times(0); |
505 | 506 |
506 EXPECT_EQ("rateLimitResizeRequests touchEvents", | 507 EXPECT_EQ("rateLimitResizeRequests touchEvents", |
507 desktop_environment_->GetCapabilities()); | 508 desktop_environment_->GetCapabilities()); |
508 | 509 |
509 // Start the input injector and screen capturer. | 510 // Start the input injector and screen capturer. |
510 input_injector_->Start(std::move(clipboard_stub)); | 511 input_injector_->Start(std::move(clipboard_stub)); |
511 | 512 |
512 // Run the message loop until the desktop is attached. | 513 // Run the message loop until the desktop is attached. |
513 setup_run_loop_->Run(); | 514 setup_run_loop_->Run(); |
514 | 515 |
515 // Stop the test. | 516 // Stop the test. |
516 DeleteDesktopEnvironment(); | 517 DeleteDesktopEnvironment(); |
517 } | 518 } |
518 | 519 |
519 // Tests that the video capturer receives a frame over IPC. | 520 // Tests that the video capturer receives a frame over IPC. |
520 TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { | 521 TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { |
521 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 522 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
522 new protocol::MockClipboardStub()); | 523 new protocol::MockClipboardStub()); |
523 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 524 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
524 .Times(0); | 525 .Times(0); |
525 | 526 |
526 // Start the input injector and screen capturer. | 527 // Start the input injector and screen capturer. |
527 input_injector_->Start(std::move(clipboard_stub)); | 528 input_injector_->Start(std::move(clipboard_stub)); |
528 video_capturer_->Start(&desktop_capturer_callback_); | 529 video_capturer_->Start(&desktop_capturer_callback_); |
529 | 530 |
530 // Run the message loop until the desktop is attached. | 531 // Run the message loop until the desktop is attached. |
531 setup_run_loop_->Run(); | 532 setup_run_loop_->Run(); |
532 | 533 |
533 // Stop the test when the first frame is captured. | 534 // Stop the test when the first frame is captured. |
534 EXPECT_CALL(desktop_capturer_callback_, OnCaptureCompleted(_)) | 535 EXPECT_CALL(desktop_capturer_callback_, OnCaptureCompleted(_)) |
535 .WillOnce(DoAll( | 536 .WillOnce(DoAll( |
536 DeleteArg<0>(), | 537 DeleteArg<0>(), |
537 InvokeWithoutArgs( | 538 InvokeWithoutArgs( |
538 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment))); | 539 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment))); |
539 | 540 |
540 // Capture a single frame. | 541 // Capture a single frame. |
541 video_capturer_->Capture(webrtc::DesktopRegion()); | 542 video_capturer_->Capture(webrtc::DesktopRegion()); |
542 } | 543 } |
543 | 544 |
544 // Tests that attaching to a new desktop works. | 545 // Tests that attaching to a new desktop works. |
545 TEST_F(IpcDesktopEnvironmentTest, Reattach) { | 546 TEST_F(IpcDesktopEnvironmentTest, Reattach) { |
546 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 547 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
547 new protocol::MockClipboardStub()); | 548 new protocol::MockClipboardStub()); |
548 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 549 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
549 .Times(0); | 550 .Times(0); |
550 | 551 |
551 // Start the input injector and screen capturer. | 552 // Start the input injector and screen capturer. |
552 input_injector_->Start(std::move(clipboard_stub)); | 553 input_injector_->Start(std::move(clipboard_stub)); |
553 video_capturer_->Start(&desktop_capturer_callback_); | 554 video_capturer_->Start(&desktop_capturer_callback_); |
554 | 555 |
555 // Run the message loop until the desktop is attached. | 556 // Run the message loop until the desktop is attached. |
556 setup_run_loop_->Run(); | 557 setup_run_loop_->Run(); |
557 | 558 |
558 // Create and start a new desktop process object. | 559 // Create and start a new desktop process object. |
559 setup_run_loop_.reset(new base::RunLoop()); | 560 setup_run_loop_.reset(new base::RunLoop()); |
560 DestoyDesktopProcess(); | 561 DestoyDesktopProcess(); |
561 CreateDesktopProcess(); | 562 CreateDesktopProcess(); |
562 setup_run_loop_->Run(); | 563 setup_run_loop_->Run(); |
563 | 564 |
564 // Stop the test. | 565 // Stop the test. |
565 DeleteDesktopEnvironment(); | 566 DeleteDesktopEnvironment(); |
566 } | 567 } |
567 | 568 |
568 // Tests injection of clipboard events. | 569 // Tests injection of clipboard events. |
569 TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { | 570 TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { |
570 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 571 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
571 new protocol::MockClipboardStub()); | 572 new protocol::MockClipboardStub()); |
572 clipboard_stub_ = clipboard_stub.get(); | 573 clipboard_stub_ = clipboard_stub.get(); |
573 | 574 |
574 // Stop the test when a clipboard event is received from the desktop process. | 575 // Stop the test when a clipboard event is received from the desktop process. |
575 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 576 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
576 .Times(1) | 577 .Times(1) |
577 .WillOnce(InvokeWithoutArgs( | 578 .WillOnce(InvokeWithoutArgs( |
578 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 579 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
579 | 580 |
580 // Start the input injector and screen capturer. | 581 // Start the input injector and screen capturer. |
(...skipping 11 matching lines...) Expand all Loading... |
592 | 593 |
593 // Send a clipboard event. | 594 // Send a clipboard event. |
594 protocol::ClipboardEvent event; | 595 protocol::ClipboardEvent event; |
595 event.set_mime_type(kMimeTypeTextUtf8); | 596 event.set_mime_type(kMimeTypeTextUtf8); |
596 event.set_data("a"); | 597 event.set_data("a"); |
597 input_injector_->InjectClipboardEvent(event); | 598 input_injector_->InjectClipboardEvent(event); |
598 } | 599 } |
599 | 600 |
600 // Tests injection of key events. | 601 // Tests injection of key events. |
601 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { | 602 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { |
602 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 603 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
603 new protocol::MockClipboardStub()); | 604 new protocol::MockClipboardStub()); |
604 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 605 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
605 .Times(0); | 606 .Times(0); |
606 | 607 |
607 // Start the input injector and screen capturer. | 608 // Start the input injector and screen capturer. |
608 input_injector_->Start(std::move(clipboard_stub)); | 609 input_injector_->Start(std::move(clipboard_stub)); |
609 video_capturer_->Start(&desktop_capturer_callback_); | 610 video_capturer_->Start(&desktop_capturer_callback_); |
610 | 611 |
611 // Run the message loop until the desktop is attached. | 612 // Run the message loop until the desktop is attached. |
612 setup_run_loop_->Run(); | 613 setup_run_loop_->Run(); |
613 | 614 |
614 // Expect a single key event. | 615 // Expect a single key event. |
615 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) | 616 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) |
616 .Times(AtLeast(1)) | 617 .Times(AtLeast(1)) |
617 .WillRepeatedly(InvokeWithoutArgs( | 618 .WillRepeatedly(InvokeWithoutArgs( |
618 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 619 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
619 | 620 |
620 // Send a key event. | 621 // Send a key event. |
621 protocol::KeyEvent event; | 622 protocol::KeyEvent event; |
622 event.set_usb_keycode(0x070004); | 623 event.set_usb_keycode(0x070004); |
623 event.set_pressed(true); | 624 event.set_pressed(true); |
624 input_injector_->InjectKeyEvent(event); | 625 input_injector_->InjectKeyEvent(event); |
625 } | 626 } |
626 | 627 |
627 // Tests injection of text events. | 628 // Tests injection of text events. |
628 TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { | 629 TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { |
629 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 630 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
630 new protocol::MockClipboardStub()); | 631 new protocol::MockClipboardStub()); |
631 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 632 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
632 .Times(0); | 633 .Times(0); |
633 | 634 |
634 // Start the input injector and screen capturer. | 635 // Start the input injector and screen capturer. |
635 input_injector_->Start(std::move(clipboard_stub)); | 636 input_injector_->Start(std::move(clipboard_stub)); |
636 video_capturer_->Start(&desktop_capturer_callback_); | 637 video_capturer_->Start(&desktop_capturer_callback_); |
637 | 638 |
638 // Run the message loop until the desktop is attached. | 639 // Run the message loop until the desktop is attached. |
639 setup_run_loop_->Run(); | 640 setup_run_loop_->Run(); |
640 | 641 |
641 // Expect a single text event. | 642 // Expect a single text event. |
642 EXPECT_CALL(*remote_input_injector_, InjectTextEvent(_)) | 643 EXPECT_CALL(*remote_input_injector_, InjectTextEvent(_)) |
643 .Times(AtLeast(1)) | 644 .Times(AtLeast(1)) |
644 .WillRepeatedly(InvokeWithoutArgs( | 645 .WillRepeatedly(InvokeWithoutArgs( |
645 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 646 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
646 | 647 |
647 // Send a text event. | 648 // Send a text event. |
648 protocol::TextEvent event; | 649 protocol::TextEvent event; |
649 event.set_text("hello"); | 650 event.set_text("hello"); |
650 input_injector_->InjectTextEvent(event); | 651 input_injector_->InjectTextEvent(event); |
651 } | 652 } |
652 | 653 |
653 // Tests injection of mouse events. | 654 // Tests injection of mouse events. |
654 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { | 655 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { |
655 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 656 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
656 new protocol::MockClipboardStub()); | 657 new protocol::MockClipboardStub()); |
657 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 658 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
658 .Times(0); | 659 .Times(0); |
659 | 660 |
660 // Start the input injector and screen capturer. | 661 // Start the input injector and screen capturer. |
661 input_injector_->Start(std::move(clipboard_stub)); | 662 input_injector_->Start(std::move(clipboard_stub)); |
662 video_capturer_->Start(&desktop_capturer_callback_); | 663 video_capturer_->Start(&desktop_capturer_callback_); |
663 | 664 |
664 // Run the message loop until the desktop is attached. | 665 // Run the message loop until the desktop is attached. |
665 setup_run_loop_->Run(); | 666 setup_run_loop_->Run(); |
666 | 667 |
667 // Expect a single mouse event. | 668 // Expect a single mouse event. |
668 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) | 669 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) |
669 .Times(1) | 670 .Times(1) |
670 .WillOnce(InvokeWithoutArgs( | 671 .WillOnce(InvokeWithoutArgs( |
671 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 672 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
672 | 673 |
673 // Send a mouse event. | 674 // Send a mouse event. |
674 protocol::MouseEvent event; | 675 protocol::MouseEvent event; |
675 event.set_x(0); | 676 event.set_x(0); |
676 event.set_y(0); | 677 event.set_y(0); |
677 input_injector_->InjectMouseEvent(event); | 678 input_injector_->InjectMouseEvent(event); |
678 } | 679 } |
679 | 680 |
680 // Tests injection of touch events. | 681 // Tests injection of touch events. |
681 TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) { | 682 TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) { |
682 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 683 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
683 new protocol::MockClipboardStub()); | 684 new protocol::MockClipboardStub()); |
684 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 685 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
685 .Times(0); | 686 .Times(0); |
686 | 687 |
687 // Start the input injector and screen capturer. | 688 // Start the input injector and screen capturer. |
688 input_injector_->Start(std::move(clipboard_stub)); | 689 input_injector_->Start(std::move(clipboard_stub)); |
689 video_capturer_->Start(&desktop_capturer_callback_); | 690 video_capturer_->Start(&desktop_capturer_callback_); |
690 | 691 |
691 // Run the message loop until the desktop is attached. | 692 // Run the message loop until the desktop is attached. |
692 setup_run_loop_->Run(); | 693 setup_run_loop_->Run(); |
(...skipping 21 matching lines...) Expand all Loading... |
714 EXPECT_CALL(*remote_input_injector_, | 715 EXPECT_CALL(*remote_input_injector_, |
715 InjectTouchEvent(EqualsTouchEventTypeAndId( | 716 InjectTouchEvent(EqualsTouchEventTypeAndId( |
716 protocol::TouchEvent::TOUCH_POINT_CANCEL, 0u))); | 717 protocol::TouchEvent::TOUCH_POINT_CANCEL, 0u))); |
717 | 718 |
718 // Send the touch event. | 719 // Send the touch event. |
719 input_injector_->InjectTouchEvent(event); | 720 input_injector_->InjectTouchEvent(event); |
720 } | 721 } |
721 | 722 |
722 // Tests that setting the desktop resolution works. | 723 // Tests that setting the desktop resolution works. |
723 TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { | 724 TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { |
724 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 725 std::unique_ptr<protocol::MockClipboardStub> clipboard_stub( |
725 new protocol::MockClipboardStub()); | 726 new protocol::MockClipboardStub()); |
726 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 727 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
727 .Times(0); | 728 .Times(0); |
728 | 729 |
729 // Start the input injector and screen capturer. | 730 // Start the input injector and screen capturer. |
730 input_injector_->Start(std::move(clipboard_stub)); | 731 input_injector_->Start(std::move(clipboard_stub)); |
731 video_capturer_->Start(&desktop_capturer_callback_); | 732 video_capturer_->Start(&desktop_capturer_callback_); |
732 | 733 |
733 // Run the message loop until the desktop is attached. | 734 // Run the message loop until the desktop is attached. |
734 setup_run_loop_->Run(); | 735 setup_run_loop_->Run(); |
735 | 736 |
736 EXPECT_CALL(daemon_channel_, SetScreenResolution(_, _)) | 737 EXPECT_CALL(daemon_channel_, SetScreenResolution(_, _)) |
737 .Times(1) | 738 .Times(1) |
738 .WillOnce(InvokeWithoutArgs( | 739 .WillOnce(InvokeWithoutArgs( |
739 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 740 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
740 | 741 |
741 // Change the desktop resolution. | 742 // Change the desktop resolution. |
742 screen_controls_->SetScreenResolution(ScreenResolution( | 743 screen_controls_->SetScreenResolution(ScreenResolution( |
743 webrtc::DesktopSize(100, 100), | 744 webrtc::DesktopSize(100, 100), |
744 webrtc::DesktopVector(96, 96))); | 745 webrtc::DesktopVector(96, 96))); |
745 } | 746 } |
746 | 747 |
747 } // namespace remoting | 748 } // namespace remoting |
OLD | NEW |