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/test/mock_callback.h" | 8 #include "base/test/mock_callback.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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Should not trigger callback since route response is error. | 148 // Should not trigger callback since route response is error. |
149 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromError( | 149 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromError( |
150 "Error", RouteRequestResult::UNKNOWN_ERROR); | 150 "Error", RouteRequestResult::UNKNOWN_ERROR); |
151 delegate_impl_->OnRouteResponse(request, *result); | 151 delegate_impl_->OnRouteResponse(request, *result); |
152 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); | 152 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); |
153 | 153 |
154 // Should not trigger callback since request doesn't match. | 154 // Should not trigger callback since request doesn't match. |
155 PresentationRequest different_request(RenderFrameHostId(100, 200), | 155 PresentationRequest different_request(RenderFrameHostId(100, 200), |
156 {presentation_url2_}, | 156 {presentation_url2_}, |
157 url::Origin(GURL(kFrameUrl))); | 157 url::Origin(GURL(kFrameUrl))); |
158 MediaRoute* media_route = new MediaRoute("differentRouteId", source2_, | 158 MediaRoute media_route("differentRouteId", source2_, "mediaSinkId", "", |
159 "mediaSinkId", "", true, "", true); | 159 true, "", true); |
160 media_route->set_incognito(incognito); | 160 media_route.set_incognito(incognito); |
161 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route), | 161 result = |
162 "differentPresentationId"); | 162 RouteRequestResult::FromSuccess(media_route, "differentPresentationId"); |
163 delegate_impl_->OnRouteResponse(different_request, *result); | 163 delegate_impl_->OnRouteResponse(different_request, *result); |
164 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); | 164 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); |
165 | 165 |
166 // Should trigger callback since request matches. | 166 // Should trigger callback since request matches. |
167 EXPECT_CALL(*this, OnDefaultPresentationStarted(_)).Times(1); | 167 EXPECT_CALL(*this, OnDefaultPresentationStarted(_)).Times(1); |
168 MediaRoute* media_route2 = | 168 MediaRoute media_route2("routeId", source1_, "mediaSinkId", "", true, "", |
169 new MediaRoute("routeId", source1_, "mediaSinkId", "", true, "", true); | 169 true); |
170 media_route2->set_incognito(incognito); | 170 media_route2.set_incognito(incognito); |
171 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route2), | 171 result = RouteRequestResult::FromSuccess(media_route2, "presentationId"); |
172 "presentationId"); | |
173 delegate_impl_->OnRouteResponse(request, *result); | 172 delegate_impl_->OnRouteResponse(request, *result); |
174 } | 173 } |
175 | 174 |
176 void SetMainFrame() { | 175 void SetMainFrame() { |
177 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); | 176 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); |
178 ASSERT_TRUE(main_frame); | 177 ASSERT_TRUE(main_frame); |
179 main_frame_process_id_ = main_frame->GetProcess()->GetID(); | 178 main_frame_process_id_ = main_frame->GetProcess()->GetID(); |
180 main_frame_routing_id_ = main_frame->GetRoutingID(); | 179 main_frame_routing_id_ = main_frame->GetRoutingID(); |
181 } | 180 } |
182 | 181 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 base::Bind(&MockCreatePresentationConnnectionCallbacks:: | 422 base::Bind(&MockCreatePresentationConnnectionCallbacks:: |
424 OnCreateConnectionSuccess, | 423 OnCreateConnectionSuccess, |
425 base::Unretained(&mock_create_connection_callbacks)), | 424 base::Unretained(&mock_create_connection_callbacks)), |
426 base::Bind( | 425 base::Bind( |
427 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, | 426 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, |
428 base::Unretained(&mock_create_connection_callbacks))); | 427 base::Unretained(&mock_create_connection_callbacks))); |
429 | 428 |
430 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionSuccess(_)) | 429 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionSuccess(_)) |
431 .Times(1); | 430 .Times(1); |
432 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromSuccess( | 431 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromSuccess( |
433 base::MakeUnique<MediaRoute>("routeId", source1_, "mediaSinkId", | 432 MediaRoute("routeId", source1_, "mediaSinkId", "description", true, "", |
434 "description", true, "", true), | 433 true), |
435 kPresentationId); | 434 kPresentationId); |
436 for (const auto& route_response_callback : route_response_callbacks) | 435 for (const auto& route_response_callback : route_response_callbacks) |
437 route_response_callback.Run(*result); | 436 route_response_callback.Run(*result); |
438 | 437 |
439 base::MockCallback<content::PresentationConnectionStateChangedCallback> | 438 base::MockCallback<content::PresentationConnectionStateChangedCallback> |
440 mock_callback; | 439 mock_callback; |
441 auto callback = mock_callback.Get(); | 440 auto callback = mock_callback.Get(); |
442 content::PresentationSessionInfo connection(presentation_url1_, | 441 content::PresentationSessionInfo connection(presentation_url1_, |
443 kPresentationId); | 442 kPresentationId); |
444 EXPECT_CALL(router_, OnAddPresentationConnectionStateChangedCallbackInvoked( | 443 EXPECT_CALL(router_, OnAddPresentationConnectionStateChangedCallbackInvoked( |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 base::Bind(&MockCreatePresentationConnnectionCallbacks:: | 635 base::Bind(&MockCreatePresentationConnnectionCallbacks:: |
637 OnCreateConnectionSuccess, | 636 OnCreateConnectionSuccess, |
638 base::Unretained(&mock_create_connection_callbacks)), | 637 base::Unretained(&mock_create_connection_callbacks)), |
639 base::Bind( | 638 base::Bind( |
640 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, | 639 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, |
641 base::Unretained(&mock_create_connection_callbacks))); | 640 base::Unretained(&mock_create_connection_callbacks))); |
642 } | 641 } |
643 #endif // !defined(OS_ANDROID) | 642 #endif // !defined(OS_ANDROID) |
644 | 643 |
645 } // namespace media_router | 644 } // namespace media_router |
OLD | NEW |