Commit fe5375a0 authored by Ana Salazar's avatar Ana Salazar Committed by Commit Bot

Cros: Swipe up on home/back button shows hotseat

This change delegates the gesture events happening in the navigation
widget to the shelf

Fixed: 1016931
Change-Id: I4c91612ff5d4283a2f4b2d21a6c890dd33f34532
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1877140
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709111}
parent 37fc9665
......@@ -3338,6 +3338,61 @@ TEST_F(HotseatShelfLayoutManagerTest, ShowingAndHidingAutohiddenShelf) {
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, GetPrimaryShelf()->GetAutoHideState());
}
// Tests that swiping up on several places in the in-app shelf shows the
// hotseat (crbug.com/1016931).
TEST_F(HotseatShelfLayoutManagerTest, SwipeUpInAppShelfShowsHotseat) {
TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
// Swipe up from the center of the shelf.
SwipeUpOnShelf();
EXPECT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
// Swipe down from the hotseat to hide it.
gfx::Rect hotseat_bounds =
GetShelfWidget()->hotseat_widget()->GetWindowBoundsInScreen();
gfx::Point start = hotseat_bounds.top_center();
gfx::Point end = start + gfx::Vector2d(0, 80);
const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100);
const int kNumScrollSteps = 4;
GetEventGenerator()->GestureScrollSequence(start, end, kTimeDelta,
kNumScrollSteps);
ASSERT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
// Swipe up from the right part of the shelf (the system tray).
start = GetShelfWidget()
->status_area_widget()
->GetWindowBoundsInScreen()
.CenterPoint();
end = start + gfx::Vector2d(0, -80);
GetEventGenerator()->GestureScrollSequence(start, end, kTimeDelta,
kNumScrollSteps);
EXPECT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
// Swipe down from the hotseat to hide it.
start = hotseat_bounds.top_center();
end = start + gfx::Vector2d(0, 80);
GetEventGenerator()->GestureScrollSequence(start, end, kTimeDelta,
kNumScrollSteps);
ASSERT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
// Swipe up from the left part of the shelf (the home/back button).
start = GetShelfWidget()
->navigation_widget()
->GetWindowBoundsInScreen()
.CenterPoint();
end = start + gfx::Vector2d(0, -80);
GetEventGenerator()->GestureScrollSequence(start, end, kTimeDelta,
kNumScrollSteps);
EXPECT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
}
// Tests that swiping up on the shelf background shows the home launcher.
TEST_P(HotseatShelfLayoutManagerTest,
SwipeUpOnShelfBackgroundShowsHomeLauncher) {
......
......@@ -249,6 +249,14 @@ bool ShelfNavigationWidget::OnNativeWidgetActivationChanged(bool active) {
return true;
}
void ShelfNavigationWidget::OnGestureEvent(ui::GestureEvent* event) {
if (shelf_->ProcessGestureEvent(*event)) {
event->StopPropagation();
return;
}
views::Widget::OnGestureEvent(event);
}
BackButton* ShelfNavigationWidget::GetBackButton() const {
return delegate_->back_button();
}
......
......@@ -48,6 +48,7 @@ class ASH_EXPORT ShelfNavigationWidget : public views::Widget,
// views::Widget:
bool OnNativeWidgetActivationChanged(bool active) override;
void OnGestureEvent(ui::GestureEvent* event) override;
// Getters for the back and home buttons.
BackButton* GetBackButton() const;
......
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