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

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

Issue 2332693003: Show media router toolbar icon ephemerally for active local routes and issues (Closed)
Patch Set: Address Devlin's comments Created 4 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_contextual_menu_unittest.cc
diff --git a/chrome/browser/ui/toolbar/media_router_contextual_menu_unittest.cc b/chrome/browser/ui/toolbar/media_router_contextual_menu_unittest.cc
index add326148d8fdc0946b0cd0b042734b593e8c412..ea10c409e4f1d3499b9d26d525edcd1edeb20763 100644
--- a/chrome/browser/ui/toolbar/media_router_contextual_menu_unittest.cc
+++ b/chrome/browser/ui/toolbar/media_router_contextual_menu_unittest.cc
@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/macros.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
#include "chrome/browser/ui/toolbar/media_router_action.h"
#include "chrome/browser/ui/toolbar/media_router_contextual_menu.h"
#include "chrome/test/base/browser_with_test_window_test.h"
@@ -115,3 +118,31 @@ TEST_F(MediaRouterContextualMenuUnitTest, ToggleCloudServicesItem) {
IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE));
}
#endif // GOOGLE_CHROME_BUILD
+
+TEST_F(MediaRouterContextualMenuUnitTest, ToggleAlwaysShowIconItem) {
+ std::unique_ptr<ToolbarActionsModel> toolbar_actions_model(
msw 2016/09/21 15:40:59 nit: just make a stack local instance and remove #
takumif 2016/09/21 17:08:18 Done.
+ new ToolbarActionsModel(browser()->profile(), nullptr));
+ MediaRouterContextualMenu menu(browser(), toolbar_actions_model.get());
+ extensions::ComponentMigrationHelper* const component_migration_helper =
+ toolbar_actions_model->component_migration_helper();
+
+ // Whether the option is checked should reflect the pref.
+ component_migration_helper->SetComponentActionPref(
+ ComponentToolbarActionsFactory::kMediaRouterActionId, true);
+ EXPECT_TRUE(
+ menu.IsCommandIdChecked(IDC_MEDIA_ROUTER_ALWAYS_SHOW_TOOLBAR_ACTION));
+
+ component_migration_helper->SetComponentActionPref(
+ ComponentToolbarActionsFactory::kMediaRouterActionId, false);
+ EXPECT_FALSE(
+ menu.IsCommandIdChecked(IDC_MEDIA_ROUTER_ALWAYS_SHOW_TOOLBAR_ACTION));
+
+ // Executing the option should toggle the pref.
+ menu.ExecuteCommand(IDC_MEDIA_ROUTER_ALWAYS_SHOW_TOOLBAR_ACTION, 0);
+ EXPECT_TRUE(component_migration_helper->GetComponentActionPref(
+ ComponentToolbarActionsFactory::kMediaRouterActionId));
+
+ menu.ExecuteCommand(IDC_MEDIA_ROUTER_ALWAYS_SHOW_TOOLBAR_ACTION, 0);
+ EXPECT_FALSE(component_migration_helper->GetComponentActionPref(
+ ComponentToolbarActionsFactory::kMediaRouterActionId));
+}

Powered by Google App Engine
This is Rietveld 408576698