Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc

Issue 2332693003: Show media router toolbar icon ephemerally for active local routes and issues (Closed)
Patch Set: Address Derek's comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 base::RunLoop().RunUntilIdle(); 1305 base::RunLoop().RunUntilIdle();
1306 1306
1307 // The new order should be reflected in the model. 1307 // The new order should be reflected in the model.
1308 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(0)); 1308 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(0));
1309 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(1)); 1309 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(1));
1310 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(2)); 1310 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(2));
1311 EXPECT_EQ(inserted_and_removed_difference, 1311 EXPECT_EQ(inserted_and_removed_difference,
1312 observer()->inserted_count() - observer()->removed_count()); 1312 observer()->inserted_count() - observer()->removed_count());
1313 } 1313 }
1314 1314
1315 TEST_F(ToolbarActionsModelUnitTest, ComponentExtensionsAddedToEnd) {
1316 Init();
1317
1318 ASSERT_TRUE(AddBrowserActionExtensions());
1319
1320 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(0));
1321 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(1));
1322 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(2));
1323
1324 const char kName[] = "component";
1325 extensions::DictionaryBuilder manifest;
1326 manifest.Set("name", kName)
1327 .Set("description", "An extension")
1328 .Set("manifest_version", 2)
1329 .Set("version", "1.0.0")
1330 .Set("browser_action", extensions::DictionaryBuilder().Build());
1331 scoped_refptr<const extensions::Extension> component_extension =
1332 extensions::ExtensionBuilder()
1333 .SetManifest(manifest.Build())
1334 .SetID(crx_file::id_util::GenerateId(kName))
1335 .SetLocation(extensions::Manifest::COMPONENT)
1336 .Build();
1337 service()->AddExtension(component_extension.get());
1338
1339 EXPECT_EQ(component_extension.get()->id(), GetActionIdAtIndex(0));
1340 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(1));
1341 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(2));
1342 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(3));
1343 }
1344
1345 // Test various different reorderings, removals, and reinsertions of the 1315 // Test various different reorderings, removals, and reinsertions of the
1346 // toolbar with component actions. 1316 // toolbar with component actions.
1347 TEST_F(ToolbarActionsModelUnitTest, 1317 TEST_F(ToolbarActionsModelUnitTest,
1348 ActionsToolbarReorderAndReinsertWithSwitchAndComponentActions) { 1318 ActionsToolbarReorderAndReinsertWithSwitchAndComponentActions) {
1349 extensions::FeatureSwitch::ScopedOverride enable_redesign( 1319 extensions::FeatureSwitch::ScopedOverride enable_redesign(
1350 extensions::FeatureSwitch::extension_action_redesign(), true); 1320 extensions::FeatureSwitch::extension_action_redesign(), true);
1351 SetMockActionsFactory(new MockComponentToolbarActionsFactory(nullptr)); 1321 SetMockActionsFactory(new MockComponentToolbarActionsFactory(nullptr));
1352 Init(); 1322 Init();
1353 1323
1354 // One component action was added when the model was initialized. 1324 // One component action was added when the model was initialized.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 } 1507 }
1538 1508
1539 TEST_F(ToolbarActionsModelUnitTest, 1509 TEST_F(ToolbarActionsModelUnitTest,
1540 MigrationToExtensionWithoutExtensionActionRedesign) { 1510 MigrationToExtensionWithoutExtensionActionRedesign) {
1541 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); 1511 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE);
1542 1512
1543 // Initialization re-enables the extension. 1513 // Initialization re-enables the extension.
1544 EXPECT_EQ(1u, num_toolbar_items()); 1514 EXPECT_EQ(1u, num_toolbar_items());
1545 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); 1515 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u));
1546 } 1516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698