| 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 "chrome/browser/media/router/presentation_service_delegate_impl.h" | 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/media/router/media_source.h" | 8 #include "chrome/browser/media/router/media_source.h" |
| 9 #include "chrome/browser/media/router/media_source_helper.h" | 9 #include "chrome/browser/media/router/media_source_helper.h" |
| 10 #include "chrome/browser/media/router/mock_media_router.h" | 10 #include "chrome/browser/media/router/mock_media_router.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 using ::testing::_; | 24 using ::testing::_; |
| 25 using ::testing::Mock; | 25 using ::testing::Mock; |
| 26 using ::testing::Return; | 26 using ::testing::Return; |
| 27 using ::testing::SaveArg; | 27 using ::testing::SaveArg; |
| 28 using ::testing::StrictMock; | 28 using ::testing::StrictMock; |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 const char kPresentationUrl1[] = "http://foo.fakeurl.com/"; | 32 const char kPresentationUrl1[] = "http://foo.fakeurl.com/"; |
| 33 const char kPresentationUrl2[] = "http://bar.fakeurl.com/"; | 33 const char kPresentationUrl2[] = "http://bar.fakeurl.com/"; |
| 34 const char kPresentationUrl3[] = |
| 35 "https://google.com/cast#__castAppId__=233637DE"; |
| 34 const char kFrameUrl[] = "http://anotherframeurl.fakeurl.com/"; | 36 const char kFrameUrl[] = "http://anotherframeurl.fakeurl.com/"; |
| 35 | 37 |
| 36 } // namespace | 38 } // namespace |
| 37 | 39 |
| 38 namespace media_router { | 40 namespace media_router { |
| 39 | 41 |
| 40 class MockDelegateObserver | 42 class MockDelegateObserver |
| 41 : public content::PresentationServiceDelegate::Observer { | 43 : public content::PresentationServiceDelegate::Observer { |
| 42 public: | 44 public: |
| 43 MOCK_METHOD0(OnDelegateDestroyed, void()); | 45 MOCK_METHOD0(OnDelegateDestroyed, void()); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 int routing_id = main_frame->GetRoutingID(); | 279 int routing_id = main_frame->GetRoutingID(); |
| 278 | 280 |
| 279 auto callback = base::Bind( | 281 auto callback = base::Bind( |
| 280 &PresentationServiceDelegateImplTest::OnDefaultPresentationStarted, | 282 &PresentationServiceDelegateImplTest::OnDefaultPresentationStarted, |
| 281 base::Unretained(this)); | 283 base::Unretained(this)); |
| 282 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, | 284 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, |
| 283 presentation_urls_, callback); | 285 presentation_urls_, callback); |
| 284 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); | 286 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); |
| 285 PresentationRequest request1 = | 287 PresentationRequest request1 = |
| 286 delegate_impl_->GetDefaultPresentationRequest(); | 288 delegate_impl_->GetDefaultPresentationRequest(); |
| 287 EXPECT_EQ(presentation_url1_, request1.presentation_url()); | 289 EXPECT_EQ(presentation_url1_, request1.presentation_urls()[0]); |
| 288 EXPECT_EQ(RenderFrameHostId(render_process_id, routing_id), | 290 EXPECT_EQ(RenderFrameHostId(render_process_id, routing_id), |
| 289 request1.render_frame_host_id()); | 291 request1.render_frame_host_id()); |
| 290 EXPECT_EQ(frame_url, request1.frame_url()); | 292 EXPECT_EQ(frame_url, request1.frame_url()); |
| 291 | 293 |
| 292 // Set to a new default presentation URL | 294 // Set to a new default presentation URL |
| 293 std::vector<GURL> new_urls = {presentation_url2_}; | 295 std::vector<GURL> new_urls = {presentation_url2_}; |
| 294 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, | 296 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, |
| 295 new_urls, callback); | 297 new_urls, callback); |
| 296 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); | 298 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); |
| 297 PresentationRequest request2 = | 299 PresentationRequest request2 = |
| 298 delegate_impl_->GetDefaultPresentationRequest(); | 300 delegate_impl_->GetDefaultPresentationRequest(); |
| 299 EXPECT_EQ(presentation_url2_, request2.presentation_url()); | 301 EXPECT_EQ(presentation_url2_, request2.presentation_urls()[0]); |
| 300 EXPECT_EQ(RenderFrameHostId(render_process_id, routing_id), | 302 EXPECT_EQ(RenderFrameHostId(render_process_id, routing_id), |
| 301 request2.render_frame_host_id()); | 303 request2.render_frame_host_id()); |
| 302 EXPECT_EQ(frame_url, request2.frame_url()); | 304 EXPECT_EQ(frame_url, request2.frame_url()); |
| 303 | 305 |
| 304 // Remove default presentation URL. | 306 // Remove default presentation URL. |
| 305 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, | 307 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, |
| 306 std::vector<GURL>(), callback); | 308 std::vector<GURL>(), callback); |
| 307 EXPECT_FALSE(delegate_impl_->HasDefaultPresentationRequest()); | 309 EXPECT_FALSE(delegate_impl_->HasDefaultPresentationRequest()); |
| 308 } | 310 } |
| 309 | 311 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 ASSERT_TRUE(main_frame); | 380 ASSERT_TRUE(main_frame); |
| 379 int render_process_id = main_frame->GetProcess()->GetID(); | 381 int render_process_id = main_frame->GetProcess()->GetID(); |
| 380 int routing_id = main_frame->GetRoutingID(); | 382 int routing_id = main_frame->GetRoutingID(); |
| 381 | 383 |
| 382 // Set up a PresentationConnection so we can listen to it. | 384 // Set up a PresentationConnection so we can listen to it. |
| 383 std::vector<MediaRouteResponseCallback> route_response_callbacks; | 385 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| 384 EXPECT_CALL(router_, JoinRoute(_, _, _, _, _, _, false)) | 386 EXPECT_CALL(router_, JoinRoute(_, _, _, _, _, _, false)) |
| 385 .WillOnce(SaveArg<4>(&route_response_callbacks)); | 387 .WillOnce(SaveArg<4>(&route_response_callbacks)); |
| 386 | 388 |
| 387 const std::string kPresentationId("pid"); | 389 const std::string kPresentationId("pid"); |
| 390 presentation_urls_.push_back(GURL(kPresentationUrl3)); |
| 388 MockCreatePresentationConnnectionCallbacks mock_create_connection_callbacks; | 391 MockCreatePresentationConnnectionCallbacks mock_create_connection_callbacks; |
| 389 delegate_impl_->JoinSession( | 392 delegate_impl_->JoinSession( |
| 390 render_process_id, routing_id, presentation_urls_, kPresentationId, | 393 render_process_id, routing_id, presentation_urls_, kPresentationId, |
| 391 base::Bind(&MockCreatePresentationConnnectionCallbacks:: | 394 base::Bind(&MockCreatePresentationConnnectionCallbacks:: |
| 392 OnCreateConnectionSuccess, | 395 OnCreateConnectionSuccess, |
| 393 base::Unretained(&mock_create_connection_callbacks)), | 396 base::Unretained(&mock_create_connection_callbacks)), |
| 394 base::Bind( | 397 base::Bind( |
| 395 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, | 398 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, |
| 396 base::Unretained(&mock_create_connection_callbacks))); | 399 base::Unretained(&mock_create_connection_callbacks))); |
| 397 | 400 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 int render_process_id = main_frame->GetProcess()->GetID(); | 467 int render_process_id = main_frame->GetProcess()->GetID(); |
| 465 int render_frame_id = main_frame->GetRoutingID(); | 468 int render_frame_id = main_frame->GetRoutingID(); |
| 466 | 469 |
| 467 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(false)); | 470 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(false)); |
| 468 EXPECT_CALL(listener, OnScreenAvailabilityNotSupported()); | 471 EXPECT_CALL(listener, OnScreenAvailabilityNotSupported()); |
| 469 EXPECT_FALSE(delegate_impl_->AddScreenAvailabilityListener( | 472 EXPECT_FALSE(delegate_impl_->AddScreenAvailabilityListener( |
| 470 render_process_id, render_frame_id, &listener)); | 473 render_process_id, render_frame_id, &listener)); |
| 471 } | 474 } |
| 472 | 475 |
| 473 } // namespace media_router | 476 } // namespace media_router |
| OLD | NEW |