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

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

Issue 2264153002: [Presentation API] Add support for multiple URLs in PresentationRequest on Media Router UI side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Mark's comments Created 4 years, 3 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 <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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // Should not trigger callback since route response is error. 98 // Should not trigger callback since route response is error.
99 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromError( 99 std::unique_ptr<RouteRequestResult> result = RouteRequestResult::FromError(
100 "Error", RouteRequestResult::UNKNOWN_ERROR); 100 "Error", RouteRequestResult::UNKNOWN_ERROR);
101 delegate_impl_->OnRouteResponse(request, *result); 101 delegate_impl_->OnRouteResponse(request, *result);
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_incognito(incognito); 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
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 GURL frame_url("http://www.google.com"); 326 GURL frame_url("http://www.google.com");
327 content::WebContentsTester::For(GetWebContents()) 327 content::WebContentsTester::For(GetWebContents())
328 ->NavigateAndCommit(frame_url); 328 ->NavigateAndCommit(frame_url);
329 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame(); 329 content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame();
330 ASSERT_TRUE(main_frame); 330 ASSERT_TRUE(main_frame);
331 int render_process_id = main_frame->GetProcess()->GetID(); 331 int render_process_id = main_frame->GetProcess()->GetID();
332 int routing_id = main_frame->GetRoutingID(); 332 int routing_id = main_frame->GetRoutingID();
333 333
334 std::string url1("http://foo.fakeUrl"); 334 std::string url1("http://foo.fakeUrl");
335 PresentationRequest observed_request1( 335 PresentationRequest observed_request1(
336 RenderFrameHostId(render_process_id, routing_id), url1, frame_url); 336 RenderFrameHostId(render_process_id, routing_id), {url1}, frame_url);
337 EXPECT_CALL(observer, OnDefaultPresentationChanged(Equals(observed_request1))) 337 EXPECT_CALL(observer, OnDefaultPresentationChanged(Equals(observed_request1)))
338 .Times(1); 338 .Times(1);
339 delegate_impl_->SetDefaultPresentationUrl(render_process_id, routing_id, url1, 339 delegate_impl_->SetDefaultPresentationUrl(render_process_id, routing_id, url1,
340 callback); 340 callback);
341 341
342 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); 342 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest());
343 PresentationRequest request1 = 343 PresentationRequest request1 =
344 delegate_impl_->GetDefaultPresentationRequest(); 344 delegate_impl_->GetDefaultPresentationRequest();
345 EXPECT_TRUE(request1.Equals(observed_request1)); 345 EXPECT_TRUE(request1.Equals(observed_request1));
346 346
347 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&observer)); 347 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&observer));
348 348
349 std::string url2("http://youtube.com"); 349 std::string url2("http://youtube.com");
350 PresentationRequest observed_request2( 350 PresentationRequest observed_request2(
351 RenderFrameHostId(render_process_id, routing_id), url2, frame_url); 351 RenderFrameHostId(render_process_id, routing_id), {url2}, frame_url);
352 EXPECT_CALL(observer, OnDefaultPresentationChanged(Equals(observed_request2))) 352 EXPECT_CALL(observer, OnDefaultPresentationChanged(Equals(observed_request2)))
353 .Times(1); 353 .Times(1);
354 delegate_impl_->SetDefaultPresentationUrl(render_process_id, routing_id, url2, 354 delegate_impl_->SetDefaultPresentationUrl(render_process_id, routing_id, url2,
355 callback); 355 callback);
356 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest()); 356 ASSERT_TRUE(delegate_impl_->HasDefaultPresentationRequest());
357 PresentationRequest request2 = 357 PresentationRequest request2 =
358 delegate_impl_->GetDefaultPresentationRequest(); 358 delegate_impl_->GetDefaultPresentationRequest();
359 EXPECT_TRUE(request2.Equals(observed_request2)); 359 EXPECT_TRUE(request2.Equals(observed_request2));
360 360
361 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&observer)); 361 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&observer));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698