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

Side by Side Diff: ash/shelf/shelf_view_unittest.cc

Issue 1809963003: Fix shelf overflow bubble position (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit test 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
« no previous file with comments | « ash/shelf/overflow_bubble_view.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 continue; 989 continue;
990 } 990 }
991 991
992 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); 992 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i);
993 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); 993 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1);
994 EXPECT_FALSE(bounds1.Intersects(bounds2)); 994 EXPECT_FALSE(bounds1.Intersects(bounds2));
995 } 995 }
996 } 996 }
997 } 997 }
998 998
999 // Making sure the overflow bubble arrow correctly tracks with shelf position.
1000 TEST_F(ShelfViewTest, OverflowArrowForShelfPosition) {
1001 const ShelfAlignment kAlignments[] = {
1002 SHELF_ALIGNMENT_BOTTOM, SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT,
1003 SHELF_ALIGNMENT_TOP};
1004
1005 // These must match what is expected for each alignment above.
1006 const views::BubbleBorder::Arrow kArrows[] = {
1007 views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP,
1008 views::BubbleBorder::RIGHT_TOP, views::BubbleBorder::TOP_LEFT};
1009
1010 for (int i = 0; i < 4; i++) {
1011 shelf_view_->shelf()->SetAlignment(kAlignments[i]);
1012
1013 // Make sure there are enough icons to trigger the overflow in new
1014 // orientation.
1015 AddButtonsUntilOverflow();
1016 test_api_->ShowOverflowBubble();
1017 ASSERT_TRUE(test_api_->overflow_bubble() &&
1018 test_api_->overflow_bubble()->IsShowing());
1019
1020 EXPECT_EQ(test_api_->overflow_bubble()->bubble_view()->arrow(), kArrows[i]);
1021 }
1022 }
1023
999 // Adds button until overflow then removes first added one. Verifies that 1024 // Adds button until overflow then removes first added one. Verifies that
1000 // the last added one changes from invisible to visible and overflow 1025 // the last added one changes from invisible to visible and overflow
1001 // chevron is gone. 1026 // chevron is gone.
1002 TEST_F(ShelfViewTest, RemoveButtonRevealsOverflowed) { 1027 TEST_F(ShelfViewTest, RemoveButtonRevealsOverflowed) {
1003 // All buttons should be visible. 1028 // All buttons should be visible.
1004 ASSERT_EQ(test_api_->GetButtonCount(), 1029 ASSERT_EQ(test_api_->GetButtonCount(),
1005 test_api_->GetLastVisibleIndex() + 1); 1030 test_api_->GetLastVisibleIndex() + 1);
1006 1031
1007 // Add platform app buttons until overflow. 1032 // Add platform app buttons until overflow.
1008 int items_added = 0; 1033 int items_added = 0;
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 1676
1652 EXPECT_EQ(2, model_->item_count()); 1677 EXPECT_EQ(2, model_->item_count());
1653 1678
1654 AddButtonsUntilOverflow(); 1679 AddButtonsUntilOverflow();
1655 1680
1656 // Show overflow bubble. 1681 // Show overflow bubble.
1657 test_api_->ShowOverflowBubble(); 1682 test_api_->ShowOverflowBubble();
1658 ASSERT_TRUE(test_api_->overflow_bubble() && 1683 ASSERT_TRUE(test_api_->overflow_bubble() &&
1659 test_api_->overflow_bubble()->IsShowing()); 1684 test_api_->overflow_bubble()->IsShowing());
1660 1685
1661 int item_width = test_api_->GetButtonSize() + 1686 int item_width = test_api_->GetButtonSize() + test_api_->GetButtonSpacing();
1662 test_api_->GetButtonSpacing();
1663 OverflowBubbleView* bubble_view = test_api_->overflow_bubble()->bubble_view(); 1687 OverflowBubbleView* bubble_view = test_api_->overflow_bubble()->bubble_view();
1664 test::OverflowBubbleViewTestAPI bubble_view_api(bubble_view); 1688 test::OverflowBubbleViewTestAPI bubble_view_api(bubble_view);
1665 1689
1666 // Add more buttons until OverflowBubble is scrollable and it has 3 invisible 1690 // Add more buttons until OverflowBubble is scrollable and it has 3 invisible
1667 // items. 1691 // items.
1668 while (bubble_view_api.GetContentsSize().width() < 1692 while (bubble_view_api.GetContentsSize().width() <
1669 (bubble_view->GetContentsBounds().width() + 3 * item_width)) 1693 (bubble_view->GetContentsBounds().width() + 3 * item_width))
1670 AddAppShortcut(); 1694 AddAppShortcut();
1671 1695
1672 ASSERT_TRUE(test_api_->overflow_bubble() && 1696 ASSERT_TRUE(test_api_->overflow_bubble() &&
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 test_api_->RunMessageLoopUntilAnimationsDone(); 1981 test_api_->RunMessageLoopUntilAnimationsDone();
1958 CheckAllItemsAreInBounds(); 1982 CheckAllItemsAreInBounds();
1959 } 1983 }
1960 1984
1961 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); 1985 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool());
1962 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, 1986 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest,
1963 testing::Bool()); 1987 testing::Bool());
1964 1988
1965 } // namespace test 1989 } // namespace test
1966 } // namespace ash 1990 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/overflow_bubble_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698