| 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 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 media_router_->OnUserGesture(); | 1299 media_router_->OnUserGesture(); |
| 1300 | 1300 |
| 1301 BindMediaRouteProvider(); | 1301 BindMediaRouteProvider(); |
| 1302 | 1302 |
| 1303 base::RunLoop run_loop; | 1303 base::RunLoop run_loop; |
| 1304 base::RunLoop run_loop2; | 1304 base::RunLoop run_loop2; |
| 1305 EXPECT_CALL(provide_handler_, Invoke(testing::Not(""))) | 1305 EXPECT_CALL(provide_handler_, Invoke(testing::Not(""))) |
| 1306 .WillOnce(InvokeWithoutArgs([&run_loop]() { | 1306 .WillOnce(InvokeWithoutArgs([&run_loop]() { |
| 1307 run_loop.Quit(); | 1307 run_loop.Quit(); |
| 1308 })); | 1308 })); |
| 1309 EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_id())) | 1309 EXPECT_CALL(*process_manager_, IsEventPageSuspended(kExtensionId)) |
| 1310 .WillOnce(Return(false)); | 1310 .WillOnce(Return(false)); |
| 1311 // EnableMdnsDisocvery() is never called except on Windows. | 1311 // EnableMdnsDisocvery() is never called except on Windows. |
| 1312 EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery()) | 1312 EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery()) |
| 1313 .WillOnce(InvokeWithoutArgs([&run_loop2]() { | 1313 .WillOnce(InvokeWithoutArgs([&run_loop2]() { |
| 1314 run_loop2.Quit(); | 1314 run_loop2.Quit(); |
| 1315 })); | 1315 })); |
| 1316 RegisterMediaRouteProvider(); | 1316 RegisterMediaRouteProvider(); |
| 1317 run_loop.Run(); | 1317 run_loop.Run(); |
| 1318 run_loop2.Run(); | 1318 run_loop2.Run(); |
| 1319 // Always a no-op at this point. | 1319 // Always a no-op at this point. |
| 1320 media_router_->OnUserGesture(); | 1320 media_router_->OnUserGesture(); |
| 1321 | 1321 |
| 1322 // Reset the extension by "suspending" and notifying MR. | 1322 // Reset the extension by "suspending" and notifying MR. |
| 1323 base::RunLoop run_loop3; | 1323 base::RunLoop run_loop3; |
| 1324 ResetMediaRouteProvider(); | 1324 ResetMediaRouteProvider(); |
| 1325 EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_id())) | 1325 EXPECT_CALL(*process_manager_, IsEventPageSuspended(kExtensionId)) |
| 1326 .WillOnce(Return(true)); | 1326 .WillOnce(Return(true)); |
| 1327 EXPECT_CALL(*process_manager_, WakeEventPage(extension_id(), _)) | 1327 EXPECT_CALL(*process_manager_, WakeEventPage(kExtensionId, _)) |
| 1328 .WillOnce(testing::DoAll( | 1328 .WillOnce(testing::DoAll( |
| 1329 media::RunCallback<1>(true), | 1329 media::RunCallback<1>(true), |
| 1330 InvokeWithoutArgs([&run_loop3]() { run_loop3.Quit(); }), | 1330 InvokeWithoutArgs([&run_loop3]() { run_loop3.Quit(); }), |
| 1331 Return(true))); | 1331 Return(true))); |
| 1332 // Use DetachRoute because it unconditionally calls RunOrDefer(). | 1332 // Use DetachRoute because it unconditionally calls RunOrDefer(). |
| 1333 media_router_->DetachRoute(kRouteId); | 1333 media_router_->DetachRoute(kRouteId); |
| 1334 run_loop3.Run(); | 1334 run_loop3.Run(); |
| 1335 | 1335 |
| 1336 base::RunLoop run_loop4; | 1336 base::RunLoop run_loop4; |
| 1337 base::RunLoop run_loop5; | 1337 base::RunLoop run_loop5; |
| 1338 // RegisterMediaRouteProvider() is called. | 1338 // RegisterMediaRouteProvider() is called. |
| 1339 // The queued DetachRoute(kRouteId) call should be executed. | 1339 // The queued DetachRoute(kRouteId) call should be executed. |
| 1340 EXPECT_CALL(provide_handler_, Invoke(testing::Not(""))) | 1340 EXPECT_CALL(provide_handler_, Invoke(testing::Not(""))) |
| 1341 .WillOnce(InvokeWithoutArgs([&run_loop4]() { | 1341 .WillOnce(InvokeWithoutArgs([&run_loop4]() { |
| 1342 run_loop4.Quit(); | 1342 run_loop4.Quit(); |
| 1343 })); | 1343 })); |
| 1344 EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_id())) | 1344 EXPECT_CALL(*process_manager_, IsEventPageSuspended(kExtensionId)) |
| 1345 .WillOnce(Return(false)); | 1345 .WillOnce(Return(false)); |
| 1346 // Expected because it was used to wake up the page. | 1346 // Expected because it was used to wake up the page. |
| 1347 EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId))); | 1347 EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId))); |
| 1348 // EnableMdnsDisocvery() is never called except on Windows. | 1348 // EnableMdnsDisocvery() is never called except on Windows. |
| 1349 EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery()) | 1349 EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery()) |
| 1350 .WillOnce(InvokeWithoutArgs([&run_loop5]() { | 1350 .WillOnce(InvokeWithoutArgs([&run_loop5]() { |
| 1351 run_loop5.Quit(); | 1351 run_loop5.Quit(); |
| 1352 })); | 1352 })); |
| 1353 BindMediaRouteProvider(); | 1353 BindMediaRouteProvider(); |
| 1354 RegisterMediaRouteProvider(); | 1354 RegisterMediaRouteProvider(); |
| 1355 run_loop4.Run(); | 1355 run_loop4.Run(); |
| 1356 run_loop5.Run(); | 1356 run_loop5.Run(); |
| 1357 // Always a no-op at this point. | 1357 // Always a no-op at this point. |
| 1358 media_router_->OnUserGesture(); | 1358 media_router_->OnUserGesture(); |
| 1359 } | 1359 } |
| 1360 #endif | 1360 #endif |
| 1361 | 1361 |
| 1362 } // namespace media_router | 1362 } // namespace media_router |
| OLD | NEW |