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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 } // namespace | 124 } // namespace |
125 | 125 |
126 class IpcDesktopEnvironmentTest : public testing::Test { | 126 class IpcDesktopEnvironmentTest : public testing::Test { |
127 public: | 127 public: |
128 IpcDesktopEnvironmentTest(); | 128 IpcDesktopEnvironmentTest(); |
129 ~IpcDesktopEnvironmentTest() override; | 129 ~IpcDesktopEnvironmentTest() override; |
130 | 130 |
131 void SetUp() override; | 131 void SetUp() override; |
| 132 void TearDown() override; |
132 | 133 |
133 void ConnectTerminal(int terminal_id, | 134 void ConnectTerminal(int terminal_id, |
134 const ScreenResolution& resolution, | 135 const ScreenResolution& resolution, |
135 bool virtual_terminal); | 136 bool virtual_terminal); |
136 void DisconnectTerminal(int terminal_id); | 137 void DisconnectTerminal(int terminal_id); |
137 | 138 |
138 // Creates a DesktopEnvironment with a fake webrtc::DesktopCapturer, to mock | 139 // Creates a DesktopEnvironment with a fake webrtc::DesktopCapturer, to mock |
139 // DesktopEnvironmentFactory::Create(). | 140 // DesktopEnvironmentFactory::Create(). |
140 DesktopEnvironment* CreateDesktopEnvironment(); | 141 DesktopEnvironment* CreateDesktopEnvironment(); |
141 | 142 |
(...skipping 20 matching lines...) Expand all Loading... |
162 | 163 |
163 // Destroys the desktop process object created by CreateDesktopProcess(). | 164 // Destroys the desktop process object created by CreateDesktopProcess(). |
164 void DestoyDesktopProcess(); | 165 void DestoyDesktopProcess(); |
165 | 166 |
166 void OnDisconnectCallback(); | 167 void OnDisconnectCallback(); |
167 | 168 |
168 // Invoked when ChromotingDesktopDaemonMsg_DesktopAttached message is | 169 // Invoked when ChromotingDesktopDaemonMsg_DesktopAttached message is |
169 // received. | 170 // received. |
170 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_pipe); | 171 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_pipe); |
171 | 172 |
| 173 void RunMainLoopUntilDone(); |
| 174 |
172 // The main message loop. | 175 // The main message loop. |
173 base::MessageLoopForUI message_loop_; | 176 base::MessageLoopForUI message_loop_; |
174 | 177 |
175 // Runs until |desktop_session_proxy_| is connected to the desktop. | 178 // Runs until |desktop_session_proxy_| is connected to the desktop. |
176 scoped_ptr<base::RunLoop> setup_run_loop_; | 179 scoped_ptr<base::RunLoop> setup_run_loop_; |
177 | 180 |
178 // Runs until there are references to |task_runner_|. | |
179 base::RunLoop main_run_loop_; | |
180 | |
181 scoped_refptr<AutoThreadTaskRunner> task_runner_; | 181 scoped_refptr<AutoThreadTaskRunner> task_runner_; |
182 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; | 182 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; |
183 | 183 |
184 std::string client_jid_; | 184 std::string client_jid_; |
185 | 185 |
186 // Clipboard stub that receives clipboard events from the desktop process. | 186 // Clipboard stub that receives clipboard events from the desktop process. |
187 protocol::ClipboardStub* clipboard_stub_; | 187 protocol::ClipboardStub* clipboard_stub_; |
188 | 188 |
189 // The daemons's end of the daemon-to-desktop channel. | 189 // The daemons's end of the daemon-to-desktop channel. |
190 scoped_ptr<IPC::ChannelProxy> desktop_channel_; | 190 scoped_ptr<IPC::ChannelProxy> desktop_channel_; |
(...skipping 24 matching lines...) Expand all Loading... |
215 // Input injector owned by |desktop_process_|. | 215 // Input injector owned by |desktop_process_|. |
216 MockInputInjector* remote_input_injector_; | 216 MockInputInjector* remote_input_injector_; |
217 | 217 |
218 // The last |terminal_id| passed to ConnectTermina(); | 218 // The last |terminal_id| passed to ConnectTermina(); |
219 int terminal_id_; | 219 int terminal_id_; |
220 | 220 |
221 webrtc::MockScreenCapturerCallback desktop_capturer_callback_; | 221 webrtc::MockScreenCapturerCallback desktop_capturer_callback_; |
222 | 222 |
223 MockClientSessionControl client_session_control_; | 223 MockClientSessionControl client_session_control_; |
224 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; | 224 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; |
| 225 |
| 226 private: |
| 227 // Runs until there are references to |task_runner_|. |
| 228 base::RunLoop main_run_loop_; |
225 }; | 229 }; |
226 | 230 |
227 IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest() | 231 IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest() |
228 : client_jid_("user@domain/rest-of-jid"), | 232 : client_jid_("user@domain/rest-of-jid"), |
229 clipboard_stub_(nullptr), | 233 clipboard_stub_(nullptr), |
230 remote_input_injector_(nullptr), | 234 remote_input_injector_(nullptr), |
231 terminal_id_(-1), | 235 terminal_id_(-1), |
232 client_session_control_factory_(&client_session_control_) { | 236 client_session_control_factory_(&client_session_control_) { |
233 } | 237 } |
234 | 238 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // Create the input injector. | 299 // Create the input injector. |
296 input_injector_ = desktop_environment_->CreateInputInjector(); | 300 input_injector_ = desktop_environment_->CreateInputInjector(); |
297 | 301 |
298 // Create the screen capturer. | 302 // Create the screen capturer. |
299 video_capturer_ = | 303 video_capturer_ = |
300 desktop_environment_->CreateVideoCapturer(); | 304 desktop_environment_->CreateVideoCapturer(); |
301 | 305 |
302 desktop_environment_->SetCapabilities(std::string()); | 306 desktop_environment_->SetCapabilities(std::string()); |
303 } | 307 } |
304 | 308 |
| 309 void IpcDesktopEnvironmentTest::TearDown() { |
| 310 RunMainLoopUntilDone(); |
| 311 } |
| 312 |
305 void IpcDesktopEnvironmentTest::ConnectTerminal( | 313 void IpcDesktopEnvironmentTest::ConnectTerminal( |
306 int terminal_id, | 314 int terminal_id, |
307 const ScreenResolution& resolution, | 315 const ScreenResolution& resolution, |
308 bool virtual_terminal) { | 316 bool virtual_terminal) { |
309 EXPECT_NE(terminal_id_, terminal_id); | 317 EXPECT_NE(terminal_id_, terminal_id); |
310 | 318 |
311 terminal_id_ = terminal_id; | 319 terminal_id_ = terminal_id; |
312 CreateDesktopProcess(); | 320 CreateDesktopProcess(); |
313 } | 321 } |
314 | 322 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 ASSERT_NE(FALSE, ::DuplicateHandle(GetCurrentProcess(), process_handle, | 439 ASSERT_NE(FALSE, ::DuplicateHandle(GetCurrentProcess(), process_handle, |
432 GetCurrentProcess(), &process_handle, | 440 GetCurrentProcess(), &process_handle, |
433 0, FALSE, DUPLICATE_SAME_ACCESS)); | 441 0, FALSE, DUPLICATE_SAME_ACCESS)); |
434 #endif | 442 #endif |
435 | 443 |
436 // Instruct DesktopSessionProxy to connect to the network-to-desktop pipe. | 444 // Instruct DesktopSessionProxy to connect to the network-to-desktop pipe. |
437 desktop_environment_factory_->OnDesktopSessionAgentAttached( | 445 desktop_environment_factory_->OnDesktopSessionAgentAttached( |
438 terminal_id_, process_handle, desktop_pipe); | 446 terminal_id_, process_handle, desktop_pipe); |
439 } | 447 } |
440 | 448 |
| 449 void IpcDesktopEnvironmentTest::RunMainLoopUntilDone() { |
| 450 task_runner_ = nullptr; |
| 451 io_task_runner_ = nullptr; |
| 452 main_run_loop_.Run(); |
| 453 } |
| 454 |
441 // Runs until the desktop is attached and exits immediately after that. | 455 // Runs until the desktop is attached and exits immediately after that. |
442 TEST_F(IpcDesktopEnvironmentTest, Basic) { | 456 TEST_F(IpcDesktopEnvironmentTest, Basic) { |
443 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 457 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
444 new protocol::MockClipboardStub()); | 458 new protocol::MockClipboardStub()); |
445 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 459 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
446 .Times(0); | 460 .Times(0); |
447 | 461 |
448 // Start the input injector and screen capturer. | 462 // Start the input injector and screen capturer. |
449 input_injector_->Start(clipboard_stub.Pass()); | 463 input_injector_->Start(clipboard_stub.Pass()); |
450 | 464 |
451 // Run the message loop until the desktop is attached. | 465 // Run the message loop until the desktop is attached. |
452 setup_run_loop_->Run(); | 466 setup_run_loop_->Run(); |
453 | 467 |
454 // Stop the test. | 468 // Stop the test. |
455 DeleteDesktopEnvironment(); | 469 DeleteDesktopEnvironment(); |
| 470 } |
456 | 471 |
457 task_runner_ = nullptr; | 472 // Check Capabilities. |
458 io_task_runner_ = nullptr; | 473 TEST_F(IpcDesktopEnvironmentTest, CapabilitiesNoTouch) { |
459 main_run_loop_.Run(); | 474 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 475 new protocol::MockClipboardStub()); |
| 476 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 477 .Times(0); |
| 478 |
| 479 EXPECT_EQ("rateLimitResizeRequests", desktop_environment_->GetCapabilities()); |
| 480 |
| 481 // Start the input injector and screen capturer. |
| 482 input_injector_->Start(clipboard_stub.Pass()); |
| 483 |
| 484 // Run the message loop until the desktop is attached. |
| 485 setup_run_loop_->Run(); |
| 486 |
| 487 // Stop the test. |
| 488 DeleteDesktopEnvironment(); |
| 489 } |
| 490 |
| 491 // Check touchEvents capability is set when the desktop environment can |
| 492 // inject touch events. |
| 493 TEST_F(IpcDesktopEnvironmentTest, TouchEventsCapabilities) { |
| 494 // Create an environment with multi touch enabled. |
| 495 desktop_environment_factory_->set_supports_touch_events(true); |
| 496 desktop_environment_ = desktop_environment_factory_->Create( |
| 497 client_session_control_factory_.GetWeakPtr()); |
| 498 |
| 499 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 500 new protocol::MockClipboardStub()); |
| 501 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 502 .Times(0); |
| 503 |
| 504 EXPECT_EQ("rateLimitResizeRequests touchEvents", |
| 505 desktop_environment_->GetCapabilities()); |
| 506 |
| 507 // Start the input injector and screen capturer. |
| 508 input_injector_->Start(clipboard_stub.Pass()); |
| 509 |
| 510 // Run the message loop until the desktop is attached. |
| 511 setup_run_loop_->Run(); |
| 512 |
| 513 // Stop the test. |
| 514 DeleteDesktopEnvironment(); |
460 } | 515 } |
461 | 516 |
462 // Tests that the video capturer receives a frame over IPC. | 517 // Tests that the video capturer receives a frame over IPC. |
463 TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { | 518 TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { |
464 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 519 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
465 new protocol::MockClipboardStub()); | 520 new protocol::MockClipboardStub()); |
466 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 521 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
467 .Times(0); | 522 .Times(0); |
468 | 523 |
469 // Start the input injector and screen capturer. | 524 // Start the input injector and screen capturer. |
470 input_injector_->Start(clipboard_stub.Pass()); | 525 input_injector_->Start(clipboard_stub.Pass()); |
471 video_capturer_->Start(&desktop_capturer_callback_); | 526 video_capturer_->Start(&desktop_capturer_callback_); |
472 | 527 |
473 // Run the message loop until the desktop is attached. | 528 // Run the message loop until the desktop is attached. |
474 setup_run_loop_->Run(); | 529 setup_run_loop_->Run(); |
475 | 530 |
476 // Stop the test when the first frame is captured. | 531 // Stop the test when the first frame is captured. |
477 EXPECT_CALL(desktop_capturer_callback_, OnCaptureCompleted(_)) | 532 EXPECT_CALL(desktop_capturer_callback_, OnCaptureCompleted(_)) |
478 .WillOnce(DoAll( | 533 .WillOnce(DoAll( |
479 DeleteArg<0>(), | 534 DeleteArg<0>(), |
480 InvokeWithoutArgs( | 535 InvokeWithoutArgs( |
481 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment))); | 536 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment))); |
482 | 537 |
483 // Capture a single frame. | 538 // Capture a single frame. |
484 video_capturer_->Capture(webrtc::DesktopRegion()); | 539 video_capturer_->Capture(webrtc::DesktopRegion()); |
485 | |
486 task_runner_ = nullptr; | |
487 io_task_runner_ = nullptr; | |
488 main_run_loop_.Run(); | |
489 } | 540 } |
490 | 541 |
491 // Tests that attaching to a new desktop works. | 542 // Tests that attaching to a new desktop works. |
492 TEST_F(IpcDesktopEnvironmentTest, Reattach) { | 543 TEST_F(IpcDesktopEnvironmentTest, Reattach) { |
493 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 544 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
494 new protocol::MockClipboardStub()); | 545 new protocol::MockClipboardStub()); |
495 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 546 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
496 .Times(0); | 547 .Times(0); |
497 | 548 |
498 // Start the input injector and screen capturer. | 549 // Start the input injector and screen capturer. |
499 input_injector_->Start(clipboard_stub.Pass()); | 550 input_injector_->Start(clipboard_stub.Pass()); |
500 video_capturer_->Start(&desktop_capturer_callback_); | 551 video_capturer_->Start(&desktop_capturer_callback_); |
501 | 552 |
502 // Run the message loop until the desktop is attached. | 553 // Run the message loop until the desktop is attached. |
503 setup_run_loop_->Run(); | 554 setup_run_loop_->Run(); |
504 | 555 |
505 // Create and start a new desktop process object. | 556 // Create and start a new desktop process object. |
506 setup_run_loop_.reset(new base::RunLoop()); | 557 setup_run_loop_.reset(new base::RunLoop()); |
507 DestoyDesktopProcess(); | 558 DestoyDesktopProcess(); |
508 CreateDesktopProcess(); | 559 CreateDesktopProcess(); |
509 setup_run_loop_->Run(); | 560 setup_run_loop_->Run(); |
510 | 561 |
511 // Stop the test. | 562 // Stop the test. |
512 DeleteDesktopEnvironment(); | 563 DeleteDesktopEnvironment(); |
513 | |
514 task_runner_ = nullptr; | |
515 io_task_runner_ = nullptr; | |
516 main_run_loop_.Run(); | |
517 } | 564 } |
518 | 565 |
519 // Tests injection of clipboard events. | 566 // Tests injection of clipboard events. |
520 TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { | 567 TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { |
521 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 568 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
522 new protocol::MockClipboardStub()); | 569 new protocol::MockClipboardStub()); |
523 clipboard_stub_ = clipboard_stub.get(); | 570 clipboard_stub_ = clipboard_stub.get(); |
524 | 571 |
525 // Stop the test when a clipboard event is received from the desktop process. | 572 // Stop the test when a clipboard event is received from the desktop process. |
526 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 573 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
(...skipping 12 matching lines...) Expand all Loading... |
539 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) | 586 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) |
540 .Times(1) | 587 .Times(1) |
541 .WillOnce(Invoke(this, | 588 .WillOnce(Invoke(this, |
542 &IpcDesktopEnvironmentTest::ReflectClipboardEvent)); | 589 &IpcDesktopEnvironmentTest::ReflectClipboardEvent)); |
543 | 590 |
544 // Send a clipboard event. | 591 // Send a clipboard event. |
545 protocol::ClipboardEvent event; | 592 protocol::ClipboardEvent event; |
546 event.set_mime_type(kMimeTypeTextUtf8); | 593 event.set_mime_type(kMimeTypeTextUtf8); |
547 event.set_data("a"); | 594 event.set_data("a"); |
548 input_injector_->InjectClipboardEvent(event); | 595 input_injector_->InjectClipboardEvent(event); |
549 | |
550 task_runner_ = nullptr; | |
551 io_task_runner_ = nullptr; | |
552 main_run_loop_.Run(); | |
553 } | 596 } |
554 | 597 |
555 // Tests injection of key events. | 598 // Tests injection of key events. |
556 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { | 599 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { |
557 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 600 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
558 new protocol::MockClipboardStub()); | 601 new protocol::MockClipboardStub()); |
559 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 602 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
560 .Times(0); | 603 .Times(0); |
561 | 604 |
562 // Start the input injector and screen capturer. | 605 // Start the input injector and screen capturer. |
563 input_injector_->Start(clipboard_stub.Pass()); | 606 input_injector_->Start(clipboard_stub.Pass()); |
564 video_capturer_->Start(&desktop_capturer_callback_); | 607 video_capturer_->Start(&desktop_capturer_callback_); |
565 | 608 |
566 // Run the message loop until the desktop is attached. | 609 // Run the message loop until the desktop is attached. |
567 setup_run_loop_->Run(); | 610 setup_run_loop_->Run(); |
568 | 611 |
569 // Expect a single key event. | 612 // Expect a single key event. |
570 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) | 613 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) |
571 .Times(AtLeast(1)) | 614 .Times(AtLeast(1)) |
572 .WillRepeatedly(InvokeWithoutArgs( | 615 .WillRepeatedly(InvokeWithoutArgs( |
573 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 616 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
574 | 617 |
575 // Send a key event. | 618 // Send a key event. |
576 protocol::KeyEvent event; | 619 protocol::KeyEvent event; |
577 event.set_usb_keycode(0x070004); | 620 event.set_usb_keycode(0x070004); |
578 event.set_pressed(true); | 621 event.set_pressed(true); |
579 input_injector_->InjectKeyEvent(event); | 622 input_injector_->InjectKeyEvent(event); |
580 | |
581 task_runner_ = nullptr; | |
582 io_task_runner_ = nullptr; | |
583 main_run_loop_.Run(); | |
584 } | 623 } |
585 | 624 |
586 // Tests injection of text events. | 625 // Tests injection of text events. |
587 TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { | 626 TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { |
588 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 627 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
589 new protocol::MockClipboardStub()); | 628 new protocol::MockClipboardStub()); |
590 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 629 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
591 .Times(0); | 630 .Times(0); |
592 | 631 |
593 // Start the input injector and screen capturer. | 632 // Start the input injector and screen capturer. |
594 input_injector_->Start(clipboard_stub.Pass()); | 633 input_injector_->Start(clipboard_stub.Pass()); |
595 video_capturer_->Start(&desktop_capturer_callback_); | 634 video_capturer_->Start(&desktop_capturer_callback_); |
596 | 635 |
597 // Run the message loop until the desktop is attached. | 636 // Run the message loop until the desktop is attached. |
598 setup_run_loop_->Run(); | 637 setup_run_loop_->Run(); |
599 | 638 |
600 // Expect a single text event. | 639 // Expect a single text event. |
601 EXPECT_CALL(*remote_input_injector_, InjectTextEvent(_)) | 640 EXPECT_CALL(*remote_input_injector_, InjectTextEvent(_)) |
602 .Times(AtLeast(1)) | 641 .Times(AtLeast(1)) |
603 .WillRepeatedly(InvokeWithoutArgs( | 642 .WillRepeatedly(InvokeWithoutArgs( |
604 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 643 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
605 | 644 |
606 // Send a text event. | 645 // Send a text event. |
607 protocol::TextEvent event; | 646 protocol::TextEvent event; |
608 event.set_text("hello"); | 647 event.set_text("hello"); |
609 input_injector_->InjectTextEvent(event); | 648 input_injector_->InjectTextEvent(event); |
610 | |
611 task_runner_ = nullptr; | |
612 io_task_runner_ = nullptr; | |
613 main_run_loop_.Run(); | |
614 } | 649 } |
615 | 650 |
616 // Tests injection of mouse events. | 651 // Tests injection of mouse events. |
617 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { | 652 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { |
618 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 653 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
619 new protocol::MockClipboardStub()); | 654 new protocol::MockClipboardStub()); |
620 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 655 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
621 .Times(0); | 656 .Times(0); |
622 | 657 |
623 // Start the input injector and screen capturer. | 658 // Start the input injector and screen capturer. |
624 input_injector_->Start(clipboard_stub.Pass()); | 659 input_injector_->Start(clipboard_stub.Pass()); |
625 video_capturer_->Start(&desktop_capturer_callback_); | 660 video_capturer_->Start(&desktop_capturer_callback_); |
626 | 661 |
627 // Run the message loop until the desktop is attached. | 662 // Run the message loop until the desktop is attached. |
628 setup_run_loop_->Run(); | 663 setup_run_loop_->Run(); |
629 | 664 |
630 // Expect a single mouse event. | 665 // Expect a single mouse event. |
631 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) | 666 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) |
632 .Times(1) | 667 .Times(1) |
633 .WillOnce(InvokeWithoutArgs( | 668 .WillOnce(InvokeWithoutArgs( |
634 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 669 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
635 | 670 |
636 // Send a mouse event. | 671 // Send a mouse event. |
637 protocol::MouseEvent event; | 672 protocol::MouseEvent event; |
638 event.set_x(0); | 673 event.set_x(0); |
639 event.set_y(0); | 674 event.set_y(0); |
640 input_injector_->InjectMouseEvent(event); | 675 input_injector_->InjectMouseEvent(event); |
641 | |
642 task_runner_ = nullptr; | |
643 io_task_runner_ = nullptr; | |
644 main_run_loop_.Run(); | |
645 } | 676 } |
646 | 677 |
647 // Tests injection of touch events. | 678 // Tests injection of touch events. |
648 TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) { | 679 TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) { |
649 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 680 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
650 new protocol::MockClipboardStub()); | 681 new protocol::MockClipboardStub()); |
651 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 682 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
652 .Times(0); | 683 .Times(0); |
653 | 684 |
654 // Start the input injector and screen capturer. | 685 // Start the input injector and screen capturer. |
(...skipping 22 matching lines...) Expand all Loading... |
677 // Expect that the event gets propagated to remote_input_injector_. | 708 // Expect that the event gets propagated to remote_input_injector_. |
678 // And one more call for ReleaseAll(). | 709 // And one more call for ReleaseAll(). |
679 EXPECT_CALL(*remote_input_injector_, | 710 EXPECT_CALL(*remote_input_injector_, |
680 InjectTouchEvent(EqualsTouchEvent(event))); | 711 InjectTouchEvent(EqualsTouchEvent(event))); |
681 EXPECT_CALL(*remote_input_injector_, | 712 EXPECT_CALL(*remote_input_injector_, |
682 InjectTouchEvent(EqualsTouchEventTypeAndId( | 713 InjectTouchEvent(EqualsTouchEventTypeAndId( |
683 protocol::TouchEvent::TOUCH_POINT_CANCEL, 0u))); | 714 protocol::TouchEvent::TOUCH_POINT_CANCEL, 0u))); |
684 | 715 |
685 // Send the touch event. | 716 // Send the touch event. |
686 input_injector_->InjectTouchEvent(event); | 717 input_injector_->InjectTouchEvent(event); |
687 | |
688 task_runner_ = nullptr; | |
689 io_task_runner_ = nullptr; | |
690 main_run_loop_.Run(); | |
691 } | 718 } |
692 | 719 |
693 // Tests that setting the desktop resolution works. | 720 // Tests that setting the desktop resolution works. |
694 TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { | 721 TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { |
695 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 722 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
696 new protocol::MockClipboardStub()); | 723 new protocol::MockClipboardStub()); |
697 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 724 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
698 .Times(0); | 725 .Times(0); |
699 | 726 |
700 // Start the input injector and screen capturer. | 727 // Start the input injector and screen capturer. |
701 input_injector_->Start(clipboard_stub.Pass()); | 728 input_injector_->Start(clipboard_stub.Pass()); |
702 video_capturer_->Start(&desktop_capturer_callback_); | 729 video_capturer_->Start(&desktop_capturer_callback_); |
703 | 730 |
704 // Run the message loop until the desktop is attached. | 731 // Run the message loop until the desktop is attached. |
705 setup_run_loop_->Run(); | 732 setup_run_loop_->Run(); |
706 | 733 |
707 EXPECT_CALL(daemon_channel_, SetScreenResolution(_, _)) | 734 EXPECT_CALL(daemon_channel_, SetScreenResolution(_, _)) |
708 .Times(1) | 735 .Times(1) |
709 .WillOnce(InvokeWithoutArgs( | 736 .WillOnce(InvokeWithoutArgs( |
710 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 737 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
711 | 738 |
712 // Change the desktop resolution. | 739 // Change the desktop resolution. |
713 screen_controls_->SetScreenResolution(ScreenResolution( | 740 screen_controls_->SetScreenResolution(ScreenResolution( |
714 webrtc::DesktopSize(100, 100), | 741 webrtc::DesktopSize(100, 100), |
715 webrtc::DesktopVector(96, 96))); | 742 webrtc::DesktopVector(96, 96))); |
716 | |
717 task_runner_ = nullptr; | |
718 io_task_runner_ = nullptr; | |
719 main_run_loop_.Run(); | |
720 } | 743 } |
721 | 744 |
722 } // namespace remoting | 745 } // namespace remoting |
OLD | NEW |