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

Unified Diff: chrome/browser/ui/toolbar/media_router_action_unittest.cc

Issue 1383653002: MediaRouterAction: Only observe Media Routes when there is a local route. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/ui/toolbar/media_router_action_unittest.cc
diff --git a/chrome/browser/ui/toolbar/media_router_action_unittest.cc b/chrome/browser/ui/toolbar/media_router_action_unittest.cc
index c10392f24da96198e7d7f62ad2dee1bee2c70a25..0e8e1be13c18676d06f1c7332a6144fc2424cea6 100644
--- a/chrome/browser/ui/toolbar/media_router_action_unittest.cc
+++ b/chrome/browser/ui/toolbar/media_router_action_unittest.cc
@@ -96,20 +96,6 @@ class MediaRouterActionUnitTest : public MediaRouterTest {
std::string())),
fake_source1_("fakeSource1"),
fake_source2_("fakeSource2"),
- fake_route_local_("route1",
- fake_source1_,
- "fakeSink1",
- "desc1",
- true,
- "path.html",
- false),
- fake_route_remote_("route2",
- fake_source2_,
- "fakeSink2",
- "desc2",
- false,
- "path.html",
- true),
active_icon_(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_MEDIA_ROUTER_ACTIVE_ICON)),
error_icon_(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
@@ -142,12 +128,6 @@ class MediaRouterActionUnitTest : public MediaRouterTest {
const media_router::Issue* fake_issue_fatal() {
return &fake_issue_fatal_;
}
- const media_router::MediaRoute fake_route_local() {
- return fake_route_local_;
- }
- const media_router::MediaRoute fake_route_remote() {
- return fake_route_remote_;
- }
const gfx::Image active_icon() { return active_icon_; }
const gfx::Image error_icon() { return error_icon_; }
const gfx::Image idle_icon() { return idle_icon_; }
@@ -165,10 +145,6 @@ class MediaRouterActionUnitTest : public MediaRouterTest {
const media_router::MediaSource fake_source1_;
const media_router::MediaSource fake_source2_;
- // Fake Routes.
- const media_router::MediaRoute fake_route_local_;
- const media_router::MediaRoute fake_route_remote_;
-
// Cached images.
const gfx::Image active_icon_;
const gfx::Image error_icon_;
@@ -214,41 +190,26 @@ TEST_F(MediaRouterActionUnitTest, UpdateIssues) {
action()->GetIcon(nullptr, gfx::Size())));
}
-// Tests the MediaRouterAction state based on updates to routes.
+// Tests the MediaRouterAction state based on updates on whether there are
+// local routes.
TEST_F(MediaRouterActionUnitTest, UpdateRoutes) {
- scoped_ptr<std::vector<media_router::MediaRoute>> routes(
- new std::vector<media_router::MediaRoute>());
-
// Initially, there are no routes.
EXPECT_TRUE(gfx::test::AreImagesEqual(
idle_icon(), action()->GetIcon(nullptr, gfx::Size())));
// Update |current_icon_| since there is a local route.
- routes->push_back(fake_route_local());
- routes->push_back(fake_route_remote());
- action()->OnRoutesUpdated(*routes.get());
+ action()->SetHasLocalRoute(true);
EXPECT_TRUE(gfx::test::AreImagesEqual(
active_icon(), action()->GetIcon(nullptr, gfx::Size())));
- // Update |current_icon_| since there are no more local routes.
- routes->clear();
- routes->push_back(fake_route_remote());
- action()->OnRoutesUpdated(*routes.get());
- EXPECT_TRUE(gfx::test::AreImagesEqual(
- idle_icon(), action()->GetIcon(nullptr, gfx::Size())));
-
- // |current_icon_| stays the same if there are no local routes or no routes.
- routes->clear();
- action()->OnRoutesUpdated(*routes.get());
+ // Update |current_icon_| since there are no local routes.
+ action()->SetHasLocalRoute(false);
EXPECT_TRUE(gfx::test::AreImagesEqual(
idle_icon(), action()->GetIcon(nullptr, gfx::Size())));
}
// Tests the MediaRouterAction icon based on updates to both issues and routes.
TEST_F(MediaRouterActionUnitTest, UpdateIssuesAndRoutes) {
- scoped_ptr<std::vector<media_router::MediaRoute>> routes(
- new std::vector<media_router::MediaRoute>());
-
// Initially, there are no issues or routes.
EXPECT_TRUE(gfx::test::AreImagesEqual(
idle_icon(), action()->GetIcon(nullptr, gfx::Size())));
@@ -260,15 +221,12 @@ TEST_F(MediaRouterActionUnitTest, UpdateIssuesAndRoutes) {
idle_icon(), action()->GetIcon(nullptr, gfx::Size())));
// Non-local routes also do not have an effect on |current_icon_|.
- routes->push_back(fake_route_remote());
- action()->OnRoutesUpdated(*routes.get());
+ action()->SetHasLocalRoute(false);
EXPECT_TRUE(gfx::test::AreImagesEqual(
idle_icon(), action()->GetIcon(nullptr, gfx::Size())));
// Update |current_icon_| since there is a local route.
- routes->clear();
- routes->push_back(fake_route_local());
- action()->OnRoutesUpdated(*routes.get());
+ action()->SetHasLocalRoute(true);
EXPECT_TRUE(gfx::test::AreImagesEqual(
active_icon(), action()->GetIcon(nullptr, gfx::Size())));
@@ -278,11 +236,8 @@ TEST_F(MediaRouterActionUnitTest, UpdateIssuesAndRoutes) {
EXPECT_TRUE(gfx::test::AreImagesEqual(
warning_icon(), action()->GetIcon(nullptr, gfx::Size())));
- // Swapping the local route for a non-local one makes no difference to the
- // |current_icon_|.
- routes->clear();
- routes->push_back(fake_route_remote());
- action()->OnRoutesUpdated(*routes.get());
+ // Closing a local route makes no difference to |current_icon_|.
+ action()->SetHasLocalRoute(false);
EXPECT_TRUE(gfx::test::AreImagesEqual(
warning_icon(), action()->GetIcon(nullptr, gfx::Size())));
@@ -292,9 +247,7 @@ TEST_F(MediaRouterActionUnitTest, UpdateIssuesAndRoutes) {
error_icon(), action()->GetIcon(nullptr, gfx::Size())));
// Fatal issues still take precedent over local routes.
- routes->clear();
- routes->push_back(fake_route_local());
- action()->OnRoutesUpdated(*routes.get());
+ action()->SetHasLocalRoute(true);
EXPECT_TRUE(gfx::test::AreImagesEqual(
error_icon(), action()->GetIcon(nullptr, gfx::Size())));
@@ -304,11 +257,8 @@ TEST_F(MediaRouterActionUnitTest, UpdateIssuesAndRoutes) {
EXPECT_TRUE(gfx::test::AreImagesEqual(
active_icon(), action()->GetIcon(nullptr, gfx::Size())));
- // Update |current_icon_| when the local route is swapped out for a non-local
- // route.
- routes->clear();
- routes->push_back(fake_route_remote());
- action()->OnRoutesUpdated(*routes.get());
+ // Update |current_icon_| when the local route is closed.
+ action()->SetHasLocalRoute(false);
EXPECT_TRUE(gfx::test::AreImagesEqual(
idle_icon(), action()->GetIcon(nullptr, gfx::Size())));
}

Powered by Google App Engine
This is Rietveld 408576698