| 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); |
| 905 extensions::FeatureSwitch::ScopedOverride enable_redesign( | 907 extensions::FeatureSwitch::ScopedOverride enable_redesign( |
| 906 extensions::FeatureSwitch::extension_action_redesign(), false); | 908 extensions::FeatureSwitch::extension_action_redesign(), false); |
| 907 Init(); | 909 Init(); |
| 908 ASSERT_TRUE(AddActionExtensions()); | 910 ASSERT_TRUE(AddActionExtensions()); |
| 909 | 911 |
| 910 EXPECT_EQ(1u, num_toolbar_items()); | 912 EXPECT_EQ(1u, num_toolbar_items()); |
| 911 EXPECT_EQ(browser_action()->id(), GetActionIdAtIndex(0u)); | 913 EXPECT_EQ(browser_action()->id(), GetActionIdAtIndex(0u)); |
| 912 } | 914 } |
| 913 | 915 |
| 914 // Test that, with the extension-action-redesign switch, the model contains | 916 // Test that, with the extension-action-redesign switch, the model contains |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 extensions::extension_action_test_util::NO_ACTION, | 965 extensions::extension_action_test_util::NO_ACTION, |
| 964 extensions::Manifest::INTERNAL); | 966 extensions::Manifest::INTERNAL); |
| 965 EXPECT_TRUE(AddExtension(internal_extension_no_action.get())); | 967 EXPECT_TRUE(AddExtension(internal_extension_no_action.get())); |
| 966 EXPECT_EQ(4u, num_toolbar_items()); | 968 EXPECT_EQ(4u, num_toolbar_items()); |
| 967 EXPECT_TRUE(ModelHasActionForId(internal_extension_no_action->id())); | 969 EXPECT_TRUE(ModelHasActionForId(internal_extension_no_action->id())); |
| 968 } | 970 } |
| 969 | 971 |
| 970 // Test that hiding actions on the toolbar results in their removal from the | 972 // Test that hiding actions on the toolbar results in their removal from the |
| 971 // model when the redesign switch is not enabled. | 973 // model when the redesign switch is not enabled. |
| 972 TEST_F(ToolbarActionsModelUnitTest, ActionsToolbarActionsVisibilityNoSwitch) { | 974 TEST_F(ToolbarActionsModelUnitTest, ActionsToolbarActionsVisibilityNoSwitch) { |
| 975 extensions::FeatureSwitch::ScopedOverride enable_media_router( |
| 976 extensions::FeatureSwitch::media_router(), false); |
| 973 extensions::FeatureSwitch::ScopedOverride enable_redesign( | 977 extensions::FeatureSwitch::ScopedOverride enable_redesign( |
| 974 extensions::FeatureSwitch::extension_action_redesign(), false); | 978 extensions::FeatureSwitch::extension_action_redesign(), false); |
| 975 Init(); | 979 Init(); |
| 976 | 980 |
| 977 extensions::ExtensionActionAPI* action_api = | 981 extensions::ExtensionActionAPI* action_api = |
| 978 extensions::ExtensionActionAPI::Get(profile()); | 982 extensions::ExtensionActionAPI::Get(profile()); |
| 979 | 983 |
| 980 ASSERT_TRUE(AddBrowserActionExtensions()); | 984 ASSERT_TRUE(AddBrowserActionExtensions()); |
| 981 // Sanity check: Order should start as A , B, C. | 985 // Sanity check: Order should start as A , B, C. |
| 982 EXPECT_EQ(3u, num_toolbar_items()); | 986 EXPECT_EQ(3u, num_toolbar_items()); |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 } | 1537 } |
| 1534 | 1538 |
| 1535 TEST_F(ToolbarActionsModelUnitTest, | 1539 TEST_F(ToolbarActionsModelUnitTest, |
| 1536 MigrationToExtensionWithoutExtensionActionRedesign) { | 1540 MigrationToExtensionWithoutExtensionActionRedesign) { |
| 1537 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); | 1541 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); |
| 1538 | 1542 |
| 1539 // Initialization re-enables the extension. | 1543 // Initialization re-enables the extension. |
| 1540 EXPECT_EQ(1u, num_toolbar_items()); | 1544 EXPECT_EQ(1u, num_toolbar_items()); |
| 1541 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); | 1545 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); |
| 1542 } | 1546 } |
| OLD | NEW |