| 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 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 })); | 1514 })); |
| 1515 BindMediaRouteProvider(); | 1515 BindMediaRouteProvider(); |
| 1516 RegisterMediaRouteProvider(); | 1516 RegisterMediaRouteProvider(); |
| 1517 run_loop4.Run(); | 1517 run_loop4.Run(); |
| 1518 run_loop5.Run(); | 1518 run_loop5.Run(); |
| 1519 // Always a no-op at this point. | 1519 // Always a no-op at this point. |
| 1520 media_router_->OnUserGesture(); | 1520 media_router_->OnUserGesture(); |
| 1521 } | 1521 } |
| 1522 #endif | 1522 #endif |
| 1523 | 1523 |
| 1524 TEST_F(MediaRouterMojoExtensionTest, UserGestureDiscovery) { |
| 1525 // TODO(amp): Fix this test before submitting. |
| 1526 // This should be queued since no MRPM is registered yet. |
| 1527 media_router_->OnUserGesture(); |
| 1528 |
| 1529 BindMediaRouteProvider(); |
| 1530 |
| 1531 base::RunLoop run_loop; |
| 1532 base::RunLoop run_loop2; |
| 1533 EXPECT_CALL(provide_handler_, Invoke(testing::Not(""))) |
| 1534 .WillOnce(InvokeWithoutArgs([&run_loop]() { |
| 1535 run_loop.Quit(); |
| 1536 })); |
| 1537 EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id())) |
| 1538 .WillOnce(Return(false)); |
| 1539 EXPECT_CALL(mock_media_route_provider_, StartDiscovery()) |
| 1540 .WillOnce(InvokeWithoutArgs([&run_loop2]() { |
| 1541 run_loop2.Quit(); |
| 1542 })); |
| 1543 RegisterMediaRouteProvider(); |
| 1544 run_loop.Run(); |
| 1545 run_loop2.Run(); |
| 1546 // Always a no-op at this point. |
| 1547 media_router_->OnUserGesture(); |
| 1548 |
| 1549 // Reset the extension by "suspending" and notifying MR. |
| 1550 base::RunLoop run_loop3; |
| 1551 ResetMediaRouteProvider(); |
| 1552 EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id())) |
| 1553 .WillOnce(Return(true)); |
| 1554 EXPECT_CALL(*process_manager_, WakeEventPage(extension_->id(), _)) |
| 1555 .WillOnce(testing::DoAll( |
| 1556 media::RunCallback<1>(true), |
| 1557 InvokeWithoutArgs([&run_loop3]() { run_loop3.Quit(); }), |
| 1558 Return(true))); |
| 1559 // Use DetachRoute because it unconditionally calls RunOrDefer(). |
| 1560 media_router_->DetachRoute(kRouteId); |
| 1561 run_loop3.Run(); |
| 1562 |
| 1563 base::RunLoop run_loop4; |
| 1564 base::RunLoop run_loop5; |
| 1565 // RegisterMediaRouteProvider() is called. |
| 1566 // The queued DetachRoute(kRouteId) call should be executed. |
| 1567 EXPECT_CALL(provide_handler_, Invoke(testing::Not(""))) |
| 1568 .WillOnce(InvokeWithoutArgs([&run_loop4]() { |
| 1569 run_loop4.Quit(); |
| 1570 })); |
| 1571 EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id())) |
| 1572 .WillOnce(Return(false)); |
| 1573 // Expected because it was used to wake up the page. |
| 1574 EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId))); |
| 1575 EXPECT_CALL(mock_media_route_provider_, StartDiscovery()) |
| 1576 .WillOnce(InvokeWithoutArgs([&run_loop5]() { |
| 1577 run_loop5.Quit(); |
| 1578 })); |
| 1579 BindMediaRouteProvider(); |
| 1580 RegisterMediaRouteProvider(); |
| 1581 run_loop4.Run(); |
| 1582 run_loop5.Run(); |
| 1583 // Always a no-op at this point. |
| 1584 media_router_->OnUserGesture(); |
| 1585 } |
| 1586 |
| 1524 } // namespace media_router | 1587 } // namespace media_router |
| OLD | NEW |