OLD | NEW |
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 "chrome/browser/media/router/presentation_service_delegate_impl.h" | 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/test/mock_callback.h" | 8 #include "base/test/mock_callback.h" |
9 #include "chrome/browser/media/router/mock_media_router.h" | 9 #include "chrome/browser/media/router/mock_media_router.h" |
10 #include "chrome/browser/media/router/mock_screen_availability_listener.h" | 10 #include "chrome/browser/media/router/mock_screen_availability_listener.h" |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 UnregisterOffscreenPresentationController( | 578 UnregisterOffscreenPresentationController( |
579 presentation_id, RenderFrameHostId(main_frame_process_id_, | 579 presentation_id, RenderFrameHostId(main_frame_process_id_, |
580 main_frame_routing_id_))); | 580 main_frame_routing_id_))); |
581 | 581 |
582 delegate_impl_->ReconnectPresentation( | 582 delegate_impl_->ReconnectPresentation( |
583 main_frame_process_id_, main_frame_routing_id_, urls, presentation_id, | 583 main_frame_process_id_, main_frame_routing_id_, urls, presentation_id, |
584 success_cb.Get(), error_cb.Get()); | 584 success_cb.Get(), error_cb.Get()); |
585 delegate_impl_->Reset(main_frame_process_id_, main_frame_routing_id_); | 585 delegate_impl_->Reset(main_frame_process_id_, main_frame_routing_id_); |
586 } | 586 } |
587 | 587 |
588 TEST_F(PresentationServiceDelegateImplTest, ConnectToPresentation) { | 588 TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) { |
589 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); | 589 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); |
590 ASSERT_TRUE(main_frame); | 590 ASSERT_TRUE(main_frame); |
591 int render_process_id = main_frame->GetProcess()->GetID(); | 591 int render_process_id = main_frame->GetProcess()->GetID(); |
592 int render_frame_id = main_frame->GetRoutingID(); | 592 int render_frame_id = main_frame->GetRoutingID(); |
593 std::string presentation_id = "presentation_id"; | 593 std::string presentation_id = "presentation_id"; |
594 GURL presentation_url = GURL("http://www.example.com/presentation.html"); | 594 GURL presentation_url = GURL("http://www.example.com/presentation.html"); |
595 content::PresentationInfo presentation_info(presentation_url, | 595 content::PresentationInfo presentation_info(presentation_url, |
596 presentation_id); | 596 presentation_id); |
597 | 597 |
598 MediaRoute media_route( | 598 MediaRoute media_route( |
(...skipping 23 matching lines...) Expand all Loading... |
622 std::move(connection_ptr), std::move(connection_request)); | 622 std::move(connection_ptr), std::move(connection_request)); |
623 | 623 |
624 EXPECT_CALL(mock_offscreen_manager, | 624 EXPECT_CALL(mock_offscreen_manager, |
625 UnregisterOffscreenPresentationController( | 625 UnregisterOffscreenPresentationController( |
626 presentation_id, | 626 presentation_id, |
627 RenderFrameHostId(render_process_id, render_frame_id))); | 627 RenderFrameHostId(render_process_id, render_frame_id))); |
628 EXPECT_CALL(router_, DetachRoute("route_id")).Times(0); | 628 EXPECT_CALL(router_, DetachRoute("route_id")).Times(0); |
629 delegate_impl_->Reset(render_process_id, render_frame_id); | 629 delegate_impl_->Reset(render_process_id, render_frame_id); |
630 } | 630 } |
631 | 631 |
| 632 TEST_F(PresentationServiceDelegateImplTest, ConnectToPresentation) { |
| 633 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); |
| 634 ASSERT_TRUE(main_frame); |
| 635 int render_process_id = main_frame->GetProcess()->GetID(); |
| 636 int render_frame_id = main_frame->GetRoutingID(); |
| 637 std::string presentation_id = "presentation_id"; |
| 638 GURL presentation_url = GURL("http://www.example.com/presentation.html"); |
| 639 content::PresentationInfo presentation_info(presentation_url, |
| 640 presentation_id); |
| 641 |
| 642 MediaRoute media_route( |
| 643 "route_id", |
| 644 MediaSourceForPresentationUrl(presentation_info.presentation_url), |
| 645 "mediaSinkId", "", true, "", true); |
| 646 |
| 647 base::MockCallback<content::PresentationConnectionCallback> success_cb; |
| 648 EXPECT_CALL(success_cb, Run(_)); |
| 649 |
| 650 delegate_impl_->OnStartPresentationSucceeded( |
| 651 render_process_id, render_frame_id, success_cb.Get(), presentation_info, |
| 652 media_route); |
| 653 |
| 654 content::PresentationConnectionPtr connection_ptr; |
| 655 MockPresentationConnectionProxy mock_proxy; |
| 656 mojo::Binding<blink::mojom::PresentationConnection> binding( |
| 657 &mock_proxy, mojo::MakeRequest(&connection_ptr)); |
| 658 |
| 659 content::PresentationConnectionRequest connection_request; |
| 660 EXPECT_CALL(router_, RegisterRouteMessageObserver(_)); |
| 661 delegate_impl_->ConnectToPresentation( |
| 662 render_process_id, render_frame_id, presentation_info, |
| 663 std::move(connection_ptr), std::move(connection_request)); |
| 664 |
| 665 EXPECT_CALL(router_, UnregisterRouteMessageObserver(_)); |
| 666 EXPECT_CALL(router_, DetachRoute("route_id")).Times(1); |
| 667 delegate_impl_->Reset(render_process_id, render_frame_id); |
| 668 |
| 669 // binding.Close(); |
| 670 } |
| 671 |
632 #if !defined(OS_ANDROID) | 672 #if !defined(OS_ANDROID) |
633 TEST_F(PresentationServiceDelegateImplTest, AutoJoinRequest) { | 673 TEST_F(PresentationServiceDelegateImplTest, AutoJoinRequest) { |
634 GURL frame_url(kFrameUrl); | 674 GURL frame_url(kFrameUrl); |
635 std::string origin(url::Origin(frame_url).Serialize()); | 675 std::string origin(url::Origin(frame_url).Serialize()); |
636 content::WebContentsTester::For(GetWebContents()) | 676 content::WebContentsTester::For(GetWebContents()) |
637 ->NavigateAndCommit(frame_url); | 677 ->NavigateAndCommit(frame_url); |
638 | 678 |
639 MockCreatePresentationConnnectionCallbacks mock_create_connection_callbacks; | 679 MockCreatePresentationConnnectionCallbacks mock_create_connection_callbacks; |
640 const std::string kPresentationId("auto-join"); | 680 const std::string kPresentationId("auto-join"); |
641 ASSERT_TRUE(IsAutoJoinPresentationId(kPresentationId)); | 681 ASSERT_TRUE(IsAutoJoinPresentationId(kPresentationId)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 base::Bind(&MockCreatePresentationConnnectionCallbacks:: | 784 base::Bind(&MockCreatePresentationConnnectionCallbacks:: |
745 OnCreateConnectionSuccess, | 785 OnCreateConnectionSuccess, |
746 base::Unretained(&mock_create_connection_callbacks)), | 786 base::Unretained(&mock_create_connection_callbacks)), |
747 base::Bind( | 787 base::Bind( |
748 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, | 788 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, |
749 base::Unretained(&mock_create_connection_callbacks))); | 789 base::Unretained(&mock_create_connection_callbacks))); |
750 } | 790 } |
751 #endif // !defined(OS_ANDROID) | 791 #endif // !defined(OS_ANDROID) |
752 | 792 |
753 } // namespace media_router | 793 } // namespace media_router |
OLD | NEW |