summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorglevin <glevin@chromium.org>2016-03-17 17:52:21 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-18 00:53:30 +0000
commit52e718a6d988b6058c0823955a8a70298e675c1d (patch)
tree35ea6cfa63767280abdebbed983d73073cbac232 /ash
parent4107f387c09d36eb24f304e2bc33ec82410bdd9a (diff)
downloadchromium_src-52e718a6d988b6058c0823955a8a70298e675c1d.zip
chromium_src-52e718a6d988b6058c0823955a8a70298e675c1d.tar.gz
chromium_src-52e718a6d988b6058c0823955a8a70298e675c1d.tar.bz2
Fix shelf overflow bubble position
BUG=589194 TEST=Put too many icons on shelf, move shelf to left, click chevron to open overflow bubble. Observe that bubble doesn't overlap shelf. Review URL: https://codereview.chromium.org/1809963003 Cr-Commit-Position: refs/heads/master@{#381855}
Diffstat (limited to 'ash')
-rw-r--r--ash/shelf/overflow_bubble_view.cc6
-rw-r--r--ash/shelf/shelf_view_unittest.cc28
2 files changed, 29 insertions, 5 deletions
diff --git a/ash/shelf/overflow_bubble_view.cc b/ash/shelf/overflow_bubble_view.cc
index ff0f2c3..6573de0 100644
--- a/ash/shelf/overflow_bubble_view.cc
+++ b/ash/shelf/overflow_bubble_view.cc
@@ -38,6 +38,9 @@ OverflowBubbleView::~OverflowBubbleView() {}
void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
ShelfView* shelf_view) {
+ shelf_view_ = shelf_view;
+ AddChildView(shelf_view_);
+
SetAnchorView(anchor);
set_arrow(GetBubbleArrow());
set_background(NULL);
@@ -52,9 +55,6 @@ void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
layer()->SetFillsBoundsOpaquely(false);
layer()->SetMasksToBounds(true);
- shelf_view_ = shelf_view;
- AddChildView(shelf_view_);
-
set_parent_window(Shell::GetContainer(
anchor->GetWidget()->GetNativeWindow()->GetRootWindow(),
kShellWindowId_ShelfBubbleContainer));
diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc
index b790223..994e146 100644
--- a/ash/shelf/shelf_view_unittest.cc
+++ b/ash/shelf/shelf_view_unittest.cc
@@ -996,6 +996,31 @@ TEST_F(ShelfViewTest, AssertNoButtonsOverlap) {
}
}
+// Making sure the overflow bubble arrow correctly tracks with shelf position.
+TEST_F(ShelfViewTest, OverflowArrowForShelfPosition) {
+ const ShelfAlignment kAlignments[] = {
+ SHELF_ALIGNMENT_BOTTOM, SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT,
+ SHELF_ALIGNMENT_TOP};
+
+ // These must match what is expected for each alignment above.
+ const views::BubbleBorder::Arrow kArrows[] = {
+ views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP,
+ views::BubbleBorder::RIGHT_TOP, views::BubbleBorder::TOP_LEFT};
+
+ for (int i = 0; i < 4; i++) {
+ shelf_view_->shelf()->SetAlignment(kAlignments[i]);
+
+ // Make sure there are enough icons to trigger the overflow in new
+ // orientation.
+ AddButtonsUntilOverflow();
+ test_api_->ShowOverflowBubble();
+ ASSERT_TRUE(test_api_->overflow_bubble() &&
+ test_api_->overflow_bubble()->IsShowing());
+
+ EXPECT_EQ(test_api_->overflow_bubble()->bubble_view()->arrow(), kArrows[i]);
+ }
+}
+
// Adds button until overflow then removes first added one. Verifies that
// the last added one changes from invisible to visible and overflow
// chevron is gone.
@@ -1658,8 +1683,7 @@ TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) {
ASSERT_TRUE(test_api_->overflow_bubble() &&
test_api_->overflow_bubble()->IsShowing());
- int item_width = test_api_->GetButtonSize() +
- test_api_->GetButtonSpacing();
+ int item_width = test_api_->GetButtonSize() + test_api_->GetButtonSpacing();
OverflowBubbleView* bubble_view = test_api_->overflow_bubble()->bubble_view();
test::OverflowBubbleViewTestAPI bubble_view_api(bubble_view);