Chromium Code Reviews| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 | 162 |
| 163 // Destroys the desktop process object created by CreateDesktopProcess(). | 163 // Destroys the desktop process object created by CreateDesktopProcess(). |
| 164 void DestoyDesktopProcess(); | 164 void DestoyDesktopProcess(); |
| 165 | 165 |
| 166 void OnDisconnectCallback(); | 166 void OnDisconnectCallback(); |
| 167 | 167 |
| 168 // Invoked when ChromotingDesktopDaemonMsg_DesktopAttached message is | 168 // Invoked when ChromotingDesktopDaemonMsg_DesktopAttached message is |
| 169 // received. | 169 // received. |
| 170 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_pipe); | 170 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_pipe); |
| 171 | 171 |
| 172 void RunMainLoopUntilDone(); | |
| 173 | |
| 172 // The main message loop. | 174 // The main message loop. |
| 173 base::MessageLoopForUI message_loop_; | 175 base::MessageLoopForUI message_loop_; |
| 174 | 176 |
| 175 // Runs until |desktop_session_proxy_| is connected to the desktop. | 177 // Runs until |desktop_session_proxy_| is connected to the desktop. |
| 176 scoped_ptr<base::RunLoop> setup_run_loop_; | 178 scoped_ptr<base::RunLoop> setup_run_loop_; |
| 177 | 179 |
| 178 // Runs until there are references to |task_runner_|. | 180 // Runs until there are references to |task_runner_|. |
| 179 base::RunLoop main_run_loop_; | 181 base::RunLoop main_run_loop_; |
|
Wez
2015/05/21 22:10:45
nit: Make this private, so that the derived tests
Rintaro Kuroiwa
2015/05/22 01:04:04
Done.
| |
| 180 | 182 |
| 181 scoped_refptr<AutoThreadTaskRunner> task_runner_; | 183 scoped_refptr<AutoThreadTaskRunner> task_runner_; |
| 182 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; | 184 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; |
| 183 | 185 |
| 184 std::string client_jid_; | 186 std::string client_jid_; |
| 185 | 187 |
| 186 // Clipboard stub that receives clipboard events from the desktop process. | 188 // Clipboard stub that receives clipboard events from the desktop process. |
| 187 protocol::ClipboardStub* clipboard_stub_; | 189 protocol::ClipboardStub* clipboard_stub_; |
| 188 | 190 |
| 189 // The daemons's end of the daemon-to-desktop channel. | 191 // The daemons's end of the daemon-to-desktop channel. |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 ASSERT_NE(FALSE, ::DuplicateHandle(GetCurrentProcess(), process_handle, | 433 ASSERT_NE(FALSE, ::DuplicateHandle(GetCurrentProcess(), process_handle, |
| 432 GetCurrentProcess(), &process_handle, | 434 GetCurrentProcess(), &process_handle, |
| 433 0, FALSE, DUPLICATE_SAME_ACCESS)); | 435 0, FALSE, DUPLICATE_SAME_ACCESS)); |
| 434 #endif | 436 #endif |
| 435 | 437 |
| 436 // Instruct DesktopSessionProxy to connect to the network-to-desktop pipe. | 438 // Instruct DesktopSessionProxy to connect to the network-to-desktop pipe. |
| 437 desktop_environment_factory_->OnDesktopSessionAgentAttached( | 439 desktop_environment_factory_->OnDesktopSessionAgentAttached( |
| 438 terminal_id_, process_handle, desktop_pipe); | 440 terminal_id_, process_handle, desktop_pipe); |
| 439 } | 441 } |
| 440 | 442 |
| 443 void IpcDesktopEnvironmentTest::RunMainLoopUntilDone() { | |
| 444 task_runner_ = nullptr; | |
| 445 io_task_runner_ = nullptr; | |
| 446 main_run_loop_.Run(); | |
| 447 } | |
| 448 | |
| 441 // Runs until the desktop is attached and exits immediately after that. | 449 // Runs until the desktop is attached and exits immediately after that. |
| 442 TEST_F(IpcDesktopEnvironmentTest, Basic) { | 450 TEST_F(IpcDesktopEnvironmentTest, Basic) { |
| 443 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 451 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 444 new protocol::MockClipboardStub()); | 452 new protocol::MockClipboardStub()); |
| 445 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 453 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 446 .Times(0); | 454 .Times(0); |
| 447 | 455 |
| 448 // Start the input injector and screen capturer. | 456 // Start the input injector and screen capturer. |
| 449 input_injector_->Start(clipboard_stub.Pass()); | 457 input_injector_->Start(clipboard_stub.Pass()); |
| 450 | 458 |
| 451 // Run the message loop until the desktop is attached. | 459 // Run the message loop until the desktop is attached. |
| 452 setup_run_loop_->Run(); | 460 setup_run_loop_->Run(); |
| 453 | 461 |
| 454 // Stop the test. | 462 // Stop the test. |
| 455 DeleteDesktopEnvironment(); | 463 DeleteDesktopEnvironment(); |
| 456 | 464 |
| 457 task_runner_ = nullptr; | 465 RunMainLoopUntilDone(); |
| 458 io_task_runner_ = nullptr; | 466 } |
| 459 main_run_loop_.Run(); | 467 |
| 468 // Check Capabilities. | |
| 469 TEST_F(IpcDesktopEnvironmentTest, CapabilitiesNoTouch) { | |
| 470 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | |
| 471 new protocol::MockClipboardStub()); | |
| 472 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | |
| 473 .Times(0); | |
| 474 | |
| 475 EXPECT_EQ("rateLimitResizeRequests", desktop_environment_->GetCapabilities()); | |
| 476 | |
| 477 // Start the input injector and screen capturer. | |
| 478 input_injector_->Start(clipboard_stub.Pass()); | |
| 479 | |
| 480 // Run the message loop until the desktop is attached. | |
| 481 setup_run_loop_->Run(); | |
| 482 | |
| 483 // Stop the test. | |
| 484 DeleteDesktopEnvironment(); | |
| 485 | |
| 486 RunMainLoopUntilDone(); | |
| 487 } | |
| 488 | |
| 489 // Check touchEvents capability is set when the desktop environment can | |
| 490 // inject touch events. | |
| 491 TEST_F(IpcDesktopEnvironmentTest, TouchEventsCapabilities) { | |
| 492 // Create an environment with multi touch enabled. | |
| 493 desktop_environment_factory_->set_supports_touch_events(true); | |
| 494 desktop_environment_ = desktop_environment_factory_->Create( | |
| 495 client_session_control_factory_.GetWeakPtr()); | |
| 496 | |
| 497 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | |
| 498 new protocol::MockClipboardStub()); | |
| 499 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | |
| 500 .Times(0); | |
| 501 | |
| 502 EXPECT_EQ("rateLimitResizeRequests touchEvents", | |
| 503 desktop_environment_->GetCapabilities()); | |
| 504 | |
| 505 // Start the input injector and screen capturer. | |
| 506 input_injector_->Start(clipboard_stub.Pass()); | |
| 507 | |
| 508 // Run the message loop until the desktop is attached. | |
| 509 setup_run_loop_->Run(); | |
| 510 | |
| 511 // Stop the test. | |
| 512 DeleteDesktopEnvironment(); | |
| 513 | |
| 514 RunMainLoopUntilDone(); | |
| 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 | 540 |
| 486 task_runner_ = nullptr; | 541 RunMainLoopUntilDone(); |
| 487 io_task_runner_ = nullptr; | |
| 488 main_run_loop_.Run(); | |
| 489 } | 542 } |
| 490 | 543 |
| 491 // Tests that attaching to a new desktop works. | 544 // Tests that attaching to a new desktop works. |
| 492 TEST_F(IpcDesktopEnvironmentTest, Reattach) { | 545 TEST_F(IpcDesktopEnvironmentTest, Reattach) { |
| 493 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 546 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 494 new protocol::MockClipboardStub()); | 547 new protocol::MockClipboardStub()); |
| 495 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 548 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 496 .Times(0); | 549 .Times(0); |
| 497 | 550 |
| 498 // Start the input injector and screen capturer. | 551 // Start the input injector and screen capturer. |
| 499 input_injector_->Start(clipboard_stub.Pass()); | 552 input_injector_->Start(clipboard_stub.Pass()); |
| 500 video_capturer_->Start(&desktop_capturer_callback_); | 553 video_capturer_->Start(&desktop_capturer_callback_); |
| 501 | 554 |
| 502 // Run the message loop until the desktop is attached. | 555 // Run the message loop until the desktop is attached. |
| 503 setup_run_loop_->Run(); | 556 setup_run_loop_->Run(); |
| 504 | 557 |
| 505 // Create and start a new desktop process object. | 558 // Create and start a new desktop process object. |
| 506 setup_run_loop_.reset(new base::RunLoop()); | 559 setup_run_loop_.reset(new base::RunLoop()); |
| 507 DestoyDesktopProcess(); | 560 DestoyDesktopProcess(); |
| 508 CreateDesktopProcess(); | 561 CreateDesktopProcess(); |
| 509 setup_run_loop_->Run(); | 562 setup_run_loop_->Run(); |
| 510 | 563 |
| 511 // Stop the test. | 564 // Stop the test. |
| 512 DeleteDesktopEnvironment(); | 565 DeleteDesktopEnvironment(); |
| 513 | 566 |
| 514 task_runner_ = nullptr; | 567 RunMainLoopUntilDone(); |
| 515 io_task_runner_ = nullptr; | |
| 516 main_run_loop_.Run(); | |
| 517 } | 568 } |
| 518 | 569 |
| 519 // Tests injection of clipboard events. | 570 // Tests injection of clipboard events. |
| 520 TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { | 571 TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { |
| 521 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 572 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 522 new protocol::MockClipboardStub()); | 573 new protocol::MockClipboardStub()); |
| 523 clipboard_stub_ = clipboard_stub.get(); | 574 clipboard_stub_ = clipboard_stub.get(); |
| 524 | 575 |
| 525 // Stop the test when a clipboard event is received from the desktop process. | 576 // Stop the test when a clipboard event is received from the desktop process. |
| 526 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 577 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 540 .Times(1) | 591 .Times(1) |
| 541 .WillOnce(Invoke(this, | 592 .WillOnce(Invoke(this, |
| 542 &IpcDesktopEnvironmentTest::ReflectClipboardEvent)); | 593 &IpcDesktopEnvironmentTest::ReflectClipboardEvent)); |
| 543 | 594 |
| 544 // Send a clipboard event. | 595 // Send a clipboard event. |
| 545 protocol::ClipboardEvent event; | 596 protocol::ClipboardEvent event; |
| 546 event.set_mime_type(kMimeTypeTextUtf8); | 597 event.set_mime_type(kMimeTypeTextUtf8); |
| 547 event.set_data("a"); | 598 event.set_data("a"); |
| 548 input_injector_->InjectClipboardEvent(event); | 599 input_injector_->InjectClipboardEvent(event); |
| 549 | 600 |
| 550 task_runner_ = nullptr; | 601 RunMainLoopUntilDone(); |
| 551 io_task_runner_ = nullptr; | |
| 552 main_run_loop_.Run(); | |
| 553 } | 602 } |
| 554 | 603 |
| 555 // Tests injection of key events. | 604 // Tests injection of key events. |
| 556 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { | 605 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { |
| 557 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 606 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 558 new protocol::MockClipboardStub()); | 607 new protocol::MockClipboardStub()); |
| 559 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 608 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 560 .Times(0); | 609 .Times(0); |
| 561 | 610 |
| 562 // Start the input injector and screen capturer. | 611 // Start the input injector and screen capturer. |
| 563 input_injector_->Start(clipboard_stub.Pass()); | 612 input_injector_->Start(clipboard_stub.Pass()); |
| 564 video_capturer_->Start(&desktop_capturer_callback_); | 613 video_capturer_->Start(&desktop_capturer_callback_); |
| 565 | 614 |
| 566 // Run the message loop until the desktop is attached. | 615 // Run the message loop until the desktop is attached. |
| 567 setup_run_loop_->Run(); | 616 setup_run_loop_->Run(); |
| 568 | 617 |
| 569 // Expect a single key event. | 618 // Expect a single key event. |
| 570 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) | 619 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) |
| 571 .Times(AtLeast(1)) | 620 .Times(AtLeast(1)) |
| 572 .WillRepeatedly(InvokeWithoutArgs( | 621 .WillRepeatedly(InvokeWithoutArgs( |
| 573 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 622 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 574 | 623 |
| 575 // Send a key event. | 624 // Send a key event. |
| 576 protocol::KeyEvent event; | 625 protocol::KeyEvent event; |
| 577 event.set_usb_keycode(0x070004); | 626 event.set_usb_keycode(0x070004); |
| 578 event.set_pressed(true); | 627 event.set_pressed(true); |
| 579 input_injector_->InjectKeyEvent(event); | 628 input_injector_->InjectKeyEvent(event); |
| 580 | 629 |
| 581 task_runner_ = nullptr; | 630 RunMainLoopUntilDone(); |
| 582 io_task_runner_ = nullptr; | |
| 583 main_run_loop_.Run(); | |
| 584 } | 631 } |
| 585 | 632 |
| 586 // Tests injection of text events. | 633 // Tests injection of text events. |
| 587 TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { | 634 TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { |
| 588 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 635 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 589 new protocol::MockClipboardStub()); | 636 new protocol::MockClipboardStub()); |
| 590 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 637 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 591 .Times(0); | 638 .Times(0); |
| 592 | 639 |
| 593 // Start the input injector and screen capturer. | 640 // Start the input injector and screen capturer. |
| 594 input_injector_->Start(clipboard_stub.Pass()); | 641 input_injector_->Start(clipboard_stub.Pass()); |
| 595 video_capturer_->Start(&desktop_capturer_callback_); | 642 video_capturer_->Start(&desktop_capturer_callback_); |
| 596 | 643 |
| 597 // Run the message loop until the desktop is attached. | 644 // Run the message loop until the desktop is attached. |
| 598 setup_run_loop_->Run(); | 645 setup_run_loop_->Run(); |
| 599 | 646 |
| 600 // Expect a single text event. | 647 // Expect a single text event. |
| 601 EXPECT_CALL(*remote_input_injector_, InjectTextEvent(_)) | 648 EXPECT_CALL(*remote_input_injector_, InjectTextEvent(_)) |
| 602 .Times(AtLeast(1)) | 649 .Times(AtLeast(1)) |
| 603 .WillRepeatedly(InvokeWithoutArgs( | 650 .WillRepeatedly(InvokeWithoutArgs( |
| 604 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 651 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 605 | 652 |
| 606 // Send a text event. | 653 // Send a text event. |
| 607 protocol::TextEvent event; | 654 protocol::TextEvent event; |
| 608 event.set_text("hello"); | 655 event.set_text("hello"); |
| 609 input_injector_->InjectTextEvent(event); | 656 input_injector_->InjectTextEvent(event); |
| 610 | 657 |
| 611 task_runner_ = nullptr; | 658 RunMainLoopUntilDone(); |
| 612 io_task_runner_ = nullptr; | |
| 613 main_run_loop_.Run(); | |
| 614 } | 659 } |
| 615 | 660 |
| 616 // Tests injection of mouse events. | 661 // Tests injection of mouse events. |
| 617 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { | 662 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { |
| 618 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 663 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 619 new protocol::MockClipboardStub()); | 664 new protocol::MockClipboardStub()); |
| 620 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 665 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 621 .Times(0); | 666 .Times(0); |
| 622 | 667 |
| 623 // Start the input injector and screen capturer. | 668 // Start the input injector and screen capturer. |
| 624 input_injector_->Start(clipboard_stub.Pass()); | 669 input_injector_->Start(clipboard_stub.Pass()); |
| 625 video_capturer_->Start(&desktop_capturer_callback_); | 670 video_capturer_->Start(&desktop_capturer_callback_); |
| 626 | 671 |
| 627 // Run the message loop until the desktop is attached. | 672 // Run the message loop until the desktop is attached. |
| 628 setup_run_loop_->Run(); | 673 setup_run_loop_->Run(); |
| 629 | 674 |
| 630 // Expect a single mouse event. | 675 // Expect a single mouse event. |
| 631 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) | 676 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) |
| 632 .Times(1) | 677 .Times(1) |
| 633 .WillOnce(InvokeWithoutArgs( | 678 .WillOnce(InvokeWithoutArgs( |
| 634 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 679 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 635 | 680 |
| 636 // Send a mouse event. | 681 // Send a mouse event. |
| 637 protocol::MouseEvent event; | 682 protocol::MouseEvent event; |
| 638 event.set_x(0); | 683 event.set_x(0); |
| 639 event.set_y(0); | 684 event.set_y(0); |
| 640 input_injector_->InjectMouseEvent(event); | 685 input_injector_->InjectMouseEvent(event); |
| 641 | 686 |
| 642 task_runner_ = nullptr; | 687 RunMainLoopUntilDone(); |
| 643 io_task_runner_ = nullptr; | |
| 644 main_run_loop_.Run(); | |
| 645 } | 688 } |
| 646 | 689 |
| 647 // Tests injection of touch events. | 690 // Tests injection of touch events. |
| 648 TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) { | 691 TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) { |
| 649 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 692 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 650 new protocol::MockClipboardStub()); | 693 new protocol::MockClipboardStub()); |
| 651 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 694 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 652 .Times(0); | 695 .Times(0); |
| 653 | 696 |
| 654 // Start the input injector and screen capturer. | 697 // Start the input injector and screen capturer. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 678 // And one more call for ReleaseAll(). | 721 // And one more call for ReleaseAll(). |
| 679 EXPECT_CALL(*remote_input_injector_, | 722 EXPECT_CALL(*remote_input_injector_, |
| 680 InjectTouchEvent(EqualsTouchEvent(event))); | 723 InjectTouchEvent(EqualsTouchEvent(event))); |
| 681 EXPECT_CALL(*remote_input_injector_, | 724 EXPECT_CALL(*remote_input_injector_, |
| 682 InjectTouchEvent(EqualsTouchEventTypeAndId( | 725 InjectTouchEvent(EqualsTouchEventTypeAndId( |
| 683 protocol::TouchEvent::TOUCH_POINT_CANCEL, 0u))); | 726 protocol::TouchEvent::TOUCH_POINT_CANCEL, 0u))); |
| 684 | 727 |
| 685 // Send the touch event. | 728 // Send the touch event. |
| 686 input_injector_->InjectTouchEvent(event); | 729 input_injector_->InjectTouchEvent(event); |
| 687 | 730 |
| 688 task_runner_ = nullptr; | 731 RunMainLoopUntilDone(); |
| 689 io_task_runner_ = nullptr; | |
| 690 main_run_loop_.Run(); | |
| 691 } | 732 } |
| 692 | 733 |
| 693 // Tests that setting the desktop resolution works. | 734 // Tests that setting the desktop resolution works. |
| 694 TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { | 735 TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { |
| 695 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( | 736 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( |
| 696 new protocol::MockClipboardStub()); | 737 new protocol::MockClipboardStub()); |
| 697 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) | 738 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) |
| 698 .Times(0); | 739 .Times(0); |
| 699 | 740 |
| 700 // Start the input injector and screen capturer. | 741 // Start the input injector and screen capturer. |
| 701 input_injector_->Start(clipboard_stub.Pass()); | 742 input_injector_->Start(clipboard_stub.Pass()); |
| 702 video_capturer_->Start(&desktop_capturer_callback_); | 743 video_capturer_->Start(&desktop_capturer_callback_); |
| 703 | 744 |
| 704 // Run the message loop until the desktop is attached. | 745 // Run the message loop until the desktop is attached. |
| 705 setup_run_loop_->Run(); | 746 setup_run_loop_->Run(); |
| 706 | 747 |
| 707 EXPECT_CALL(daemon_channel_, SetScreenResolution(_, _)) | 748 EXPECT_CALL(daemon_channel_, SetScreenResolution(_, _)) |
| 708 .Times(1) | 749 .Times(1) |
| 709 .WillOnce(InvokeWithoutArgs( | 750 .WillOnce(InvokeWithoutArgs( |
| 710 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); | 751 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); |
| 711 | 752 |
| 712 // Change the desktop resolution. | 753 // Change the desktop resolution. |
| 713 screen_controls_->SetScreenResolution(ScreenResolution( | 754 screen_controls_->SetScreenResolution(ScreenResolution( |
| 714 webrtc::DesktopSize(100, 100), | 755 webrtc::DesktopSize(100, 100), |
| 715 webrtc::DesktopVector(96, 96))); | 756 webrtc::DesktopVector(96, 96))); |
| 716 | 757 |
| 717 task_runner_ = nullptr; | 758 RunMainLoopUntilDone(); |
| 718 io_task_runner_ = nullptr; | |
| 719 main_run_loop_.Run(); | |
| 720 } | 759 } |
| 721 | 760 |
| 722 } // namespace remoting | 761 } // namespace remoting |
| OLD | NEW |