| Index: content/browser/presentation/presentation_service_impl_unittest.cc
|
| diff --git a/content/browser/presentation/presentation_service_impl_unittest.cc b/content/browser/presentation/presentation_service_impl_unittest.cc
|
| index 73f3dde1d00b56c60105fe3cf9dfe1c974423aad..5d7e7298f73eab2775a1c112d9f2f7690db200c7 100644
|
| --- a/content/browser/presentation/presentation_service_impl_unittest.cc
|
| +++ b/content/browser/presentation/presentation_service_impl_unittest.cc
|
| @@ -60,12 +60,13 @@ void DoNothing(blink::mojom::PresentationSessionInfoPtr info,
|
|
|
| } // namespace
|
|
|
| -class MockPresentationServiceDelegate : public PresentationServiceDelegate {
|
| +class MockPresentationServiceDelegate
|
| + : public ControllerPresentationServiceDelegate {
|
| public:
|
| MOCK_METHOD3(AddObserver,
|
| - void(int render_process_id,
|
| - int render_frame_id,
|
| - PresentationServiceDelegate::Observer* observer));
|
| + void(int render_process_id,
|
| + int render_frame_id,
|
| + PresentationServiceDelegateBase::Observer* observer));
|
| MOCK_METHOD2(RemoveObserver,
|
| void(int render_process_id, int render_frame_id));
|
|
|
| @@ -139,6 +140,21 @@ class MockPresentationServiceDelegate : public PresentationServiceDelegate {
|
| const content::PresentationConnectionStateChangedCallback&
|
| state_changed_cb));
|
|
|
| + void ConnectToOffscreenPresentation(
|
| + int render_process_id,
|
| + int render_frame_id,
|
| + const PresentationSessionInfo& session,
|
| + PresentationConnectionPtr connection) override {
|
| + RegisterOffscreenPresentationConnectionRaw(
|
| + render_process_id, render_frame_id, session, connection.get());
|
| + }
|
| +
|
| + MOCK_METHOD4(RegisterOffscreenPresentationConnectionRaw,
|
| + void(int render_process_id,
|
| + int render_frame_id,
|
| + const PresentationSessionInfo& session,
|
| + blink::mojom::PresentationConnection* connection));
|
| +
|
| void set_screen_availability_listening_supported(bool value) {
|
| screen_availability_listening_supported_ = value;
|
| }
|
| @@ -147,6 +163,36 @@ class MockPresentationServiceDelegate : public PresentationServiceDelegate {
|
| bool screen_availability_listening_supported_ = true;
|
| };
|
|
|
| +class MockReceiverPresentationServiceDelegate
|
| + : public ReceiverPresentationServiceDelegate {
|
| + public:
|
| + MOCK_METHOD3(AddObserver,
|
| + void(int render_process_id,
|
| + int render_frame_id,
|
| + PresentationServiceDelegateBase::Observer* observer));
|
| + MOCK_METHOD2(RemoveObserver,
|
| + void(int render_process_id, int render_frame_id));
|
| + MOCK_METHOD2(Reset, void(int render_process_id, int routing_id));
|
| + MOCK_METHOD1(RegisterReceiverConnectionAvailableCallback,
|
| + void(const content::ReceiverConnectionAvailableCallback&));
|
| +};
|
| +
|
| +class MockPresentationConnection : public blink::mojom::PresentationConnection {
|
| + public:
|
| + void SetTargetConnection(
|
| + blink::mojom::PresentationConnectionPtr connection) override {
|
| + SetTargetConnection(*connection);
|
| + }
|
| + MOCK_METHOD1(SetTargetConnection,
|
| + void(blink::mojom::PresentationConnection& connection));
|
| +
|
| + void OnMessage(blink::mojom::SessionMessagePtr message) override {
|
| + OnConnectionMessageReceived(*message);
|
| + }
|
| + MOCK_METHOD1(OnConnectionMessageReceived,
|
| + void(const blink::mojom::SessionMessage& message));
|
| +};
|
| +
|
| class MockPresentationServiceClient
|
| : public blink::mojom::PresentationServiceClient {
|
| public:
|
| @@ -190,7 +236,8 @@ class MockPresentationServiceClient
|
| void(const blink::mojom::PresentationSessionInfo& session_info));
|
|
|
| void OnReceiverConnectionAvailable(
|
| - blink::mojom::PresentationSessionInfoPtr session_info) override {
|
| + blink::mojom::PresentationSessionInfoPtr session_info,
|
| + blink::mojom::PresentationConnectionPtr connection) override {
|
| OnReceiverConnectionAvailable(*session_info);
|
| }
|
| MOCK_METHOD1(OnReceiverConnectionAvailable,
|
| @@ -214,7 +261,7 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| TestRenderFrameHost* render_frame_host = contents()->GetMainFrame();
|
| render_frame_host->InitializeRenderFrameIfNeeded();
|
| service_impl_.reset(new PresentationServiceImpl(
|
| - render_frame_host, contents(), &mock_delegate_));
|
| + render_frame_host, contents(), &mock_delegate_, nullptr));
|
| service_impl_->Bind(std::move(request));
|
|
|
| blink::mojom::PresentationServiceClientPtr client_ptr;
|
| @@ -374,6 +421,7 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| }
|
|
|
| MockPresentationServiceDelegate mock_delegate_;
|
| + MockReceiverPresentationServiceDelegate mock_receiver_delegate_;
|
|
|
| std::unique_ptr<PresentationServiceImpl> service_impl_;
|
| mojo::InterfacePtr<blink::mojom::PresentationService> service_ptr_;
|
| @@ -661,6 +709,53 @@ TEST_F(PresentationServiceImplTest, ListenForSessionMessagesWithEmptyMsg) {
|
| RunListenForSessionMessages(text_msg, binary_data, false);
|
| }
|
|
|
| +TEST_F(PresentationServiceImplTest, SetPresentationConnection) {
|
| + blink::mojom::PresentationSessionInfoPtr session(
|
| + blink::mojom::PresentationSessionInfo::New());
|
| + session->url = GURL(kPresentationUrl1);
|
| + session->id = kPresentationId;
|
| +
|
| + blink::mojom::PresentationConnectionPtr connection;
|
| +
|
| + MockPresentationConnection mock_presentation_connection;
|
| + mojo::Binding<blink::mojom::PresentationConnection> binding(
|
| + &mock_presentation_connection, mojo::GetProxy(&connection));
|
| +
|
| + EXPECT_CALL(mock_delegate_,
|
| + RegisterOffscreenPresentationConnectionRaw(_, _, _, _))
|
| + .Times(1);
|
| +
|
| + service_impl_->SetPresentationConnection(std::move(session),
|
| + std::move(connection));
|
| +}
|
| +
|
| +TEST_F(PresentationServiceImplTest, ReceiverPresentationServiceDelegate) {
|
| + MockReceiverPresentationServiceDelegate mock_receiver_delegate;
|
| +
|
| + PresentationServiceImpl service_impl(contents()->GetMainFrame(), contents(),
|
| + &mock_delegate_,
|
| + &mock_receiver_delegate);
|
| +
|
| + EXPECT_CALL(mock_receiver_delegate,
|
| + RegisterReceiverConnectionAvailableCallback(_));
|
| +
|
| + blink::mojom::PresentationServiceClientPtr client_ptr;
|
| + client_binding_.reset(
|
| + new mojo::Binding<blink::mojom::PresentationServiceClient>(
|
| + &mock_client_, mojo::GetProxy(&client_ptr)));
|
| + service_impl.SetClient(std::move(client_ptr));
|
| +
|
| + // NO-OP for ControllerPresentationServiceDelegate API functions
|
| + EXPECT_CALL(mock_delegate_, ListenForSessionMessages(_, _, _, _)).Times(0);
|
| +
|
| + blink::mojom::PresentationSessionInfoPtr session(
|
| + blink::mojom::PresentationSessionInfo::New());
|
| + session->url = GURL(kPresentationUrl1);
|
| + session->id = kPresentationId;
|
| +
|
| + service_impl.ListenForSessionMessages(std::move(session));
|
| +}
|
| +
|
| TEST_F(PresentationServiceImplTest, StartSessionInProgress) {
|
| EXPECT_CALL(mock_delegate_, StartSession(_, _, presentation_urls_, _, _))
|
| .Times(1);
|
|
|