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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 }; | 57 }; |
58 | 58 |
59 class MockCreatePresentationConnnectionCallbacks { | 59 class MockCreatePresentationConnnectionCallbacks { |
60 public: | 60 public: |
61 MOCK_METHOD1(OnCreateConnectionSuccess, | 61 MOCK_METHOD1(OnCreateConnectionSuccess, |
62 void(const content::PresentationSessionInfo& connection)); | 62 void(const content::PresentationSessionInfo& connection)); |
63 MOCK_METHOD1(OnCreateConnectionError, | 63 MOCK_METHOD1(OnCreateConnectionError, |
64 void(const content::PresentationError& error)); | 64 void(const content::PresentationError& error)); |
65 }; | 65 }; |
66 | 66 |
| 67 class MockPresentationSessionStartedCallback { |
| 68 public: |
| 69 MOCK_METHOD1(OnPresentationSessionStartedCallback, |
| 70 void(const content::PresentationSessionInfo&)); |
| 71 }; |
| 72 |
67 class PresentationServiceDelegateImplTest | 73 class PresentationServiceDelegateImplTest |
68 : public ChromeRenderViewHostTestHarness { | 74 : public ChromeRenderViewHostTestHarness { |
69 public: | 75 public: |
70 PresentationServiceDelegateImplTest() | 76 PresentationServiceDelegateImplTest() |
71 : delegate_impl_(nullptr), | 77 : delegate_impl_(nullptr), |
72 presentation_url1_(kPresentationUrl1), | 78 presentation_url1_(kPresentationUrl1), |
73 presentation_url2_(kPresentationUrl2) {} | 79 presentation_url2_(kPresentationUrl2) {} |
74 | 80 |
75 void SetUp() override { | 81 void SetUp() override { |
76 ChromeRenderViewHostTestHarness::SetUp(); | 82 ChromeRenderViewHostTestHarness::SetUp(); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); | 483 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); |
478 ASSERT_TRUE(main_frame); | 484 ASSERT_TRUE(main_frame); |
479 int render_process_id = main_frame->GetProcess()->GetID(); | 485 int render_process_id = main_frame->GetProcess()->GetID(); |
480 int render_frame_id = main_frame->GetRoutingID(); | 486 int render_frame_id = main_frame->GetRoutingID(); |
481 | 487 |
482 OffscreenPresentationManager* presentation_manager = | 488 OffscreenPresentationManager* presentation_manager = |
483 OffscreenPresentationManagerFactory:: | 489 OffscreenPresentationManagerFactory:: |
484 GetOrCreateForControllerBrowserContext(GetWebContents()); | 490 GetOrCreateForControllerBrowserContext(GetWebContents()); |
485 | 491 |
486 content::PresentationSessionInfo session_info(GURL("presentation_url"), | 492 content::PresentationSessionInfo session_info(GURL("presentation_url"), |
487 "presentation_id"); | 493 "presentation_id", false); |
488 | 494 |
489 EXPECT_EQ(size_t(0), presentation_manager->offscreen_presentations_.size()); | 495 EXPECT_EQ(size_t(0), presentation_manager->offscreen_presentations_.size()); |
| 496 |
| 497 MockPresentationSessionStartedCallback mock_callback; |
| 498 EXPECT_CALL(mock_callback, OnPresentationSessionStartedCallback(_)); |
| 499 MediaRoute media_route( |
| 500 "route_id", MediaSourceForPresentationUrl(session_info.presentation_url), |
| 501 "mediaSinkId", "", true, "", true); |
| 502 delegate_impl_->OnStartSessionSucceeded( |
| 503 render_process_id, render_frame_id, |
| 504 base::Bind(&MockPresentationSessionStartedCallback:: |
| 505 OnPresentationSessionStartedCallback, |
| 506 base::Unretained(&mock_callback)), |
| 507 session_info, media_route); |
| 508 |
490 content::PresentationConnectionPtr connection; | 509 content::PresentationConnectionPtr connection; |
491 delegate_impl_->ConnectToOffscreenPresentation( | 510 delegate_impl_->ConnectToOffscreenPresentation( |
492 render_process_id, render_frame_id, session_info, std::move(connection)); | 511 render_process_id, render_frame_id, session_info, std::move(connection)); |
493 EXPECT_EQ(size_t(1), presentation_manager->offscreen_presentations_.size()); | 512 EXPECT_EQ(size_t(1), presentation_manager->offscreen_presentations_.size()); |
| 513 |
| 514 EXPECT_CALL(router_, DetachRoute("route_id")); |
| 515 delegate_impl_->Reset(render_process_id, render_frame_id); |
| 516 EXPECT_TRUE(presentation_manager->offscreen_presentations_.empty()); |
494 } | 517 } |
495 | 518 |
496 } // namespace media_router | 519 } // namespace media_router |
OLD | NEW |