Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: remoting/host/client_session_unittest.cc

Issue 1458323002: Simplify It2Me host shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 .WillOnce(Invoke(client_session_.get(), &ClientSession::SetCapabilities)); 325 .WillOnce(Invoke(client_session_.get(), &ClientSession::SetCapabilities));
326 } 326 }
327 327
328 void ClientSessionTest::SetSendMessageAndDisconnectExpectation( 328 void ClientSessionTest::SetSendMessageAndDisconnectExpectation(
329 const std::string& message_type) { 329 const std::string& message_type) {
330 protocol::ExtensionMessage message; 330 protocol::ExtensionMessage message;
331 message.set_type(message_type); 331 message.set_type(message_type);
332 message.set_data("data"); 332 message.set_data("data");
333 333
334 Expectation authenticated = 334 Expectation authenticated =
335 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 335 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
336 .WillOnce(Return(true));
337 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) 336 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_))
338 .After(authenticated) 337 .After(authenticated)
339 .WillOnce(DoAll( 338 .WillOnce(DoAll(
340 DeliverClientMessage(client_session_.get(), message), 339 DeliverClientMessage(client_session_.get(), message),
341 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), 340 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession),
342 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); 341 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession)));
343 } 342 }
344 343
345 TEST_F(ClientSessionTest, ClipboardStubFilter) { 344 TEST_F(ClientSessionTest, ClipboardStubFilter) {
346 CreateClientSession(); 345 CreateClientSession();
347 346
348 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 347 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
349 .WillOnce(Return(true));
350 EXPECT_CALL(*input_injector_, StartPtr(_)); 348 EXPECT_CALL(*input_injector_, StartPtr(_));
351 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 349 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
352 350
353 // Wait for the first video packet to be captured to make sure that 351 // Wait for the first video packet to be captured to make sure that
354 // the injected input will go though. Otherwise mouse events will be blocked 352 // the injected input will go though. Otherwise mouse events will be blocked
355 // by the mouse clamping filter. 353 // by the mouse clamping filter.
356 base::RunLoop run_loop; 354 base::RunLoop run_loop;
357 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) 355 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
358 .Times(AtLeast(1)) 356 .Times(AtLeast(1))
359 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 357 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 mouse_event1.set_x(100); 442 mouse_event1.set_x(100);
445 mouse_event1.set_y(101); 443 mouse_event1.set_y(101);
446 protocol::MouseEvent mouse_event2; 444 protocol::MouseEvent mouse_event2;
447 mouse_event2.set_x(200); 445 mouse_event2.set_x(200);
448 mouse_event2.set_y(201); 446 mouse_event2.set_y(201);
449 protocol::MouseEvent mouse_event3; 447 protocol::MouseEvent mouse_event3;
450 mouse_event3.set_x(300); 448 mouse_event3.set_x(300);
451 mouse_event3.set_y(301); 449 mouse_event3.set_y(301);
452 450
453 Expectation authenticated = 451 Expectation authenticated =
454 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 452 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
455 .WillOnce(Return(true));
456 EXPECT_CALL(*input_injector_, StartPtr(_)) 453 EXPECT_CALL(*input_injector_, StartPtr(_))
457 .After(authenticated); 454 .After(authenticated);
458 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) 455 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_))
459 .After(authenticated); 456 .After(authenticated);
460 457
461 // Wait for the first video packet to be captured to make sure that 458 // Wait for the first video packet to be captured to make sure that
462 // the injected input will go though. Otherwise mouse events will be blocked 459 // the injected input will go though. Otherwise mouse events will be blocked
463 // by the mouse clamping filter. 460 // by the mouse clamping filter.
464 Sequence s; 461 Sequence s;
465 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) 462 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 498
502 protocol::KeyEvent key2; 499 protocol::KeyEvent key2;
503 key2.set_pressed(true); 500 key2.set_pressed(true);
504 key2.set_usb_keycode(2); 501 key2.set_usb_keycode(2);
505 502
506 protocol::MouseEvent mousedown; 503 protocol::MouseEvent mousedown;
507 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT); 504 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT);
508 mousedown.set_button_down(true); 505 mousedown.set_button_down(true);
509 506
510 Expectation authenticated = 507 Expectation authenticated =
511 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 508 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
512 .WillOnce(Return(true));
513 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated); 509 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated);
514 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) 510 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_))
515 .After(authenticated); 511 .After(authenticated);
516 512
517 // Wait for the first video packet to be captured to make sure that 513 // Wait for the first video packet to be captured to make sure that
518 // the injected input will go though. Otherwise mouse events will be blocked 514 // the injected input will go though. Otherwise mouse events will be blocked
519 // by the mouse clamping filter. 515 // by the mouse clamping filter.
520 Sequence s; 516 Sequence s;
521 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) 517 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
522 .InSequence(s) 518 .InSequence(s)
(...skipping 19 matching lines...) Expand all
542 .InSequence(s); 538 .InSequence(s);
543 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)).InSequence(s); 539 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)).InSequence(s);
544 540
545 ConnectClientSession(); 541 ConnectClientSession();
546 } 542 }
547 543
548 TEST_F(ClientSessionTest, ClampMouseEvents) { 544 TEST_F(ClientSessionTest, ClampMouseEvents) {
549 CreateClientSession(); 545 CreateClientSession();
550 546
551 Expectation authenticated = 547 Expectation authenticated =
552 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 548 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
553 .WillOnce(Return(true));
554 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated); 549 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated);
555 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) 550 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_))
556 .After(authenticated); 551 .After(authenticated);
557 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)).After(authenticated); 552 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)).After(authenticated);
558 553
559 Expectation connected = authenticated; 554 Expectation connected = authenticated;
560 555
561 int input_x[3] = { -999, 100, 999 }; 556 int input_x[3] = { -999, 100, 999 };
562 int expected_x[3] = { 0, 100, FakeDesktopCapturer::kWidth - 1 }; 557 int expected_x[3] = { 0, 100, FakeDesktopCapturer::kWidth - 1 };
563 int input_y[3] = { -999, 50, 999 }; 558 int input_y[3] = { -999, 50, 999 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 599 }
605 600
606 TEST_F(ClientSessionTest, NoGnubbyAuth) { 601 TEST_F(ClientSessionTest, NoGnubbyAuth) {
607 CreateClientSession(); 602 CreateClientSession();
608 603
609 protocol::ExtensionMessage message; 604 protocol::ExtensionMessage message;
610 message.set_type("gnubby-auth"); 605 message.set_type("gnubby-auth");
611 message.set_data("test"); 606 message.set_data("test");
612 607
613 Expectation authenticated = 608 Expectation authenticated =
614 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 609 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
615 .WillOnce(Return(true));
616 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated); 610 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated);
617 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) 611 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_))
618 .After(authenticated) 612 .After(authenticated)
619 .WillOnce(DoAll( 613 .WillOnce(DoAll(
620 DeliverClientMessage(client_session_.get(), message), 614 DeliverClientMessage(client_session_.get(), message),
621 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), 615 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession),
622 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); 616 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession)));
623 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 617 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
624 618
625 ConnectClientSession(); 619 ConnectClientSession();
626 } 620 }
627 621
628 TEST_F(ClientSessionTest, EnableGnubbyAuth) { 622 TEST_F(ClientSessionTest, EnableGnubbyAuth) {
629 CreateClientSession(); 623 CreateClientSession();
630 624
631 // Lifetime controlled by object under test. 625 // Lifetime controlled by object under test.
632 MockGnubbyAuthHandler* gnubby_auth_handler = new MockGnubbyAuthHandler(); 626 MockGnubbyAuthHandler* gnubby_auth_handler = new MockGnubbyAuthHandler();
633 627
634 protocol::ExtensionMessage message; 628 protocol::ExtensionMessage message;
635 message.set_type("gnubby-auth"); 629 message.set_type("gnubby-auth");
636 message.set_data("test"); 630 message.set_data("test");
637 631
638 Expectation authenticated = 632 Expectation authenticated =
639 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 633 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
640 .WillOnce(Return(true));
641 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated); 634 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated);
642 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) 635 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_))
643 .After(authenticated) 636 .After(authenticated)
644 .WillOnce(DoAll( 637 .WillOnce(DoAll(
645 SetGnubbyAuthHandlerForTesting(client_session_.get(), 638 SetGnubbyAuthHandlerForTesting(client_session_.get(),
646 gnubby_auth_handler), 639 gnubby_auth_handler),
647 DeliverClientMessage(client_session_.get(), message), 640 DeliverClientMessage(client_session_.get(), message),
648 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), 641 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession),
649 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); 642 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession)));
650 EXPECT_CALL(*gnubby_auth_handler, DeliverClientMessage(_)); 643 EXPECT_CALL(*gnubby_auth_handler, DeliverClientMessage(_));
651 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 644 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
652 645
653 ConnectClientSession(); 646 ConnectClientSession();
654 } 647 }
655 648
656 // Verifies that the client's video pipeline can be reset mid-session. 649 // Verifies that the client's video pipeline can be reset mid-session.
657 TEST_F(ClientSessionTest, ResetVideoPipeline) { 650 TEST_F(ClientSessionTest, ResetVideoPipeline) {
658 CreateClientSession(); 651 CreateClientSession();
659 652
660 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 653 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
661 .WillOnce(Return(true));
662 654
663 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _)) 655 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
664 .WillOnce(DoAll( 656 .WillOnce(DoAll(
665 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), 657 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession),
666 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); 658 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession)));
667 659
668 ConnectClientSession(); 660 ConnectClientSession();
669 661
670 client_session_->ResetVideoPipeline(); 662 client_session_->ResetVideoPipeline();
671 } 663 }
(...skipping 10 matching lines...) Expand all
682 extensions_.push_back(&extension2); 674 extensions_.push_back(&extension2);
683 FakeExtension extension3("ext3", "cap3"); 675 FakeExtension extension3("ext3", "cap3");
684 extensions_.push_back(&extension3); 676 extensions_.push_back(&extension3);
685 677
686 // Set the second extension to request to modify the video pipeline. 678 // Set the second extension to request to modify the video pipeline.
687 extension2.set_steal_video_capturer(true); 679 extension2.set_steal_video_capturer(true);
688 680
689 CreateClientSession(); 681 CreateClientSession();
690 682
691 Expectation authenticated = 683 Expectation authenticated =
692 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 684 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
693 .WillOnce(Return(true));
694 685
695 // Verify that the ClientSession reports the correct capabilities, and mimic 686 // Verify that the ClientSession reports the correct capabilities, and mimic
696 // the client reporting an overlapping set of capabilities. 687 // the client reporting an overlapping set of capabilities.
697 EXPECT_CALL(client_stub_, 688 EXPECT_CALL(client_stub_,
698 SetCapabilities(EqCapabilities("cap1 cap3 default"))) 689 SetCapabilities(EqCapabilities("cap1 cap3 default")))
699 .After(authenticated) 690 .After(authenticated)
700 .WillOnce(SetCapabilities(client_session_.get(), "cap1 cap4 default")); 691 .WillOnce(SetCapabilities(client_session_.get(), "cap1 cap4 default"));
701 692
702 // Verify that the correct extension messages are delivered, and dropped. 693 // Verify that the correct extension messages are delivered, and dropped.
703 protocol::ExtensionMessage message1; 694 protocol::ExtensionMessage message1;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 // Verifies that an extension can "steal" the video capture, in which case no 729 // Verifies that an extension can "steal" the video capture, in which case no
739 // VideoFramePump is instantiated. 730 // VideoFramePump is instantiated.
740 TEST_F(ClientSessionTest, StealVideoCapturer) { 731 TEST_F(ClientSessionTest, StealVideoCapturer) {
741 FakeExtension extension("ext1", "cap1"); 732 FakeExtension extension("ext1", "cap1");
742 extensions_.push_back(&extension); 733 extensions_.push_back(&extension);
743 734
744 CreateClientSession(); 735 CreateClientSession();
745 736
746 SetMatchCapabilitiesExpectation(); 737 SetMatchCapabilitiesExpectation();
747 738
748 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) 739 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
749 .WillOnce(Return(true));
750 740
751 ConnectClientSession(); 741 ConnectClientSession();
752 742
753 base::RunLoop().RunUntilIdle(); 743 base::RunLoop().RunUntilIdle();
754 744
755 extension.set_steal_video_capturer(true); 745 extension.set_steal_video_capturer(true);
756 client_session_->ResetVideoPipeline(); 746 client_session_->ResetVideoPipeline();
757 747
758 base::RunLoop().RunUntilIdle(); 748 base::RunLoop().RunUntilIdle();
759 749
(...skipping 10 matching lines...) Expand all
770 760
771 DisconnectClientSession(); 761 DisconnectClientSession();
772 StopClientSession(); 762 StopClientSession();
773 763
774 // ext1 was instantiated and wrapped the video capturer. 764 // ext1 was instantiated and wrapped the video capturer.
775 EXPECT_TRUE(extension.was_instantiated()); 765 EXPECT_TRUE(extension.was_instantiated());
776 EXPECT_TRUE(extension.has_wrapped_video_capturer()); 766 EXPECT_TRUE(extension.has_wrapped_video_capturer());
777 } 767 }
778 768
779 } // namespace remoting 769 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698