| 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 "content/browser/presentation/presentation_service_impl.h" | 5 #include "content/browser/presentation/presentation_service_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 SendMessageRawPtr(render_process_id, render_frame_id, session, | 132 SendMessageRawPtr(render_process_id, render_frame_id, session, |
| 133 message_request.release(), send_message_cb); | 133 message_request.release(), send_message_cb); |
| 134 } | 134 } |
| 135 MOCK_METHOD4(ListenForConnectionStateChange, | 135 MOCK_METHOD4(ListenForConnectionStateChange, |
| 136 void(int render_process_id, | 136 void(int render_process_id, |
| 137 int render_frame_id, | 137 int render_frame_id, |
| 138 const content::PresentationSessionInfo& connection, | 138 const content::PresentationSessionInfo& connection, |
| 139 const content::PresentationConnectionStateChangedCallback& | 139 const content::PresentationConnectionStateChangedCallback& |
| 140 state_changed_cb)); | 140 state_changed_cb)); |
| 141 | 141 |
| 142 void ConnectToPresentation( | 142 void ConnectToOffscreenPresentation( |
| 143 int render_process_id, | 143 int render_process_id, |
| 144 int render_frame_id, | 144 int render_frame_id, |
| 145 const content::PresentationSessionInfo& session, | 145 const content::PresentationSessionInfo& session, |
| 146 PresentationConnectionPtr controller_conn_ptr, | 146 PresentationConnectionPtr controller_conn_ptr, |
| 147 PresentationConnectionRequest receiver_conn_request) override { | 147 PresentationConnectionRequest receiver_conn_request) override { |
| 148 RegisterOffscreenPresentationConnectionRaw( | 148 RegisterOffscreenPresentationConnectionRaw( |
| 149 render_process_id, render_frame_id, session, controller_conn_ptr.get()); | 149 render_process_id, render_frame_id, session, controller_conn_ptr.get()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 MOCK_METHOD4(RegisterOffscreenPresentationConnectionRaw, | 152 MOCK_METHOD4(RegisterOffscreenPresentationConnectionRaw, |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 base::RunLoop run_loop; | 507 base::RunLoop run_loop; |
| 508 EXPECT_CALL(mock_client_, | 508 EXPECT_CALL(mock_client_, |
| 509 OnDefaultSessionStarted(SessionInfoEquals(session_info))) | 509 OnDefaultSessionStarted(SessionInfoEquals(session_info))) |
| 510 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 510 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 511 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)); | 511 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)); |
| 512 callback.Run( | 512 callback.Run( |
| 513 content::PresentationSessionInfo(presentation_url2_, kPresentationId)); | 513 content::PresentationSessionInfo(presentation_url2_, kPresentationId)); |
| 514 run_loop.Run(); | 514 run_loop.Run(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) { | 517 TEST_F(PresentationServiceImplTest, |
| 518 ListenForConnectionStateChange) { |
| 518 content::PresentationSessionInfo connection(presentation_url1_, | 519 content::PresentationSessionInfo connection(presentation_url1_, |
| 519 kPresentationId); | 520 kPresentationId); |
| 520 content::PresentationConnectionStateChangedCallback state_changed_cb; | 521 content::PresentationConnectionStateChangedCallback state_changed_cb; |
| 521 // Trigger state change. It should be propagated back up to |mock_client_|. | 522 // Trigger state change. It should be propagated back up to |mock_client_|. |
| 522 content::PresentationSessionInfo presentation_connection(presentation_url1_, | 523 content::PresentationSessionInfo presentation_connection(presentation_url1_, |
| 523 kPresentationId); | 524 kPresentationId); |
| 524 | 525 |
| 525 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) | 526 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) |
| 526 .WillOnce(SaveArg<3>(&state_changed_cb)); | 527 .WillOnce(SaveArg<3>(&state_changed_cb)); |
| 527 service_impl_->ListenForConnectionStateChange(connection); | 528 service_impl_->ListenForConnectionStateChange(connection); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 mock_delegate_.set_screen_availability_listening_supported(false); | 916 mock_delegate_.set_screen_availability_listening_supported(false); |
| 916 base::RunLoop run_loop; | 917 base::RunLoop run_loop; |
| 917 EXPECT_CALL(mock_client_, | 918 EXPECT_CALL(mock_client_, |
| 918 OnScreenAvailabilityNotSupported(presentation_url1_)) | 919 OnScreenAvailabilityNotSupported(presentation_url1_)) |
| 919 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 920 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 920 ListenForScreenAvailabilityAndWait(presentation_url1_, false); | 921 ListenForScreenAvailabilityAndWait(presentation_url1_, false); |
| 921 run_loop.Run(); | 922 run_loop.Run(); |
| 922 } | 923 } |
| 923 | 924 |
| 924 } // namespace content | 925 } // namespace content |
| OLD | NEW |