| 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 28 matching lines...) Expand all Loading... |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 // Matches mojo structs. | 41 // Matches mojo structs. |
| 42 MATCHER_P(Equals, expected, "") { | 42 MATCHER_P(Equals, expected, "") { |
| 43 return expected.Equals(arg); | 43 return expected.Equals(arg); |
| 44 } | 44 } |
| 45 | 45 |
| 46 const char *const kPresentationId = "presentationId"; | 46 const char *const kPresentationId = "presentationId"; |
| 47 const char *const kPresentationUrl = "http://foo.com/index.html"; | 47 const char *const kPresentationUrl = "http://foo.com/index.html"; |
| 48 | 48 |
| 49 bool ArePresentationSessionMessagesEqual( | |
| 50 const blink::mojom::SessionMessage* expected, | |
| 51 const blink::mojom::SessionMessage* actual) { | |
| 52 return expected->type == actual->type && | |
| 53 expected->message == actual->message && | |
| 54 expected->data.Equals(actual->data); | |
| 55 } | |
| 56 | |
| 57 void DoNothing(blink::mojom::PresentationSessionInfoPtr info, | 49 void DoNothing(blink::mojom::PresentationSessionInfoPtr info, |
| 58 blink::mojom::PresentationErrorPtr error) {} | 50 blink::mojom::PresentationErrorPtr error) {} |
| 59 | 51 |
| 60 } // namespace | 52 } // namespace |
| 61 | 53 |
| 62 class MockPresentationServiceDelegate : public PresentationServiceDelegate { | 54 class MockPresentationServiceDelegate : public PresentationServiceDelegate { |
| 63 public: | 55 public: |
| 64 MOCK_METHOD3(AddObserver, | 56 MOCK_METHOD3(AddObserver, |
| 65 void(int render_process_id, | 57 void(int render_process_id, |
| 66 int render_frame_id, | 58 int render_frame_id, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 137 } |
| 146 | 138 |
| 147 private: | 139 private: |
| 148 bool screen_availability_listening_supported_ = true; | 140 bool screen_availability_listening_supported_ = true; |
| 149 }; | 141 }; |
| 150 | 142 |
| 151 class MockPresentationServiceClient | 143 class MockPresentationServiceClient |
| 152 : public blink::mojom::PresentationServiceClient { | 144 : public blink::mojom::PresentationServiceClient { |
| 153 public: | 145 public: |
| 154 MOCK_METHOD2(OnScreenAvailabilityUpdated, | 146 MOCK_METHOD2(OnScreenAvailabilityUpdated, |
| 155 void(const mojo::String& url, bool available)); | 147 void(const std::string& url, bool available)); |
| 156 void OnConnectionStateChanged( | 148 void OnConnectionStateChanged( |
| 157 blink::mojom::PresentationSessionInfoPtr connection, | 149 blink::mojom::PresentationSessionInfoPtr connection, |
| 158 blink::mojom::PresentationConnectionState new_state) override { | 150 blink::mojom::PresentationConnectionState new_state) override { |
| 159 OnConnectionStateChanged(*connection, new_state); | 151 OnConnectionStateChanged(*connection, new_state); |
| 160 } | 152 } |
| 161 MOCK_METHOD2(OnConnectionStateChanged, | 153 MOCK_METHOD2(OnConnectionStateChanged, |
| 162 void(const blink::mojom::PresentationSessionInfo& connection, | 154 void(const blink::mojom::PresentationSessionInfo& connection, |
| 163 blink::mojom::PresentationConnectionState new_state)); | 155 blink::mojom::PresentationConnectionState new_state)); |
| 164 | 156 |
| 165 void OnConnectionClosed( | 157 void OnConnectionClosed( |
| 166 blink::mojom::PresentationSessionInfoPtr connection, | 158 blink::mojom::PresentationSessionInfoPtr connection, |
| 167 blink::mojom::PresentationConnectionCloseReason reason, | 159 blink::mojom::PresentationConnectionCloseReason reason, |
| 168 const mojo::String& message) override { | 160 const std::string& message) override { |
| 169 OnConnectionClosed(*connection, reason, message); | 161 OnConnectionClosed(*connection, reason, message); |
| 170 } | 162 } |
| 171 MOCK_METHOD3(OnConnectionClosed, | 163 MOCK_METHOD3(OnConnectionClosed, |
| 172 void(const blink::mojom::PresentationSessionInfo& connection, | 164 void(const blink::mojom::PresentationSessionInfo& connection, |
| 173 blink::mojom::PresentationConnectionCloseReason reason, | 165 blink::mojom::PresentationConnectionCloseReason reason, |
| 174 const mojo::String& message)); | 166 const std::string& message)); |
| 175 | 167 |
| 176 MOCK_METHOD1(OnScreenAvailabilityNotSupported, void(const mojo::String& url)); | 168 MOCK_METHOD1(OnScreenAvailabilityNotSupported, void(const std::string& url)); |
| 177 | 169 |
| 178 void OnSessionMessagesReceived( | 170 void OnSessionMessagesReceived( |
| 179 blink::mojom::PresentationSessionInfoPtr session_info, | 171 blink::mojom::PresentationSessionInfoPtr session_info, |
| 180 mojo::Array<blink::mojom::SessionMessagePtr> messages) override { | 172 std::vector<blink::mojom::SessionMessagePtr> messages) override { |
| 181 messages_received_ = std::move(messages); | 173 messages_received_ = std::move(messages); |
| 182 MessagesReceived(); | 174 MessagesReceived(); |
| 183 } | 175 } |
| 184 MOCK_METHOD0(MessagesReceived, void()); | 176 MOCK_METHOD0(MessagesReceived, void()); |
| 185 | 177 |
| 186 void OnDefaultSessionStarted( | 178 void OnDefaultSessionStarted( |
| 187 blink::mojom::PresentationSessionInfoPtr session_info) override { | 179 blink::mojom::PresentationSessionInfoPtr session_info) override { |
| 188 OnDefaultSessionStarted(*session_info); | 180 OnDefaultSessionStarted(*session_info); |
| 189 } | 181 } |
| 190 MOCK_METHOD1(OnDefaultSessionStarted, | 182 MOCK_METHOD1(OnDefaultSessionStarted, |
| 191 void(const blink::mojom::PresentationSessionInfo& session_info)); | 183 void(const blink::mojom::PresentationSessionInfo& session_info)); |
| 192 | 184 |
| 193 mojo::Array<blink::mojom::SessionMessagePtr> messages_received_; | 185 std::vector<blink::mojom::SessionMessagePtr> messages_received_; |
| 194 }; | 186 }; |
| 195 | 187 |
| 196 class PresentationServiceImplTest : public RenderViewHostImplTestHarness { | 188 class PresentationServiceImplTest : public RenderViewHostImplTestHarness { |
| 197 public: | 189 public: |
| 198 PresentationServiceImplTest() {} | 190 PresentationServiceImplTest() {} |
| 199 | 191 |
| 200 void SetUp() override { | 192 void SetUp() override { |
| 201 RenderViewHostImplTestHarness::SetUp(); | 193 RenderViewHostImplTestHarness::SetUp(); |
| 202 | 194 |
| 203 auto request = mojo::GetProxy(&service_ptr_); | 195 auto request = mojo::GetProxy(&service_ptr_); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 217 | 209 |
| 218 void TearDown() override { | 210 void TearDown() override { |
| 219 service_ptr_.reset(); | 211 service_ptr_.reset(); |
| 220 if (service_impl_.get()) { | 212 if (service_impl_.get()) { |
| 221 EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1); | 213 EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1); |
| 222 service_impl_.reset(); | 214 service_impl_.reset(); |
| 223 } | 215 } |
| 224 RenderViewHostImplTestHarness::TearDown(); | 216 RenderViewHostImplTestHarness::TearDown(); |
| 225 } | 217 } |
| 226 | 218 |
| 227 void ListenForScreenAvailabilityAndWait( | 219 void ListenForScreenAvailabilityAndWait(const std::string& url, |
| 228 const mojo::String& url, bool delegate_success) { | 220 bool delegate_success) { |
| 229 base::RunLoop run_loop; | 221 base::RunLoop run_loop; |
| 230 // This will call to |service_impl_| via mojo. Process the message | 222 // This will call to |service_impl_| via mojo. Process the message |
| 231 // using RunLoop. | 223 // using RunLoop. |
| 232 // The callback shouldn't be invoked since there is no availability | 224 // The callback shouldn't be invoked since there is no availability |
| 233 // result yet. | 225 // result yet. |
| 234 EXPECT_CALL(mock_delegate_, AddScreenAvailabilityListener()) | 226 EXPECT_CALL(mock_delegate_, AddScreenAvailabilityListener()) |
| 235 .WillOnce(DoAll( | 227 .WillOnce(DoAll( |
| 236 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), | 228 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), |
| 237 Return(delegate_success))); | 229 Return(delegate_success))); |
| 238 service_ptr_->ListenForScreenAvailability(url); | 230 service_ptr_->ListenForScreenAvailability(url); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 254 run_loop.Run(); | 246 run_loop.Run(); |
| 255 run_loop_quit_closure_.Reset(); | 247 run_loop_quit_closure_.Reset(); |
| 256 } | 248 } |
| 257 | 249 |
| 258 void SimulateScreenAvailabilityChangeAndWait( | 250 void SimulateScreenAvailabilityChangeAndWait( |
| 259 const std::string& url, bool available) { | 251 const std::string& url, bool available) { |
| 260 auto listener_it = service_impl_->screen_availability_listeners_.find(url); | 252 auto listener_it = service_impl_->screen_availability_listeners_.find(url); |
| 261 ASSERT_TRUE(listener_it->second); | 253 ASSERT_TRUE(listener_it->second); |
| 262 | 254 |
| 263 base::RunLoop run_loop; | 255 base::RunLoop run_loop; |
| 264 EXPECT_CALL(mock_client_, | 256 EXPECT_CALL(mock_client_, OnScreenAvailabilityUpdated(url, available)) |
| 265 OnScreenAvailabilityUpdated(mojo::String(url), available)) | 257 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 266 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | |
| 267 listener_it->second->OnScreenAvailabilityChanged(available); | 258 listener_it->second->OnScreenAvailabilityChanged(available); |
| 268 run_loop.Run(); | 259 run_loop.Run(); |
| 269 } | 260 } |
| 270 | 261 |
| 271 void ExpectReset() { | 262 void ExpectReset() { |
| 272 EXPECT_CALL(mock_delegate_, Reset(_, _)).Times(1); | 263 EXPECT_CALL(mock_delegate_, Reset(_, _)).Times(1); |
| 273 } | 264 } |
| 274 | 265 |
| 275 void ExpectCleanState() { | 266 void ExpectCleanState() { |
| 276 EXPECT_TRUE(service_impl_->default_presentation_url_.empty()); | 267 EXPECT_TRUE(service_impl_->default_presentation_url_.empty()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 292 void ExpectNewSessionCallbackError( | 283 void ExpectNewSessionCallbackError( |
| 293 blink::mojom::PresentationSessionInfoPtr info, | 284 blink::mojom::PresentationSessionInfoPtr info, |
| 294 blink::mojom::PresentationErrorPtr error) { | 285 blink::mojom::PresentationErrorPtr error) { |
| 295 EXPECT_TRUE(info.is_null()); | 286 EXPECT_TRUE(info.is_null()); |
| 296 EXPECT_FALSE(error.is_null()); | 287 EXPECT_FALSE(error.is_null()); |
| 297 if (!run_loop_quit_closure_.is_null()) | 288 if (!run_loop_quit_closure_.is_null()) |
| 298 run_loop_quit_closure_.Run(); | 289 run_loop_quit_closure_.Run(); |
| 299 } | 290 } |
| 300 | 291 |
| 301 void ExpectSessionMessages( | 292 void ExpectSessionMessages( |
| 302 const mojo::Array<blink::mojom::SessionMessagePtr>& expected_msgs, | 293 const std::vector<blink::mojom::SessionMessagePtr>& expected_msgs, |
| 303 const mojo::Array<blink::mojom::SessionMessagePtr>& actual_msgs) { | 294 const std::vector<blink::mojom::SessionMessagePtr>& actual_msgs) { |
| 304 EXPECT_EQ(expected_msgs.size(), actual_msgs.size()); | 295 EXPECT_EQ(expected_msgs.size(), actual_msgs.size()); |
| 305 for (size_t i = 0; i < actual_msgs.size(); ++i) { | 296 for (size_t i = 0; i < actual_msgs.size(); ++i) |
| 306 EXPECT_TRUE(ArePresentationSessionMessagesEqual(expected_msgs[i].get(), | 297 EXPECT_TRUE(expected_msgs[i].Equals(actual_msgs[i])); |
| 307 actual_msgs[i].get())); | |
| 308 } | |
| 309 } | 298 } |
| 310 | 299 |
| 311 void ExpectSendSessionMessageCallback(bool success) { | 300 void ExpectSendSessionMessageCallback(bool success) { |
| 312 EXPECT_TRUE(success); | 301 EXPECT_TRUE(success); |
| 313 EXPECT_FALSE(service_impl_->send_message_callback_); | 302 EXPECT_FALSE(service_impl_->send_message_callback_); |
| 314 if (!run_loop_quit_closure_.is_null()) | 303 if (!run_loop_quit_closure_.is_null()) |
| 315 run_loop_quit_closure_.Run(); | 304 run_loop_quit_closure_.Run(); |
| 316 } | 305 } |
| 317 | 306 |
| 318 void RunListenForSessionMessages(const std::string& text_msg, | 307 void RunListenForSessionMessages(const std::string& text_msg, |
| 319 const std::vector<uint8_t>& binary_data, | 308 const std::vector<uint8_t>& binary_data, |
| 320 bool pass_ownership) { | 309 bool pass_ownership) { |
| 321 mojo::Array<blink::mojom::SessionMessagePtr> expected_msgs(2); | 310 std::vector<blink::mojom::SessionMessagePtr> expected_msgs(2); |
| 322 expected_msgs[0] = blink::mojom::SessionMessage::New(); | 311 expected_msgs[0] = blink::mojom::SessionMessage::New(); |
| 323 expected_msgs[0]->type = blink::mojom::PresentationMessageType::TEXT; | 312 expected_msgs[0]->type = blink::mojom::PresentationMessageType::TEXT; |
| 324 expected_msgs[0]->message = text_msg; | 313 expected_msgs[0]->message = text_msg; |
| 325 expected_msgs[1] = blink::mojom::SessionMessage::New(); | 314 expected_msgs[1] = blink::mojom::SessionMessage::New(); |
| 326 expected_msgs[1]->type = | 315 expected_msgs[1]->type = |
| 327 blink::mojom::PresentationMessageType::ARRAY_BUFFER; | 316 blink::mojom::PresentationMessageType::ARRAY_BUFFER; |
| 328 expected_msgs[1]->data = mojo::Array<uint8_t>::From(binary_data); | 317 expected_msgs[1]->data = binary_data; |
| 329 | 318 |
| 330 blink::mojom::PresentationSessionInfoPtr session( | 319 blink::mojom::PresentationSessionInfoPtr session( |
| 331 blink::mojom::PresentationSessionInfo::New()); | 320 blink::mojom::PresentationSessionInfo::New()); |
| 332 session->url = kPresentationUrl; | 321 session->url = kPresentationUrl; |
| 333 session->id = kPresentationId; | 322 session->id = kPresentationId; |
| 334 | 323 |
| 335 PresentationSessionMessageCallback message_cb; | 324 PresentationSessionMessageCallback message_cb; |
| 336 { | 325 { |
| 337 base::RunLoop run_loop; | 326 base::RunLoop run_loop; |
| 338 EXPECT_CALL(mock_delegate_, ListenForSessionMessages(_, _, _, _)) | 327 EXPECT_CALL(mock_delegate_, ListenForSessionMessages(_, _, _, _)) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 blink::mojom::PresentationSessionInfo presentation_connection; | 498 blink::mojom::PresentationSessionInfo presentation_connection; |
| 510 presentation_connection.url = kPresentationUrl; | 499 presentation_connection.url = kPresentationUrl; |
| 511 presentation_connection.id = kPresentationId; | 500 presentation_connection.id = kPresentationId; |
| 512 { | 501 { |
| 513 base::RunLoop run_loop; | 502 base::RunLoop run_loop; |
| 514 PresentationConnectionStateChangeInfo closed_info( | 503 PresentationConnectionStateChangeInfo closed_info( |
| 515 PRESENTATION_CONNECTION_STATE_CLOSED); | 504 PRESENTATION_CONNECTION_STATE_CLOSED); |
| 516 closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY; | 505 closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY; |
| 517 closed_info.message = "Foo"; | 506 closed_info.message = "Foo"; |
| 518 | 507 |
| 519 EXPECT_CALL(mock_client_, | 508 EXPECT_CALL( |
| 520 OnConnectionClosed( | 509 mock_client_, |
| 521 Equals(presentation_connection), | 510 OnConnectionClosed( |
| 522 blink::mojom::PresentationConnectionCloseReason::WENT_AWAY, | 511 Equals(presentation_connection), |
| 523 mojo::String("Foo"))) | 512 blink::mojom::PresentationConnectionCloseReason::WENT_AWAY, "Foo")) |
| 524 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 513 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 525 state_changed_cb.Run(closed_info); | 514 state_changed_cb.Run(closed_info); |
| 526 run_loop.Run(); | 515 run_loop.Run(); |
| 527 } | 516 } |
| 528 } | 517 } |
| 529 | 518 |
| 530 TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrl) { | 519 TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrl) { |
| 531 EXPECT_CALL(mock_delegate_, | 520 EXPECT_CALL(mock_delegate_, |
| 532 SetDefaultPresentationUrl(_, _, Eq(kPresentationUrl), _)) | 521 SetDefaultPresentationUrl(_, _, Eq(kPresentationUrl), _)) |
| 533 .Times(1); | 522 .Times(1); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 .WillOnce(DoAll( | 562 .WillOnce(DoAll( |
| 574 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), | 563 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), |
| 575 SaveArg<4>(&error_cb))); | 564 SaveArg<4>(&error_cb))); |
| 576 run_loop.Run(); | 565 run_loop.Run(); |
| 577 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); | 566 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); |
| 578 SaveQuitClosureAndRunLoop(); | 567 SaveQuitClosureAndRunLoop(); |
| 579 } | 568 } |
| 580 | 569 |
| 581 TEST_F(PresentationServiceImplTest, JoinSessionSuccess) { | 570 TEST_F(PresentationServiceImplTest, JoinSessionSuccess) { |
| 582 service_ptr_->JoinSession( | 571 service_ptr_->JoinSession( |
| 583 kPresentationUrl, | 572 kPresentationUrl, base::Optional<std::string>(kPresentationId), |
| 584 kPresentationId, | 573 base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackSuccess, |
| 585 base::Bind( | 574 base::Unretained(this))); |
| 586 &PresentationServiceImplTest::ExpectNewSessionCallbackSuccess, | |
| 587 base::Unretained(this))); | |
| 588 base::RunLoop run_loop; | 575 base::RunLoop run_loop; |
| 589 base::Callback<void(const PresentationSessionInfo&)> success_cb; | 576 base::Callback<void(const PresentationSessionInfo&)> success_cb; |
| 590 EXPECT_CALL(mock_delegate_, JoinSession( | 577 EXPECT_CALL(mock_delegate_, JoinSession( |
| 591 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) | 578 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) |
| 592 .WillOnce(DoAll( | 579 .WillOnce(DoAll( |
| 593 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), | 580 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), |
| 594 SaveArg<4>(&success_cb))); | 581 SaveArg<4>(&success_cb))); |
| 595 run_loop.Run(); | 582 run_loop.Run(); |
| 596 | 583 |
| 597 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) | 584 EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _)) |
| 598 .Times(1); | 585 .Times(1); |
| 599 success_cb.Run(PresentationSessionInfo(kPresentationUrl, kPresentationId)); | 586 success_cb.Run(PresentationSessionInfo(kPresentationUrl, kPresentationId)); |
| 600 SaveQuitClosureAndRunLoop(); | 587 SaveQuitClosureAndRunLoop(); |
| 601 } | 588 } |
| 602 | 589 |
| 603 TEST_F(PresentationServiceImplTest, JoinSessionError) { | 590 TEST_F(PresentationServiceImplTest, JoinSessionError) { |
| 604 service_ptr_->JoinSession( | 591 service_ptr_->JoinSession( |
| 605 kPresentationUrl, | 592 kPresentationUrl, base::Optional<std::string>(kPresentationId), |
| 606 kPresentationId, | 593 base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackError, |
| 607 base::Bind( | 594 base::Unretained(this))); |
| 608 &PresentationServiceImplTest::ExpectNewSessionCallbackError, | |
| 609 base::Unretained(this))); | |
| 610 base::RunLoop run_loop; | 595 base::RunLoop run_loop; |
| 611 base::Callback<void(const PresentationError&)> error_cb; | 596 base::Callback<void(const PresentationError&)> error_cb; |
| 612 EXPECT_CALL(mock_delegate_, JoinSession( | 597 EXPECT_CALL(mock_delegate_, JoinSession( |
| 613 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) | 598 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) |
| 614 .WillOnce(DoAll( | 599 .WillOnce(DoAll( |
| 615 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), | 600 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), |
| 616 SaveArg<5>(&error_cb))); | 601 SaveArg<5>(&error_cb))); |
| 617 run_loop.Run(); | 602 run_loop.Run(); |
| 618 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); | 603 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); |
| 619 SaveQuitClosureAndRunLoop(); | 604 SaveQuitClosureAndRunLoop(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 std::vector<uint8_t> data; | 697 std::vector<uint8_t> data; |
| 713 data.assign(buffer, buffer + sizeof(buffer)); | 698 data.assign(buffer, buffer + sizeof(buffer)); |
| 714 | 699 |
| 715 blink::mojom::PresentationSessionInfoPtr session( | 700 blink::mojom::PresentationSessionInfoPtr session( |
| 716 blink::mojom::PresentationSessionInfo::New()); | 701 blink::mojom::PresentationSessionInfo::New()); |
| 717 session->url = kPresentationUrl; | 702 session->url = kPresentationUrl; |
| 718 session->id = kPresentationId; | 703 session->id = kPresentationId; |
| 719 blink::mojom::SessionMessagePtr message_request( | 704 blink::mojom::SessionMessagePtr message_request( |
| 720 blink::mojom::SessionMessage::New()); | 705 blink::mojom::SessionMessage::New()); |
| 721 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER; | 706 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER; |
| 722 message_request->data = mojo::Array<uint8_t>::From(data); | 707 message_request->data = data; |
| 723 service_ptr_->SendSessionMessage( | 708 service_ptr_->SendSessionMessage( |
| 724 std::move(session), std::move(message_request), | 709 std::move(session), std::move(message_request), |
| 725 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, | 710 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, |
| 726 base::Unretained(this))); | 711 base::Unretained(this))); |
| 727 | 712 |
| 728 base::RunLoop run_loop; | 713 base::RunLoop run_loop; |
| 729 base::Callback<void(bool)> send_message_cb; | 714 base::Callback<void(bool)> send_message_cb; |
| 730 PresentationSessionMessage* test_message = nullptr; | 715 PresentationSessionMessage* test_message = nullptr; |
| 731 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) | 716 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) |
| 732 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), | 717 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 756 std::vector<uint8_t> data; | 741 std::vector<uint8_t> data; |
| 757 data.assign(buffer, buffer + sizeof(buffer)); | 742 data.assign(buffer, buffer + sizeof(buffer)); |
| 758 | 743 |
| 759 blink::mojom::PresentationSessionInfoPtr session( | 744 blink::mojom::PresentationSessionInfoPtr session( |
| 760 blink::mojom::PresentationSessionInfo::New()); | 745 blink::mojom::PresentationSessionInfo::New()); |
| 761 session->url = kPresentationUrl; | 746 session->url = kPresentationUrl; |
| 762 session->id = kPresentationId; | 747 session->id = kPresentationId; |
| 763 blink::mojom::SessionMessagePtr message_request( | 748 blink::mojom::SessionMessagePtr message_request( |
| 764 blink::mojom::SessionMessage::New()); | 749 blink::mojom::SessionMessage::New()); |
| 765 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER; | 750 message_request->type = blink::mojom::PresentationMessageType::ARRAY_BUFFER; |
| 766 message_request->data = mojo::Array<uint8_t>::From(data); | 751 message_request->data = data; |
| 767 service_ptr_->SendSessionMessage( | 752 service_ptr_->SendSessionMessage( |
| 768 std::move(session), std::move(message_request), | 753 std::move(session), std::move(message_request), |
| 769 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, | 754 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, |
| 770 base::Unretained(this))); | 755 base::Unretained(this))); |
| 771 | 756 |
| 772 base::RunLoop run_loop; | 757 base::RunLoop run_loop; |
| 773 base::Callback<void(bool)> send_message_cb; | 758 base::Callback<void(bool)> send_message_cb; |
| 774 PresentationSessionMessage* test_message = nullptr; | 759 PresentationSessionMessage* test_message = nullptr; |
| 775 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) | 760 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) |
| 776 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), | 761 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 787 std::vector<uint8_t> data; | 772 std::vector<uint8_t> data; |
| 788 data.assign(buffer, buffer + sizeof(buffer)); | 773 data.assign(buffer, buffer + sizeof(buffer)); |
| 789 | 774 |
| 790 blink::mojom::PresentationSessionInfoPtr session( | 775 blink::mojom::PresentationSessionInfoPtr session( |
| 791 blink::mojom::PresentationSessionInfo::New()); | 776 blink::mojom::PresentationSessionInfo::New()); |
| 792 session->url = kPresentationUrl; | 777 session->url = kPresentationUrl; |
| 793 session->id = kPresentationId; | 778 session->id = kPresentationId; |
| 794 blink::mojom::SessionMessagePtr message_request( | 779 blink::mojom::SessionMessagePtr message_request( |
| 795 blink::mojom::SessionMessage::New()); | 780 blink::mojom::SessionMessage::New()); |
| 796 message_request->type = blink::mojom::PresentationMessageType::BLOB; | 781 message_request->type = blink::mojom::PresentationMessageType::BLOB; |
| 797 message_request->data = mojo::Array<uint8_t>::From(data); | 782 message_request->data = data; |
| 798 service_ptr_->SendSessionMessage( | 783 service_ptr_->SendSessionMessage( |
| 799 std::move(session), std::move(message_request), | 784 std::move(session), std::move(message_request), |
| 800 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, | 785 base::Bind(&PresentationServiceImplTest::ExpectSendSessionMessageCallback, |
| 801 base::Unretained(this))); | 786 base::Unretained(this))); |
| 802 | 787 |
| 803 base::RunLoop run_loop; | 788 base::RunLoop run_loop; |
| 804 base::Callback<void(bool)> send_message_cb; | 789 base::Callback<void(bool)> send_message_cb; |
| 805 PresentationSessionMessage* test_message = nullptr; | 790 PresentationSessionMessage* test_message = nullptr; |
| 806 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) | 791 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) |
| 807 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), | 792 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 mock_delegate_.set_screen_availability_listening_supported(false); | 835 mock_delegate_.set_screen_availability_listening_supported(false); |
| 851 base::RunLoop run_loop; | 836 base::RunLoop run_loop; |
| 852 EXPECT_CALL(mock_client_, | 837 EXPECT_CALL(mock_client_, |
| 853 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))) | 838 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))) |
| 854 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 839 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 855 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); | 840 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); |
| 856 run_loop.Run(); | 841 run_loop.Run(); |
| 857 } | 842 } |
| 858 | 843 |
| 859 } // namespace content | 844 } // namespace content |
| OLD | NEW |