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

Side by Side Diff: content/browser/presentation/presentation_service_impl_unittest.cc

Issue 2949053002: [Presentation API] OffscreenPresentationManager should only interact with top level receiver frame (Closed)
Patch Set: add unit test Created 3 years, 5 months 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
« no previous file with comments | « content/browser/presentation/presentation_service_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/presentation/presentation_service_impl.h" 5 #include "content/browser/presentation/presentation_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <iterator> 10 #include <iterator>
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 605
606 PresentationInfo expected(presentation_url1_, kPresentationId); 606 PresentationInfo expected(presentation_url1_, kPresentationId);
607 EXPECT_CALL(mock_delegate_, RegisterOffscreenPresentationConnectionRaw( 607 EXPECT_CALL(mock_delegate_, RegisterOffscreenPresentationConnectionRaw(
608 _, _, InfoEquals(expected), _)); 608 _, _, InfoEquals(expected), _));
609 609
610 service_impl_->SetPresentationConnection( 610 service_impl_->SetPresentationConnection(
611 presentation_info, std::move(connection), std::move(request)); 611 presentation_info, std::move(connection), std::move(request));
612 } 612 }
613 613
614 TEST_F(PresentationServiceImplTest, ReceiverPresentationServiceDelegate) { 614 TEST_F(PresentationServiceImplTest, ReceiverPresentationServiceDelegate) {
615 MockReceiverPresentationServiceDelegate mock_receiver_delegate; 615 EXPECT_CALL(mock_receiver_delegate_, AddObserver(_, _, _)).Times(1);
616 EXPECT_CALL(mock_receiver_delegate, AddObserver(_, _, _)).Times(1);
617 616
618 PresentationServiceImpl service_impl(main_rfh(), contents(), nullptr, 617 PresentationServiceImpl service_impl(main_rfh(), contents(), nullptr,
619 &mock_receiver_delegate); 618 &mock_receiver_delegate_);
620 619
621 ReceiverConnectionAvailableCallback callback; 620 ReceiverConnectionAvailableCallback callback;
622 EXPECT_CALL(mock_receiver_delegate, 621 EXPECT_CALL(mock_receiver_delegate_,
623 RegisterReceiverConnectionAvailableCallback(_)) 622 RegisterReceiverConnectionAvailableCallback(_))
624 .WillOnce(SaveArg<0>(&callback)); 623 .WillOnce(SaveArg<0>(&callback));
625 624
626 blink::mojom::PresentationServiceClientPtr client_ptr; 625 blink::mojom::PresentationServiceClientPtr client_ptr;
627 client_binding_.reset( 626 client_binding_.reset(
628 new mojo::Binding<blink::mojom::PresentationServiceClient>( 627 new mojo::Binding<blink::mojom::PresentationServiceClient>(
629 &mock_client_, mojo::MakeRequest(&client_ptr))); 628 &mock_client_, mojo::MakeRequest(&client_ptr)));
630 service_impl.controller_delegate_ = nullptr; 629 service_impl.controller_delegate_ = nullptr;
631 service_impl.SetClient(std::move(client_ptr)); 630 service_impl.SetClient(std::move(client_ptr));
632 EXPECT_FALSE(callback.is_null()); 631 EXPECT_FALSE(callback.is_null());
633 632
634 PresentationInfo presentation_info(presentation_url1_, kPresentationId); 633 PresentationInfo presentation_info(presentation_url1_, kPresentationId);
635 634
636 // Client gets notified of receiver connections. 635 // Client gets notified of receiver connections.
637 blink::mojom::PresentationConnectionPtr controller_connection; 636 blink::mojom::PresentationConnectionPtr controller_connection;
638 MockPresentationConnection mock_presentation_connection; 637 MockPresentationConnection mock_presentation_connection;
639 mojo::Binding<blink::mojom::PresentationConnection> connection_binding( 638 mojo::Binding<blink::mojom::PresentationConnection> connection_binding(
640 &mock_presentation_connection, mojo::MakeRequest(&controller_connection)); 639 &mock_presentation_connection, mojo::MakeRequest(&controller_connection));
641 blink::mojom::PresentationConnectionPtr receiver_connection; 640 blink::mojom::PresentationConnectionPtr receiver_connection;
642 EXPECT_CALL(mock_client_, 641 EXPECT_CALL(mock_client_,
643 OnReceiverConnectionAvailable(InfoEquals(presentation_info))); 642 OnReceiverConnectionAvailable(InfoEquals(presentation_info)));
644 callback.Run(presentation_info, std::move(controller_connection), 643 callback.Run(presentation_info, std::move(controller_connection),
645 mojo::MakeRequest(&receiver_connection)); 644 mojo::MakeRequest(&receiver_connection));
646 base::RunLoop().RunUntilIdle(); 645 base::RunLoop().RunUntilIdle();
647 646
648 EXPECT_CALL(mock_receiver_delegate, RemoveObserver(_, _)).Times(1); 647 EXPECT_CALL(mock_receiver_delegate_, RemoveObserver(_, _)).Times(1);
648 }
649
650 TEST_F(PresentationServiceImplTest, ReceiverDelegateOnSubFrame) {
651 EXPECT_CALL(mock_receiver_delegate_, AddObserver(_, _, _)).Times(1);
652
653 PresentationServiceImpl service_impl(main_rfh(), contents(), nullptr,
654 &mock_receiver_delegate_);
655 service_impl.is_main_frame_ = false;
656
657 ReceiverConnectionAvailableCallback callback;
658 EXPECT_CALL(mock_receiver_delegate_,
659 RegisterReceiverConnectionAvailableCallback(_))
660 .Times(0);
661
662 blink::mojom::PresentationServiceClientPtr client_ptr;
663 client_binding_.reset(
664 new mojo::Binding<blink::mojom::PresentationServiceClient>(
665 &mock_client_, mojo::MakeRequest(&client_ptr)));
666 service_impl.controller_delegate_ = nullptr;
667 service_impl.SetClient(std::move(client_ptr));
668
669 EXPECT_CALL(mock_receiver_delegate_, Reset(_, _)).Times(0);
670 service_impl.Reset();
671
672 EXPECT_CALL(mock_receiver_delegate_, RemoveObserver(_, _)).Times(1);
649 } 673 }
650 674
651 } // namespace content 675 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/presentation/presentation_service_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698