OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 <memory> | 5 #include <memory> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "content/public/test/test_browser_thread_bundle.h" | 9 #include "content/public/test/test_browser_thread_bundle.h" |
10 #include "content/renderer/presentation/presentation_connection_proxy.h" | 10 #include "content/renderer/presentation/presentation_connection_proxy.h" |
11 #include "content/renderer/presentation/presentation_dispatcher.h" | 11 #include "content/renderer/presentation/presentation_dispatcher.h" |
12 #include "content/renderer/presentation/test_presentation_connection.h" | 12 #include "content/renderer/presentation/test_presentation_connection.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nAvailabilityObserver.h" | 14 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nAvailabilityObserver.h" |
15 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnection.h" | 15 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnection.h" |
16 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnectionCallbacks.h" | 16 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnectionCallbacks.h" |
17 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" | 17 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" |
18 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nError.h" | 18 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nError.h" |
| 19 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nReceiver.h" |
19 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nSessionInfo.h" | 20 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nSessionInfo.h" |
20 #include "third_party/WebKit/public/web/WebArrayBuffer.h" | 21 #include "third_party/WebKit/public/web/WebArrayBuffer.h" |
21 | 22 |
22 using ::testing::_; | 23 using ::testing::_; |
23 using ::testing::Invoke; | 24 using ::testing::Invoke; |
24 using blink::WebArrayBuffer; | 25 using blink::WebArrayBuffer; |
25 using blink::WebPresentationAvailabilityCallbacks; | 26 using blink::WebPresentationAvailabilityCallbacks; |
26 using blink::WebPresentationAvailabilityObserver; | 27 using blink::WebPresentationAvailabilityObserver; |
27 using blink::WebPresentationConnectionCallbacks; | 28 using blink::WebPresentationConnectionCallbacks; |
28 using blink::WebPresentationError; | 29 using blink::WebPresentationError; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 ListenForConnectionMessagesInternal(session_info.get()); | 109 ListenForConnectionMessagesInternal(session_info.get()); |
109 } | 110 } |
110 MOCK_METHOD1(ListenForConnectionMessagesInternal, | 111 MOCK_METHOD1(ListenForConnectionMessagesInternal, |
111 void(PresentationSessionInfo* session_info)); | 112 void(PresentationSessionInfo* session_info)); |
112 | 113 |
113 void SetPresentationConnection( | 114 void SetPresentationConnection( |
114 blink::mojom::PresentationSessionInfoPtr session, | 115 blink::mojom::PresentationSessionInfoPtr session, |
115 blink::mojom::PresentationConnectionPtr controller_conn_ptr, | 116 blink::mojom::PresentationConnectionPtr controller_conn_ptr, |
116 blink::mojom::PresentationConnectionRequest receiver_conn_request) | 117 blink::mojom::PresentationConnectionRequest receiver_conn_request) |
117 override { | 118 override { |
118 SetPresentationConnection(session.get(), controller_conn_ptr.get()); | 119 SetPresentationConnectionInternal(session.get(), controller_conn_ptr.get()); |
119 } | 120 } |
120 MOCK_METHOD2(SetPresentationConnection, | 121 MOCK_METHOD2(SetPresentationConnectionInternal, |
121 void(PresentationSessionInfo* session_info, | 122 void(PresentationSessionInfo* session_info, |
122 PresentationConnection* connection)); | 123 PresentationConnection* connection)); |
123 }; | 124 }; |
124 | 125 |
| 126 class TestPresentationConnectionProxy : public PresentationConnectionProxy { |
| 127 public: |
| 128 TestPresentationConnectionProxy(blink::WebPresentationConnection* connection) |
| 129 : PresentationConnectionProxy(connection) {} |
| 130 |
| 131 void SendConnectionMessage(blink::mojom::ConnectionMessagePtr session_message, |
| 132 const OnMessageCallback& callback) const override { |
| 133 SendConnectionMessageInternal(session_message.get(), callback); |
| 134 } |
| 135 MOCK_CONST_METHOD2(SendConnectionMessageInternal, |
| 136 void(blink::mojom::ConnectionMessage*, |
| 137 const OnMessageCallback&)); |
| 138 }; |
| 139 |
| 140 class TestPresentationReceiver : public blink::WebPresentationReceiver { |
| 141 public: |
| 142 blink::WebPresentationConnection* onReceiverConnectionAvailable( |
| 143 const blink::WebPresentationSessionInfo&) override { |
| 144 return &connection_; |
| 145 } |
| 146 |
| 147 TestPresentationConnection connection_; |
| 148 }; |
| 149 |
125 class MockPresentationAvailabilityCallbacks | 150 class MockPresentationAvailabilityCallbacks |
126 : public blink::WebCallbacks<bool, const blink::WebPresentationError&> { | 151 : public blink::WebCallbacks<bool, const blink::WebPresentationError&> { |
127 public: | 152 public: |
128 MOCK_METHOD1(onSuccess, void(bool value)); | 153 MOCK_METHOD1(onSuccess, void(bool value)); |
129 MOCK_METHOD1(onError, void(const blink::WebPresentationError&)); | 154 MOCK_METHOD1(onError, void(const blink::WebPresentationError&)); |
130 }; | 155 }; |
131 | 156 |
132 class TestWebPresentationConnectionCallback | 157 class TestWebPresentationConnectionCallback |
133 : public WebPresentationConnectionCallbacks { | 158 : public WebPresentationConnectionCallbacks { |
134 public: | 159 public: |
135 TestWebPresentationConnectionCallback(WebURL url, WebString id) | 160 TestWebPresentationConnectionCallback(WebURL url, WebString id) |
136 : url_(url), id_(id), callback_called_(false) {} | 161 : url_(url), id_(id), callback_called_(false) {} |
137 ~TestWebPresentationConnectionCallback() override { | 162 ~TestWebPresentationConnectionCallback() override { |
138 EXPECT_TRUE(callback_called_); | 163 EXPECT_TRUE(callback_called_); |
139 } | 164 } |
140 | 165 |
141 void onSuccess(const WebPresentationSessionInfo& info) override { | 166 void onSuccess(const WebPresentationSessionInfo& info) override { |
142 callback_called_ = true; | 167 callback_called_ = true; |
143 EXPECT_EQ(info.url, url_); | 168 EXPECT_EQ(info.url, url_); |
144 EXPECT_EQ(info.id, id_); | 169 EXPECT_EQ(info.id, id_); |
145 } | 170 } |
146 | 171 |
147 blink::WebPresentationConnection* getConnection() override { | 172 blink::WebPresentationConnection* getConnection() override { |
148 return &connection_; | 173 return &connection_; |
149 } | 174 } |
150 | 175 |
| 176 TestPresentationConnection connection_; |
| 177 |
151 private: | 178 private: |
152 const WebURL url_; | 179 const WebURL url_; |
153 const WebString id_; | 180 const WebString id_; |
154 bool callback_called_; | 181 bool callback_called_; |
155 TestPresentationConnection connection_; | |
156 }; | 182 }; |
157 | 183 |
158 class TestWebPresentationConnectionErrorCallback | 184 class TestWebPresentationConnectionErrorCallback |
159 : public WebPresentationConnectionCallbacks { | 185 : public WebPresentationConnectionCallbacks { |
160 public: | 186 public: |
161 TestWebPresentationConnectionErrorCallback( | 187 TestWebPresentationConnectionErrorCallback( |
162 WebPresentationError::ErrorType error_type, | 188 WebPresentationError::ErrorType error_type, |
163 WebString message) | 189 WebString message) |
164 : error_type_(error_type), message_(message), callback_called_(false) {} | 190 : error_type_(error_type), message_(message), callback_called_(false) {} |
165 ~TestWebPresentationConnectionErrorCallback() override { | 191 ~TestWebPresentationConnectionErrorCallback() override { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 std::vector<MockPresentationAvailabilityObserver*> mock_observers_; | 325 std::vector<MockPresentationAvailabilityObserver*> mock_observers_; |
300 | 326 |
301 MockPresentationService presentation_service_; | 327 MockPresentationService presentation_service_; |
302 TestPresentationDispatcher dispatcher_; | 328 TestPresentationDispatcher dispatcher_; |
303 | 329 |
304 private: | 330 private: |
305 content::TestBrowserThreadBundle thread_bundle_; | 331 content::TestBrowserThreadBundle thread_bundle_; |
306 }; | 332 }; |
307 | 333 |
308 TEST_F(PresentationDispatcherTest, TestStartSession) { | 334 TEST_F(PresentationDispatcherTest, TestStartSession) { |
| 335 auto* test_connection_callback = |
| 336 new TestWebPresentationConnectionCallback(url1_, presentation_id_); |
| 337 EXPECT_FALSE(test_connection_callback->connection_.proxy_); |
| 338 |
309 base::RunLoop run_loop; | 339 base::RunLoop run_loop; |
310 | 340 EXPECT_CALL(presentation_service_, ListenForConnectionMessagesInternal(_)); |
| 341 EXPECT_CALL(presentation_service_, SetPresentationConnectionInternal(_, _)); |
311 EXPECT_CALL(presentation_service_, StartSession(gurls_, _)) | 342 EXPECT_CALL(presentation_service_, StartSession(gurls_, _)) |
312 .WillOnce(Invoke([this]( | 343 .WillOnce(Invoke([this]( |
313 const std::vector<GURL>& presentation_urls, | 344 const std::vector<GURL>& presentation_urls, |
314 const PresentationService::StartSessionCallback& callback) { | 345 const PresentationService::StartSessionCallback& callback) { |
315 PresentationSessionInfoPtr session_info(PresentationSessionInfo::New()); | 346 PresentationSessionInfoPtr session_info(PresentationSessionInfo::New()); |
316 session_info->url = gurl1_; | 347 session_info->url = gurl1_; |
317 session_info->id = presentation_id_.utf8(); | 348 session_info->id = presentation_id_.utf8(); |
318 callback.Run(std::move(session_info), PresentationErrorPtr()); | 349 callback.Run(std::move(session_info), PresentationErrorPtr()); |
319 })); | 350 })); |
320 client()->startSession( | 351 dispatcher_.startSession(urls_, base::WrapUnique(test_connection_callback)); |
321 urls_, base::MakeUnique<TestWebPresentationConnectionCallback>( | |
322 url1_, presentation_id_)); | |
323 run_loop.RunUntilIdle(); | 352 run_loop.RunUntilIdle(); |
| 353 |
| 354 EXPECT_TRUE(test_connection_callback->connection_.proxy_); |
324 } | 355 } |
325 | 356 |
326 TEST_F(PresentationDispatcherTest, TestStartSessionError) { | 357 TEST_F(PresentationDispatcherTest, TestStartSessionError) { |
327 WebString error_message = WebString::fromUTF8("Test error message"); | 358 WebString error_message = WebString::fromUTF8("Test error message"); |
328 base::RunLoop run_loop; | 359 base::RunLoop run_loop; |
329 | 360 |
330 EXPECT_CALL(presentation_service_, StartSession(gurls_, _)) | 361 EXPECT_CALL(presentation_service_, StartSession(gurls_, _)) |
331 .WillOnce(Invoke([&error_message]( | 362 .WillOnce(Invoke([&error_message]( |
332 const std::vector<GURL>& presentation_urls, | 363 const std::vector<GURL>& presentation_urls, |
333 const PresentationService::StartSessionCallback& callback) { | 364 const PresentationService::StartSessionCallback& callback) { |
334 PresentationErrorPtr error(PresentationError::New()); | 365 PresentationErrorPtr error(PresentationError::New()); |
335 error->error_type = PresentationErrorType::NO_AVAILABLE_SCREENS; | 366 error->error_type = PresentationErrorType::NO_AVAILABLE_SCREENS; |
336 error->message = error_message.utf8(); | 367 error->message = error_message.utf8(); |
337 callback.Run(PresentationSessionInfoPtr(), std::move(error)); | 368 callback.Run(PresentationSessionInfoPtr(), std::move(error)); |
338 })); | 369 })); |
339 client()->startSession( | 370 dispatcher_.startSession( |
340 urls_, | 371 urls_, |
341 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( | 372 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( |
342 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); | 373 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); |
343 run_loop.RunUntilIdle(); | 374 run_loop.RunUntilIdle(); |
344 } | 375 } |
345 | 376 |
346 TEST_F(PresentationDispatcherTest, TestJoinSessionError) { | 377 TEST_F(PresentationDispatcherTest, TestJoinSessionError) { |
347 WebString error_message = WebString::fromUTF8("Test error message"); | 378 WebString error_message = WebString::fromUTF8("Test error message"); |
348 base::RunLoop run_loop; | 379 base::RunLoop run_loop; |
349 | 380 |
(...skipping 10 matching lines...) Expand all Loading... |
360 callback.Run(PresentationSessionInfoPtr(), std::move(error)); | 391 callback.Run(PresentationSessionInfoPtr(), std::move(error)); |
361 })); | 392 })); |
362 dispatcher_.joinSession( | 393 dispatcher_.joinSession( |
363 urls_, presentation_id_, | 394 urls_, presentation_id_, |
364 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( | 395 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( |
365 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); | 396 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); |
366 run_loop.RunUntilIdle(); | 397 run_loop.RunUntilIdle(); |
367 } | 398 } |
368 | 399 |
369 TEST_F(PresentationDispatcherTest, TestJoinSession) { | 400 TEST_F(PresentationDispatcherTest, TestJoinSession) { |
| 401 auto* test_connection_callback = |
| 402 new TestWebPresentationConnectionCallback(url1_, presentation_id_); |
| 403 EXPECT_FALSE(test_connection_callback->connection_.proxy_); |
| 404 |
370 base::RunLoop run_loop; | 405 base::RunLoop run_loop; |
371 | 406 |
| 407 EXPECT_CALL(presentation_service_, ListenForConnectionMessagesInternal(_)); |
| 408 EXPECT_CALL(presentation_service_, SetPresentationConnectionInternal(_, _)); |
372 EXPECT_CALL(presentation_service_, JoinSession(gurls_, _, _)) | 409 EXPECT_CALL(presentation_service_, JoinSession(gurls_, _, _)) |
373 .WillOnce(Invoke([this]( | 410 .WillOnce(Invoke([this]( |
374 const std::vector<GURL>& presentation_urls, | 411 const std::vector<GURL>& presentation_urls, |
375 const base::Optional<std::string>& presentation_id, | 412 const base::Optional<std::string>& presentation_id, |
376 const PresentationService::JoinSessionCallback& callback) { | 413 const PresentationService::JoinSessionCallback& callback) { |
377 EXPECT_TRUE(presentation_id.has_value()); | 414 EXPECT_TRUE(presentation_id.has_value()); |
378 EXPECT_EQ(presentation_id_.utf8(), presentation_id.value()); | 415 EXPECT_EQ(presentation_id_.utf8(), presentation_id.value()); |
379 PresentationSessionInfoPtr session_info(PresentationSessionInfo::New()); | 416 PresentationSessionInfoPtr session_info(PresentationSessionInfo::New()); |
380 session_info->url = gurl1_; | 417 session_info->url = gurl1_; |
381 session_info->id = presentation_id_.utf8(); | 418 session_info->id = presentation_id_.utf8(); |
382 callback.Run(std::move(session_info), PresentationErrorPtr()); | 419 callback.Run(std::move(session_info), PresentationErrorPtr()); |
383 })); | 420 })); |
384 dispatcher_.joinSession( | 421 dispatcher_.joinSession(urls_, presentation_id_, |
385 urls_, presentation_id_, | 422 base::WrapUnique(test_connection_callback)); |
386 base::MakeUnique<TestWebPresentationConnectionCallback>( | |
387 url1_, presentation_id_)); | |
388 run_loop.RunUntilIdle(); | 423 run_loop.RunUntilIdle(); |
| 424 |
| 425 EXPECT_TRUE(test_connection_callback->connection_.proxy_); |
389 } | 426 } |
390 | 427 |
391 TEST_F(PresentationDispatcherTest, TestSendString) { | 428 TEST_F(PresentationDispatcherTest, TestSendString) { |
392 WebString message = WebString::fromUTF8("test message"); | 429 WebString message = WebString::fromUTF8("test message"); |
| 430 TestPresentationConnection connection; |
| 431 TestPresentationConnectionProxy connection_proxy(&connection); |
| 432 |
393 base::RunLoop run_loop; | 433 base::RunLoop run_loop; |
394 EXPECT_CALL(presentation_service_, SendConnectionMessageInternal(_, _, _)) | 434 EXPECT_CALL(connection_proxy, SendConnectionMessageInternal(_, _)) |
395 .WillOnce(Invoke([this, &message]( | 435 .WillOnce(Invoke([this, &message](ConnectionMessage* session_message, |
396 PresentationSessionInfo* session_info, | 436 const OnMessageCallback& callback) { |
397 ConnectionMessage* message_request, | 437 EXPECT_EQ(blink::mojom::PresentationMessageType::TEXT, |
398 const PresentationService::SendConnectionMessageCallback& callback) { | 438 session_message->type); |
399 EXPECT_EQ(gurl1_, session_info->url); | 439 EXPECT_EQ(message.utf8(), session_message->message.value()); |
400 EXPECT_EQ(presentation_id_.utf8(), session_info->id); | |
401 EXPECT_TRUE(message_request->message.has_value()); | |
402 EXPECT_EQ(message.utf8(), message_request->message.value()); | |
403 callback.Run(true); | |
404 })); | 440 })); |
405 dispatcher_.sendString(url1_, presentation_id_, message, nullptr); | 441 dispatcher_.sendString(url1_, presentation_id_, message, &connection_proxy); |
406 run_loop.RunUntilIdle(); | 442 run_loop.RunUntilIdle(); |
407 } | 443 } |
408 | 444 |
409 TEST_F(PresentationDispatcherTest, TestSendArrayBuffer) { | 445 TEST_F(PresentationDispatcherTest, TestSendArrayBuffer) { |
| 446 TestPresentationConnection connection; |
| 447 TestPresentationConnectionProxy connection_proxy(&connection); |
| 448 |
410 base::RunLoop run_loop; | 449 base::RunLoop run_loop; |
411 EXPECT_CALL(presentation_service_, SendConnectionMessageInternal(_, _, _)) | 450 EXPECT_CALL(connection_proxy, SendConnectionMessageInternal(_, _)) |
412 .WillOnce(Invoke([this]( | 451 .WillOnce(Invoke([this](ConnectionMessage* message_request, |
413 PresentationSessionInfo* session_info, | 452 const OnMessageCallback& callback) { |
414 ConnectionMessage* message_request, | |
415 const PresentationService::SendConnectionMessageCallback& callback) { | |
416 EXPECT_EQ(gurl1_, session_info->url); | |
417 EXPECT_EQ(presentation_id_.utf8(), session_info->id); | |
418 std::vector<uint8_t> data( | 453 std::vector<uint8_t> data( |
419 array_buffer_data(), | 454 array_buffer_data(), |
420 array_buffer_data() + array_buffer_.byteLength()); | 455 array_buffer_data() + array_buffer_.byteLength()); |
421 EXPECT_TRUE(message_request->data.has_value()); | 456 EXPECT_TRUE(message_request->data.has_value()); |
422 EXPECT_EQ(data, message_request->data.value()); | 457 EXPECT_EQ(data, message_request->data.value()); |
423 callback.Run(true); | |
424 })); | 458 })); |
425 dispatcher_.sendArrayBuffer(url1_, presentation_id_, array_buffer_data(), | 459 dispatcher_.sendArrayBuffer(url1_, presentation_id_, array_buffer_data(), |
426 array_buffer_.byteLength(), nullptr); | 460 array_buffer_.byteLength(), &connection_proxy); |
427 run_loop.RunUntilIdle(); | 461 run_loop.RunUntilIdle(); |
428 } | 462 } |
429 | 463 |
430 TEST_F(PresentationDispatcherTest, TestSendBlobData) { | 464 TEST_F(PresentationDispatcherTest, TestSendBlobData) { |
| 465 TestPresentationConnection connection; |
| 466 TestPresentationConnectionProxy connection_proxy(&connection); |
| 467 |
431 base::RunLoop run_loop; | 468 base::RunLoop run_loop; |
432 EXPECT_CALL(presentation_service_, SendConnectionMessageInternal(_, _, _)) | 469 EXPECT_CALL(connection_proxy, SendConnectionMessageInternal(_, _)) |
433 .WillOnce(Invoke([this]( | 470 .WillOnce(Invoke([this](ConnectionMessage* message_request, |
434 PresentationSessionInfo* session_info, | 471 const OnMessageCallback& callback) { |
435 ConnectionMessage* message_request, | |
436 const PresentationService::SendConnectionMessageCallback& callback) { | |
437 EXPECT_EQ(gurl1_, session_info->url); | |
438 EXPECT_EQ(presentation_id_.utf8(), session_info->id); | |
439 std::vector<uint8_t> data( | 472 std::vector<uint8_t> data( |
440 array_buffer_data(), | 473 array_buffer_data(), |
441 array_buffer_data() + array_buffer_.byteLength()); | 474 array_buffer_data() + array_buffer_.byteLength()); |
442 EXPECT_TRUE(message_request->data.has_value()); | 475 EXPECT_TRUE(message_request->data.has_value()); |
443 EXPECT_EQ(data, message_request->data.value()); | 476 EXPECT_EQ(data, message_request->data.value()); |
444 callback.Run(true); | 477 callback.Run(true); |
445 })); | 478 })); |
446 dispatcher_.sendBlobData(url1_, presentation_id_, array_buffer_data(), | 479 dispatcher_.sendBlobData(url1_, presentation_id_, array_buffer_data(), |
447 array_buffer_.byteLength(), nullptr); | 480 array_buffer_.byteLength(), &connection_proxy); |
448 run_loop.RunUntilIdle(); | 481 run_loop.RunUntilIdle(); |
449 } | 482 } |
450 | 483 |
| 484 TEST_F(PresentationDispatcherTest, TestOnReceiverConnectionAvailable) { |
| 485 PresentationSessionInfoPtr session_info(PresentationSessionInfo::New()); |
| 486 session_info->url = gurl1_; |
| 487 session_info->id = presentation_id_.utf8(); |
| 488 |
| 489 blink::mojom::PresentationConnectionPtr controller_connection_ptr; |
| 490 TestPresentationConnection controller_connection; |
| 491 TestPresentationConnectionProxy controller_connection_proxy( |
| 492 &controller_connection); |
| 493 mojo::Binding<blink::mojom::PresentationConnection> binding( |
| 494 &controller_connection_proxy, |
| 495 mojo::MakeRequest(&controller_connection_ptr)); |
| 496 |
| 497 blink::mojom::PresentationConnectionPtr receiver_connection_ptr; |
| 498 |
| 499 TestPresentationReceiver receiver; |
| 500 dispatcher_.setReceiver(&receiver); |
| 501 |
| 502 base::RunLoop run_loop; |
| 503 EXPECT_CALL(controller_connection, |
| 504 didChangeState(blink::WebPresentationConnectionState::Connected)); |
| 505 EXPECT_CALL(receiver.connection_, |
| 506 didChangeState(blink::WebPresentationConnectionState::Connected)); |
| 507 |
| 508 dispatcher_.OnReceiverConnectionAvailable( |
| 509 std::move(session_info), std::move(controller_connection_ptr), |
| 510 mojo::MakeRequest(&receiver_connection_ptr)); |
| 511 |
| 512 EXPECT_TRUE(receiver_connection_ptr); |
| 513 EXPECT_TRUE(receiver.connection_.proxy_); |
| 514 run_loop.RunUntilIdle(); |
| 515 } |
| 516 |
451 TEST_F(PresentationDispatcherTest, TestCloseSession) { | 517 TEST_F(PresentationDispatcherTest, TestCloseSession) { |
452 base::RunLoop run_loop; | 518 base::RunLoop run_loop; |
453 EXPECT_CALL(presentation_service_, | 519 EXPECT_CALL(presentation_service_, |
454 CloseConnection(gurl1_, presentation_id_.utf8())); | 520 CloseConnection(gurl1_, presentation_id_.utf8())); |
455 dispatcher_.closeSession(url1_, presentation_id_); | 521 dispatcher_.closeSession(url1_, presentation_id_); |
456 run_loop.RunUntilIdle(); | 522 run_loop.RunUntilIdle(); |
457 } | 523 } |
458 | 524 |
459 TEST_F(PresentationDispatcherTest, TestTerminateSession) { | 525 TEST_F(PresentationDispatcherTest, TestTerminateSession) { |
460 base::RunLoop run_loop; | 526 base::RunLoop run_loop; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 | 793 |
728 for (auto* mock_observer : mock_observers_) | 794 for (auto* mock_observer : mock_observers_) |
729 EXPECT_CALL(*mock_observer, availabilityChanged(false)); | 795 EXPECT_CALL(*mock_observer, availabilityChanged(false)); |
730 | 796 |
731 base::RunLoop run_loop_2; | 797 base::RunLoop run_loop_2; |
732 ChangeURLState(gurl2_, URLState::Unavailable); | 798 ChangeURLState(gurl2_, URLState::Unavailable); |
733 run_loop_2.RunUntilIdle(); | 799 run_loop_2.RunUntilIdle(); |
734 } | 800 } |
735 | 801 |
736 } // namespace content | 802 } // namespace content |
OLD | NEW |