Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: content/renderer/presentation/presentation_dispatcher_unittest.cc

Issue 2471573005: [Presentation API] (5th) (1-UA) integrate controller and receiver side for 1-UA messaging (Closed)
Patch Set: Fix PresentationDispatcherTest failures Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Does not take ownership of |connection|.
136 : url_(url), id_(id), callback_called_(false) {} 161 TestWebPresentationConnectionCallback(WebURL url,
162 WebString id,
163 TestPresentationConnection* connection)
164 : url_(url), id_(id), callback_called_(false), connection_(connection) {}
137 ~TestWebPresentationConnectionCallback() override { 165 ~TestWebPresentationConnectionCallback() override {
138 EXPECT_TRUE(callback_called_); 166 EXPECT_TRUE(callback_called_);
139 } 167 }
140 168
141 void onSuccess(const WebPresentationSessionInfo& info) override { 169 void onSuccess(const WebPresentationSessionInfo& info) override {
142 callback_called_ = true; 170 callback_called_ = true;
143 EXPECT_EQ(info.url, url_); 171 EXPECT_EQ(info.url, url_);
144 EXPECT_EQ(info.id, id_); 172 EXPECT_EQ(info.id, id_);
145 } 173 }
146 174
147 blink::WebPresentationConnection* getConnection() override { 175 blink::WebPresentationConnection* getConnection() override {
148 return &connection_; 176 return connection_;
149 } 177 }
150 178
151 private: 179 private:
152 const WebURL url_; 180 const WebURL url_;
153 const WebString id_; 181 const WebString id_;
154 bool callback_called_; 182 bool callback_called_;
155 TestPresentationConnection connection_; 183 TestPresentationConnection* connection_;
156 }; 184 };
157 185
158 class TestWebPresentationConnectionErrorCallback 186 class TestWebPresentationConnectionErrorCallback
159 : public WebPresentationConnectionCallbacks { 187 : public WebPresentationConnectionCallbacks {
160 public: 188 public:
161 TestWebPresentationConnectionErrorCallback( 189 TestWebPresentationConnectionErrorCallback(
162 WebPresentationError::ErrorType error_type, 190 WebPresentationError::ErrorType error_type,
163 WebString message) 191 WebString message)
164 : error_type_(error_type), message_(message), callback_called_(false) {} 192 : error_type_(error_type), message_(message), callback_called_(false) {}
165 ~TestWebPresentationConnectionErrorCallback() override { 193 ~TestWebPresentationConnectionErrorCallback() override {
(...skipping 30 matching lines...) Expand all
196 mojo::MakeRequest(&presentation_service_)); 224 mojo::MakeRequest(&presentation_service_));
197 } 225 }
198 } 226 }
199 227
200 MockPresentationService* mock_presentation_service_; 228 MockPresentationService* mock_presentation_service_;
201 std::unique_ptr<mojo::Binding<PresentationService>> mock_binding_; 229 std::unique_ptr<mojo::Binding<PresentationService>> mock_binding_;
202 }; 230 };
203 231
204 class PresentationDispatcherTest : public ::testing::Test { 232 class PresentationDispatcherTest : public ::testing::Test {
205 public: 233 public:
234 using OnMessageCallback = PresentationConnectionProxy::OnMessageCallback;
235
206 enum class URLState { Available, Unavailable, Unsupported, Unknown }; 236 enum class URLState { Available, Unavailable, Unsupported, Unknown };
207 237
208 PresentationDispatcherTest() 238 PresentationDispatcherTest()
209 : gurl1_(GURL("https://www.example.com/1.html")), 239 : gurl1_(GURL("https://www.example.com/1.html")),
210 gurl2_(GURL("https://www.example.com/2.html")), 240 gurl2_(GURL("https://www.example.com/2.html")),
211 gurl3_(GURL("https://www.example.com/3.html")), 241 gurl3_(GURL("https://www.example.com/3.html")),
212 gurl4_(GURL("https://www.example.com/4.html")), 242 gurl4_(GURL("https://www.example.com/4.html")),
213 gurls_({gurl1_, gurl2_, gurl3_, gurl4_}), 243 gurls_({gurl1_, gurl2_, gurl3_, gurl4_}),
214 url1_(WebURL(gurl1_)), 244 url1_(WebURL(gurl1_)),
215 url2_(WebURL(gurl2_)), 245 url2_(WebURL(gurl2_)),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 std::vector<MockPresentationAvailabilityObserver*> mock_observers_; 329 std::vector<MockPresentationAvailabilityObserver*> mock_observers_;
300 330
301 MockPresentationService presentation_service_; 331 MockPresentationService presentation_service_;
302 TestPresentationDispatcher dispatcher_; 332 TestPresentationDispatcher dispatcher_;
303 333
304 private: 334 private:
305 content::TestBrowserThreadBundle thread_bundle_; 335 content::TestBrowserThreadBundle thread_bundle_;
306 }; 336 };
307 337
308 TEST_F(PresentationDispatcherTest, TestStartSession) { 338 TEST_F(PresentationDispatcherTest, TestStartSession) {
309 base::RunLoop run_loop; 339 TestPresentationConnection connection;
340 EXPECT_FALSE(connection.proxy());
341 {
342 base::RunLoop run_loop;
343 EXPECT_CALL(presentation_service_, ListenForConnectionMessagesInternal(_));
344 EXPECT_CALL(presentation_service_, SetPresentationConnectionInternal(_, _));
345 EXPECT_CALL(presentation_service_, StartSession(gurls_, _))
346 .WillOnce(Invoke(
347 [this](const std::vector<GURL>& presentation_urls,
348 const PresentationService::StartSessionCallback& callback) {
349 PresentationSessionInfoPtr session_info(
350 PresentationSessionInfo::New());
351 session_info->url = gurl1_;
352 session_info->id = presentation_id_.utf8();
353 callback.Run(std::move(session_info), PresentationErrorPtr());
354 }));
310 355
311 EXPECT_CALL(presentation_service_, StartSession(gurls_, _)) 356 dispatcher_.startSession(
312 .WillOnce(Invoke([this]( 357 urls_, base::MakeUnique<TestWebPresentationConnectionCallback>(
313 const std::vector<GURL>& presentation_urls, 358 url1_, presentation_id_, &connection));
314 const PresentationService::StartSessionCallback& callback) { 359 run_loop.RunUntilIdle();
315 PresentationSessionInfoPtr session_info(PresentationSessionInfo::New()); 360 }
316 session_info->url = gurl1_; 361 EXPECT_TRUE(connection.proxy());
317 session_info->id = presentation_id_.utf8();
318 callback.Run(std::move(session_info), PresentationErrorPtr());
319 }));
320 client()->startSession(
321 urls_, base::MakeUnique<TestWebPresentationConnectionCallback>(
322 url1_, presentation_id_));
323 run_loop.RunUntilIdle();
324 } 362 }
325 363
326 TEST_F(PresentationDispatcherTest, TestStartSessionError) { 364 TEST_F(PresentationDispatcherTest, TestStartSessionError) {
327 WebString error_message = WebString::fromUTF8("Test error message"); 365 WebString error_message = WebString::fromUTF8("Test error message");
328 base::RunLoop run_loop; 366 base::RunLoop run_loop;
329 367
330 EXPECT_CALL(presentation_service_, StartSession(gurls_, _)) 368 EXPECT_CALL(presentation_service_, StartSession(gurls_, _))
331 .WillOnce(Invoke([&error_message]( 369 .WillOnce(Invoke([&error_message](
332 const std::vector<GURL>& presentation_urls, 370 const std::vector<GURL>& presentation_urls,
333 const PresentationService::StartSessionCallback& callback) { 371 const PresentationService::StartSessionCallback& callback) {
334 PresentationErrorPtr error(PresentationError::New()); 372 PresentationErrorPtr error(PresentationError::New());
335 error->error_type = PresentationErrorType::NO_AVAILABLE_SCREENS; 373 error->error_type = PresentationErrorType::NO_AVAILABLE_SCREENS;
336 error->message = error_message.utf8(); 374 error->message = error_message.utf8();
337 callback.Run(PresentationSessionInfoPtr(), std::move(error)); 375 callback.Run(PresentationSessionInfoPtr(), std::move(error));
338 })); 376 }));
339 client()->startSession( 377 dispatcher_.startSession(
340 urls_, 378 urls_,
341 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( 379 base::MakeUnique<TestWebPresentationConnectionErrorCallback>(
342 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); 380 WebPresentationError::ErrorTypeNoAvailableScreens, error_message));
343 run_loop.RunUntilIdle(); 381 run_loop.RunUntilIdle();
344 } 382 }
345 383
346 TEST_F(PresentationDispatcherTest, TestJoinSessionError) { 384 TEST_F(PresentationDispatcherTest, TestJoinSessionError) {
347 WebString error_message = WebString::fromUTF8("Test error message"); 385 WebString error_message = WebString::fromUTF8("Test error message");
348 base::RunLoop run_loop; 386 base::RunLoop run_loop;
349 387
(...skipping 10 matching lines...) Expand all
360 callback.Run(PresentationSessionInfoPtr(), std::move(error)); 398 callback.Run(PresentationSessionInfoPtr(), std::move(error));
361 })); 399 }));
362 dispatcher_.joinSession( 400 dispatcher_.joinSession(
363 urls_, presentation_id_, 401 urls_, presentation_id_,
364 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( 402 base::MakeUnique<TestWebPresentationConnectionErrorCallback>(
365 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); 403 WebPresentationError::ErrorTypeNoAvailableScreens, error_message));
366 run_loop.RunUntilIdle(); 404 run_loop.RunUntilIdle();
367 } 405 }
368 406
369 TEST_F(PresentationDispatcherTest, TestJoinSession) { 407 TEST_F(PresentationDispatcherTest, TestJoinSession) {
370 base::RunLoop run_loop; 408 TestPresentationConnection connection;
409 EXPECT_FALSE(connection.proxy());
410 {
411 base::RunLoop run_loop;
412 EXPECT_CALL(presentation_service_, ListenForConnectionMessagesInternal(_));
413 EXPECT_CALL(presentation_service_, SetPresentationConnectionInternal(_, _));
414 EXPECT_CALL(presentation_service_, JoinSession(gurls_, _, _))
415 .WillOnce(Invoke(
416 [this](const std::vector<GURL>& presentation_urls,
417 const base::Optional<std::string>& presentation_id,
418 const PresentationService::JoinSessionCallback& callback) {
419 EXPECT_TRUE(presentation_id.has_value());
420 EXPECT_EQ(presentation_id_.utf8(), presentation_id.value());
421 PresentationSessionInfoPtr session_info(
422 PresentationSessionInfo::New());
423 session_info->url = gurl1_;
424 session_info->id = presentation_id_.utf8();
425 callback.Run(std::move(session_info), PresentationErrorPtr());
426 }));
371 427
372 EXPECT_CALL(presentation_service_, JoinSession(gurls_, _, _)) 428 dispatcher_.joinSession(
373 .WillOnce(Invoke([this]( 429 urls_, presentation_id_,
374 const std::vector<GURL>& presentation_urls, 430 base::MakeUnique<TestWebPresentationConnectionCallback>(
375 const base::Optional<std::string>& presentation_id, 431 url1_, presentation_id_, &connection));
376 const PresentationService::JoinSessionCallback& callback) { 432 run_loop.RunUntilIdle();
377 EXPECT_TRUE(presentation_id.has_value()); 433 }
378 EXPECT_EQ(presentation_id_.utf8(), presentation_id.value()); 434 EXPECT_TRUE(connection.proxy());
379 PresentationSessionInfoPtr session_info(PresentationSessionInfo::New());
380 session_info->url = gurl1_;
381 session_info->id = presentation_id_.utf8();
382 callback.Run(std::move(session_info), PresentationErrorPtr());
383 }));
384 dispatcher_.joinSession(
385 urls_, presentation_id_,
386 base::MakeUnique<TestWebPresentationConnectionCallback>(
387 url1_, presentation_id_));
388 run_loop.RunUntilIdle();
389 } 435 }
390 436
391 TEST_F(PresentationDispatcherTest, TestSendString) { 437 TEST_F(PresentationDispatcherTest, TestSendString) {
392 WebString message = WebString::fromUTF8("test message"); 438 WebString message = WebString::fromUTF8("test message");
439 TestPresentationConnection connection;
440 TestPresentationConnectionProxy connection_proxy(&connection);
441
393 base::RunLoop run_loop; 442 base::RunLoop run_loop;
394 EXPECT_CALL(presentation_service_, SendConnectionMessageInternal(_, _, _)) 443 EXPECT_CALL(connection_proxy, SendConnectionMessageInternal(_, _))
395 .WillOnce(Invoke([this, &message]( 444 .WillOnce(Invoke([this, &message](ConnectionMessage* session_message,
396 PresentationSessionInfo* session_info, 445 const OnMessageCallback& callback) {
397 ConnectionMessage* message_request, 446 EXPECT_EQ(blink::mojom::PresentationMessageType::TEXT,
398 const PresentationService::SendConnectionMessageCallback& callback) { 447 session_message->type);
399 EXPECT_EQ(gurl1_, session_info->url); 448 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 })); 449 }));
405 dispatcher_.sendString(url1_, presentation_id_, message, nullptr); 450 dispatcher_.sendString(url1_, presentation_id_, message, &connection_proxy);
406 run_loop.RunUntilIdle(); 451 run_loop.RunUntilIdle();
407 } 452 }
408 453
409 TEST_F(PresentationDispatcherTest, TestSendArrayBuffer) { 454 TEST_F(PresentationDispatcherTest, TestSendArrayBuffer) {
455 TestPresentationConnection connection;
456 TestPresentationConnectionProxy connection_proxy(&connection);
457
410 base::RunLoop run_loop; 458 base::RunLoop run_loop;
411 EXPECT_CALL(presentation_service_, SendConnectionMessageInternal(_, _, _)) 459 EXPECT_CALL(connection_proxy, SendConnectionMessageInternal(_, _))
412 .WillOnce(Invoke([this]( 460 .WillOnce(Invoke([this](ConnectionMessage* message_request,
413 PresentationSessionInfo* session_info, 461 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( 462 std::vector<uint8_t> data(
419 array_buffer_data(), 463 array_buffer_data(),
420 array_buffer_data() + array_buffer_.byteLength()); 464 array_buffer_data() + array_buffer_.byteLength());
421 EXPECT_TRUE(message_request->data.has_value()); 465 EXPECT_TRUE(message_request->data.has_value());
422 EXPECT_EQ(data, message_request->data.value()); 466 EXPECT_EQ(data, message_request->data.value());
423 callback.Run(true);
424 })); 467 }));
425 dispatcher_.sendArrayBuffer(url1_, presentation_id_, array_buffer_data(), 468 dispatcher_.sendArrayBuffer(url1_, presentation_id_, array_buffer_data(),
426 array_buffer_.byteLength(), nullptr); 469 array_buffer_.byteLength(), &connection_proxy);
427 run_loop.RunUntilIdle(); 470 run_loop.RunUntilIdle();
428 } 471 }
429 472
430 TEST_F(PresentationDispatcherTest, TestSendBlobData) { 473 TEST_F(PresentationDispatcherTest, TestSendBlobData) {
474 TestPresentationConnection connection;
475 TestPresentationConnectionProxy connection_proxy(&connection);
476
431 base::RunLoop run_loop; 477 base::RunLoop run_loop;
432 EXPECT_CALL(presentation_service_, SendConnectionMessageInternal(_, _, _)) 478 EXPECT_CALL(connection_proxy, SendConnectionMessageInternal(_, _))
433 .WillOnce(Invoke([this]( 479 .WillOnce(Invoke([this](ConnectionMessage* message_request,
434 PresentationSessionInfo* session_info, 480 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( 481 std::vector<uint8_t> data(
440 array_buffer_data(), 482 array_buffer_data(),
441 array_buffer_data() + array_buffer_.byteLength()); 483 array_buffer_data() + array_buffer_.byteLength());
442 EXPECT_TRUE(message_request->data.has_value()); 484 EXPECT_TRUE(message_request->data.has_value());
443 EXPECT_EQ(data, message_request->data.value()); 485 EXPECT_EQ(data, message_request->data.value());
444 callback.Run(true); 486 callback.Run(true);
445 })); 487 }));
446 dispatcher_.sendBlobData(url1_, presentation_id_, array_buffer_data(), 488 dispatcher_.sendBlobData(url1_, presentation_id_, array_buffer_data(),
447 array_buffer_.byteLength(), nullptr); 489 array_buffer_.byteLength(), &connection_proxy);
448 run_loop.RunUntilIdle(); 490 run_loop.RunUntilIdle();
449 } 491 }
450 492
493 TEST_F(PresentationDispatcherTest, TestOnReceiverConnectionAvailable) {
494 PresentationSessionInfoPtr session_info(PresentationSessionInfo::New());
495 session_info->url = gurl1_;
496 session_info->id = presentation_id_.utf8();
497
498 blink::mojom::PresentationConnectionPtr controller_connection_ptr;
499 TestPresentationConnection controller_connection;
500 TestPresentationConnectionProxy controller_connection_proxy(
501 &controller_connection);
502 mojo::Binding<blink::mojom::PresentationConnection> binding(
503 &controller_connection_proxy,
504 mojo::MakeRequest(&controller_connection_ptr));
505
506 blink::mojom::PresentationConnectionPtr receiver_connection_ptr;
507
508 TestPresentationReceiver receiver;
509 dispatcher_.setReceiver(&receiver);
510
511 base::RunLoop run_loop;
512 EXPECT_CALL(controller_connection,
513 didChangeState(blink::WebPresentationConnectionState::Connected));
514 EXPECT_CALL(receiver.connection_,
515 didChangeState(blink::WebPresentationConnectionState::Connected));
516
517 dispatcher_.OnReceiverConnectionAvailable(
518 std::move(session_info), std::move(controller_connection_ptr),
519 mojo::MakeRequest(&receiver_connection_ptr));
520
521 EXPECT_TRUE(receiver_connection_ptr);
522 EXPECT_TRUE(receiver.connection_.proxy());
523 run_loop.RunUntilIdle();
524 }
525
451 TEST_F(PresentationDispatcherTest, TestCloseSession) { 526 TEST_F(PresentationDispatcherTest, TestCloseSession) {
452 base::RunLoop run_loop; 527 base::RunLoop run_loop;
453 EXPECT_CALL(presentation_service_, 528 EXPECT_CALL(presentation_service_,
454 CloseConnection(gurl1_, presentation_id_.utf8())); 529 CloseConnection(gurl1_, presentation_id_.utf8()));
455 dispatcher_.closeSession(url1_, presentation_id_); 530 dispatcher_.closeSession(url1_, presentation_id_);
456 run_loop.RunUntilIdle(); 531 run_loop.RunUntilIdle();
457 } 532 }
458 533
459 TEST_F(PresentationDispatcherTest, TestTerminateSession) { 534 TEST_F(PresentationDispatcherTest, TestTerminateSession) {
460 base::RunLoop run_loop; 535 base::RunLoop run_loop;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 802
728 for (auto* mock_observer : mock_observers_) 803 for (auto* mock_observer : mock_observers_)
729 EXPECT_CALL(*mock_observer, availabilityChanged(false)); 804 EXPECT_CALL(*mock_observer, availabilityChanged(false));
730 805
731 base::RunLoop run_loop_2; 806 base::RunLoop run_loop_2;
732 ChangeURLState(gurl2_, URLState::Unavailable); 807 ChangeURLState(gurl2_, URLState::Unavailable);
733 run_loop_2.RunUntilIdle(); 808 run_loop_2.RunUntilIdle();
734 } 809 }
735 810
736 } // namespace content 811 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698