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

Unified Diff: chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc

Issue 1782223002: [Extensions UI] Update ToolbarActionsBar::NeedsOverflow() for popped out actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finnur's Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_bar.cc ('k') | chrome/browser/ui/views/toolbar/app_menu.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc b/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc
index a84530b2feda140fb5148ae4580d7da8273b212f..ac79127993250d63e1320be05b2671857011c3d8 100644
--- a/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc
+++ b/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc
@@ -595,3 +595,64 @@ TEST_P(ToolbarActionsBarRedesignUnitTest, TestStartAndEndIndexes) {
EXPECT_EQ(3u, overflow_bar()->GetEndIndexInBounds());
EXPECT_FALSE(toolbar_actions_bar()->NeedsOverflow());
}
+
+// Tests the logic for determining if the container needs an overflow menu item.
+TEST_P(ToolbarActionsBarRedesignUnitTest, TestNeedsOverflow) {
+ CreateAndAddExtension(
+ "extension 1",
+ extensions::extension_action_test_util::BROWSER_ACTION);
+ // One extension on the main bar, none overflowed. Overflow not needed.
+ EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
+ EXPECT_EQ(0u, overflow_bar()->GetIconCount());
+ EXPECT_FALSE(toolbar_actions_bar()->NeedsOverflow());
+
+ // Set one extension in the overflow menu, none on the main bar. Overflow
+ // needed.
+ toolbar_model()->SetVisibleIconCount(0u);
+ EXPECT_EQ(0u, toolbar_actions_bar()->GetIconCount());
+ EXPECT_EQ(1u, overflow_bar()->GetIconCount());
+ EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
+
+ // Pop out an extension for a non-sticky popup. Even though the extension is
+ // on the main bar, overflow is still needed because it will pop back in
+ // when the menu is opened.
+ ToolbarActionViewController* action = toolbar_actions_bar()->GetActions()[0];
+ {
+ base::RunLoop run_loop;
+ toolbar_actions_bar()->PopOutAction(action, false, run_loop.QuitClosure());
+ run_loop.Run();
+ }
+ EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
+ EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
+
+ // Back to one in overflow, none on the main bar.
+ toolbar_actions_bar()->UndoPopOut();
+ EXPECT_EQ(0u, toolbar_actions_bar()->GetIconCount());
+ EXPECT_EQ(1u, overflow_bar()->GetIconCount());
+ EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
+
+ // Pop out an extension for a sticky popup. Overflow shouldn't be needed now
+ // because the extension will remain popped out even when the menu opens.
+ {
+ base::RunLoop run_loop;
+ toolbar_actions_bar()->PopOutAction(action, true, run_loop.QuitClosure());
+ run_loop.Run();
+ }
+ EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
+ EXPECT_FALSE(toolbar_actions_bar()->NeedsOverflow());
+
+ // Add another extension and verify that if one is still in overflow when
+ // another is popped out, we still need overflow.
+ toolbar_actions_bar()->UndoPopOut();
+ CreateAndAddExtension(
+ "extension 2",
+ extensions::extension_action_test_util::BROWSER_ACTION);
+ toolbar_model()->SetVisibleIconCount(0u);
+ {
+ base::RunLoop run_loop;
+ toolbar_actions_bar()->PopOutAction(action, true, run_loop.QuitClosure());
+ run_loop.Run();
+ }
+ EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
+ EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
+}
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_bar.cc ('k') | chrome/browser/ui/views/toolbar/app_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698