Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | |
| 6 | |
| 5 #include "base/macros.h" | 7 #include "base/macros.h" |
| 6 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 7 #include "chrome/browser/extensions/browser_action_test_util.h" | 9 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 8 #include "chrome/browser/signin/fake_signin_manager_builder.h" | 10 #include "chrome/browser/signin/fake_signin_manager_builder.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
| 12 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" | |
| 10 #include "chrome/browser/ui/toolbar/media_router_action.h" | 13 #include "chrome/browser/ui/toolbar/media_router_action.h" |
| 11 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" | 14 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" |
| 12 #include "chrome/test/base/browser_with_test_window_test.h" | 15 #include "chrome/test/base/browser_with_test_window_test.h" |
| 13 | 16 |
| 14 class MediaRouterContextualMenuUnitTest : public BrowserWithTestWindowTest { | 17 class MediaRouterContextualMenuUnitTest : public BrowserWithTestWindowTest { |
| 15 public: | 18 public: |
| 16 MediaRouterContextualMenuUnitTest() {} | 19 MediaRouterContextualMenuUnitTest() {} |
| 17 ~MediaRouterContextualMenuUnitTest() override {} | 20 ~MediaRouterContextualMenuUnitTest() override {} |
| 18 | 21 |
| 19 void SetUp() override { | 22 void SetUp() override { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 111 |
| 109 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); | 112 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); |
| 110 EXPECT_TRUE(menu.IsCommandIdChecked( | 113 EXPECT_TRUE(menu.IsCommandIdChecked( |
| 111 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | 114 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); |
| 112 | 115 |
| 113 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); | 116 menu.ExecuteCommand(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE, 0); |
| 114 EXPECT_FALSE(menu.IsCommandIdChecked( | 117 EXPECT_FALSE(menu.IsCommandIdChecked( |
| 115 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); | 118 IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)); |
| 116 } | 119 } |
| 117 #endif // GOOGLE_CHROME_BUILD | 120 #endif // GOOGLE_CHROME_BUILD |
| 121 | |
| 122 TEST_F(MediaRouterContextualMenuUnitTest, ToggleAlwaysShowIconItem) { | |
| 123 std::unique_ptr<ToolbarActionsModel> toolbar_actions_model( | |
| 124 new ToolbarActionsModel(browser()->profile(), nullptr)); | |
| 125 MediaRouterContextualMenu menu(browser(), toolbar_actions_model.get()); | |
| 126 extensions::ComponentMigrationHelper* const component_migration_helper = | |
| 127 toolbar_actions_model->component_migration_helper(); | |
| 128 | |
| 129 // Whether the option is checked should refrect the pref. | |
|
Devlin
2016/09/20 21:55:48
s/refrect/reflect?
takumif
2016/09/20 23:38:11
Oops. Fixed.
| |
| 130 component_migration_helper->SetComponentActionPref( | |
| 131 ComponentToolbarActionsFactory::kMediaRouterActionId, true); | |
| 132 EXPECT_TRUE( | |
| 133 menu.IsCommandIdChecked(IDC_MEDIA_ROUTER_ALWAYS_SHOW_TOOLBAR_ACTION)); | |
| 134 | |
| 135 component_migration_helper->SetComponentActionPref( | |
| 136 ComponentToolbarActionsFactory::kMediaRouterActionId, false); | |
| 137 EXPECT_FALSE( | |
| 138 menu.IsCommandIdChecked(IDC_MEDIA_ROUTER_ALWAYS_SHOW_TOOLBAR_ACTION)); | |
| 139 | |
| 140 // Executing the option should toggle the pref. | |
| 141 menu.ExecuteCommand(IDC_MEDIA_ROUTER_ALWAYS_SHOW_TOOLBAR_ACTION, 0); | |
| 142 EXPECT_TRUE(component_migration_helper->GetComponentActionPref( | |
| 143 ComponentToolbarActionsFactory::kMediaRouterActionId)); | |
| 144 | |
| 145 menu.ExecuteCommand(IDC_MEDIA_ROUTER_ALWAYS_SHOW_TOOLBAR_ACTION, 0); | |
| 146 EXPECT_FALSE(component_migration_helper->GetComponentActionPref( | |
| 147 ComponentToolbarActionsFactory::kMediaRouterActionId)); | |
| 148 } | |
| OLD | NEW |