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

Unified Diff: chrome/browser/media/router/mojo/media_router_mojo_impl_unittest.cc

Issue 1862913004: [Media Router] Wire through a new MRPM call to update media sinks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed indent, added wake reason. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/mojo/media_router_mojo_impl_unittest.cc
diff --git a/chrome/browser/media/router/mojo/media_router_mojo_impl_unittest.cc b/chrome/browser/media/router/mojo/media_router_mojo_impl_unittest.cc
index 764a778002fb5251f48e0547352752b6336ea582..d750d61b06d9e385a3636ca4e6f68bcd2cdaab3e 100644
--- a/chrome/browser/media/router/mojo/media_router_mojo_impl_unittest.cc
+++ b/chrome/browser/media/router/mojo/media_router_mojo_impl_unittest.cc
@@ -1521,4 +1521,67 @@ TEST_F(MediaRouterMojoExtensionTest, EnableMdnsAfterEachRegister) {
}
#endif
+TEST_F(MediaRouterMojoExtensionTest, UserGestureDiscovery) {
+ // TODO(amp): Fix this test before submitting.
+ // This should be queued since no MRPM is registered yet.
+ media_router_->OnUserGesture();
+
+ BindMediaRouteProvider();
+
+ base::RunLoop run_loop;
+ base::RunLoop run_loop2;
+ EXPECT_CALL(provide_handler_, Invoke(testing::Not("")))
+ .WillOnce(InvokeWithoutArgs([&run_loop]() {
+ run_loop.Quit();
+ }));
+ EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
+ .WillOnce(Return(false));
+ EXPECT_CALL(mock_media_route_provider_, StartDiscovery())
+ .WillOnce(InvokeWithoutArgs([&run_loop2]() {
+ run_loop2.Quit();
+ }));
+ RegisterMediaRouteProvider();
+ run_loop.Run();
+ run_loop2.Run();
+ // Always a no-op at this point.
+ media_router_->OnUserGesture();
+
+ // Reset the extension by "suspending" and notifying MR.
+ base::RunLoop run_loop3;
+ ResetMediaRouteProvider();
+ EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
+ .WillOnce(Return(true));
+ EXPECT_CALL(*process_manager_, WakeEventPage(extension_->id(), _))
+ .WillOnce(testing::DoAll(
+ media::RunCallback<1>(true),
+ InvokeWithoutArgs([&run_loop3]() { run_loop3.Quit(); }),
+ Return(true)));
+ // Use DetachRoute because it unconditionally calls RunOrDefer().
+ media_router_->DetachRoute(kRouteId);
+ run_loop3.Run();
+
+ base::RunLoop run_loop4;
+ base::RunLoop run_loop5;
+ // RegisterMediaRouteProvider() is called.
+ // The queued DetachRoute(kRouteId) call should be executed.
+ EXPECT_CALL(provide_handler_, Invoke(testing::Not("")))
+ .WillOnce(InvokeWithoutArgs([&run_loop4]() {
+ run_loop4.Quit();
+ }));
+ EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
+ .WillOnce(Return(false));
+ // Expected because it was used to wake up the page.
+ EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId)));
+ EXPECT_CALL(mock_media_route_provider_, StartDiscovery())
+ .WillOnce(InvokeWithoutArgs([&run_loop5]() {
+ run_loop5.Quit();
+ }));
+ BindMediaRouteProvider();
+ RegisterMediaRouteProvider();
+ run_loop4.Run();
+ run_loop5.Run();
+ // Always a no-op at this point.
+ media_router_->OnUserGesture();
+}
+
} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698