| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 376 |
| 377 EXPECT_CALL(mock_media_route_provider_, | 377 EXPECT_CALL(mock_media_route_provider_, |
| 378 TerminateRoute(mojo::String(kRouteId))); | 378 TerminateRoute(mojo::String(kRouteId))); |
| 379 base::RunLoop run_loop2; | 379 base::RunLoop run_loop2; |
| 380 router()->OnOffTheRecordProfileShutdown(); | 380 router()->OnOffTheRecordProfileShutdown(); |
| 381 run_loop2.RunUntilIdle(); | 381 run_loop2.RunUntilIdle(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 TEST_F(MediaRouterMojoImplTest, JoinRoute) { | 384 TEST_F(MediaRouterMojoImplTest, JoinRoute) { |
| 385 MediaSource media_source(kSource); | 385 MediaSource media_source(kSource); |
| 386 | |
| 387 MediaRoute expected_route(kRouteId, media_source, kSinkId, "", false, "", | 386 MediaRoute expected_route(kRouteId, media_source, kSinkId, "", false, "", |
| 388 false); | 387 false); |
| 389 | 388 |
| 390 interfaces::MediaRoutePtr route = CreateMojoRoute(); | 389 interfaces::MediaRoutePtr route = CreateMojoRoute(); |
| 391 // Make sure the MR has received an update with the route, so it knows there | 390 // Make sure the MR has received an update with the route, so it knows there |
| 392 // is a local route to join. | 391 // is a route to join. |
| 393 mojo::Array<interfaces::MediaRoutePtr> mojo_routes(1); | 392 mojo::Array<interfaces::MediaRoutePtr> mojo_routes(1); |
| 394 mojo_routes[0] = route->Clone(); | 393 mojo_routes[0] = route->Clone(); |
| 395 router()->OnRoutesUpdated(std::move(mojo_routes), mojo::String(), | 394 router()->OnRoutesUpdated(std::move(mojo_routes), mojo::String(), |
| 396 mojo::Array<mojo::String>()); | 395 mojo::Array<mojo::String>()); |
| 396 EXPECT_TRUE(router()->HasJoinableRoute()); |
| 397 | 397 |
| 398 // Use a lambda function as an invocation target here to work around | 398 // Use a lambda function as an invocation target here to work around |
| 399 // a limitation with GMock::Invoke that prevents it from using move-only types | 399 // a limitation with GMock::Invoke that prevents it from using move-only types |
| 400 // in runnable parameter lists. | 400 // in runnable parameter lists. |
| 401 EXPECT_CALL( | 401 EXPECT_CALL( |
| 402 mock_media_route_provider_, | 402 mock_media_route_provider_, |
| 403 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId), | 403 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId), |
| 404 mojo::String(kOrigin), kInvalidTabId, kTimeoutMillis, _, _)) | 404 mojo::String(kOrigin), kInvalidTabId, kTimeoutMillis, _, _)) |
| 405 .WillOnce(Invoke([&route]( | 405 .WillOnce(Invoke([&route]( |
| 406 const mojo::String& source, const mojo::String& presentation_id, | 406 const mojo::String& source, const mojo::String& presentation_id, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 435 route_response_callbacks.push_back(base::Bind( | 435 route_response_callbacks.push_back(base::Bind( |
| 436 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler))); | 436 &RouteResponseCallbackHandler::Invoke, base::Unretained(&handler))); |
| 437 router()->JoinRoute(kSource, kPresentationId, GURL(kOrigin), nullptr, | 437 router()->JoinRoute(kSource, kPresentationId, GURL(kOrigin), nullptr, |
| 438 route_response_callbacks, | 438 route_response_callbacks, |
| 439 base::TimeDelta::FromMilliseconds(kTimeoutMillis), false); | 439 base::TimeDelta::FromMilliseconds(kTimeoutMillis), false); |
| 440 run_loop.Run(); | 440 run_loop.Run(); |
| 441 } | 441 } |
| 442 | 442 |
| 443 TEST_F(MediaRouterMojoImplTest, JoinRouteTimedOutFails) { | 443 TEST_F(MediaRouterMojoImplTest, JoinRouteTimedOutFails) { |
| 444 // Make sure the MR has received an update with the route, so it knows there | 444 // Make sure the MR has received an update with the route, so it knows there |
| 445 // is a local route to join. | 445 // is a route to join. |
| 446 mojo::Array<interfaces::MediaRoutePtr> mojo_routes(1); | 446 mojo::Array<interfaces::MediaRoutePtr> mojo_routes(1); |
| 447 mojo_routes[0] = CreateMojoRoute(); | 447 mojo_routes[0] = CreateMojoRoute(); |
| 448 router()->OnRoutesUpdated(std::move(mojo_routes), mojo::String(), | 448 router()->OnRoutesUpdated(std::move(mojo_routes), mojo::String(), |
| 449 mojo::Array<mojo::String>()); | 449 mojo::Array<mojo::String>()); |
| 450 EXPECT_TRUE(router()->HasJoinableRoute()); |
| 450 | 451 |
| 451 EXPECT_CALL( | 452 EXPECT_CALL( |
| 452 mock_media_route_provider_, | 453 mock_media_route_provider_, |
| 453 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId), | 454 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId), |
| 454 mojo::String(kOrigin), kInvalidTabId, kTimeoutMillis, _, _)) | 455 mojo::String(kOrigin), kInvalidTabId, kTimeoutMillis, _, _)) |
| 455 .WillOnce(Invoke( | 456 .WillOnce(Invoke( |
| 456 [](const mojo::String& source, const mojo::String& presentation_id, | 457 [](const mojo::String& source, const mojo::String& presentation_id, |
| 457 const mojo::String& origin, int tab_id, int64_t timeout_millis, | 458 const mojo::String& origin, int tab_id, int64_t timeout_millis, |
| 458 bool off_the_record, | 459 bool off_the_record, |
| 459 const interfaces::MediaRouteProvider::JoinRouteCallback& cb) { | 460 const interfaces::MediaRouteProvider::JoinRouteCallback& cb) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 472 router()->JoinRoute(kSource, kPresentationId, GURL(kOrigin), nullptr, | 473 router()->JoinRoute(kSource, kPresentationId, GURL(kOrigin), nullptr, |
| 473 route_response_callbacks, | 474 route_response_callbacks, |
| 474 base::TimeDelta::FromMilliseconds(kTimeoutMillis), false); | 475 base::TimeDelta::FromMilliseconds(kTimeoutMillis), false); |
| 475 run_loop.Run(); | 476 run_loop.Run(); |
| 476 } | 477 } |
| 477 | 478 |
| 478 TEST_F(MediaRouterMojoImplTest, JoinRouteOffTheRecordMismatchFails) { | 479 TEST_F(MediaRouterMojoImplTest, JoinRouteOffTheRecordMismatchFails) { |
| 479 interfaces::MediaRoutePtr route = CreateMojoRoute(); | 480 interfaces::MediaRoutePtr route = CreateMojoRoute(); |
| 480 | 481 |
| 481 // Make sure the MR has received an update with the route, so it knows there | 482 // Make sure the MR has received an update with the route, so it knows there |
| 482 // is a local route to join. | 483 // is a route to join. |
| 483 mojo::Array<interfaces::MediaRoutePtr> mojo_routes(1); | 484 mojo::Array<interfaces::MediaRoutePtr> mojo_routes(1); |
| 484 mojo_routes[0] = route->Clone(); | 485 mojo_routes[0] = route->Clone(); |
| 485 router()->OnRoutesUpdated(std::move(mojo_routes), mojo::String(), | 486 router()->OnRoutesUpdated(std::move(mojo_routes), mojo::String(), |
| 486 mojo::Array<mojo::String>()); | 487 mojo::Array<mojo::String>()); |
| 488 EXPECT_TRUE(router()->HasJoinableRoute()); |
| 487 | 489 |
| 488 // Use a lambda function as an invocation target here to work around | 490 // Use a lambda function as an invocation target here to work around |
| 489 // a limitation with GMock::Invoke that prevents it from using move-only types | 491 // a limitation with GMock::Invoke that prevents it from using move-only types |
| 490 // in runnable parameter lists. | 492 // in runnable parameter lists. |
| 491 EXPECT_CALL( | 493 EXPECT_CALL( |
| 492 mock_media_route_provider_, | 494 mock_media_route_provider_, |
| 493 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId), | 495 JoinRoute(mojo::String(kSource), mojo::String(kPresentationId), |
| 494 mojo::String(kOrigin), kInvalidTabId, kTimeoutMillis, true, _)) | 496 mojo::String(kOrigin), kInvalidTabId, kTimeoutMillis, true, _)) |
| 495 .WillOnce(Invoke([&route]( | 497 .WillOnce(Invoke([&route]( |
| 496 const mojo::String& source, const mojo::String& presentation_id, | 498 const mojo::String& source, const mojo::String& presentation_id, |
| (...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 EXPECT_CALL(mock_media_route_provider_, | 1632 EXPECT_CALL(mock_media_route_provider_, |
| 1631 UpdateMediaSinks(mojo::String(MediaSourceForDesktop().id()))) | 1633 UpdateMediaSinks(mojo::String(MediaSourceForDesktop().id()))) |
| 1632 .WillOnce(InvokeWithoutArgs([&run_loop2]() { | 1634 .WillOnce(InvokeWithoutArgs([&run_loop2]() { |
| 1633 run_loop2.Quit(); | 1635 run_loop2.Quit(); |
| 1634 })); | 1636 })); |
| 1635 | 1637 |
| 1636 run_loop2.Run(); | 1638 run_loop2.Run(); |
| 1637 } | 1639 } |
| 1638 | 1640 |
| 1639 } // namespace media_router | 1641 } // namespace media_router |
| OLD | NEW |