Commit fda66958 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

applist: Fix flinging mechanics on shelf and applist.

Previously the fling in the wrong direction would do the same as a fling
in the right direction. (ex. flinging down when dragging up from the
shelf would show the home launcher as well)

Test: ash_unittests HomeLauncherModeGestureHandlerTest.Fling*
Bug: 896510
Change-Id: I0a366eaab679e5e041947a07e80bd82ab495a8af
Reviewed-on: https://chromium-review.googlesource.com/c/1289073
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarWeidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600860}
parent a51492da
...@@ -571,8 +571,15 @@ bool HomeLauncherGestureHandler::IsFinalStateShow() { ...@@ -571,8 +571,15 @@ bool HomeLauncherGestureHandler::IsFinalStateShow() {
// If fling velocity is greater than the threshold, show the launcher if // If fling velocity is greater than the threshold, show the launcher if
// sliding up, or hide the launcher if sliding down, irregardless of // sliding up, or hide the launcher if sliding down, irregardless of
// |last_event_location_|. // |last_event_location_|.
if (std::fabs(last_scroll_y_) > kScrollVelocityThreshold) if (mode_ == Mode::kSlideUpToShow &&
return mode_ == Mode::kSlideUpToShow; last_scroll_y_ < -kScrollVelocityThreshold) {
return true;
}
if (mode_ == Mode::kSlideDownToHide &&
last_scroll_y_ > kScrollVelocityThreshold) {
return false;
}
return last_event_location_ return last_event_location_
? IsLastEventInTopHalf(*last_event_location_, display_.work_area()) ? IsLastEventInTopHalf(*last_event_location_, display_.work_area())
......
...@@ -138,6 +138,14 @@ TEST_F(HomeLauncherGestureHandlerTest, FlingingSlideUp) { ...@@ -138,6 +138,14 @@ TEST_F(HomeLauncherGestureHandlerTest, FlingingSlideUp) {
auto window = CreateWindowForTesting(); auto window = CreateWindowForTesting();
ASSERT_TRUE(window->IsVisible()); ASSERT_TRUE(window->IsVisible());
// Tests that flinging down in this mode will keep the window visible.
DoPress(Mode::kSlideUpToShow);
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 300), 10.f);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr);
ASSERT_TRUE(window->IsVisible());
// Tests that flinging up in this mode will hide the window and show the
// home launcher.
DoPress(Mode::kSlideUpToShow); DoPress(Mode::kSlideUpToShow);
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 300), -10.f); GetGestureHandler()->OnScrollEvent(gfx::Point(0, 300), -10.f);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr); GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr);
...@@ -153,6 +161,13 @@ TEST_F(HomeLauncherGestureHandlerTest, FlingingSlideDown) { ...@@ -153,6 +161,13 @@ TEST_F(HomeLauncherGestureHandlerTest, FlingingSlideDown) {
wm::GetWindowState(window.get())->Minimize(); wm::GetWindowState(window.get())->Minimize();
ASSERT_FALSE(window->IsVisible()); ASSERT_FALSE(window->IsVisible());
// Tests that flinging up in this mode will not show the mru window.
DoPress(Mode::kSlideDownToHide);
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 100), -10.f);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100), nullptr);
ASSERT_FALSE(window->IsVisible());
// Tests that flinging down in this mode will show the mru window.
DoPress(Mode::kSlideDownToHide); DoPress(Mode::kSlideDownToHide);
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 100), 10.f); GetGestureHandler()->OnScrollEvent(gfx::Point(0, 100), 10.f);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100), nullptr); GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100), nullptr);
......
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