| 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 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 base::RunLoop().RunUntilIdle(); | 1301 base::RunLoop().RunUntilIdle(); |
| 1302 | 1302 |
| 1303 // The new order should be reflected in the model. | 1303 // The new order should be reflected in the model. |
| 1304 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(0)); | 1304 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(0)); |
| 1305 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(1)); | 1305 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(1)); |
| 1306 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(2)); | 1306 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(2)); |
| 1307 EXPECT_EQ(inserted_and_removed_difference, | 1307 EXPECT_EQ(inserted_and_removed_difference, |
| 1308 observer()->inserted_count() - observer()->removed_count()); | 1308 observer()->inserted_count() - observer()->removed_count()); |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 TEST_F(ToolbarActionsModelUnitTest, ComponentExtensionsAddedToEnd) { | |
| 1312 Init(); | |
| 1313 | |
| 1314 ASSERT_TRUE(AddBrowserActionExtensions()); | |
| 1315 | |
| 1316 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(0)); | |
| 1317 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(1)); | |
| 1318 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(2)); | |
| 1319 | |
| 1320 const char kName[] = "component"; | |
| 1321 extensions::DictionaryBuilder manifest; | |
| 1322 manifest.Set("name", kName) | |
| 1323 .Set("description", "An extension") | |
| 1324 .Set("manifest_version", 2) | |
| 1325 .Set("version", "1.0.0") | |
| 1326 .Set("browser_action", extensions::DictionaryBuilder().Build()); | |
| 1327 scoped_refptr<const extensions::Extension> component_extension = | |
| 1328 extensions::ExtensionBuilder() | |
| 1329 .SetManifest(manifest.Build()) | |
| 1330 .SetID(crx_file::id_util::GenerateId(kName)) | |
| 1331 .SetLocation(extensions::Manifest::COMPONENT) | |
| 1332 .Build(); | |
| 1333 service()->AddExtension(component_extension.get()); | |
| 1334 | |
| 1335 EXPECT_EQ(component_extension.get()->id(), GetActionIdAtIndex(0)); | |
| 1336 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(1)); | |
| 1337 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(2)); | |
| 1338 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(3)); | |
| 1339 } | |
| 1340 | |
| 1341 // Test various different reorderings, removals, and reinsertions of the | 1311 // Test various different reorderings, removals, and reinsertions of the |
| 1342 // toolbar with component actions. | 1312 // toolbar with component actions. |
| 1343 TEST_F(ToolbarActionsModelUnitTest, | 1313 TEST_F(ToolbarActionsModelUnitTest, |
| 1344 ActionsToolbarReorderAndReinsertWithSwitchAndComponentActions) { | 1314 ActionsToolbarReorderAndReinsertWithSwitchAndComponentActions) { |
| 1345 extensions::FeatureSwitch::ScopedOverride enable_redesign( | 1315 extensions::FeatureSwitch::ScopedOverride enable_redesign( |
| 1346 extensions::FeatureSwitch::extension_action_redesign(), true); | 1316 extensions::FeatureSwitch::extension_action_redesign(), true); |
| 1347 SetMockActionsFactory(new MockComponentToolbarActionsFactory(nullptr)); | 1317 SetMockActionsFactory(new MockComponentToolbarActionsFactory(nullptr)); |
| 1348 Init(); | 1318 Init(); |
| 1349 | 1319 |
| 1350 // One component action was added when the model was initialized. | 1320 // One component action was added when the model was initialized. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 } | 1503 } |
| 1534 | 1504 |
| 1535 TEST_F(ToolbarActionsModelUnitTest, | 1505 TEST_F(ToolbarActionsModelUnitTest, |
| 1536 MigrationToExtensionWithoutExtensionActionRedesign) { | 1506 MigrationToExtensionWithoutExtensionActionRedesign) { |
| 1537 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); | 1507 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); |
| 1538 | 1508 |
| 1539 // Initialization re-enables the extension. | 1509 // Initialization re-enables the extension. |
| 1540 EXPECT_EQ(1u, num_toolbar_items()); | 1510 EXPECT_EQ(1u, num_toolbar_items()); |
| 1541 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); | 1511 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); |
| 1542 } | 1512 } |
| OLD | NEW |