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

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: add missing run loops 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 9079344b26a021b1025ec9b62bd271a5dcf25f69..02d50f8774eaa5f7c71ab91a6f8236cb6c48b665 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
@@ -20,6 +20,7 @@
#include "base/thread_task_runner_handle.h"
#include "chrome/browser/media/router/issue.h"
#include "chrome/browser/media/router/media_route.h"
+#include "chrome/browser/media/router/media_source_helper.h"
#include "chrome/browser/media/router/mock_media_router.h"
#include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h"
#include "chrome/browser/media/router/mojo/media_router_mojo_test.h"
@@ -1472,7 +1473,10 @@ TEST_F(MediaRouterMojoExtensionTest, EnableMdnsAfterEachRegister) {
run_loop.Quit();
}));
EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
- .WillOnce(Return(false));
+ .WillOnce(Return(false)).WillOnce(Return(false));
+ EXPECT_CALL(mock_media_route_provider_,
+ UpdateMediaSinks(mojo::String(MediaSourceForDesktop().id())))
+ .Times(2);
// EnableMdnsDisocvery() is never called except on Windows.
EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery())
.WillOnce(InvokeWithoutArgs([&run_loop2]() {
@@ -1481,47 +1485,91 @@ TEST_F(MediaRouterMojoExtensionTest, EnableMdnsAfterEachRegister) {
RegisterMediaRouteProvider();
run_loop.Run();
run_loop2.Run();
- // Always a no-op at this point.
+ // Should not call EnableMdnsDiscovery, but will call UpdateMediaSinks
media_router_->OnUserGesture();
+ base::RunLoop run_loop3;
+ run_loop3.RunUntilIdle();
// Reset the extension by "suspending" and notifying MR.
- base::RunLoop run_loop3;
+ base::RunLoop run_loop4;
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(); }),
+ InvokeWithoutArgs([&run_loop4]() { run_loop4.Quit(); }),
Return(true)));
// Use DetachRoute because it unconditionally calls RunOrDefer().
media_router_->DetachRoute(kRouteId);
- run_loop3.Run();
+ run_loop4.Run();
- base::RunLoop run_loop4;
base::RunLoop run_loop5;
+ base::RunLoop run_loop6;
// 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();
+ .WillOnce(InvokeWithoutArgs([&run_loop5]() {
+ run_loop5.Quit();
}));
EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
- .WillOnce(Return(false));
+ .WillOnce(Return(false)).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_,
+ UpdateMediaSinks(mojo::String(MediaSourceForDesktop().id())));
// EnableMdnsDisocvery() is never called except on Windows.
EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery())
- .WillOnce(InvokeWithoutArgs([&run_loop5]() {
- run_loop5.Quit();
+ .WillOnce(InvokeWithoutArgs([&run_loop6]() {
+ run_loop6.Quit();
}));
BindMediaRouteProvider();
RegisterMediaRouteProvider();
- run_loop4.Run();
run_loop5.Run();
- // Always a no-op at this point.
+ run_loop6.Run();
+ // Should not call EnableMdnsDiscovery, but will call UpdateMediaSinks
media_router_->OnUserGesture();
+ base::RunLoop run_loop7;
+ run_loop7.RunUntilIdle();
mark a. foltz 2016/04/22 22:20:39 These run loops are getting crazy. The mock MRP s
}
#endif
+TEST_F(MediaRouterMojoExtensionTest, UpdateMediaSinksOnUserGesture) {
+ BindMediaRouteProvider();
+
+ base::RunLoop run_loop;
+ EXPECT_CALL(provide_handler_, Invoke(testing::Not("")))
+ .WillOnce(InvokeWithoutArgs([&run_loop]() {
+ run_loop.Quit();
+ }));
+ EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
+#if defined(OS_WIN)
+ // Windows calls once for EnableMdnsDiscovery
mark a. foltz 2016/04/22 22:20:38 "...calls an additional time for..."
+ .Times(3)
+#else
+ // All others call once for registration, and once for the user gesture.
mark a. foltz 2016/04/22 22:20:38 Thanks for adding comments to the expectations.
+ .Times(2)
+#endif
+ .WillRepeatedly(Return(false));
+
+
+ RegisterMediaRouteProvider();
+ run_loop.Run();
+
+ media_router_->OnUserGesture();
+
+ base::RunLoop run_loop2;
+
+#if defined(OS_WIN)
+ EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery());
+#endif
+ EXPECT_CALL(mock_media_route_provider_,
+ UpdateMediaSinks(mojo::String(MediaSourceForDesktop().id())))
+ .WillOnce(InvokeWithoutArgs([&run_loop2]() {
+ run_loop2.Quit();
+ }));
+
+ run_loop2.Run();
+}
+
} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698