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

Unified Diff: chrome/browser/ui/ash/system_tray_tray_cast_browsertest_media_router_chromeos.cc

Issue 2525563003: mash: Change CastConfigDelegate to a mojoified CastConfigClient. (Closed)
Patch Set: Add more RunAllPendingInMessageLoop to the tray tests. Created 4 years 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/ui/ash/system_tray_tray_cast_browsertest_media_router_chromeos.cc
diff --git a/chrome/browser/ui/ash/system_tray_tray_cast_browsertest_media_router_chromeos.cc b/chrome/browser/ui/ash/system_tray_tray_cast_browsertest_media_router_chromeos.cc
index d026e98acddf44826322b63013570a353dc273b0..4b9a2fdae43580c47b59a3b2a0e523854e15d8df 100644
--- a/chrome/browser/ui/ash/system_tray_tray_cast_browsertest_media_router_chromeos.cc
+++ b/chrome/browser/ui/ash/system_tray_tray_cast_browsertest_media_router_chromeos.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/media/router/media_sinks_observer.h"
#include "chrome/browser/media/router/media_source_helper.h"
#include "chrome/browser/media/router/mock_media_router.h"
-#include "chrome/browser/ui/ash/cast_config_delegate_media_router.h"
+#include "chrome/browser/ui/ash/cast_config_client_media_router.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/test_utils.h"
#include "url/gurl.h"
@@ -57,10 +57,12 @@ class SystemTrayTrayCastMediaRouterChromeOSTest : public InProcessBrowserTest {
~SystemTrayTrayCastMediaRouterChromeOSTest() override {}
media_router::MediaSinksObserver* media_sinks_observer() const {
+ DCHECK(media_sinks_observer_);
return media_sinks_observer_;
}
media_router::MediaRoutesObserver* media_routes_observer() const {
+ DCHECK(media_routes_observer_);
return media_routes_observer_;
}
@@ -75,19 +77,34 @@ class SystemTrayTrayCastMediaRouterChromeOSTest : public InProcessBrowserTest {
}
void SetUpInProcessBrowserTestFixture() override {
+ InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
+
ON_CALL(media_router_, RegisterMediaSinksObserver(_))
.WillByDefault(Invoke(
this, &SystemTrayTrayCastMediaRouterChromeOSTest::CaptureSink));
ON_CALL(media_router_, RegisterMediaRoutesObserver(_))
.WillByDefault(Invoke(
this, &SystemTrayTrayCastMediaRouterChromeOSTest::CaptureRoutes));
+ CastConfigClientMediaRouter::SetMediaRouterForTest(&media_router_);
+ }
+
+ void SetUpOnMainThread() override {
+ InProcessBrowserTest::SetUpOnMainThread();
+ cast_config_client_media_router_ =
+ base::MakeUnique<CastConfigClientMediaRouter>();
James Cook 2016/12/02 04:15:52 Why do you need to make a second CastConfigClientM
Elliot Glaysher 2016/12/02 19:23:11 Deleted. I suspect this was a side effect of putti
+ cast_config_client_media_router_->FlushForTesting();
+ }
- CastConfigDelegateMediaRouter::SetMediaRouterForTest(&media_router_);
+ void TearDownInProcessBrowserTestFixture() override {
+ cast_config_client_media_router_.reset();
+ CastConfigClientMediaRouter::SetMediaRouterForTest(nullptr);
+ InProcessBrowserTest::TearDownInProcessBrowserTestFixture();
}
media_router::MockMediaRouter media_router_;
media_router::MediaSinksObserver* media_sinks_observer_ = nullptr;
media_router::MediaRoutesObserver* media_routes_observer_ = nullptr;
+ std::unique_ptr<CastConfigClientMediaRouter> cast_config_client_media_router_;
DISALLOW_COPY_AND_ASSIGN(SystemTrayTrayCastMediaRouterChromeOSTest);
};
@@ -112,25 +129,24 @@ IN_PROC_BROWSER_TEST_F(SystemTrayTrayCastMediaRouterChromeOSTest,
// The tray should be hidden when there are no sinks.
EXPECT_FALSE(test_api.IsTrayVisible());
media_sinks_observer()->OnSinksUpdated(zero_sinks, std::vector<GURL>());
+ content::RunAllPendingInMessageLoop();
James Cook 2016/12/02 04:15:52 Maybe comment the first one of these to say that i
Elliot Glaysher 2016/12/02 19:23:11 Done.
EXPECT_FALSE(test_api.IsTrayVisible());
EXPECT_FALSE(test_api.IsTraySelectViewVisible());
// The tray should be visible with any more than zero sinks.
media_sinks_observer()->OnSinksUpdated(one_sink, std::vector<GURL>());
+ content::RunAllPendingInMessageLoop();
EXPECT_TRUE(test_api.IsTrayVisible());
media_sinks_observer()->OnSinksUpdated(two_sinks, std::vector<GURL>());
+ content::RunAllPendingInMessageLoop();
EXPECT_TRUE(test_api.IsTrayVisible());
EXPECT_TRUE(test_api.IsTraySelectViewVisible());
// And if all of the sinks go away, it should be hidden again.
media_sinks_observer()->OnSinksUpdated(zero_sinks, std::vector<GURL>());
+ content::RunAllPendingInMessageLoop();
EXPECT_FALSE(test_api.IsTrayVisible());
EXPECT_FALSE(test_api.IsTraySelectViewVisible());
-
- // The CastConfigDelegate instance gets destroyed before the TrayCast
- // instance. The delegate will assert if there are still callbacks registered.
- // We need to cleanup the TrayCast callbacks to prevent the assert.
- ash::TrayCastTestAPI(GetTrayCast()).ReleaseConfigCallbacks();
}
// Verifies that we show the cast view when we start a casting session, and that
@@ -147,6 +163,7 @@ IN_PROC_BROWSER_TEST_F(SystemTrayTrayCastMediaRouterChromeOSTest,
sinks.push_back(MakeSink("remote_sink", "name"));
sinks.push_back(MakeSink("local_sink", "name"));
media_sinks_observer()->OnSinksUpdated(sinks, std::vector<GURL>());
+ content::RunAllPendingInMessageLoop();
// Create route combinations. More details below.
media_router::MediaRoute non_local_route =
@@ -165,6 +182,7 @@ IN_PROC_BROWSER_TEST_F(SystemTrayTrayCastMediaRouterChromeOSTest,
test_api.OnCastingSessionStartedOrStopped(true /*is_casting*/);
media_routes_observer()->OnRoutesUpdated(
multiple_routes, std::vector<media_router::MediaRoute::Id>());
+ content::RunAllPendingInMessageLoop();
EXPECT_TRUE(test_api.IsTrayCastViewVisible());
EXPECT_EQ("local_route", test_api.GetDisplayedCastId());
@@ -172,7 +190,6 @@ IN_PROC_BROWSER_TEST_F(SystemTrayTrayCastMediaRouterChromeOSTest,
test_api.OnCastingSessionStartedOrStopped(false /*is_casting*/);
media_routes_observer()->OnRoutesUpdated(
no_routes, std::vector<media_router::MediaRoute::Id>());
+ content::RunAllPendingInMessageLoop();
EXPECT_FALSE(test_api.IsTrayCastViewVisible());
-
- ash::TrayCastTestAPI(GetTrayCast()).ReleaseConfigCallbacks();
}

Powered by Google App Engine
This is Rietveld 408576698