| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/toolbar/toolbar_actions_model.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 EXPECT_EQ(num_toolbar_items(), toolbar_model()->visible_icon_count()); | 895 EXPECT_EQ(num_toolbar_items(), toolbar_model()->visible_icon_count()); |
| 896 toolbar_model()->OnActionToolbarPrefChange(); | 896 toolbar_model()->OnActionToolbarPrefChange(); |
| 897 // Should still be at max size. | 897 // Should still be at max size. |
| 898 EXPECT_TRUE(toolbar_model()->all_icons_visible()); | 898 EXPECT_TRUE(toolbar_model()->all_icons_visible()); |
| 899 EXPECT_EQ(num_toolbar_items(), toolbar_model()->visible_icon_count()); | 899 EXPECT_EQ(num_toolbar_items(), toolbar_model()->visible_icon_count()); |
| 900 } | 900 } |
| 901 | 901 |
| 902 // Test that, in the absence of the extension-action-redesign switch, the | 902 // Test that, in the absence of the extension-action-redesign switch, the |
| 903 // model only contains extensions with browser actions and component actions. | 903 // model only contains extensions with browser actions and component actions. |
| 904 TEST_F(ToolbarActionsModelUnitTest, TestToolbarExtensionTypesDisabledSwitch) { | 904 TEST_F(ToolbarActionsModelUnitTest, TestToolbarExtensionTypesDisabledSwitch) { |
| 905 extensions::FeatureSwitch::ScopedOverride enable_media_router( | |
| 906 extensions::FeatureSwitch::media_router(), false); | |
| 907 extensions::FeatureSwitch::ScopedOverride enable_redesign( | 905 extensions::FeatureSwitch::ScopedOverride enable_redesign( |
| 908 extensions::FeatureSwitch::extension_action_redesign(), false); | 906 extensions::FeatureSwitch::extension_action_redesign(), false); |
| 909 Init(); | 907 Init(); |
| 910 ASSERT_TRUE(AddActionExtensions()); | 908 ASSERT_TRUE(AddActionExtensions()); |
| 911 | 909 |
| 912 EXPECT_EQ(1u, num_toolbar_items()); | 910 EXPECT_EQ(1u, num_toolbar_items()); |
| 913 EXPECT_EQ(browser_action()->id(), GetActionIdAtIndex(0u)); | 911 EXPECT_EQ(browser_action()->id(), GetActionIdAtIndex(0u)); |
| 914 } | 912 } |
| 915 | 913 |
| 916 // Test that, with the extension-action-redesign switch, the model contains | 914 // Test that, with the extension-action-redesign switch, the model contains |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 extensions::extension_action_test_util::NO_ACTION, | 963 extensions::extension_action_test_util::NO_ACTION, |
| 966 extensions::Manifest::INTERNAL); | 964 extensions::Manifest::INTERNAL); |
| 967 EXPECT_TRUE(AddExtension(internal_extension_no_action.get())); | 965 EXPECT_TRUE(AddExtension(internal_extension_no_action.get())); |
| 968 EXPECT_EQ(4u, num_toolbar_items()); | 966 EXPECT_EQ(4u, num_toolbar_items()); |
| 969 EXPECT_TRUE(ModelHasActionForId(internal_extension_no_action->id())); | 967 EXPECT_TRUE(ModelHasActionForId(internal_extension_no_action->id())); |
| 970 } | 968 } |
| 971 | 969 |
| 972 // Test that hiding actions on the toolbar results in their removal from the | 970 // Test that hiding actions on the toolbar results in their removal from the |
| 973 // model when the redesign switch is not enabled. | 971 // model when the redesign switch is not enabled. |
| 974 TEST_F(ToolbarActionsModelUnitTest, ActionsToolbarActionsVisibilityNoSwitch) { | 972 TEST_F(ToolbarActionsModelUnitTest, ActionsToolbarActionsVisibilityNoSwitch) { |
| 975 extensions::FeatureSwitch::ScopedOverride enable_media_router( | |
| 976 extensions::FeatureSwitch::media_router(), false); | |
| 977 extensions::FeatureSwitch::ScopedOverride enable_redesign( | 973 extensions::FeatureSwitch::ScopedOverride enable_redesign( |
| 978 extensions::FeatureSwitch::extension_action_redesign(), false); | 974 extensions::FeatureSwitch::extension_action_redesign(), false); |
| 979 Init(); | 975 Init(); |
| 980 | 976 |
| 981 extensions::ExtensionActionAPI* action_api = | 977 extensions::ExtensionActionAPI* action_api = |
| 982 extensions::ExtensionActionAPI::Get(profile()); | 978 extensions::ExtensionActionAPI::Get(profile()); |
| 983 | 979 |
| 984 ASSERT_TRUE(AddBrowserActionExtensions()); | 980 ASSERT_TRUE(AddBrowserActionExtensions()); |
| 985 // Sanity check: Order should start as A , B, C. | 981 // Sanity check: Order should start as A , B, C. |
| 986 EXPECT_EQ(3u, num_toolbar_items()); | 982 EXPECT_EQ(3u, num_toolbar_items()); |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 } | 1503 } |
| 1508 | 1504 |
| 1509 TEST_F(ToolbarActionsModelUnitTest, | 1505 TEST_F(ToolbarActionsModelUnitTest, |
| 1510 MigrationToExtensionWithoutExtensionActionRedesign) { | 1506 MigrationToExtensionWithoutExtensionActionRedesign) { |
| 1511 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); | 1507 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); |
| 1512 | 1508 |
| 1513 // Initialization re-enables the extension. | 1509 // Initialization re-enables the extension. |
| 1514 EXPECT_EQ(1u, num_toolbar_items()); | 1510 EXPECT_EQ(1u, num_toolbar_items()); |
| 1515 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); | 1511 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); |
| 1516 } | 1512 } |
| OLD | NEW |