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

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: Really fix tests. :) 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..b97c2ee588ff3b24e8572b9c33bbba748756bd06 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,7 +1485,7 @@ 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();
btolsch 2016/04/16 00:25:55 Add another RunLoop here to send the mojo call thr
amp 2016/04/16 01:35:52 Done.
// Reset the extension by "suspending" and notifying MR.
@@ -1507,9 +1511,11 @@ TEST_F(MediaRouterMojoExtensionTest, EnableMdnsAfterEachRegister) {
run_loop4.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]() {
@@ -1519,9 +1525,47 @@ TEST_F(MediaRouterMojoExtensionTest, EnableMdnsAfterEachRegister) {
RegisterMediaRouteProvider();
run_loop4.Run();
run_loop5.Run();
- // Always a no-op at this point.
+ // Should not call EnableMdnsDiscovery, but will call UpdateMediaSinks
media_router_->OnUserGesture();
btolsch 2016/04/16 00:25:55 Add another RunLoop here to send the mojo call thr
amp 2016/04/16 01:35:52 Done.
}
#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
+ .Times(3)
+#else
+ // All others call once for registration, and once for the user gesture.
+ .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