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/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/media/router/media_source.h" | 9 #include "chrome/browser/media/router/media_source.h" |
10 #include "chrome/browser/media/router/media_source_helper.h" | 10 #include "chrome/browser/media/router/media_source_helper.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 receiver_callback)); | 90 receiver_callback)); |
91 MOCK_METHOD1(OnOffscreenPresentationReceiverTerminated, | 91 MOCK_METHOD1(OnOffscreenPresentationReceiverTerminated, |
92 void(const std::string& presentation_id)); | 92 void(const std::string& presentation_id)); |
93 }; | 93 }; |
94 | 94 |
95 std::unique_ptr<KeyedService> BuildMockOffscreenPresentationManager( | 95 std::unique_ptr<KeyedService> BuildMockOffscreenPresentationManager( |
96 content::BrowserContext* context) { | 96 content::BrowserContext* context) { |
97 return base::MakeUnique<MockOffscreenPresentationManager>(); | 97 return base::MakeUnique<MockOffscreenPresentationManager>(); |
98 } | 98 } |
99 | 99 |
| 100 class MockPresentationSessionStartedCallback { |
| 101 public: |
| 102 MOCK_METHOD1(OnPresentationSessionStartedCallback, |
| 103 void(const content::PresentationSessionInfo&)); |
| 104 }; |
| 105 |
100 class PresentationServiceDelegateImplTest | 106 class PresentationServiceDelegateImplTest |
101 : public ChromeRenderViewHostTestHarness { | 107 : public ChromeRenderViewHostTestHarness { |
102 public: | 108 public: |
103 PresentationServiceDelegateImplTest() | 109 PresentationServiceDelegateImplTest() |
104 : delegate_impl_(nullptr), | 110 : delegate_impl_(nullptr), |
105 presentation_url1_(kPresentationUrl1), | 111 presentation_url1_(kPresentationUrl1), |
106 presentation_url2_(kPresentationUrl2) {} | 112 presentation_url2_(kPresentationUrl2) {} |
107 | 113 |
108 void SetUp() override { | 114 void SetUp() override { |
109 ChromeRenderViewHostTestHarness::SetUp(); | 115 ChromeRenderViewHostTestHarness::SetUp(); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 514 |
509 TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) { | 515 TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) { |
510 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); | 516 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); |
511 ASSERT_TRUE(main_frame); | 517 ASSERT_TRUE(main_frame); |
512 int render_process_id = main_frame->GetProcess()->GetID(); | 518 int render_process_id = main_frame->GetProcess()->GetID(); |
513 int render_frame_id = main_frame->GetRoutingID(); | 519 int render_frame_id = main_frame->GetRoutingID(); |
514 content::PresentationSessionInfo session_info( | 520 content::PresentationSessionInfo session_info( |
515 GURL("http://www.example.com/presentation.html"), "presentation_id", | 521 GURL("http://www.example.com/presentation.html"), "presentation_id", |
516 true); | 522 true); |
517 | 523 |
| 524 MockPresentationSessionStartedCallback mock_callback; |
| 525 EXPECT_CALL(mock_callback, OnPresentationSessionStartedCallback(_)); |
| 526 MediaRoute media_route( |
| 527 "route_id", MediaSourceForPresentationUrl(session_info.presentation_url), |
| 528 "mediaSinkId", "", true, "", true); |
| 529 delegate_impl_->OnStartSessionSucceeded( |
| 530 render_process_id, render_frame_id, |
| 531 base::Bind(&MockPresentationSessionStartedCallback:: |
| 532 OnPresentationSessionStartedCallback, |
| 533 base::Unretained(&mock_callback)), |
| 534 session_info, media_route); |
| 535 |
518 OffscreenPresentationManagerFactory::GetInstance()->SetTestingFactory( | 536 OffscreenPresentationManagerFactory::GetInstance()->SetTestingFactory( |
519 profile(), &BuildMockOffscreenPresentationManager); | 537 profile(), &BuildMockOffscreenPresentationManager); |
520 MockOffscreenPresentationManager* mock_offscreen_manager = | 538 MockOffscreenPresentationManager* mock_offscreen_manager = |
521 static_cast<MockOffscreenPresentationManager*>( | 539 static_cast<MockOffscreenPresentationManager*>( |
522 OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext( | 540 OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext( |
523 profile())); | 541 profile())); |
524 EXPECT_CALL(*mock_offscreen_manager, | 542 EXPECT_CALL(*mock_offscreen_manager, |
525 RegisterOffscreenPresentationController(_, _, _)); | 543 RegisterOffscreenPresentationController(_, _, _)); |
526 | 544 |
527 content::PresentationConnectionPtr connection_ptr; | 545 content::PresentationConnectionPtr connection_ptr; |
528 delegate_impl_->ConnectToOffscreenPresentation(render_process_id, | 546 delegate_impl_->ConnectToOffscreenPresentation(render_process_id, |
529 render_frame_id, session_info, | 547 render_frame_id, session_info, |
530 std::move(connection_ptr)); | 548 std::move(connection_ptr)); |
| 549 |
| 550 EXPECT_CALL(router_, DetachRoute("route_id")); |
| 551 delegate_impl_->Reset(render_process_id, render_frame_id); |
531 } | 552 } |
532 | 553 |
533 } // namespace media_router | 554 } // namespace media_router |
OLD | NEW |