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

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

Issue 2469013003: Keep the toolbar overflow menu the same when removing a component action (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 EXPECT_TRUE(toolbar_model()->all_icons_visible()); 1423 EXPECT_TRUE(toolbar_model()->all_icons_visible());
1424 1424
1425 // Load extension C again. 1425 // Load extension C again.
1426 ASSERT_TRUE(AddExtension(browser_action_c())); 1426 ASSERT_TRUE(AddExtension(browser_action_c()));
1427 EXPECT_EQ(5u, observer()->inserted_count()); 1427 EXPECT_EQ(5u, observer()->inserted_count());
1428 EXPECT_EQ(2u, num_toolbar_items()); 1428 EXPECT_EQ(2u, num_toolbar_items());
1429 EXPECT_EQ(component_action_id(), GetActionIdAtIndex(0u)); 1429 EXPECT_EQ(component_action_id(), GetActionIdAtIndex(0u));
1430 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(1u)); 1430 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(1u));
1431 } 1431 }
1432 1432
1433 TEST_F(ToolbarActionsModelUnitTest, AddAndRemoveComponentActionWithOVerflow) {
1434 Init();
1435 // Add three extension actions: A, B, C.
1436 ASSERT_TRUE(AddBrowserActionExtensions());
1437 EXPECT_EQ(3u, num_toolbar_items());
1438
1439 // Hide the last icon: A, B, [C].
1440 toolbar_model()->SetVisibleIconCount(2);
1441 EXPECT_EQ(2u, toolbar_model()->visible_icon_count());
1442 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(2u));
1443
1444 // Add a component action, CA. Now the icons should be: A, B, CA, [C].
1445 toolbar_model()->AddComponentAction(component_action_id());
1446 EXPECT_EQ(4u, num_toolbar_items());
1447 EXPECT_EQ(3u, toolbar_model()->visible_icon_count());
1448 EXPECT_EQ(component_action_id(), GetActionIdAtIndex(2u));
1449 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(3u));
1450
1451 // Remove the component action. Extension C should stay in the overflow.
1452 // The icons should be: A, B, [C].
1453 toolbar_model()->RemoveComponentAction(component_action_id());
1454 EXPECT_EQ(3u, num_toolbar_items());
1455 EXPECT_EQ(2u, toolbar_model()->visible_icon_count());
1456 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(2u));
1457 }
1458
1433 TEST_F(ToolbarActionsModelUnitTest, 1459 TEST_F(ToolbarActionsModelUnitTest,
1434 TestUninstallVisibleExtensionDoesntBringOutOther) { 1460 TestUninstallVisibleExtensionDoesntBringOutOther) {
1435 Init(); 1461 Init();
1436 ASSERT_TRUE(AddBrowserActionExtensions()); 1462 ASSERT_TRUE(AddBrowserActionExtensions());
1437 toolbar_model()->SetVisibleIconCount(2u); 1463 toolbar_model()->SetVisibleIconCount(2u);
1438 EXPECT_EQ(3u, num_toolbar_items()); 1464 EXPECT_EQ(3u, num_toolbar_items());
1439 EXPECT_EQ(2u, toolbar_model()->visible_icon_count()); 1465 EXPECT_EQ(2u, toolbar_model()->visible_icon_count());
1440 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(0u)); 1466 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(0u));
1441 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(1u)); 1467 EXPECT_EQ(browser_action_b()->id(), GetActionIdAtIndex(1u));
1442 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(2u)); 1468 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(2u));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 } 1541 }
1516 1542
1517 TEST_F(ToolbarActionsModelUnitTest, 1543 TEST_F(ToolbarActionsModelUnitTest,
1518 MigrationToExtensionWithoutExtensionActionRedesign) { 1544 MigrationToExtensionWithoutExtensionActionRedesign) {
1519 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); 1545 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE);
1520 1546
1521 // Initialization re-enables the extension. 1547 // Initialization re-enables the extension.
1522 EXPECT_EQ(1u, num_toolbar_items()); 1548 EXPECT_EQ(1u, num_toolbar_items());
1523 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); 1549 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u));
1524 } 1550 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698