| 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 "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/media/router/media_source.h" | 9 #include "chrome/browser/media/router/media_source.h" |
| 10 #include "chrome/browser/media/router/media_source_helper.h" | 10 #include "chrome/browser/media/router/media_source_helper.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 delegate_impl_->GetDefaultPresentationRequest(); | 100 delegate_impl_->GetDefaultPresentationRequest(); |
| 101 | 101 |
| 102 // Should not trigger callback since route response is error. | 102 // Should not trigger callback since route response is error. |
| 103 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromError( | 103 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromError( |
| 104 "Error", RouteRequestResult::UNKNOWN_ERROR); | 104 "Error", RouteRequestResult::UNKNOWN_ERROR); |
| 105 delegate_impl_->OnRouteResponse(request, *result); | 105 delegate_impl_->OnRouteResponse(request, *result); |
| 106 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); | 106 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); |
| 107 | 107 |
| 108 // Should not trigger callback since request doesn't match. | 108 // Should not trigger callback since request doesn't match. |
| 109 PresentationRequest different_request(RenderFrameHostId(100, 200), | 109 PresentationRequest different_request(RenderFrameHostId(100, 200), |
| 110 kPresentationUrl2, GURL(kFrameUrl)); | 110 {kPresentationUrl2}, GURL(kFrameUrl)); |
| 111 MediaRoute* media_route = new MediaRoute( | 111 MediaRoute* media_route = new MediaRoute( |
| 112 "differentRouteId", MediaSourceForPresentationUrl(kPresentationUrl2), | 112 "differentRouteId", MediaSourceForPresentationUrl(kPresentationUrl2), |
| 113 "mediaSinkId", "", true, "", true); | 113 "mediaSinkId", "", true, "", true); |
| 114 media_route->set_incognito(incognito); | 114 media_route->set_incognito(incognito); |
| 115 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route), | 115 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route), |
| 116 "differentPresentationId"); | 116 "differentPresentationId"); |
| 117 delegate_impl_->OnRouteResponse(different_request, *result); | 117 delegate_impl_->OnRouteResponse(different_request, *result); |
| 118 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); | 118 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); |
| 119 | 119 |
| 120 // Should trigger callback since request matches. | 120 // Should trigger callback since request matches. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 322 |
| 323 GURL frame_url(kFrameUrl); | 323 GURL frame_url(kFrameUrl); |
| 324 content::WebContentsTester::For(GetWebContents()) | 324 content::WebContentsTester::For(GetWebContents()) |
| 325 ->NavigateAndCommit(frame_url); | 325 ->NavigateAndCommit(frame_url); |
| 326 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); | 326 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); |
| 327 ASSERT_TRUE(main_frame); | 327 ASSERT_TRUE(main_frame); |
| 328 int render_process_id = main_frame->GetProcess()->GetID(); | 328 int render_process_id = main_frame->GetProcess()->GetID(); |
| 329 int routing_id = main_frame->GetRoutingID(); | 329 int routing_id = main_frame->GetRoutingID(); |
| 330 | 330 |
| 331 PresentationRequest observed_request1( | 331 PresentationRequest observed_request1( |
| 332 RenderFrameHostId(render_process_id, routing_id), kPresentationUrl1, | 332 RenderFrameHostId(render_process_id, routing_id), {kPresentationUrl1}, |
| 333 frame_url); | 333 frame_url); |
| 334 EXPECT_CALL(observer, OnDefaultPresentationChanged(Equals(observed_request1))) | 334 EXPECT_CALL(observer, OnDefaultPresentationChanged(Equals(observed_request1))) |
| 335 .Times(1); | 335 .Times(1); |
| 336 std::vector<std::string> request1_urls({kPresentationUrl1}); | 336 std::vector<std::string> request1_urls({kPresentationUrl1}); |
| 337 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, | 337 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, |
| 338 request1_urls, callback); | 338 request1_urls, callback); |
| 339 | 339 |
| 340 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); | 340 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); |
| 341 PresentationRequest request1 = | 341 PresentationRequest request1 = |
| 342 delegate_impl_->GetDefaultPresentationRequest(); | 342 delegate_impl_->GetDefaultPresentationRequest(); |
| 343 EXPECT_TRUE(request1.Equals(observed_request1)); | 343 EXPECT_TRUE(request1.Equals(observed_request1)); |
| 344 | 344 |
| 345 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&observer)); | 345 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&observer)); |
| 346 | 346 |
| 347 PresentationRequest observed_request2( | 347 PresentationRequest observed_request2( |
| 348 RenderFrameHostId(render_process_id, routing_id), kPresentationUrl2, | 348 RenderFrameHostId(render_process_id, routing_id), {kPresentationUrl2}, |
| 349 frame_url); | 349 frame_url); |
| 350 EXPECT_CALL(observer, OnDefaultPresentationChanged(Equals(observed_request2))) | 350 EXPECT_CALL(observer, OnDefaultPresentationChanged(Equals(observed_request2))) |
| 351 .Times(1); | 351 .Times(1); |
| 352 std::vector<std::string> request2_urls({kPresentationUrl2}); | 352 std::vector<std::string> request2_urls({kPresentationUrl2}); |
| 353 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, | 353 delegate_impl_->SetDefaultPresentationUrls(render_process_id, routing_id, |
| 354 request2_urls, callback); | 354 request2_urls, callback); |
| 355 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); | 355 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); |
| 356 PresentationRequest request2 = | 356 PresentationRequest request2 = |
| 357 delegate_impl_->GetDefaultPresentationRequest(); | 357 delegate_impl_->GetDefaultPresentationRequest(); |
| 358 EXPECT_TRUE(request2.Equals(observed_request2)); | 358 EXPECT_TRUE(request2.Equals(observed_request2)); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 int render_process_id = main_frame->GetProcess()->GetID(); | 460 int render_process_id = main_frame->GetProcess()->GetID(); |
| 461 int render_frame_id = main_frame->GetRoutingID(); | 461 int render_frame_id = main_frame->GetRoutingID(); |
| 462 | 462 |
| 463 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(false)); | 463 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(false)); |
| 464 EXPECT_CALL(listener, OnScreenAvailabilityNotSupported()); | 464 EXPECT_CALL(listener, OnScreenAvailabilityNotSupported()); |
| 465 EXPECT_FALSE(delegate_impl_->AddScreenAvailabilityListener( | 465 EXPECT_FALSE(delegate_impl_->AddScreenAvailabilityListener( |
| 466 render_process_id, render_frame_id, &listener)); | 466 render_process_id, render_frame_id, &listener)); |
| 467 } | 467 } |
| 468 | 468 |
| 469 } // namespace media_router | 469 } // namespace media_router |
| OLD | NEW |