| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 const std::string& presentation_url, | 96 const std::string& presentation_url, |
| 97 const PresentationSessionStartedCallback& success_cb, | 97 const PresentationSessionStartedCallback& success_cb, |
| 98 const PresentationSessionErrorCallback& error_cb)); | 98 const PresentationSessionErrorCallback& error_cb)); |
| 99 MOCK_METHOD6(JoinSession, | 99 MOCK_METHOD6(JoinSession, |
| 100 void(int render_process_id, | 100 void(int render_process_id, |
| 101 int render_frame_id, | 101 int render_frame_id, |
| 102 const std::string& presentation_url, | 102 const std::string& presentation_url, |
| 103 const std::string& presentation_id, | 103 const std::string& presentation_id, |
| 104 const PresentationSessionStartedCallback& success_cb, | 104 const PresentationSessionStartedCallback& success_cb, |
| 105 const PresentationSessionErrorCallback& error_cb)); | 105 const PresentationSessionErrorCallback& error_cb)); |
| 106 MOCK_METHOD3(CloseSession, | 106 MOCK_METHOD3(CloseConnection, |
| 107 void(int render_process_id, | 107 void(int render_process_id, |
| 108 int render_frame_id, | 108 int render_frame_id, |
| 109 const std::string& presentation_id)); | 109 const std::string& presentation_id)); |
| 110 MOCK_METHOD3(TerminateSession, | 110 MOCK_METHOD3(Terminate, |
| 111 void(int render_process_id, | 111 void(int render_process_id, |
| 112 int render_frame_id, | 112 int render_frame_id, |
| 113 const std::string& presentation_id)); | 113 const std::string& presentation_id)); |
| 114 MOCK_METHOD4(ListenForSessionMessages, | 114 MOCK_METHOD4(ListenForSessionMessages, |
| 115 void(int render_process_id, | 115 void(int render_process_id, |
| 116 int render_frame_id, | 116 int render_frame_id, |
| 117 const content::PresentationSessionInfo& session, | 117 const content::PresentationSessionInfo& session, |
| 118 const PresentationSessionMessageCallback& message_cb)); | 118 const PresentationSessionMessageCallback& message_cb)); |
| 119 MOCK_METHOD5(SendMessageRawPtr, | 119 MOCK_METHOD5(SendMessageRawPtr, |
| 120 void(int render_process_id, | 120 void(int render_process_id, |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 EXPECT_CALL(mock_delegate_, JoinSession( | 564 EXPECT_CALL(mock_delegate_, JoinSession( |
| 565 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) | 565 _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _)) |
| 566 .WillOnce(DoAll( | 566 .WillOnce(DoAll( |
| 567 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), | 567 InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), |
| 568 SaveArg<5>(&error_cb))); | 568 SaveArg<5>(&error_cb))); |
| 569 run_loop.Run(); | 569 run_loop.Run(); |
| 570 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); | 570 error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message")); |
| 571 SaveQuitClosureAndRunLoop(); | 571 SaveQuitClosureAndRunLoop(); |
| 572 } | 572 } |
| 573 | 573 |
| 574 TEST_F(PresentationServiceImplTest, CloseSession) { | 574 TEST_F(PresentationServiceImplTest, CloseConnection) { |
| 575 service_ptr_->CloseSession(kPresentationUrl, kPresentationId); | 575 service_ptr_->CloseConnection(kPresentationUrl, kPresentationId); |
| 576 base::RunLoop run_loop; | 576 base::RunLoop run_loop; |
| 577 EXPECT_CALL(mock_delegate_, CloseSession(_, _, Eq(kPresentationId))) | 577 EXPECT_CALL(mock_delegate_, CloseConnection(_, _, Eq(kPresentationId))) |
| 578 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 578 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 579 run_loop.Run(); | 579 run_loop.Run(); |
| 580 } | 580 } |
| 581 | 581 |
| 582 TEST_F(PresentationServiceImplTest, TerminateSession) { | 582 TEST_F(PresentationServiceImplTest, Terminate) { |
| 583 service_ptr_->TerminateSession(kPresentationUrl, kPresentationId); | 583 service_ptr_->Terminate(kPresentationUrl, kPresentationId); |
| 584 base::RunLoop run_loop; | 584 base::RunLoop run_loop; |
| 585 EXPECT_CALL(mock_delegate_, TerminateSession(_, _, Eq(kPresentationId))) | 585 EXPECT_CALL(mock_delegate_, Terminate(_, _, Eq(kPresentationId))) |
| 586 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 586 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 587 run_loop.Run(); | 587 run_loop.Run(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 TEST_F(PresentationServiceImplTest, ListenForSessionMessagesPassed) { | 590 TEST_F(PresentationServiceImplTest, ListenForSessionMessagesPassed) { |
| 591 std::string text_msg("123"); | 591 std::string text_msg("123"); |
| 592 std::vector<uint8_t> binary_data(3, '\1'); | 592 std::vector<uint8_t> binary_data(3, '\1'); |
| 593 RunListenForSessionMessages(text_msg, binary_data, true); | 593 RunListenForSessionMessages(text_msg, binary_data, true); |
| 594 } | 594 } |
| 595 | 595 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 | 804 |
| 805 TEST_F(PresentationServiceImplTest, ScreenAvailabilityNotSupported) { | 805 TEST_F(PresentationServiceImplTest, ScreenAvailabilityNotSupported) { |
| 806 mock_delegate_.set_screen_availability_listening_supported(false); | 806 mock_delegate_.set_screen_availability_listening_supported(false); |
| 807 EXPECT_CALL(mock_client_, | 807 EXPECT_CALL(mock_client_, |
| 808 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))); | 808 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))); |
| 809 | 809 |
| 810 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); | 810 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); |
| 811 } | 811 } |
| 812 | 812 |
| 813 } // namespace content | 813 } // namespace content |
| OLD | NEW |