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

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc

Issue 2471573005: [Presentation API] (5th) (1-UA) integrate controller and receiver side for 1-UA messaging (Closed)
Patch Set: split renderer related changes into 4th patch Created 4 years 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 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
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 ASSERT_TRUE(main_frame); 505 ASSERT_TRUE(main_frame);
500 int render_process_id = main_frame->GetProcess()->GetID(); 506 int render_process_id = main_frame->GetProcess()->GetID();
501 int render_frame_id = main_frame->GetRoutingID(); 507 int render_frame_id = main_frame->GetRoutingID();
502 508
503 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(false)); 509 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(false));
504 EXPECT_CALL(listener, OnScreenAvailabilityNotSupported()); 510 EXPECT_CALL(listener, OnScreenAvailabilityNotSupported());
505 EXPECT_FALSE(delegate_impl_->AddScreenAvailabilityListener( 511 EXPECT_FALSE(delegate_impl_->AddScreenAvailabilityListener(
506 render_process_id, render_frame_id, &listener)); 512 render_process_id, render_frame_id, &listener));
507 } 513 }
508 514
509 TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) { 515 TEST_F(PresentationServiceDelegateImplTest, ConnectToPresentation) {
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 media_route.set_offscreen_presentation(true);
530 delegate_impl_->OnStartSessionSucceeded(
531 render_process_id, render_frame_id,
532 base::Bind(&MockPresentationSessionStartedCallback::
533 OnPresentationSessionStartedCallback,
534 base::Unretained(&mock_callback)),
535 session_info, media_route);
536
518 OffscreenPresentationManagerFactory::GetInstance()->SetTestingFactory( 537 OffscreenPresentationManagerFactory::GetInstance()->SetTestingFactory(
519 profile(), &BuildMockOffscreenPresentationManager); 538 profile(), &BuildMockOffscreenPresentationManager);
520 MockOffscreenPresentationManager* mock_offscreen_manager = 539 MockOffscreenPresentationManager* mock_offscreen_manager =
521 static_cast<MockOffscreenPresentationManager*>( 540 static_cast<MockOffscreenPresentationManager*>(
522 OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext( 541 OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext(
523 profile())); 542 profile()));
524 EXPECT_CALL(*mock_offscreen_manager, 543 EXPECT_CALL(*mock_offscreen_manager,
525 RegisterOffscreenPresentationController(_, _, _)); 544 RegisterOffscreenPresentationController(_, _, _));
526 545
527 content::PresentationConnectionPtr connection_ptr; 546 content::PresentationConnectionPtr connection_ptr;
528 delegate_impl_->ConnectToOffscreenPresentation(render_process_id, 547 delegate_impl_->ConnectToPresentation(render_process_id, render_frame_id,
529 render_frame_id, session_info, 548 session_info,
530 std::move(connection_ptr)); 549 std::move(connection_ptr));
550
551 EXPECT_CALL(router_, DetachRoute("route_id"));
552 delegate_impl_->Reset(render_process_id, render_frame_id);
531 } 553 }
532 554
533 } // namespace media_router 555 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698