Commit 1838e5db authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

applist: Remove dead code from home_laucher_gesture_handler.cc.

The logic to check if we should handle certain scrolls was moved to
shelf_layout_manager.cc in [1]. The logic remaining in
home_laucher_gesture_handler.cc is no longer needed.

[1] https://chromium-review.googlesource.com/c/1307233

Test: manual
Bug: 896790
Change-Id: Ic4b8a65ff8b4f6f3b5ed39147c09a68506bb1181
Reviewed-on: https://chromium-review.googlesource.com/c/1334648
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608205}
parent 477e29d8
......@@ -809,8 +809,7 @@ bool AppListControllerImpl::ProcessHomeLauncherGesture(
return home_launcher_gesture_handler_->OnScrollEvent(
screen_location, event->details().scroll_y());
case ui::ET_GESTURE_END:
return home_launcher_gesture_handler_->OnReleaseEvent(
screen_location, /*out_dragged_down=*/nullptr);
return home_launcher_gesture_handler_->OnReleaseEvent(screen_location);
default:
break;
}
......
......@@ -74,6 +74,7 @@ bool CanProcessWindow(aura::Window* window,
if (window->type() == aura::client::WINDOW_TYPE_POPUP)
return false;
// Do not process if |window| is not the root of a transient tree.
if (::wm::GetTransientParent(window))
return false;
......@@ -181,7 +182,6 @@ bool HomeLauncherGestureHandler::OnPressEvent(Mode mode,
return false;
mode_ = mode;
initial_event_location_ = location;
last_event_location_ = base::make_optional(location);
UpdateWindows(0.0, /*animate=*/false);
......@@ -198,11 +198,6 @@ bool HomeLauncherGestureHandler::OnScrollEvent(const gfx::Point& location,
last_event_location_ = base::make_optional(location);
last_scroll_y_ = scroll_y;
if (mode_ == Mode::kSlideUpToShow &&
(*last_event_location_ - initial_event_location_).y() > 0) {
UpdateWindows(0.0, /*animate=*/false);
return true;
}
DCHECK(display_.is_valid());
UpdateWindows(GetHeightInWorkAreaAsRatio(location, display_.work_area()),
......@@ -210,8 +205,7 @@ bool HomeLauncherGestureHandler::OnScrollEvent(const gfx::Point& location,
return true;
}
bool HomeLauncherGestureHandler::OnReleaseEvent(const gfx::Point& location,
bool* out_dragged_down) {
bool HomeLauncherGestureHandler::OnReleaseEvent(const gfx::Point& location) {
if (IsAnimating())
return false;
......@@ -228,11 +222,6 @@ bool HomeLauncherGestureHandler::OnReleaseEvent(const gfx::Point& location,
}
last_event_location_ = base::make_optional(location);
if (out_dragged_down) {
DCHECK_EQ(mode_, Mode::kSlideUpToShow);
*out_dragged_down =
(*last_event_location_ - initial_event_location_).y() > 0;
}
AnimateToFinalState();
return true;
}
......
......@@ -53,7 +53,7 @@ class ASH_EXPORT HomeLauncherGestureHandler : aura::WindowObserver,
// was not processed.
bool OnPressEvent(Mode mode, const gfx::Point& location);
bool OnScrollEvent(const gfx::Point& location, float scroll_y);
bool OnReleaseEvent(const gfx::Point& location, bool* out_dragged_down);
bool OnReleaseEvent(const gfx::Point& location);
// Cancel a current drag and animates the items to their final state based on
// |last_event_location_|.
......@@ -158,8 +158,6 @@ class ASH_EXPORT HomeLauncherGestureHandler : aura::WindowObserver,
// hidden so the home launcher is visible when swiping up.
std::vector<aura::Window*> hidden_windows_;
gfx::Point initial_event_location_;
// Tracks the location of the last received event in screen coordinates. Empty
// if there is currently no window being processed.
base::Optional<gfx::Point> last_event_location_;
......
......@@ -141,14 +141,14 @@ TEST_F(HomeLauncherGestureHandlerTest, FlingingSlideUp) {
// 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);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300));
ASSERT_TRUE(window->IsVisible());
// Tests that flinging up in this mode will hide the window and show the
// home launcher.
DoPress(Mode::kSlideUpToShow);
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 300), -10.f);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300));
EXPECT_FALSE(window->IsVisible());
}
......@@ -164,13 +164,13 @@ TEST_F(HomeLauncherGestureHandlerTest, FlingingSlideDown) {
// 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);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100));
ASSERT_FALSE(window->IsVisible());
// Tests that flinging down in this mode will show the mru window.
DoPress(Mode::kSlideDownToHide);
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 100), 10.f);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100));
EXPECT_TRUE(window->IsVisible());
}
......@@ -185,12 +185,6 @@ TEST_F(HomeLauncherGestureHandlerTest, SlidingBelowPressPoint) {
GetGestureHandler()->OnPressEvent(Mode::kSlideUpToShow, gfx::Point(0, 400));
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 420), 1.f);
EXPECT_EQ(gfx::Transform(), window->transform());
// Tests that OnReleaseEvent returns true when checking if the release point
// is below the press point.
bool released_below;
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 420), &released_below);
EXPECT_TRUE(released_below);
}
// Tests that the home launcher gestures work with overview mode as expected.
......@@ -221,7 +215,7 @@ TEST_F(HomeLauncherGestureHandlerTest, OverviewMode) {
// Tests that after releasing at below the halfway point, we remain in
// overview mode.
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300));
EXPECT_TRUE(controller->IsSelecting());
EXPECT_EQ(window1_initial_translation,
window1->transform().To2dTranslation().y());
......@@ -231,7 +225,7 @@ TEST_F(HomeLauncherGestureHandlerTest, OverviewMode) {
// Tests that after releasing on the bottom half, overview mode has been
// exited, and the two windows have been minimized to show the home launcher.
DoPress(Mode::kSlideUpToShow);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100));
EXPECT_FALSE(controller->IsSelecting());
EXPECT_TRUE(wm::GetWindowState(window1.get())->IsMinimized());
EXPECT_TRUE(wm::GetWindowState(window2.get())->IsMinimized());
......@@ -268,7 +262,7 @@ TEST_F(HomeLauncherGestureHandlerTest, SplitviewOneSnappedWindow) {
// Tests that after releasing at below the halfway point, we remain in
// both splitview and overview mode.
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300));
EXPECT_EQ(window1->transform(), gfx::Transform());
EXPECT_EQ(window2_initial_translation,
window2->transform().To2dTranslation().y());
......@@ -278,7 +272,7 @@ TEST_F(HomeLauncherGestureHandlerTest, SplitviewOneSnappedWindow) {
// Tests that after releasing on the bottom half, overivew and splitview have
// both been exited, and both windows are minimized to show the home launcher.
DoPress(Mode::kSlideUpToShow);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100));
EXPECT_FALSE(window_selector_controller->IsSelecting());
EXPECT_FALSE(split_view_controller->IsSplitViewModeActive());
EXPECT_TRUE(wm::GetWindowState(window1.get())->IsMinimized());
......@@ -314,7 +308,7 @@ TEST_F(HomeLauncherGestureHandlerTest, SplitviewTwoSnappedWindows) {
// Tests that after releasing at below the halfway point, we remain in
// splitview.
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300));
EXPECT_EQ(window1->transform(), gfx::Transform());
EXPECT_EQ(window2->transform(), gfx::Transform());
EXPECT_TRUE(split_view_controller->IsSplitViewModeActive());
......@@ -322,7 +316,7 @@ TEST_F(HomeLauncherGestureHandlerTest, SplitviewTwoSnappedWindows) {
// Tests that after releasing on the bottom half, splitview has been ended,
// and the two windows have been minimized to show the home launcher.
DoPress(Mode::kSlideUpToShow);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100));
EXPECT_FALSE(split_view_controller->IsSplitViewModeActive());
EXPECT_TRUE(wm::GetWindowState(window1.get())->IsMinimized());
EXPECT_TRUE(wm::GetWindowState(window2.get())->IsMinimized());
......@@ -399,7 +393,7 @@ TEST_P(HomeLauncherModeGestureHandlerTest, BelowHalfShowsWindow) {
EXPECT_NE(1.f, window1->layer()->opacity());
// Tests the transform and opacity have returned to the identity and 1.
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300));
EXPECT_EQ(gfx::Transform(), window1->transform());
EXPECT_EQ(1.f, window1->layer()->opacity());
......@@ -426,7 +420,7 @@ TEST_P(HomeLauncherModeGestureHandlerTest, AboveHalfReleaseMinimizesWindow) {
ASSERT_FALSE(window3->IsVisible());
// Test that |window1| is minimized on release.
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100));
EXPECT_TRUE(wm::GetWindowState(window1.get())->IsMinimized());
// The rest of the windows remain invisible, to show the home launcher.
......@@ -460,7 +454,7 @@ TEST_P(HomeLauncherModeGestureHandlerTest, WindowWithTransientChild) {
// Tests that after releasing on the bottom half, the transient child reverts
// to its original values.
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300));
EXPECT_EQ(1.0f, child->layer()->opacity());
EXPECT_EQ(gfx::Transform(), child->transform());
}
......@@ -514,7 +508,7 @@ TEST_P(HomeLauncherModeGestureHandlerTest, AnimatingToEndResetsState) {
EXPECT_FALSE(GetGestureHandler()->transient_descendants_values_.empty());
// Tests that after a drag, the variables are either null or empty.
GetGestureHandler()->OnReleaseEvent(gfx::Point(10, 10), nullptr);
GetGestureHandler()->OnReleaseEvent(gfx::Point(10, 10));
EXPECT_FALSE(GetGestureHandler()->window());
EXPECT_FALSE(GetGestureHandler()->last_event_location_);
EXPECT_EQ(Mode::kNone, GetGestureHandler()->mode_);
......
......@@ -1318,16 +1318,8 @@ void ShelfLayoutManager::CompleteAppListDrag(
HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
bool dragged_down;
if (home_launcher_handler &&
home_launcher_handler->OnReleaseEvent(gesture_in_screen.location(),
&dragged_down)) {
if (dragged_down && visibility_state() == SHELF_AUTO_HIDE) {
DCHECK_EQ(SHELF_AUTO_HIDE_SHOWN, gesture_drag_auto_hide_state_);
gesture_drag_auto_hide_state_ = SHELF_AUTO_HIDE_HIDDEN;
gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
UpdateVisibilityState();
}
home_launcher_handler->OnReleaseEvent(gesture_in_screen.location())) {
gesture_drag_status_ = GESTURE_DRAG_NONE;
return;
}
......
......@@ -9,6 +9,8 @@
#include "ash/accelerators/accelerator_controller.h"
#include "ash/accelerators/accelerator_table.h"
#include "ash/app_list/app_list_controller_impl.h"
#include "ash/app_list/home_launcher_gesture_handler.h"
#include "ash/app_list/test/app_list_test_helper.h"
#include "ash/focus_cycler.h"
#include "ash/public/cpp/app_list/app_list_features.h"
......@@ -2481,6 +2483,70 @@ TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) {
EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
}
// Tests that the shelf forwards the appropriate events to the home launcher
// gesture handler to handle.
TEST_F(ShelfLayoutManagerTest, HomeLauncherGestureHandler) {
// Home launcher is only available in tablet mode.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
// Home launcher gesture handler needs at least one window.
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
const gfx::Point shelf_center =
GetVisibleShelfWidgetBoundsInScreen().CenterPoint();
// Helper to create a scroll event for this test.
auto create_scroll_event = [&shelf_center](ui::EventType type,
float scroll_y) {
ui::GestureEventDetails details =
type == ui::ET_GESTURE_SCROLL_END
? ui::GestureEventDetails(type)
: ui::GestureEventDetails(type, 0, scroll_y);
return ui::GestureEvent(shelf_center.x(), shelf_center.y(), 0,
base::TimeTicks(), details);
};
// The home launcher gesture handler should not be handling any window
// initially.
ShelfLayoutManager* manager = GetShelfLayoutManager();
HomeLauncherGestureHandler* gesture_handler =
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
ASSERT_TRUE(gesture_handler);
ASSERT_FALSE(gesture_handler->window());
// Tests that after scrolling up on the shelf, the home launcher gesture
// handler will be acting on |window|.
manager->ProcessGestureEvent(
create_scroll_event(ui::ET_GESTURE_SCROLL_BEGIN, -1.f));
EXPECT_EQ(window.get(), gesture_handler->window());
// Tests that since the initial scroll event was scrolled up, the home
// launcher gesture handler will continue to act on |window| regardless of
// direction of scroll updates.
manager->ProcessGestureEvent(
create_scroll_event(ui::ET_GESTURE_SCROLL_UPDATE, -1.f));
EXPECT_EQ(window.get(), gesture_handler->window());
manager->ProcessGestureEvent(
create_scroll_event(ui::ET_GESTURE_SCROLL_UPDATE, 1.f));
EXPECT_EQ(window.get(), gesture_handler->window());
// End the scroll.
manager->ProcessGestureEvent(
create_scroll_event(ui::ET_GESTURE_SCROLL_END, 1.f));
ASSERT_FALSE(gesture_handler->window());
// Tests that if the initial scroll event is directed downwards, the home
// launcher gesture handler will not act on |window|.
manager->ProcessGestureEvent(
create_scroll_event(ui::ET_GESTURE_SCROLL_BEGIN, 1.f));
EXPECT_FALSE(gesture_handler->window());
manager->ProcessGestureEvent(
create_scroll_event(ui::ET_GESTURE_SCROLL_UPDATE, -1.f));
EXPECT_FALSE(gesture_handler->window());
}
class ShelfLayoutManagerKeyboardTest : public AshTestBase {
public:
ShelfLayoutManagerKeyboardTest() = default;
......
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