| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 delegate_impl_ = PresentationServiceDelegateImpl::FromWebContents(wc); | 71 delegate_impl_ = PresentationServiceDelegateImpl::FromWebContents(wc); |
| 72 delegate_impl_->SetMediaRouterForTest(&router_); | 72 delegate_impl_->SetMediaRouterForTest(&router_); |
| 73 } | 73 } |
| 74 | 74 |
| 75 MOCK_METHOD1(OnDefaultPresentationStarted, | 75 MOCK_METHOD1(OnDefaultPresentationStarted, |
| 76 void(const content::PresentationSessionInfo& session_info)); | 76 void(const content::PresentationSessionInfo& session_info)); |
| 77 | 77 |
| 78 protected: | 78 protected: |
| 79 virtual content::WebContents* GetWebContents() { return web_contents(); } | 79 virtual content::WebContents* GetWebContents() { return web_contents(); } |
| 80 | 80 |
| 81 void RunDefaultPresentationUrlCallbackTest(bool off_the_record) { | 81 void RunDefaultPresentationUrlCallbackTest(bool incognito) { |
| 82 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); | 82 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); |
| 83 ASSERT_TRUE(main_frame); | 83 ASSERT_TRUE(main_frame); |
| 84 int render_process_id = main_frame->GetProcess()->GetID(); | 84 int render_process_id = main_frame->GetProcess()->GetID(); |
| 85 int routing_id = main_frame->GetRoutingID(); | 85 int routing_id = main_frame->GetRoutingID(); |
| 86 | 86 |
| 87 auto callback = base::Bind( | 87 auto callback = base::Bind( |
| 88 &PresentationServiceDelegateImplTest::OnDefaultPresentationStarted, | 88 &PresentationServiceDelegateImplTest::OnDefaultPresentationStarted, |
| 89 base::Unretained(this)); | 89 base::Unretained(this)); |
| 90 std::string presentation_url1("http://foo.fakeUrl"); | 90 std::string presentation_url1("http://foo.fakeUrl"); |
| 91 delegate_impl_->SetDefaultPresentationUrl(render_process_id, routing_id, | 91 delegate_impl_->SetDefaultPresentationUrl(render_process_id, routing_id, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 102 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); | 102 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); |
| 103 | 103 |
| 104 // Should not trigger callback since request doesn't match. | 104 // Should not trigger callback since request doesn't match. |
| 105 std::string presentation_url2("http://bar.fakeUrl"); | 105 std::string presentation_url2("http://bar.fakeUrl"); |
| 106 PresentationRequest different_request( | 106 PresentationRequest different_request( |
| 107 RenderFrameHostId(100, 200), presentation_url2, | 107 RenderFrameHostId(100, 200), presentation_url2, |
| 108 GURL("http://anotherFrameUrl.fakeUrl")); | 108 GURL("http://anotherFrameUrl.fakeUrl")); |
| 109 MediaRoute* media_route = new MediaRoute( | 109 MediaRoute* media_route = new MediaRoute( |
| 110 "differentRouteId", MediaSourceForPresentationUrl(presentation_url2), | 110 "differentRouteId", MediaSourceForPresentationUrl(presentation_url2), |
| 111 "mediaSinkId", "", true, "", true); | 111 "mediaSinkId", "", true, "", true); |
| 112 media_route->set_off_the_record(off_the_record); | 112 media_route->set_incognito(incognito); |
| 113 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route), | 113 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route), |
| 114 "differentPresentationId"); | 114 "differentPresentationId"); |
| 115 delegate_impl_->OnRouteResponse(different_request, *result); | 115 delegate_impl_->OnRouteResponse(different_request, *result); |
| 116 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); | 116 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); |
| 117 | 117 |
| 118 // Should trigger callback since request matches. | 118 // Should trigger callback since request matches. |
| 119 EXPECT_CALL(*this, OnDefaultPresentationStarted(_)).Times(1); | 119 EXPECT_CALL(*this, OnDefaultPresentationStarted(_)).Times(1); |
| 120 MediaRoute* media_route2 = new MediaRoute( | 120 MediaRoute* media_route2 = new MediaRoute( |
| 121 "routeId", MediaSourceForPresentationUrl(presentation_url1), | 121 "routeId", MediaSourceForPresentationUrl(presentation_url1), |
| 122 "mediaSinkId", "", true, "", true); | 122 "mediaSinkId", "", true, "", true); |
| 123 media_route2->set_off_the_record(off_the_record); | 123 media_route2->set_incognito(incognito); |
| 124 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route2), | 124 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route2), |
| 125 "presentationId"); | 125 "presentationId"); |
| 126 delegate_impl_->OnRouteResponse(request, *result); | 126 delegate_impl_->OnRouteResponse(request, *result); |
| 127 } | 127 } |
| 128 | 128 |
| 129 PresentationServiceDelegateImpl* delegate_impl_; | 129 PresentationServiceDelegateImpl* delegate_impl_; |
| 130 MockMediaRouter router_; | 130 MockMediaRouter router_; |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 class PresentationServiceDelegateImplIncognitoTest | 133 class PresentationServiceDelegateImplIncognitoTest |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 int render_process_id = main_frame->GetProcess()->GetID(); | 463 int render_process_id = main_frame->GetProcess()->GetID(); |
| 464 int render_frame_id = main_frame->GetRoutingID(); | 464 int render_frame_id = main_frame->GetRoutingID(); |
| 465 | 465 |
| 466 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(false)); | 466 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(false)); |
| 467 EXPECT_CALL(listener, OnScreenAvailabilityNotSupported()); | 467 EXPECT_CALL(listener, OnScreenAvailabilityNotSupported()); |
| 468 EXPECT_FALSE(delegate_impl_->AddScreenAvailabilityListener( | 468 EXPECT_FALSE(delegate_impl_->AddScreenAvailabilityListener( |
| 469 render_process_id, render_frame_id, &listener)); | 469 render_process_id, render_frame_id, &listener)); |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace media_router | 472 } // namespace media_router |
| OLD | NEW |