| 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> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/extensions/browser_action_test_util.h" | 9 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 10 #include "chrome/browser/extensions/extension_action_test_util.h" | 10 #include "chrome/browser/extensions/extension_action_test_util.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // Run the same checks as before. All existing menu items should be now | 117 // Run the same checks as before. All existing menu items should be now |
| 118 // enabled and visible. | 118 // enabled and visible. |
| 119 EXPECT_EQ(model_->GetItemCount(), expected_number_items); | 119 EXPECT_EQ(model_->GetItemCount(), expected_number_items); |
| 120 for (int i = 0; i < expected_number_items; i++) { | 120 for (int i = 0; i < expected_number_items; i++) { |
| 121 EXPECT_TRUE(model_->IsEnabledAt(i)); | 121 EXPECT_TRUE(model_->IsEnabledAt(i)); |
| 122 EXPECT_TRUE(model_->IsVisibleAt(i)); | 122 EXPECT_TRUE(model_->IsVisibleAt(i)); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Note that "Manage devices" is always disabled on Linux. |
| 127 TEST_F(MediaRouterContextualMenuUnitTest, ManageDevicesDisabledInIncognito) { |
| 128 // Create the MediaRouterAction under an incognito profile. |
| 129 profile()->ForceIncognito(true); |
| 130 action_ = base::MakeUnique<MediaRouterAction>( |
| 131 browser(), browser_action_test_util_->GetToolbarActionsBar()); |
| 132 model_ = static_cast<ui::SimpleMenuModel*>(action_->GetContextMenu()); |
| 133 EXPECT_EQ(-1, model_->GetIndexOfCommandId(IDC_MEDIA_ROUTER_MANAGE_DEVICES)); |
| 134 } |
| 135 |
| 126 // Tests whether the cloud services item is correctly toggled. This menu item | 136 // Tests whether the cloud services item is correctly toggled. This menu item |
| 127 // is only availble on official Chrome builds. | 137 // is only availble on official Chrome builds. |
| 128 TEST_F(MediaRouterContextualMenuUnitTest, ToggleCloudServicesItem) { | 138 TEST_F(MediaRouterContextualMenuUnitTest, ToggleCloudServicesItem) { |
| 129 // The Media Router Action has a getter for the model, but not the delegate. | 139 // The Media Router Action has a getter for the model, but not the delegate. |
| 130 // Create the MediaRouterContextualMenu ui::SimpleMenuModel::Delegate here. | 140 // Create the MediaRouterContextualMenu ui::SimpleMenuModel::Delegate here. |
| 131 MediaRouterContextualMenu menu(browser(), kInToolbar, kShownByPolicy); | 141 MediaRouterContextualMenu menu(browser(), kInToolbar, kShownByPolicy); |
| 132 | 142 |
| 133 // Set up an authenticated account such that the cloud services menu item is | 143 // Set up an authenticated account such that the cloud services menu item is |
| 134 // surfaced. Whether or not it is surfaced is tested in the "Basic" test. | 144 // surfaced. Whether or not it is surfaced is tested in the "Basic" test. |
| 135 signin_manager_->SetAuthenticatedAccountInfo("foo@bar.com", "password"); | 145 signin_manager_->SetAuthenticatedAccountInfo("foo@bar.com", "password"); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 TEST_F(MediaRouterContextualMenuUnitTest, ShowActionInToolbarItem) { | 204 TEST_F(MediaRouterContextualMenuUnitTest, ShowActionInToolbarItem) { |
| 195 MediaRouterContextualMenu menu(browser(), kInOverflowMenu, kShownByUser); | 205 MediaRouterContextualMenu menu(browser(), kInOverflowMenu, kShownByUser); |
| 196 | 206 |
| 197 // When the action icon is in the overflow menu, this menu item should say | 207 // When the action icon is in the overflow menu, this menu item should say |
| 198 // "Show in toolbar". | 208 // "Show in toolbar". |
| 199 const base::string16& menu_item_label = menu.menu_model()->GetLabelAt( | 209 const base::string16& menu_item_label = menu.menu_model()->GetLabelAt( |
| 200 menu.menu_model()->GetIndexOfCommandId(IDC_MEDIA_ROUTER_SHOW_IN_TOOLBAR)); | 210 menu.menu_model()->GetIndexOfCommandId(IDC_MEDIA_ROUTER_SHOW_IN_TOOLBAR)); |
| 201 EXPECT_EQ(menu_item_label, | 211 EXPECT_EQ(menu_item_label, |
| 202 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON_IN_TOOLBAR)); | 212 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON_IN_TOOLBAR)); |
| 203 } | 213 } |
| OLD | NEW |