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

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: Addressed Mark's comments 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(RenderFrameHostId(100, 200), 154 PresentationRequest different_request(RenderFrameHostId(100, 200),
155 {presentation_url2_}, 155 {presentation_url2_},
156 url::Origin(GURL(kFrameUrl))); 156 url::Origin(GURL(kFrameUrl)));
157 MediaRoute* media_route = new MediaRoute("differentRouteId", source2_, 157 MediaRoute media_route("differentRouteId", source2_, "mediaSinkId", "",
mark a. foltz 2017/02/09 22:53:52 Since the route description isn't represented by a
158 "mediaSinkId", "", true, "", true); 158 true, "", true);
159 media_route->set_incognito(incognito); 159 media_route.set_incognito(incognito);
160 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route), 160 result =
161 "differentPresentationId"); 161 RouteRequestResult::FromSuccess(media_route, "differentPresentationId");
162 delegate_impl_->OnRouteResponse(different_request, *result); 162 delegate_impl_->OnRouteResponse(different_request, *result);
163 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this)); 163 EXPECT_TRUE(Mock::VerifyAndClearExpectations(this));
164 164
165 // Should trigger callback since request matches. 165 // Should trigger callback since request matches.
166 EXPECT_CALL(*this, OnDefaultPresentationStarted(_)).Times(1); 166 EXPECT_CALL(*this, OnDefaultPresentationStarted(_)).Times(1);
167 MediaRoute* media_route2 = 167 MediaRoute media_route2("routeId", source1_, "mediaSinkId", "", true, "",
168 new MediaRoute("routeId", source1_, "mediaSinkId", "", true, "", true); 168 true);
169 media_route2->set_incognito(incognito); 169 media_route2.set_incognito(incognito);
170 result = RouteRequestResult::FromSuccess(base::WrapUnique(media_route2), 170 result = RouteRequestResult::FromSuccess(media_route2, "presentationId");
171 "presentationId");
172 delegate_impl_->OnRouteResponse(request, *result); 171 delegate_impl_->OnRouteResponse(request, *result);
173 } 172 }
174 173
175 void SetMainFrame() { 174 void SetMainFrame() {
176 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); 175 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame();
177 ASSERT_TRUE(main_frame); 176 ASSERT_TRUE(main_frame);
178 main_frame_process_id_ = main_frame->GetProcess()->GetID(); 177 main_frame_process_id_ = main_frame->GetProcess()->GetID();
179 main_frame_routing_id_ = main_frame->GetRoutingID(); 178 main_frame_routing_id_ = main_frame->GetRoutingID();
180 } 179 }
181 180
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 421 base::Bind(&MockCreatePresentationConnnectionCallbacks::
423 OnCreateConnectionSuccess, 422 OnCreateConnectionSuccess,
424 base::Unretained(&mock_create_connection_callbacks)), 423 base::Unretained(&mock_create_connection_callbacks)),
425 base::Bind( 424 base::Bind(
426 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 425 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
427 base::Unretained(&mock_create_connection_callbacks))); 426 base::Unretained(&mock_create_connection_callbacks)));
428 427
429 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionSuccess(_)) 428 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionSuccess(_))
430 .Times(1); 429 .Times(1);
431 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromSuccess( 430 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromSuccess(
432 base::MakeUnique<MediaRoute>("routeId", source1_, "mediaSinkId", 431 MediaRoute("routeId", source1_, "mediaSinkId", "description", true, "",
433 "description", true, "", true), 432 true),
434 kPresentationId); 433 kPresentationId);
435 for (const auto& route_response_callback : route_response_callbacks) 434 for (const auto& route_response_callback : route_response_callbacks)
436 route_response_callback.Run(*result); 435 route_response_callback.Run(*result);
437 436
438 MockPresentationConnectionStateChangedCallback mock_callback; 437 MockPresentationConnectionStateChangedCallback mock_callback;
439 content::PresentationConnectionStateChangedCallback callback = 438 content::PresentationConnectionStateChangedCallback callback =
440 base::Bind(&MockPresentationConnectionStateChangedCallback::Run, 439 base::Bind(&MockPresentationConnectionStateChangedCallback::Run,
441 base::Unretained(&mock_callback)); 440 base::Unretained(&mock_callback));
442 content::PresentationSessionInfo connection(presentation_url1_, 441 content::PresentationSessionInfo connection(presentation_url1_,
443 kPresentationId); 442 kPresentationId);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 616 base::Bind(&MockCreatePresentationConnnectionCallbacks::
618 OnCreateConnectionSuccess, 617 OnCreateConnectionSuccess,
619 base::Unretained(&mock_create_connection_callbacks)), 618 base::Unretained(&mock_create_connection_callbacks)),
620 base::Bind( 619 base::Bind(
621 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 620 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
622 base::Unretained(&mock_create_connection_callbacks))); 621 base::Unretained(&mock_create_connection_callbacks)));
623 } 622 }
624 #endif // !defined(OS_ANDROID) 623 #endif // !defined(OS_ANDROID)
625 624
626 } // namespace media_router 625 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698