Commit dc4c2a66 authored by Yulun Wu's avatar Yulun Wu Committed by Commit Bot

Don't move shelf components independently of shelf.

Navigation and Status widgets should follow shelf bounds which do not
change during drag when auto hide is disabled.

Bug: 1097622
Change-Id: Icefb10663c39aeefb22a02bef2cdfca0958b4a41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2265555Reviewed-by: default avatarYulun Wu <yulunwu@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: Yulun Wu <yulunwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782771}
parent 489f6830
......@@ -1749,6 +1749,10 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
shelf_->shelf_widget()->GetTargetBounds();
updated_target_bounds.set_y(adjusted_shelf_position);
shelf_->shelf_widget()->set_target_bounds(updated_target_bounds);
shelf_->navigation_widget()->UpdateTargetBoundsForGesture(
adjusted_shelf_position);
shelf_->status_area_widget()->UpdateTargetBoundsForGesture(
adjusted_shelf_position);
}
int hotseat_y = 0;
......@@ -1775,17 +1779,12 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
gfx::Rect hotseat_bounds = shelf_->hotseat_widget()->GetTargetBounds();
hotseat_bounds.set_y(hotseat_y + adjusted_shelf_position);
shelf_->hotseat_widget()->set_target_bounds(hotseat_bounds);
shelf_->navigation_widget()->UpdateTargetBoundsForGesture(
adjusted_shelf_position);
shelf_->status_area_widget()->UpdateTargetBoundsForGesture(
adjusted_shelf_position);
return;
}
shelf_->shelf_widget()->UpdateTargetBoundsForGesture(shelf_position);
shelf_->navigation_widget()->UpdateTargetBoundsForGesture(shelf_position);
shelf_->hotseat_widget()->UpdateTargetBoundsForGesture(shelf_position);
shelf_->navigation_widget()->UpdateTargetBoundsForGesture(shelf_position);
shelf_->status_area_widget()->UpdateTargetBoundsForGesture(shelf_position);
}
......
......@@ -758,6 +758,64 @@ TEST_P(ShelfLayoutManagerTest, StatusAreaMoveWithSwipeOnAutoHiddenShelf) {
GetWidgetOffsetFromBottom(shelf->status_area_widget()));
}
TEST_P(ShelfLayoutManagerTest,
NavigationWidgetDoesNotMoveWithoutAutoHiddenShelf) {
Shelf* shelf = GetPrimaryShelf();
CreateTestWidget();
TabletModeControllerTestApi().EnterTabletMode();
shelf->SetAutoHideBehavior(ShelfAutoHideBehavior::kNever);
gfx::Rect nav_widget_bounds =
shelf->navigation_widget()->GetWindowBoundsInScreen();
const gfx::Point end(nav_widget_bounds.top_center());
const gfx::Point middle(end +
gfx::Vector2d(0, -nav_widget_bounds.height() / 2));
const gfx::Point start(end + gfx::Vector2d(0, -nav_widget_bounds.height()));
// Perform a drag down on the status area widget.
ui::test::EventGenerator* generator = GetEventGenerator();
generator->MoveTouch(start);
generator->PressTouch();
generator->MoveTouch(middle);
EXPECT_EQ(nav_widget_bounds,
shelf->navigation_widget()->GetWindowBoundsInScreen());
generator->MoveTouch(end);
EXPECT_EQ(nav_widget_bounds,
shelf->navigation_widget()->GetWindowBoundsInScreen());
generator->ReleaseTouch();
EXPECT_EQ(nav_widget_bounds,
shelf->navigation_widget()->GetWindowBoundsInScreen());
}
TEST_P(ShelfLayoutManagerTest, StatusWidgetDoesNotMoveWithoutAutoHiddenShelf) {
Shelf* shelf = GetPrimaryShelf();
CreateTestWidget();
TabletModeControllerTestApi().EnterTabletMode();
shelf->SetAutoHideBehavior(ShelfAutoHideBehavior::kNever);
gfx::Rect status_widget_bounds =
shelf->status_area_widget()->GetWindowBoundsInScreen();
const gfx::Point end(status_widget_bounds.top_center());
const gfx::Point middle(end +
gfx::Vector2d(0, -status_widget_bounds.height() / 2));
const gfx::Point start(end +
gfx::Vector2d(0, -status_widget_bounds.height()));
// Perform a drag down on the status area widget.
ui::test::EventGenerator* generator = GetEventGenerator();
generator->MoveTouch(start);
generator->PressTouch();
generator->MoveTouch(middle);
EXPECT_EQ(status_widget_bounds,
shelf->status_area_widget()->GetWindowBoundsInScreen());
generator->MoveTouch(end);
EXPECT_EQ(status_widget_bounds,
shelf->status_area_widget()->GetWindowBoundsInScreen());
generator->ReleaseTouch();
EXPECT_EQ(status_widget_bounds,
shelf->status_area_widget()->GetWindowBoundsInScreen());
}
// Checks that the navigation widget follows along the auto-hidden shelf when
// the user swipes it up or down.
TEST_P(ShelfLayoutManagerTest, NavigationWidgetMoveWithSwipeOnAutoHiddenShelf) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment