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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 SendMessageRawPtr(render_process_id, render_frame_id, session, | 140 SendMessageRawPtr(render_process_id, render_frame_id, session, |
141 message_request.release(), send_message_cb); | 141 message_request.release(), send_message_cb); |
142 } | 142 } |
143 MOCK_METHOD4(ListenForConnectionStateChange, | 143 MOCK_METHOD4(ListenForConnectionStateChange, |
144 void(int render_process_id, | 144 void(int render_process_id, |
145 int render_frame_id, | 145 int render_frame_id, |
146 const content::PresentationSessionInfo& connection, | 146 const content::PresentationSessionInfo& connection, |
147 const content::PresentationConnectionStateChangedCallback& | 147 const content::PresentationConnectionStateChangedCallback& |
148 state_changed_cb)); | 148 state_changed_cb)); |
149 | 149 |
150 void ConnectToOffscreenPresentation( | 150 void ConnectToPresentation( |
151 int render_process_id, | 151 int render_process_id, |
152 int render_frame_id, | 152 int render_frame_id, |
153 const content::PresentationSessionInfo& session, | 153 const content::PresentationSessionInfo& session, |
154 PresentationConnectionPtr controller_conn_ptr, | 154 PresentationConnectionPtr controller_conn_ptr, |
155 PresentationConnectionRequest receiver_conn_request) override { | 155 PresentationConnectionRequest receiver_conn_request) override { |
156 RegisterOffscreenPresentationConnectionRaw( | 156 RegisterOffscreenPresentationConnectionRaw( |
157 render_process_id, render_frame_id, session, controller_conn_ptr.get()); | 157 render_process_id, render_frame_id, session, controller_conn_ptr.get()); |
158 } | 158 } |
159 | 159 |
160 MOCK_METHOD4(RegisterOffscreenPresentationConnectionRaw, | 160 MOCK_METHOD4(RegisterOffscreenPresentationConnectionRaw, |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 base::RunLoop run_loop; | 536 base::RunLoop run_loop; |
537 EXPECT_CALL(mock_client_, | 537 EXPECT_CALL(mock_client_, |
538 OnDefaultSessionStarted(SessionInfoEquals(ByRef(session_info)))) | 538 OnDefaultSessionStarted(SessionInfoEquals(ByRef(session_info)))) |
539 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 539 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
540 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)); | 540 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)); |
541 callback.Run( | 541 callback.Run( |
542 content::PresentationSessionInfo(presentation_url2_, kPresentationId)); | 542 content::PresentationSessionInfo(presentation_url2_, kPresentationId)); |
543 run_loop.Run(); | 543 run_loop.Run(); |
544 } | 544 } |
545 | 545 |
546 TEST_F(PresentationServiceImplTest, | 546 TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) { |
547 ListenForConnectionStateChange) { | |
548 content::PresentationSessionInfo connection(presentation_url1_, | 547 content::PresentationSessionInfo connection(presentation_url1_, |
549 kPresentationId); | 548 kPresentationId); |
550 content::PresentationConnectionStateChangedCallback state_changed_cb; | 549 content::PresentationConnectionStateChangedCallback state_changed_cb; |
551 // Trigger state change. It should be propagated back up to |mock_client_|. | 550 // Trigger state change. It should be propagated back up to |mock_client_|. |
552 blink::mojom::PresentationSessionInfo presentation_connection; | 551 blink::mojom::PresentationSessionInfo presentation_connection; |
553 presentation_connection.url = presentation_url1_; | 552 presentation_connection.url = presentation_url1_; |
554 presentation_connection.id = kPresentationId; | 553 presentation_connection.id = kPresentationId; |
555 | 554 |
556 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) | 555 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) |
557 .WillOnce(SaveArg<3>(&state_changed_cb)); | 556 .WillOnce(SaveArg<3>(&state_changed_cb)); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 mock_delegate_.set_screen_availability_listening_supported(false); | 967 mock_delegate_.set_screen_availability_listening_supported(false); |
969 base::RunLoop run_loop; | 968 base::RunLoop run_loop; |
970 EXPECT_CALL(mock_client_, | 969 EXPECT_CALL(mock_client_, |
971 OnScreenAvailabilityNotSupported(presentation_url1_)) | 970 OnScreenAvailabilityNotSupported(presentation_url1_)) |
972 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 971 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
973 ListenForScreenAvailabilityAndWait(presentation_url1_, false); | 972 ListenForScreenAvailabilityAndWait(presentation_url1_, false); |
974 run_loop.Run(); | 973 run_loop.Run(); |
975 } | 974 } |
976 | 975 |
977 } // namespace content | 976 } // namespace content |
OLD | NEW |