| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 19 #include "base/test/histogram_tester.h" | 19 #include "base/test/histogram_tester.h" |
| 20 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
| 21 #include "chrome/browser/media/router/issue.h" | 21 #include "chrome/browser/media/router/issue.h" |
| 22 #include "chrome/browser/media/router/media_route.h" | 22 #include "chrome/browser/media/router/media_route.h" |
| 23 #include "chrome/browser/media/router/media_source_helper.h" |
| 23 #include "chrome/browser/media/router/mock_media_router.h" | 24 #include "chrome/browser/media/router/mock_media_router.h" |
| 24 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" | 25 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" |
| 25 #include "chrome/browser/media/router/mojo/media_router_mojo_test.h" | 26 #include "chrome/browser/media/router/mojo/media_router_mojo_test.h" |
| 26 #include "chrome/browser/media/router/mojo/media_router_type_converters.h" | 27 #include "chrome/browser/media/router/mojo/media_router_type_converters.h" |
| 27 #include "chrome/browser/media/router/presentation_session_messages_observer.h" | 28 #include "chrome/browser/media/router/presentation_session_messages_observer.h" |
| 28 #include "chrome/browser/media/router/test_helper.h" | 29 #include "chrome/browser/media/router/test_helper.h" |
| 29 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 30 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 30 #include "chrome/test/base/testing_browser_process.h" | 31 #include "chrome/test/base/testing_browser_process.h" |
| 31 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
| 32 #include "components/version_info/version_info.h" | 33 #include "components/version_info/version_info.h" |
| (...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 })); | 1518 })); |
| 1518 BindMediaRouteProvider(); | 1519 BindMediaRouteProvider(); |
| 1519 RegisterMediaRouteProvider(); | 1520 RegisterMediaRouteProvider(); |
| 1520 run_loop4.Run(); | 1521 run_loop4.Run(); |
| 1521 run_loop5.Run(); | 1522 run_loop5.Run(); |
| 1522 // Always a no-op at this point. | 1523 // Always a no-op at this point. |
| 1523 media_router_->OnUserGesture(); | 1524 media_router_->OnUserGesture(); |
| 1524 } | 1525 } |
| 1525 #endif | 1526 #endif |
| 1526 | 1527 |
| 1528 TEST_F(MediaRouterMojoExtensionTest, UpdateMediaSinksOnUserGesture) { |
| 1529 BindMediaRouteProvider(); |
| 1530 |
| 1531 base::RunLoop run_loop; |
| 1532 EXPECT_CALL(provide_handler_, Invoke(testing::Not(""))) |
| 1533 .WillOnce(InvokeWithoutArgs([&run_loop]() { |
| 1534 run_loop.Quit(); |
| 1535 })); |
| 1536 // Called once for registration, and once for the user gesture. |
| 1537 EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id())) |
| 1538 .WillOnce(Return(false)).WillOnce(Return(false)); |
| 1539 RegisterMediaRouteProvider(); |
| 1540 run_loop.Run(); |
| 1541 |
| 1542 media_router_->OnUserGesture(); |
| 1543 |
| 1544 base::RunLoop run_loop2; |
| 1545 |
| 1546 EXPECT_CALL(mock_media_route_provider_, |
| 1547 UpdateMediaSinks(mojo::String(MediaSourceForDesktop().id()))) |
| 1548 .WillOnce(InvokeWithoutArgs([&run_loop2]() { |
| 1549 run_loop2.Quit(); |
| 1550 })); |
| 1551 |
| 1552 run_loop2.Run(); |
| 1553 } |
| 1554 |
| 1527 } // namespace media_router | 1555 } // namespace media_router |
| OLD | NEW |