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

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

Issue 1821823002: [Media Router] Conditionally enable mDNS on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lost change to call Created 4 years, 9 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/media_router_mojo_impl_unittest.cc
diff --git a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
index 469da5d189cb51d4cbe3b77abc6b4d31d63af604..90528154a2169bff5409718de781a37b435c97b4 100644
--- a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
+++ b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
@@ -41,6 +41,7 @@
#include "testing/gtest/include/gtest/gtest.h"
using testing::_;
+using testing::AtMost;
using testing::Eq;
using testing::Invoke;
using testing::InvokeWithoutArgs;
@@ -1333,6 +1334,8 @@ TEST_F(MediaRouterMojoExtensionTest, DeferredBindingAndSuspension) {
}));
EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
.WillOnce(Return(false));
+ EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery())
+ .Times(AtMost(1));
EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId)))
.WillOnce(InvokeWithoutArgs([&run_loop2]() {
run_loop2.Quit();
@@ -1363,6 +1366,8 @@ TEST_F(MediaRouterMojoExtensionTest, DeferredBindingAndSuspension) {
}));
EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
.WillOnce(Return(false));
+ EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery())
+ .Times(AtMost(1));
EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId2)))
.WillOnce(InvokeWithoutArgs([&run_loop5]() {
run_loop5.Quit();
@@ -1474,6 +1479,8 @@ TEST_F(MediaRouterMojoExtensionTest, DropOldestPendingRequest) {
run_loop.Quit();
}));
EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()));
+ EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery())
+ .Times(AtMost(1));
EXPECT_CALL(mock_media_route_provider_, DetachRoute(mojo::String(kRouteId2)))
.Times(kMaxPendingRequests)
.WillRepeatedly(InvokeWithoutArgs([&run_loop2, &count]() {
@@ -1487,4 +1494,82 @@ TEST_F(MediaRouterMojoExtensionTest, DropOldestPendingRequest) {
1);
}
+TEST_F(MediaRouterMojoExtensionTest, EnableMdnsAfterEachRegister) {
mark a. foltz 2016/03/29 00:48:20 How about surrounding the entire test with #if def
+ // This should be queued since no MRPM is registered yet.
+ media_router_->OnUserInteraction();
+
+ BindMediaRouteProvider();
+
+ base::RunLoop run_loop;
+#if defined(OS_WIN)
+ base::RunLoop run_loop2;
+#endif
+ EXPECT_CALL(provide_handler_, Invoke(testing::Not("")))
+ .WillOnce(InvokeWithoutArgs([&run_loop]() {
+ run_loop.Quit();
+ }));
+ EXPECT_CALL(*process_manager_, IsEventPageSuspended(extension_->id()))
+ .WillOnce(Return(false));
+ // EnableMdnsDisocvery() is never called except on Windows.
+#if defined(OS_WIN)
+ EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery())
+ .WillOnce(InvokeWithoutArgs([&run_loop2]() {
+ run_loop2.Quit();
+ }));
+#endif
+ RegisterMediaRouteProvider();
+ run_loop.Run();
+#if defined(OS_WIN)
+ run_loop2.Run();
+#endif
+ // Always a no-op at this point.
+ media_router_->OnUserInteraction();
+
+ // 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;
+#if defined(OS_WIN)
+ base::RunLoop run_loop5;
+#endif
+ // 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)));
+ // EnableMdnsDisocvery() is never called except on Windows.
+#if defined(OS_WIN)
+ EXPECT_CALL(mock_media_route_provider_, EnableMdnsDiscovery())
+ .WillOnce(InvokeWithoutArgs([&run_loop5]() {
+ run_loop5.Quit();
+ }));
+#endif
+ BindMediaRouteProvider();
+ RegisterMediaRouteProvider();
+ run_loop4.Run();
+#if defined(OS_WIN)
+ run_loop5.Run();
+#else
+ base::RunLoop().RunUntilIdle();
+#endif
+ // Always a no-op at this point.
+ media_router_->OnUserInteraction();
+}
+
} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698