| 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" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 TestPresentationConnectionProxy(blink::WebPresentationConnection* connection) | 117 TestPresentationConnectionProxy(blink::WebPresentationConnection* connection) |
| 118 : PresentationConnectionProxy(connection) {} | 118 : PresentationConnectionProxy(connection) {} |
| 119 | 119 |
| 120 void SendConnectionMessage(blink::mojom::ConnectionMessagePtr session_message, | 120 void SendConnectionMessage(blink::mojom::ConnectionMessagePtr session_message, |
| 121 const OnMessageCallback& callback) const override { | 121 const OnMessageCallback& callback) const override { |
| 122 SendConnectionMessageInternal(session_message.get(), callback); | 122 SendConnectionMessageInternal(session_message.get(), callback); |
| 123 } | 123 } |
| 124 MOCK_CONST_METHOD2(SendConnectionMessageInternal, | 124 MOCK_CONST_METHOD2(SendConnectionMessageInternal, |
| 125 void(blink::mojom::ConnectionMessage*, | 125 void(blink::mojom::ConnectionMessage*, |
| 126 const OnMessageCallback&)); | 126 const OnMessageCallback&)); |
| 127 MOCK_CONST_METHOD0(close, void()); |
| 127 }; | 128 }; |
| 128 | 129 |
| 129 class TestPresentationReceiver : public blink::WebPresentationReceiver { | 130 class TestPresentationReceiver : public blink::WebPresentationReceiver { |
| 130 public: | 131 public: |
| 131 blink::WebPresentationConnection* onReceiverConnectionAvailable( | 132 blink::WebPresentationConnection* onReceiverConnectionAvailable( |
| 132 const blink::WebPresentationSessionInfo&) override { | 133 const blink::WebPresentationSessionInfo&) override { |
| 133 return &connection_; | 134 return &connection_; |
| 134 } | 135 } |
| 135 | 136 |
| 136 TestPresentationConnection connection_; | 137 TestPresentationConnection connection_; |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 std::move(session_info), std::move(controller_connection_ptr), | 500 std::move(session_info), std::move(controller_connection_ptr), |
| 500 mojo::MakeRequest(&receiver_connection_ptr)); | 501 mojo::MakeRequest(&receiver_connection_ptr)); |
| 501 | 502 |
| 502 EXPECT_TRUE(receiver_connection_ptr); | 503 EXPECT_TRUE(receiver_connection_ptr); |
| 503 EXPECT_TRUE(receiver.connection_.proxy()); | 504 EXPECT_TRUE(receiver.connection_.proxy()); |
| 504 run_loop.RunUntilIdle(); | 505 run_loop.RunUntilIdle(); |
| 505 } | 506 } |
| 506 | 507 |
| 507 TEST_F(PresentationDispatcherTest, TestCloseSession) { | 508 TEST_F(PresentationDispatcherTest, TestCloseSession) { |
| 508 base::RunLoop run_loop; | 509 base::RunLoop run_loop; |
| 510 TestPresentationConnection connection; |
| 511 TestPresentationConnectionProxy test_proxy(&connection); |
| 512 EXPECT_CALL(test_proxy, close()); |
| 509 EXPECT_CALL(presentation_service_, | 513 EXPECT_CALL(presentation_service_, |
| 510 CloseConnection(gurl1_, presentation_id_.utf8())); | 514 CloseConnection(gurl1_, presentation_id_.utf8())); |
| 511 dispatcher_.closeSession(url1_, presentation_id_); | 515 dispatcher_.closeSession(url1_, presentation_id_, &test_proxy); |
| 512 run_loop.RunUntilIdle(); | 516 run_loop.RunUntilIdle(); |
| 513 } | 517 } |
| 514 | 518 |
| 515 TEST_F(PresentationDispatcherTest, TestTerminateSession) { | 519 TEST_F(PresentationDispatcherTest, TestTerminateSession) { |
| 516 base::RunLoop run_loop; | 520 base::RunLoop run_loop; |
| 517 EXPECT_CALL(presentation_service_, | 521 EXPECT_CALL(presentation_service_, |
| 518 Terminate(gurl1_, presentation_id_.utf8())); | 522 Terminate(gurl1_, presentation_id_.utf8())); |
| 519 dispatcher_.terminateSession(url1_, presentation_id_); | 523 dispatcher_.terminateSession(url1_, presentation_id_); |
| 520 run_loop.RunUntilIdle(); | 524 run_loop.RunUntilIdle(); |
| 521 } | 525 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 787 |
| 784 for (auto* mock_observer : mock_observers_) | 788 for (auto* mock_observer : mock_observers_) |
| 785 EXPECT_CALL(*mock_observer, availabilityChanged(false)); | 789 EXPECT_CALL(*mock_observer, availabilityChanged(false)); |
| 786 | 790 |
| 787 base::RunLoop run_loop_2; | 791 base::RunLoop run_loop_2; |
| 788 ChangeURLState(gurl2_, URLState::Unavailable); | 792 ChangeURLState(gurl2_, URLState::Unavailable); |
| 789 run_loop_2.RunUntilIdle(); | 793 run_loop_2.RunUntilIdle(); |
| 790 } | 794 } |
| 791 | 795 |
| 792 } // namespace content | 796 } // namespace content |
| OLD | NEW |