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/common/presentation_connection_message.h" | 9 #include "content/public/common/presentation_connection_message.h" |
10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
11 #include "content/renderer/presentation/presentation_connection_proxy.h" | 11 #include "content/renderer/presentation/presentation_connection_proxy.h" |
12 #include "content/renderer/presentation/presentation_dispatcher.h" | 12 #include "content/renderer/presentation/presentation_dispatcher.h" |
13 #include "content/renderer/presentation/test_presentation_connection.h" | 13 #include "content/renderer/presentation/test_presentation_connection.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nAvailabilityObserver.h" | 15 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nAvailabilityObserver.h" |
16 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnection.h" | 16 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnection.h" |
17 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnectionCallbacks.h" | 17 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnectionCallbacks.h" |
18 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" | 18 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" |
19 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nError.h" | 19 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nError.h" |
| 20 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nInfo.h" |
20 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nReceiver.h" | 21 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nReceiver.h" |
21 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nSessionInfo.h" | |
22 #include "third_party/WebKit/public/web/WebArrayBuffer.h" | 22 #include "third_party/WebKit/public/web/WebArrayBuffer.h" |
23 | 23 |
24 using ::testing::_; | 24 using ::testing::_; |
25 using ::testing::Invoke; | 25 using ::testing::Invoke; |
26 using blink::WebArrayBuffer; | 26 using blink::WebArrayBuffer; |
27 using blink::WebPresentationAvailabilityCallbacks; | 27 using blink::WebPresentationAvailabilityCallbacks; |
28 using blink::WebPresentationAvailabilityObserver; | 28 using blink::WebPresentationAvailabilityObserver; |
29 using blink::WebPresentationConnectionCallbacks; | 29 using blink::WebPresentationConnectionCallbacks; |
30 using blink::WebPresentationError; | 30 using blink::WebPresentationError; |
31 using blink::WebPresentationSessionInfo; | 31 using blink::WebPresentationInfo; |
32 using blink::WebString; | 32 using blink::WebString; |
33 using blink::WebURL; | 33 using blink::WebURL; |
34 using blink::WebVector; | 34 using blink::WebVector; |
35 using blink::mojom::PresentationConnection; | 35 using blink::mojom::PresentationConnection; |
36 using blink::mojom::PresentationService; | 36 using blink::mojom::PresentationService; |
37 using blink::mojom::PresentationServiceClientPtr; | 37 using blink::mojom::PresentationServiceClientPtr; |
38 | 38 |
39 // TODO(crbug.com/576808): Add test cases for the following: | 39 // TODO(crbug.com/576808): Add test cases for the following: |
40 // - State changes | 40 // - State changes |
41 // - Messages received | 41 // - Messages received |
(...skipping 18 matching lines...) Expand all Loading... |
60 }; | 60 }; |
61 | 61 |
62 class MockPresentationService : public PresentationService { | 62 class MockPresentationService : public PresentationService { |
63 public: | 63 public: |
64 void SetClient(PresentationServiceClientPtr client) override {} | 64 void SetClient(PresentationServiceClientPtr client) override {} |
65 MOCK_METHOD1(SetDefaultPresentationUrls, | 65 MOCK_METHOD1(SetDefaultPresentationUrls, |
66 void(const std::vector<GURL>& presentation_urls)); | 66 void(const std::vector<GURL>& presentation_urls)); |
67 MOCK_METHOD1(ListenForScreenAvailability, void(const GURL& availability_url)); | 67 MOCK_METHOD1(ListenForScreenAvailability, void(const GURL& availability_url)); |
68 MOCK_METHOD1(StopListeningForScreenAvailability, | 68 MOCK_METHOD1(StopListeningForScreenAvailability, |
69 void(const GURL& availability_url)); | 69 void(const GURL& availability_url)); |
70 MOCK_METHOD2(StartSession, | 70 MOCK_METHOD2(StartPresentation, |
71 void(const std::vector<GURL>& presentation_urls, | 71 void(const std::vector<GURL>& presentation_urls, |
72 const StartSessionCallback& callback)); | 72 const StartPresentationCallback& callback)); |
73 MOCK_METHOD3(JoinSession, | 73 MOCK_METHOD3(ReconnectPresentation, |
74 void(const std::vector<GURL>& presentation_urls, | 74 void(const std::vector<GURL>& presentation_urls, |
75 const base::Optional<std::string>& presentation_id, | 75 const base::Optional<std::string>& presentation_id, |
76 const JoinSessionCallback& callback)); | 76 const ReconnectPresentationCallback& callback)); |
| 77 void SetPresentationConnection( |
| 78 const PresentationInfo& presentation_info, |
| 79 blink::mojom::PresentationConnectionPtr controller_conn_ptr, |
| 80 blink::mojom::PresentationConnectionRequest receiver_conn_request) |
| 81 override { |
| 82 SetPresentationConnection(presentation_info, controller_conn_ptr.get()); |
| 83 } |
| 84 MOCK_METHOD2(SetPresentationConnection, |
| 85 void(const PresentationInfo& presentation_info, |
| 86 PresentationConnection* connection)); |
77 MOCK_METHOD2(CloseConnection, | 87 MOCK_METHOD2(CloseConnection, |
78 void(const GURL& presentation_url, | 88 void(const GURL& presentation_url, |
79 const std::string& presentation_id)); | 89 const std::string& presentation_id)); |
80 MOCK_METHOD2(Terminate, | 90 MOCK_METHOD2(Terminate, |
81 void(const GURL& presentation_url, | 91 void(const GURL& presentation_url, |
82 const std::string& presentation_id)); | 92 const std::string& presentation_id)); |
83 | |
84 MOCK_METHOD1(ListenForConnectionMessages, | 93 MOCK_METHOD1(ListenForConnectionMessages, |
85 void(const PresentationSessionInfo& session_info)); | 94 void(const PresentationInfo& presentation_info)); |
86 | |
87 void SetPresentationConnection( | |
88 const PresentationSessionInfo& session_info, | |
89 blink::mojom::PresentationConnectionPtr controller_conn_ptr, | |
90 blink::mojom::PresentationConnectionRequest receiver_conn_request) | |
91 override { | |
92 SetPresentationConnection(session_info, controller_conn_ptr.get()); | |
93 } | |
94 MOCK_METHOD2(SetPresentationConnection, | |
95 void(const PresentationSessionInfo& session_info, | |
96 PresentationConnection* connection)); | |
97 }; | 95 }; |
98 | 96 |
99 class TestPresentationConnectionProxy : public PresentationConnectionProxy { | 97 class TestPresentationConnectionProxy : public PresentationConnectionProxy { |
100 public: | 98 public: |
101 TestPresentationConnectionProxy(blink::WebPresentationConnection* connection) | 99 TestPresentationConnectionProxy(blink::WebPresentationConnection* connection) |
102 : PresentationConnectionProxy(connection) {} | 100 : PresentationConnectionProxy(connection) {} |
103 | 101 |
104 // PresentationConnectionMessage is move-only. | 102 // PresentationConnectionMessage is move-only. |
105 void SendConnectionMessage(PresentationConnectionMessage message, | 103 void SendConnectionMessage(PresentationConnectionMessage message, |
106 const OnMessageCallback& cb) const { | 104 const OnMessageCallback& cb) const { |
107 SendConnectionMessageInternal(message, cb); | 105 SendConnectionMessageInternal(message, cb); |
108 } | 106 } |
109 MOCK_CONST_METHOD2(SendConnectionMessageInternal, | 107 MOCK_CONST_METHOD2(SendConnectionMessageInternal, |
110 void(const PresentationConnectionMessage&, | 108 void(const PresentationConnectionMessage&, |
111 const OnMessageCallback&)); | 109 const OnMessageCallback&)); |
112 MOCK_CONST_METHOD0(close, void()); | 110 MOCK_CONST_METHOD0(close, void()); |
113 }; | 111 }; |
114 | 112 |
115 class TestPresentationReceiver : public blink::WebPresentationReceiver { | 113 class TestPresentationReceiver : public blink::WebPresentationReceiver { |
116 public: | 114 public: |
117 blink::WebPresentationConnection* onReceiverConnectionAvailable( | 115 blink::WebPresentationConnection* onReceiverConnectionAvailable( |
118 const blink::WebPresentationSessionInfo&) override { | 116 const blink::WebPresentationInfo&) override { |
119 return &connection_; | 117 return &connection_; |
120 } | 118 } |
121 | 119 |
122 MOCK_METHOD1(didChangeSessionState, | 120 MOCK_METHOD1(didChangeConnectionState, |
123 void(blink::WebPresentationConnectionState)); | 121 void(blink::WebPresentationConnectionState)); |
124 MOCK_METHOD0(terminateConnection, void()); | 122 MOCK_METHOD0(terminateConnection, void()); |
125 | 123 |
126 TestPresentationConnection connection_; | 124 TestPresentationConnection connection_; |
127 }; | 125 }; |
128 | 126 |
129 class MockPresentationAvailabilityCallbacks | 127 class MockPresentationAvailabilityCallbacks |
130 : public blink::WebCallbacks<bool, const blink::WebPresentationError&> { | 128 : public blink::WebCallbacks<bool, const blink::WebPresentationError&> { |
131 public: | 129 public: |
132 MOCK_METHOD1(onSuccess, void(bool value)); | 130 MOCK_METHOD1(onSuccess, void(bool value)); |
133 MOCK_METHOD1(onError, void(const blink::WebPresentationError&)); | 131 MOCK_METHOD1(onError, void(const blink::WebPresentationError&)); |
134 }; | 132 }; |
135 | 133 |
136 class TestWebPresentationConnectionCallback | 134 class TestWebPresentationConnectionCallback |
137 : public WebPresentationConnectionCallbacks { | 135 : public WebPresentationConnectionCallbacks { |
138 public: | 136 public: |
139 // Does not take ownership of |connection|. | 137 // Does not take ownership of |connection|. |
140 TestWebPresentationConnectionCallback(WebURL url, | 138 TestWebPresentationConnectionCallback(WebURL url, |
141 WebString id, | 139 WebString id, |
142 TestPresentationConnection* connection) | 140 TestPresentationConnection* connection) |
143 : url_(url), id_(id), callback_called_(false), connection_(connection) {} | 141 : url_(url), id_(id), callback_called_(false), connection_(connection) {} |
144 ~TestWebPresentationConnectionCallback() override { | 142 ~TestWebPresentationConnectionCallback() override { |
145 EXPECT_TRUE(callback_called_); | 143 EXPECT_TRUE(callback_called_); |
146 } | 144 } |
147 | 145 |
148 void onSuccess(const WebPresentationSessionInfo& info) override { | 146 void onSuccess(const WebPresentationInfo& info) override { |
149 callback_called_ = true; | 147 callback_called_ = true; |
150 EXPECT_EQ(info.url, url_); | 148 EXPECT_EQ(info.url, url_); |
151 EXPECT_EQ(info.id, id_); | 149 EXPECT_EQ(info.id, id_); |
152 } | 150 } |
153 | 151 |
154 blink::WebPresentationConnection* getConnection() override { | 152 blink::WebPresentationConnection* getConnection() override { |
155 return connection_; | 153 return connection_; |
156 } | 154 } |
157 | 155 |
158 private: | 156 private: |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 MockPresentationAvailabilityObserver mock_observer3_; | 305 MockPresentationAvailabilityObserver mock_observer3_; |
308 std::vector<MockPresentationAvailabilityObserver*> mock_observers_; | 306 std::vector<MockPresentationAvailabilityObserver*> mock_observers_; |
309 | 307 |
310 MockPresentationService presentation_service_; | 308 MockPresentationService presentation_service_; |
311 TestPresentationDispatcher dispatcher_; | 309 TestPresentationDispatcher dispatcher_; |
312 | 310 |
313 private: | 311 private: |
314 content::TestBrowserThreadBundle thread_bundle_; | 312 content::TestBrowserThreadBundle thread_bundle_; |
315 }; | 313 }; |
316 | 314 |
317 TEST_F(PresentationDispatcherTest, TestStartSession) { | 315 TEST_F(PresentationDispatcherTest, TestStartPresentation) { |
318 TestPresentationConnection connection; | 316 TestPresentationConnection connection; |
319 EXPECT_FALSE(connection.proxy()); | 317 EXPECT_FALSE(connection.proxy()); |
320 { | 318 { |
321 base::RunLoop run_loop; | 319 base::RunLoop run_loop; |
322 EXPECT_CALL(presentation_service_, ListenForConnectionMessages(_)); | 320 EXPECT_CALL(presentation_service_, ListenForConnectionMessages(_)); |
323 EXPECT_CALL(presentation_service_, SetPresentationConnection(_, _)); | 321 EXPECT_CALL(presentation_service_, SetPresentationConnection(_, _)); |
324 EXPECT_CALL(presentation_service_, StartSession(gurls_, _)) | 322 EXPECT_CALL(presentation_service_, StartPresentation(gurls_, _)) |
325 .WillOnce(Invoke([this]( | 323 .WillOnce( |
326 const std::vector<GURL>& presentation_urls, | 324 Invoke([this](const std::vector<GURL>& presentation_urls, |
327 const PresentationService::StartSessionCallback& callback) { | 325 const PresentationService::StartPresentationCallback& |
328 PresentationSessionInfo session_info(gurl1_, presentation_id_.utf8()); | 326 callback) { |
329 callback.Run(session_info, base::nullopt); | 327 PresentationInfo presentation_info(gurl1_, |
330 })); | 328 presentation_id_.utf8()); |
| 329 callback.Run(presentation_info, base::nullopt); |
| 330 })); |
331 | 331 |
332 dispatcher_.startSession( | 332 dispatcher_.startPresentation( |
333 urls_, base::MakeUnique<TestWebPresentationConnectionCallback>( | 333 urls_, base::MakeUnique<TestWebPresentationConnectionCallback>( |
334 url1_, presentation_id_, &connection)); | 334 url1_, presentation_id_, &connection)); |
335 run_loop.RunUntilIdle(); | 335 run_loop.RunUntilIdle(); |
336 } | 336 } |
337 EXPECT_TRUE(connection.proxy()); | 337 EXPECT_TRUE(connection.proxy()); |
338 } | 338 } |
339 | 339 |
340 TEST_F(PresentationDispatcherTest, TestStartSessionError) { | 340 TEST_F(PresentationDispatcherTest, TestStartPresentationError) { |
341 WebString error_message = WebString::fromUTF8("Test error message"); | 341 WebString error_message = WebString::fromUTF8("Test error message"); |
342 base::RunLoop run_loop; | 342 base::RunLoop run_loop; |
343 | 343 |
344 EXPECT_CALL(presentation_service_, StartSession(gurls_, _)) | 344 EXPECT_CALL(presentation_service_, StartPresentation(gurls_, _)) |
345 .WillOnce(Invoke([&error_message]( | 345 .WillOnce(Invoke([&error_message]( |
346 const std::vector<GURL>& presentation_urls, | 346 const std::vector<GURL>& presentation_urls, |
347 const PresentationService::StartSessionCallback& callback) { | 347 const PresentationService::StartPresentationCallback& |
| 348 callback) { |
348 callback.Run( | 349 callback.Run( |
349 base::nullopt, | 350 base::nullopt, |
350 PresentationError(content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, | 351 PresentationError(content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, |
351 error_message.utf8())); | 352 error_message.utf8())); |
352 })); | 353 })); |
353 dispatcher_.startSession( | 354 dispatcher_.startPresentation( |
354 urls_, | 355 urls_, |
355 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( | 356 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( |
356 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); | 357 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); |
357 run_loop.RunUntilIdle(); | 358 run_loop.RunUntilIdle(); |
358 } | 359 } |
359 | 360 |
360 TEST_F(PresentationDispatcherTest, TestJoinSessionError) { | 361 TEST_F(PresentationDispatcherTest, TestReconnectPresentationError) { |
361 WebString error_message = WebString::fromUTF8("Test error message"); | 362 WebString error_message = WebString::fromUTF8("Test error message"); |
362 base::RunLoop run_loop; | 363 base::RunLoop run_loop; |
363 | 364 |
364 EXPECT_CALL(presentation_service_, JoinSession(gurls_, _, _)) | 365 EXPECT_CALL(presentation_service_, ReconnectPresentation(gurls_, _, _)) |
365 .WillOnce(Invoke([this, &error_message]( | 366 .WillOnce( |
366 const std::vector<GURL>& presentation_urls, | 367 Invoke([this, &error_message]( |
367 const base::Optional<std::string>& presentation_id, | 368 const std::vector<GURL>& presentation_urls, |
368 const PresentationService::JoinSessionCallback& callback) { | 369 const base::Optional<std::string>& presentation_id, |
369 EXPECT_TRUE(presentation_id.has_value()); | 370 const PresentationService::ReconnectPresentationCallback& |
370 EXPECT_EQ(presentation_id_.utf8(), presentation_id.value()); | 371 callback) { |
371 callback.Run( | 372 EXPECT_TRUE(presentation_id.has_value()); |
372 base::nullopt, | 373 EXPECT_EQ(presentation_id_.utf8(), presentation_id.value()); |
373 PresentationError(content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, | 374 callback.Run(base::nullopt, |
374 error_message.utf8())); | 375 PresentationError( |
375 })); | 376 content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, |
376 dispatcher_.joinSession( | 377 error_message.utf8())); |
| 378 })); |
| 379 dispatcher_.reconnectPresentation( |
377 urls_, presentation_id_, | 380 urls_, presentation_id_, |
378 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( | 381 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( |
379 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); | 382 WebPresentationError::ErrorTypeNoAvailableScreens, error_message)); |
380 run_loop.RunUntilIdle(); | 383 run_loop.RunUntilIdle(); |
381 } | 384 } |
382 | 385 |
383 TEST_F(PresentationDispatcherTest, TestJoinSession) { | 386 TEST_F(PresentationDispatcherTest, TestReconnectPresentation) { |
384 TestPresentationConnection connection; | 387 TestPresentationConnection connection; |
385 EXPECT_FALSE(connection.proxy()); | 388 EXPECT_FALSE(connection.proxy()); |
386 { | 389 { |
387 base::RunLoop run_loop; | 390 base::RunLoop run_loop; |
388 EXPECT_CALL(presentation_service_, ListenForConnectionMessages(_)); | 391 EXPECT_CALL(presentation_service_, ListenForConnectionMessages(_)); |
389 EXPECT_CALL(presentation_service_, SetPresentationConnection(_, _)); | 392 EXPECT_CALL(presentation_service_, SetPresentationConnection(_, _)); |
390 EXPECT_CALL(presentation_service_, JoinSession(gurls_, _, _)) | 393 EXPECT_CALL(presentation_service_, ReconnectPresentation(gurls_, _, _)) |
391 .WillOnce(Invoke([this]( | 394 .WillOnce(Invoke( |
392 const std::vector<GURL>& presentation_urls, | 395 [this](const std::vector<GURL>& presentation_urls, |
393 const base::Optional<std::string>& presentation_id, | 396 const base::Optional<std::string>& presentation_id, |
394 const PresentationService::JoinSessionCallback& callback) { | 397 const PresentationService::ReconnectPresentationCallback& |
395 EXPECT_TRUE(presentation_id.has_value()); | 398 callback) { |
396 EXPECT_EQ(presentation_id_.utf8(), presentation_id.value()); | 399 EXPECT_TRUE(presentation_id.has_value()); |
397 callback.Run(PresentationSessionInfo(gurl1_, presentation_id_.utf8()), | 400 EXPECT_EQ(presentation_id_.utf8(), presentation_id.value()); |
398 base::nullopt); | 401 callback.Run(PresentationInfo(gurl1_, presentation_id_.utf8()), |
399 })); | 402 base::nullopt); |
| 403 })); |
400 | 404 |
401 dispatcher_.joinSession( | 405 dispatcher_.reconnectPresentation( |
402 urls_, presentation_id_, | 406 urls_, presentation_id_, |
403 base::MakeUnique<TestWebPresentationConnectionCallback>( | 407 base::MakeUnique<TestWebPresentationConnectionCallback>( |
404 url1_, presentation_id_, &connection)); | 408 url1_, presentation_id_, &connection)); |
405 run_loop.RunUntilIdle(); | 409 run_loop.RunUntilIdle(); |
406 } | 410 } |
407 EXPECT_TRUE(connection.proxy()); | 411 EXPECT_TRUE(connection.proxy()); |
408 } | 412 } |
409 | 413 |
410 TEST_F(PresentationDispatcherTest, TestSendString) { | 414 TEST_F(PresentationDispatcherTest, TestSendString) { |
411 WebString message = WebString::fromUTF8("test message"); | 415 WebString message = WebString::fromUTF8("test message"); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 const OnMessageCallback& callback) { | 465 const OnMessageCallback& callback) { |
462 EXPECT_EQ(message_request, expected_message); | 466 EXPECT_EQ(message_request, expected_message); |
463 callback.Run(true); | 467 callback.Run(true); |
464 })); | 468 })); |
465 dispatcher_.sendBlobData(url1_, presentation_id_, array_buffer_data(), | 469 dispatcher_.sendBlobData(url1_, presentation_id_, array_buffer_data(), |
466 array_buffer_.byteLength(), &connection_proxy); | 470 array_buffer_.byteLength(), &connection_proxy); |
467 run_loop.RunUntilIdle(); | 471 run_loop.RunUntilIdle(); |
468 } | 472 } |
469 | 473 |
470 TEST_F(PresentationDispatcherTest, TestOnReceiverConnectionAvailable) { | 474 TEST_F(PresentationDispatcherTest, TestOnReceiverConnectionAvailable) { |
471 PresentationSessionInfo session_info(gurl1_, presentation_id_.utf8()); | 475 PresentationInfo presentation_info(gurl1_, presentation_id_.utf8()); |
472 | 476 |
473 blink::mojom::PresentationConnectionPtr controller_connection_ptr; | 477 blink::mojom::PresentationConnectionPtr controller_connection_ptr; |
474 TestPresentationConnection controller_connection; | 478 TestPresentationConnection controller_connection; |
475 TestPresentationConnectionProxy controller_connection_proxy( | 479 TestPresentationConnectionProxy controller_connection_proxy( |
476 &controller_connection); | 480 &controller_connection); |
477 mojo::Binding<blink::mojom::PresentationConnection> binding( | 481 mojo::Binding<blink::mojom::PresentationConnection> binding( |
478 &controller_connection_proxy, | 482 &controller_connection_proxy, |
479 mojo::MakeRequest(&controller_connection_ptr)); | 483 mojo::MakeRequest(&controller_connection_ptr)); |
480 | 484 |
481 blink::mojom::PresentationConnectionPtr receiver_connection_ptr; | 485 blink::mojom::PresentationConnectionPtr receiver_connection_ptr; |
482 | 486 |
483 TestPresentationReceiver receiver; | 487 TestPresentationReceiver receiver; |
484 dispatcher_.setReceiver(&receiver); | 488 dispatcher_.setReceiver(&receiver); |
485 | 489 |
486 base::RunLoop run_loop; | 490 base::RunLoop run_loop; |
487 EXPECT_CALL(controller_connection, | 491 EXPECT_CALL(controller_connection, |
488 didChangeState(blink::WebPresentationConnectionState::Connected)); | 492 didChangeState(blink::WebPresentationConnectionState::Connected)); |
489 EXPECT_CALL(receiver.connection_, | 493 EXPECT_CALL(receiver.connection_, |
490 didChangeState(blink::WebPresentationConnectionState::Connected)); | 494 didChangeState(blink::WebPresentationConnectionState::Connected)); |
491 | 495 |
492 dispatcher_.OnReceiverConnectionAvailable( | 496 dispatcher_.OnReceiverConnectionAvailable( |
493 std::move(session_info), std::move(controller_connection_ptr), | 497 std::move(presentation_info), std::move(controller_connection_ptr), |
494 mojo::MakeRequest(&receiver_connection_ptr)); | 498 mojo::MakeRequest(&receiver_connection_ptr)); |
495 | 499 |
496 EXPECT_TRUE(receiver_connection_ptr); | 500 EXPECT_TRUE(receiver_connection_ptr); |
497 EXPECT_TRUE(receiver.connection_.proxy()); | 501 EXPECT_TRUE(receiver.connection_.proxy()); |
498 run_loop.RunUntilIdle(); | 502 run_loop.RunUntilIdle(); |
499 } | 503 } |
500 | 504 |
501 TEST_F(PresentationDispatcherTest, TestCloseSession) { | 505 TEST_F(PresentationDispatcherTest, TestCloseConnection) { |
502 base::RunLoop run_loop; | 506 base::RunLoop run_loop; |
503 TestPresentationConnection connection; | 507 TestPresentationConnection connection; |
504 TestPresentationConnectionProxy test_proxy(&connection); | 508 TestPresentationConnectionProxy test_proxy(&connection); |
505 EXPECT_CALL(test_proxy, close()); | 509 EXPECT_CALL(test_proxy, close()); |
506 EXPECT_CALL(presentation_service_, | 510 EXPECT_CALL(presentation_service_, |
507 CloseConnection(gurl1_, presentation_id_.utf8())); | 511 CloseConnection(gurl1_, presentation_id_.utf8())); |
508 dispatcher_.closeSession(url1_, presentation_id_, &test_proxy); | 512 dispatcher_.closeConnection(url1_, presentation_id_, &test_proxy); |
509 run_loop.RunUntilIdle(); | 513 run_loop.RunUntilIdle(); |
510 } | 514 } |
511 | 515 |
512 TEST_F(PresentationDispatcherTest, TestTerminateSession) { | 516 TEST_F(PresentationDispatcherTest, TestTerminatePresentation) { |
513 base::RunLoop run_loop; | 517 base::RunLoop run_loop; |
514 EXPECT_CALL(presentation_service_, | 518 EXPECT_CALL(presentation_service_, |
515 Terminate(gurl1_, presentation_id_.utf8())); | 519 Terminate(gurl1_, presentation_id_.utf8())); |
516 dispatcher_.terminateConnection(url1_, presentation_id_); | 520 dispatcher_.terminatePresentation(url1_, presentation_id_); |
517 run_loop.RunUntilIdle(); | 521 run_loop.RunUntilIdle(); |
518 } | 522 } |
519 | 523 |
520 TEST_F(PresentationDispatcherTest, TestListenForScreenAvailability) { | 524 TEST_F(PresentationDispatcherTest, TestListenForScreenAvailability) { |
521 base::RunLoop run_loop1; | 525 base::RunLoop run_loop1; |
522 for (const auto& gurl : gurls_) { | 526 for (const auto& gurl : gurls_) { |
523 EXPECT_CALL(presentation_service_, ListenForScreenAvailability(gurl)); | 527 EXPECT_CALL(presentation_service_, ListenForScreenAvailability(gurl)); |
524 EXPECT_CALL(presentation_service_, | 528 EXPECT_CALL(presentation_service_, |
525 StopListeningForScreenAvailability(gurl)); | 529 StopListeningForScreenAvailability(gurl)); |
526 } | 530 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 | 784 |
781 for (auto* mock_observer : mock_observers_) | 785 for (auto* mock_observer : mock_observers_) |
782 EXPECT_CALL(*mock_observer, availabilityChanged(false)); | 786 EXPECT_CALL(*mock_observer, availabilityChanged(false)); |
783 | 787 |
784 base::RunLoop run_loop_2; | 788 base::RunLoop run_loop_2; |
785 ChangeURLState(gurl2_, URLState::Unavailable); | 789 ChangeURLState(gurl2_, URLState::Unavailable); |
786 run_loop_2.RunUntilIdle(); | 790 run_loop_2.RunUntilIdle(); |
787 } | 791 } |
788 | 792 |
789 } // namespace content | 793 } // namespace content |
OLD | NEW |