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

Side by Side 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: 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 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_bar_unittest.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // Set the width back to the preferred width. All should be back to normal. 588 // Set the width back to the preferred width. All should be back to normal.
589 browser_action_test_util()->SetWidth( 589 browser_action_test_util()->SetWidth(
590 toolbar_actions_bar()->GetPreferredSize().width()); 590 toolbar_actions_bar()->GetPreferredSize().width());
591 EXPECT_EQ(3u, toolbar_actions_bar()->GetIconCount()); 591 EXPECT_EQ(3u, toolbar_actions_bar()->GetIconCount());
592 EXPECT_EQ(0u, toolbar_actions_bar()->GetStartIndexInBounds()); 592 EXPECT_EQ(0u, toolbar_actions_bar()->GetStartIndexInBounds());
593 EXPECT_EQ(3u, toolbar_actions_bar()->GetEndIndexInBounds()); 593 EXPECT_EQ(3u, toolbar_actions_bar()->GetEndIndexInBounds());
594 EXPECT_EQ(3u, overflow_bar()->GetStartIndexInBounds()); 594 EXPECT_EQ(3u, overflow_bar()->GetStartIndexInBounds());
595 EXPECT_EQ(3u, overflow_bar()->GetEndIndexInBounds()); 595 EXPECT_EQ(3u, overflow_bar()->GetEndIndexInBounds());
596 EXPECT_FALSE(toolbar_actions_bar()->NeedsOverflow()); 596 EXPECT_FALSE(toolbar_actions_bar()->NeedsOverflow());
597 } 597 }
598
599 // Tests the logic for determining if the container needs an overflow menu item.
600 TEST_P(ToolbarActionsBarRedesignUnitTest, TestNeedsOverflow) {
601 CreateAndAddExtension(
602 "extension 1",
603 extensions::extension_action_test_util::BROWSER_ACTION);
604 // One extension on the main bar, none overflowed. Overflow not needed.
605 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
606 EXPECT_EQ(0u, overflow_bar()->GetIconCount());
607 EXPECT_FALSE(toolbar_actions_bar()->NeedsOverflow());
608
609 // One extension in the overflow menu, none on the main bar. Overflow needed.
Finnur 2016/03/11 15:10:11 s/One/Set one/
Devlin 2016/03/11 17:32:10 Done.
610 toolbar_model()->SetVisibleIconCount(0u);
611 EXPECT_EQ(0u, toolbar_actions_bar()->GetIconCount());
612 EXPECT_EQ(1u, overflow_bar()->GetIconCount());
613 EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
614
615 // Pop out an extension for a non-sticky popup. Even though the extension is
616 // on the main bar, overflow is still needed because it will pop back in
617 // when the menu is opened.
618 ToolbarActionViewController* action = toolbar_actions_bar()->GetActions()[0];
619 {
620 base::RunLoop run_loop;
621 toolbar_actions_bar()->PopOutAction(action, false, run_loop.QuitClosure());
622 run_loop.Run();
623 }
624 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
625 EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
626
627 // Back to one in overflow, none on the main bar.
628 toolbar_actions_bar()->UndoPopOut();
629 EXPECT_EQ(0u, toolbar_actions_bar()->GetIconCount());
630 EXPECT_EQ(1u, overflow_bar()->GetIconCount());
631 EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
632
633 // Pop out an extension for a sticky popup. Overflow shouldn't be needed now
634 // because the extension will remain popped out even when the menu opens.
635 {
636 base::RunLoop run_loop;
637 toolbar_actions_bar()->PopOutAction(action, true, run_loop.QuitClosure());
638 run_loop.Run();
639 }
640 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
641 EXPECT_FALSE(toolbar_actions_bar()->NeedsOverflow());
642
643 // Add another extension and verify that if one is still in overflow when
644 // another is popped out, we still need overflow.
645 toolbar_actions_bar()->UndoPopOut();
646 CreateAndAddExtension(
647 "extension 2",
648 extensions::extension_action_test_util::BROWSER_ACTION);
649 toolbar_model()->SetVisibleIconCount(0u);
650 {
651 base::RunLoop run_loop;
652 toolbar_actions_bar()->PopOutAction(action, true, run_loop.QuitClosure());
653 run_loop.Run();
654 }
655 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
656 EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
657 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698