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 "content/browser/presentation/presentation_service_impl.h" | 5 #include "content/browser/presentation/presentation_service_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 OnDefaultSessionStarted(*session_info); | 185 OnDefaultSessionStarted(*session_info); |
186 } | 186 } |
187 MOCK_METHOD1(OnDefaultSessionStarted, | 187 MOCK_METHOD1(OnDefaultSessionStarted, |
188 void(const mojom::PresentationSessionInfo& session_info)); | 188 void(const mojom::PresentationSessionInfo& session_info)); |
189 | 189 |
190 mojo::Array<mojom::SessionMessagePtr> messages_received_; | 190 mojo::Array<mojom::SessionMessagePtr> messages_received_; |
191 }; | 191 }; |
192 | 192 |
193 class PresentationServiceImplTest : public RenderViewHostImplTestHarness { | 193 class PresentationServiceImplTest : public RenderViewHostImplTestHarness { |
194 public: | 194 public: |
195 PresentationServiceImplTest() : default_session_started_count_(0) {} | 195 PresentationServiceImplTest() {} |
196 | 196 |
197 void SetUp() override { | 197 void SetUp() override { |
198 RenderViewHostImplTestHarness::SetUp(); | 198 RenderViewHostImplTestHarness::SetUp(); |
199 | 199 |
200 auto request = mojo::GetProxy(&service_ptr_); | 200 auto request = mojo::GetProxy(&service_ptr_); |
201 EXPECT_CALL(mock_delegate_, AddObserver(_, _, _)).Times(1); | 201 EXPECT_CALL(mock_delegate_, AddObserver(_, _, _)).Times(1); |
202 service_impl_.reset(new PresentationServiceImpl( | 202 service_impl_.reset(new PresentationServiceImpl( |
203 contents()->GetMainFrame(), contents(), &mock_delegate_)); | 203 contents()->GetMainFrame(), contents(), &mock_delegate_)); |
204 service_impl_->Bind(std::move(request)); | 204 service_impl_->Bind(std::move(request)); |
205 | 205 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 MockPresentationServiceDelegate mock_delegate_; | 359 MockPresentationServiceDelegate mock_delegate_; |
360 | 360 |
361 std::unique_ptr<PresentationServiceImpl> service_impl_; | 361 std::unique_ptr<PresentationServiceImpl> service_impl_; |
362 mojo::InterfacePtr<mojom::PresentationService> service_ptr_; | 362 mojo::InterfacePtr<mojom::PresentationService> service_ptr_; |
363 | 363 |
364 MockPresentationServiceClient mock_client_; | 364 MockPresentationServiceClient mock_client_; |
365 std::unique_ptr<mojo::Binding<mojom::PresentationServiceClient>> | 365 std::unique_ptr<mojo::Binding<mojom::PresentationServiceClient>> |
366 client_binding_; | 366 client_binding_; |
367 | 367 |
368 base::Closure run_loop_quit_closure_; | 368 base::Closure run_loop_quit_closure_; |
369 int default_session_started_count_; | |
370 }; | 369 }; |
371 | 370 |
372 TEST_F(PresentationServiceImplTest, ListenForScreenAvailability) { | 371 TEST_F(PresentationServiceImplTest, ListenForScreenAvailability) { |
373 ListenForScreenAvailabilityAndWait(kPresentationUrl, true); | 372 ListenForScreenAvailabilityAndWait(kPresentationUrl, true); |
374 | 373 |
375 SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, true); | 374 SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, true); |
376 SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, false); | 375 SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, false); |
377 SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, true); | 376 SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, true); |
378 } | 377 } |
379 | 378 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 mock_delegate_.set_screen_availability_listening_supported(false); | 838 mock_delegate_.set_screen_availability_listening_supported(false); |
840 base::RunLoop run_loop; | 839 base::RunLoop run_loop; |
841 EXPECT_CALL(mock_client_, | 840 EXPECT_CALL(mock_client_, |
842 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))) | 841 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))) |
843 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 842 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
844 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); | 843 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); |
845 run_loop.Run(); | 844 run_loop.Run(); |
846 } | 845 } |
847 | 846 |
848 } // namespace content | 847 } // namespace content |
OLD | NEW |