| 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" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 MOCK_METHOD2(SetPresentationConnection, | 99 MOCK_METHOD2(SetPresentationConnection, |
| 100 void(const PresentationInfo& presentation_info, | 100 void(const PresentationInfo& presentation_info, |
| 101 PresentationConnection* connection)); | 101 PresentationConnection* connection)); |
| 102 | 102 |
| 103 MOCK_METHOD2(CloseConnection, | 103 MOCK_METHOD2(CloseConnection, |
| 104 void(const GURL& presentation_url, | 104 void(const GURL& presentation_url, |
| 105 const std::string& presentation_id)); | 105 const std::string& presentation_id)); |
| 106 MOCK_METHOD2(Terminate, | 106 MOCK_METHOD2(Terminate, |
| 107 void(const GURL& presentation_url, | 107 void(const GURL& presentation_url, |
| 108 const std::string& presentation_id)); | 108 const std::string& presentation_id)); |
| 109 MOCK_METHOD1(ListenForConnectionMessages, | |
| 110 void(const PresentationInfo& presentation_info)); | |
| 111 }; | 109 }; |
| 112 | 110 |
| 113 class TestPresentationConnectionProxy : public PresentationConnectionProxy { | 111 class TestPresentationConnectionProxy : public PresentationConnectionProxy { |
| 114 public: | 112 public: |
| 115 TestPresentationConnectionProxy(blink::WebPresentationConnection* connection) | 113 TestPresentationConnectionProxy(blink::WebPresentationConnection* connection) |
| 116 : PresentationConnectionProxy(connection) {} | 114 : PresentationConnectionProxy(connection) {} |
| 117 | 115 |
| 118 // PresentationConnectionMessage is move-only. | 116 // PresentationConnectionMessage is move-only. |
| 119 void SendConnectionMessage(PresentationConnectionMessage message, | 117 void SendConnectionMessage(PresentationConnectionMessage message, |
| 120 OnMessageCallback cb) const { | 118 OnMessageCallback cb) const { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 329 |
| 332 private: | 330 private: |
| 333 content::TestBrowserThreadBundle thread_bundle_; | 331 content::TestBrowserThreadBundle thread_bundle_; |
| 334 }; | 332 }; |
| 335 | 333 |
| 336 TEST_F(PresentationDispatcherTest, TestStartPresentation) { | 334 TEST_F(PresentationDispatcherTest, TestStartPresentation) { |
| 337 TestPresentationConnection connection; | 335 TestPresentationConnection connection; |
| 338 EXPECT_FALSE(connection.proxy()); | 336 EXPECT_FALSE(connection.proxy()); |
| 339 { | 337 { |
| 340 base::RunLoop run_loop; | 338 base::RunLoop run_loop; |
| 341 EXPECT_CALL(presentation_service_, ListenForConnectionMessages(_)); | |
| 342 EXPECT_CALL(presentation_service_, SetPresentationConnection(_, _)); | 339 EXPECT_CALL(presentation_service_, SetPresentationConnection(_, _)); |
| 343 EXPECT_CALL(presentation_service_, StartPresentationInternal(gurls_, _)) | 340 EXPECT_CALL(presentation_service_, StartPresentationInternal(gurls_, _)) |
| 344 .WillOnce(Invoke( | 341 .WillOnce(Invoke( |
| 345 [this](const std::vector<GURL>& presentation_urls, | 342 [this](const std::vector<GURL>& presentation_urls, |
| 346 PresentationService::StartPresentationCallback& callback) { | 343 PresentationService::StartPresentationCallback& callback) { |
| 347 PresentationInfo presentation_info(gurl1_, | 344 PresentationInfo presentation_info(gurl1_, |
| 348 presentation_id_.Utf8()); | 345 presentation_id_.Utf8()); |
| 349 std::move(callback).Run(presentation_info, base::nullopt); | 346 std::move(callback).Run(presentation_info, base::nullopt); |
| 350 })); | 347 })); |
| 351 | 348 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( | 400 base::MakeUnique<TestWebPresentationConnectionErrorCallback>( |
| 404 WebPresentationError::kErrorTypeNoAvailableScreens, error_message)); | 401 WebPresentationError::kErrorTypeNoAvailableScreens, error_message)); |
| 405 run_loop.RunUntilIdle(); | 402 run_loop.RunUntilIdle(); |
| 406 } | 403 } |
| 407 | 404 |
| 408 TEST_F(PresentationDispatcherTest, TestReconnectPresentation) { | 405 TEST_F(PresentationDispatcherTest, TestReconnectPresentation) { |
| 409 TestPresentationConnection connection; | 406 TestPresentationConnection connection; |
| 410 EXPECT_FALSE(connection.proxy()); | 407 EXPECT_FALSE(connection.proxy()); |
| 411 { | 408 { |
| 412 base::RunLoop run_loop; | 409 base::RunLoop run_loop; |
| 413 EXPECT_CALL(presentation_service_, ListenForConnectionMessages(_)); | |
| 414 EXPECT_CALL(presentation_service_, SetPresentationConnection(_, _)); | 410 EXPECT_CALL(presentation_service_, SetPresentationConnection(_, _)); |
| 415 EXPECT_CALL(presentation_service_, | 411 EXPECT_CALL(presentation_service_, |
| 416 ReconnectPresentationInternal(gurls_, _, _)) | 412 ReconnectPresentationInternal(gurls_, _, _)) |
| 417 .WillOnce(Invoke( | 413 .WillOnce(Invoke( |
| 418 [this]( | 414 [this]( |
| 419 const std::vector<GURL>& presentation_urls, | 415 const std::vector<GURL>& presentation_urls, |
| 420 const base::Optional<std::string>& presentation_id, | 416 const base::Optional<std::string>& presentation_id, |
| 421 PresentationService::ReconnectPresentationCallback& callback) { | 417 PresentationService::ReconnectPresentationCallback& callback) { |
| 422 EXPECT_TRUE(presentation_id.has_value()); | 418 EXPECT_TRUE(presentation_id.has_value()); |
| 423 EXPECT_EQ(presentation_id_.Utf8(), presentation_id.value()); | 419 EXPECT_EQ(presentation_id_.Utf8(), presentation_id.value()); |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 EXPECT_CALL(*mock_observer, | 865 EXPECT_CALL(*mock_observer, |
| 870 AvailabilityChanged(ScreenAvailability::SOURCE_NOT_SUPPORTED)); | 866 AvailabilityChanged(ScreenAvailability::SOURCE_NOT_SUPPORTED)); |
| 871 } | 867 } |
| 872 | 868 |
| 873 base::RunLoop run_loop_3; | 869 base::RunLoop run_loop_3; |
| 874 ChangeURLState(gurl2_, ScreenAvailability::SOURCE_NOT_SUPPORTED); | 870 ChangeURLState(gurl2_, ScreenAvailability::SOURCE_NOT_SUPPORTED); |
| 875 run_loop_3.RunUntilIdle(); | 871 run_loop_3.RunUntilIdle(); |
| 876 } | 872 } |
| 877 | 873 |
| 878 } // namespace content | 874 } // namespace content |
| OLD | NEW |