Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc

Issue 2666873006: [Media Router] Convert to use typemaps for media_router.mojom. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // Should not trigger callback since route response is error. 147 // Should not trigger callback since route response is error.
148 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromError( 148 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromError(
149 "Error", RouteRequestResult::UNKNOWN_ERROR); 149 "Error", RouteRequestResult::UNKNOWN_ERROR);
150 delegate_impl_->OnRouteResponse(request, *result); 150 delegate_impl_->OnRouteResponse(request, *result);
151 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); 151 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this));
152 152
153 // Should not trigger callback since request doesn't match. 153 // Should not trigger callback since request doesn't match.
154 PresentationRequest different_request( 154 PresentationRequest different_request(
155 RenderFrameHostId(100, 200), {presentation_url2_}, GURL(kFrameUrl)); 155 RenderFrameHostId(100, 200), {presentation_url2_}, GURL(kFrameUrl));
156 MediaRoute* media_route = new MediaRoute("differentRouteId", source2_, 156 MediaRoute media_route("differentRouteId", source2_, "mediaSinkId", "",
157 "mediaSinkId", "", true, "", true); 157 true, "", true);
158 media_route->set_incognito(incognito); 158 media_route.set_incognito(incognito);
159 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route), 159 result =
160 "differentPresentationId"); 160 RouteRequestResult::FromSuccess(media_route, "differentPresentationId");
161 delegate_impl_->OnRouteResponse(different_request, *result); 161 delegate_impl_->OnRouteResponse(different_request, *result);
162 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); 162 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this));
163 163
164 // Should trigger callback since request matches. 164 // Should trigger callback since request matches.
165 EXPECT_CALL(*this, OnDefaultPresentationStarted(_)).Times(1); 165 EXPECT_CALL(*this, OnDefaultPresentationStarted(_)).Times(1);
166 MediaRoute* media_route2 = 166 MediaRoute media_route2("routeId", source1_, "mediaSinkId", "", true, "",
167 new MediaRoute("routeId", source1_, "mediaSinkId", "", true, "", true); 167 true);
168 media_route2->set_incognito(incognito); 168 media_route2.set_incognito(incognito);
169 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route2), 169 result = RouteRequestResult::FromSuccess(media_route2, "presentationId");
170 "presentationId");
171 delegate_impl_->OnRouteResponse(request, *result); 170 delegate_impl_->OnRouteResponse(request, *result);
172 } 171 }
173 172
174 void SetMainFrame() { 173 void SetMainFrame() {
175 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); 174 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame();
176 ASSERT_TRUE(main_frame); 175 ASSERT_TRUE(main_frame);
177 main_frame_process_id_ = main_frame->GetProcess()->GetID(); 176 main_frame_process_id_ = main_frame->GetProcess()->GetID();
178 main_frame_routing_id_ = main_frame->GetRoutingID(); 177 main_frame_routing_id_ = main_frame->GetRoutingID();
179 } 178 }
180 179
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 420 base::Bind(&MockCreatePresentationConnnectionCallbacks::
422 OnCreateConnectionSuccess, 421 OnCreateConnectionSuccess,
423 base::Unretained(&mock_create_connection_callbacks)), 422 base::Unretained(&mock_create_connection_callbacks)),
424 base::Bind( 423 base::Bind(
425 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 424 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
426 base::Unretained(&mock_create_connection_callbacks))); 425 base::Unretained(&mock_create_connection_callbacks)));
427 426
428 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionSuccess(_)) 427 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionSuccess(_))
429 .Times(1); 428 .Times(1);
430 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromSuccess( 429 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromSuccess(
431 base::MakeUnique<MediaRoute>("routeId", source1_, "mediaSinkId", 430 MediaRoute("routeId", source1_, "mediaSinkId", "description", true, "",
432 "description", true, "", true), 431 true),
433 kPresentationId); 432 kPresentationId);
434 for (const auto& route_response_callback : route_response_callbacks) 433 for (const auto& route_response_callback : route_response_callbacks)
435 route_response_callback.Run(*result); 434 route_response_callback.Run(*result);
436 435
437 MockPresentationConnectionStateChangedCallback mock_callback; 436 MockPresentationConnectionStateChangedCallback mock_callback;
438 content::PresentationConnectionStateChangedCallback callback = 437 content::PresentationConnectionStateChangedCallback callback =
439 base::Bind(&MockPresentationConnectionStateChangedCallback::Run, 438 base::Bind(&MockPresentationConnectionStateChangedCallback::Run,
440 base::Unretained(&mock_callback)); 439 base::Unretained(&mock_callback));
441 content::PresentationSessionInfo connection(presentation_url1_, 440 content::PresentationSessionInfo connection(presentation_url1_,
442 kPresentationId); 441 kPresentationId);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 615 base::Bind(&MockCreatePresentationConnnectionCallbacks::
617 OnCreateConnectionSuccess, 616 OnCreateConnectionSuccess,
618 base::Unretained(&mock_create_connection_callbacks)), 617 base::Unretained(&mock_create_connection_callbacks)),
619 base::Bind( 618 base::Bind(
620 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 619 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
621 base::Unretained(&mock_create_connection_callbacks))); 620 base::Unretained(&mock_create_connection_callbacks)));
622 } 621 }
623 #endif // !defined(OS_ANDROID) 622 #endif // !defined(OS_ANDROID)
624 623
625 } // namespace media_router 624 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698