Commit 9dca9880 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

overview gesture: Remove kDragWindowToHomeOrOverview mode and migrate tests.

Remove kDragWindowToHomeOrOverview mode from HomeLauncherGestureHandler
and migrate tests.

No functional change.

Bug: 997885
Change-Id: I727e1c6bbc11d88416eb3e92a8f113c7d4c8e4ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879818
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709291}
parent b3aa48fd
...@@ -1734,6 +1734,7 @@ test("ash_unittests") { ...@@ -1734,6 +1734,7 @@ test("ash_unittests") {
"frame/non_client_frame_view_ash_unittest.cc", "frame/non_client_frame_view_ash_unittest.cc",
"highlighter/highlighter_controller_unittest.cc", "highlighter/highlighter_controller_unittest.cc",
"highlighter/highlighter_gesture_util_unittest.cc", "highlighter/highlighter_gesture_util_unittest.cc",
"home_screen/drag_window_from_shelf_controller_unittest.cc",
"home_screen/home_launcher_gesture_handler_unittest.cc", "home_screen/home_launcher_gesture_handler_unittest.cc",
"home_screen/home_screen_controller_unittest.cc", "home_screen/home_screen_controller_unittest.cc",
"ime/ime_controller_unittest.cc", "ime/ime_controller_unittest.cc",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include "ash/ash_export.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/wm/splitview/split_view_controller.h" #include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/splitview/split_view_drag_indicators.h" #include "ash/wm/splitview/split_view_drag_indicators.h"
...@@ -24,7 +25,7 @@ namespace ash { ...@@ -24,7 +25,7 @@ namespace ash {
// The window drag controller that will be used when a window is dragged up by // The window drag controller that will be used when a window is dragged up by
// swiping up from the shelf to homescreen, overview or splitview. // swiping up from the shelf to homescreen, overview or splitview.
class DragWindowFromShelfController : public aura::WindowObserver { class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
public: public:
// The distance for the dragged window to pass over shelf so that it can be // The distance for the dragged window to pass over shelf so that it can be
// dragged into home launcher or overview. If not pass this value, the window // dragged into home launcher or overview. If not pass this value, the window
...@@ -61,6 +62,9 @@ class DragWindowFromShelfController : public aura::WindowObserver { ...@@ -61,6 +62,9 @@ class DragWindowFromShelfController : public aura::WindowObserver {
// aura::WindowObserver: // aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override; void OnWindowDestroying(aura::Window* window) override;
aura::Window* dragged_window() const { return window_; }
bool drag_started() const { return drag_started_; }
private: private:
class WindowsHider; class WindowsHider;
......
This diff is collapsed.
...@@ -26,7 +26,6 @@ namespace ash { ...@@ -26,7 +26,6 @@ namespace ash {
class HomeLauncherGestureHandlerObserver; class HomeLauncherGestureHandlerObserver;
class SwipeHomeToOverviewController; class SwipeHomeToOverviewController;
class DragWindowFromShelfController;
// HomeLauncherGestureHandler makes modifications to a window's transform and // HomeLauncherGestureHandler makes modifications to a window's transform and
// opacity when gesture drag events are received and forwarded to it. // opacity when gesture drag events are received and forwarded to it.
...@@ -45,13 +44,6 @@ class ASH_EXPORT HomeLauncherGestureHandler ...@@ -45,13 +44,6 @@ class ASH_EXPORT HomeLauncherGestureHandler
// Sliding up the MRU window to display launcher. If in overview mode, // Sliding up the MRU window to display launcher. If in overview mode,
// slides up overview mode as well. // slides up overview mode as well.
kSlideUpToShow, kSlideUpToShow,
// Sliding up from the shelf to drag the MRU window (or one of the snapped
// window in splitview) around to enter either home launcher screen or to
// overview screen. If in overview mode, this mode is a no-op. Note: This
// mode is behind the feature flag kDragFromShelfToHomeOrOverview.
// TODO(crbug.com/997885): Remove this mode. The window dragging logic has
// been moved into shelf dragging.
kDragWindowToHomeOrOverview,
// Sliding down the MRU window to hide launcher. // Sliding down the MRU window to hide launcher.
kSlideDownToHide, kSlideDownToHide,
// Sliding up from the shelf in home launcher screen to the overview screen. // Sliding up from the shelf in home launcher screen to the overview screen.
...@@ -154,10 +146,8 @@ class ASH_EXPORT HomeLauncherGestureHandler ...@@ -154,10 +146,8 @@ class ASH_EXPORT HomeLauncherGestureHandler
// Sets up windows that will be used in dragging and animation. If |window| is // Sets up windows that will be used in dragging and animation. If |window| is
// not null for kSlideDownToHide mode, it will be set as the window to run // not null for kSlideDownToHide mode, it will be set as the window to run
// slide down animation. |window| is not used for kSlideUpToShow or // slide down animation. |window| is not used for kSlideUpToShow mode. Returns
// kDragWindowToHomeOrOverview mode. |location_in_screen| is only used for // true if windows are successfully set up.
// kDragWindowToHomeOrOverview mode to find the eligible widnow to drag.
// Returns true if windows are successfully set up.
bool SetUpWindows(Mode mode, bool SetUpWindows(Mode mode,
aura::Window* window, aura::Window* window,
base::Optional<gfx::Point> location_in_screen); base::Optional<gfx::Point> location_in_screen);
...@@ -218,10 +208,6 @@ class ASH_EXPORT HomeLauncherGestureHandler ...@@ -218,10 +208,6 @@ class ASH_EXPORT HomeLauncherGestureHandler
// The display where the windows are being processed. // The display where the windows are being processed.
display::Display display_; display::Display display_;
// The window drag controller that will be used in kDragWindowToHomeOrOverview
// mode. Will not be created in other modes.
std::unique_ptr<DragWindowFromShelfController> window_drag_controller_;
// The gesture controller that switches from home screen to overview when it // The gesture controller that switches from home screen to overview when it
// detects a swipe from the shelf area. // detects a swipe from the shelf area.
std::unique_ptr<SwipeHomeToOverviewController> std::unique_ptr<SwipeHomeToOverviewController>
......
...@@ -128,9 +128,6 @@ GetHomeLauncherGestureHandlerModeForDrag() { ...@@ -128,9 +128,6 @@ GetHomeLauncherGestureHandlerModeForDrag() {
return HomeLauncherGestureHandler::Mode::kSwipeHomeToOverview; return HomeLauncherGestureHandler::Mode::kSwipeHomeToOverview;
} }
if (features::IsDragFromShelfToHomeOrOverviewEnabled())
return HomeLauncherGestureHandler::Mode::kDragWindowToHomeOrOverview;
return HomeLauncherGestureHandler::Mode::kSlideUpToShow; return HomeLauncherGestureHandler::Mode::kSlideUpToShow;
} }
......
...@@ -237,6 +237,10 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -237,6 +237,10 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; } ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; }
HotseatState hotseat_state() const { return state_.hotseat_state; } HotseatState hotseat_state() const { return state_.hotseat_state; }
DragWindowFromShelfController* window_drag_controller_for_testing() {
return window_drag_controller_.get();
}
// TODO(harrym|oshima): These templates will be moved to a new Shelf class. // TODO(harrym|oshima): These templates will be moved to a new Shelf class.
// A helper function for choosing values specific to a shelf alignment. // A helper function for choosing values specific to a shelf alignment.
template <typename T> template <typename T>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ash/app_list/test/app_list_test_helper.h" #include "ash/app_list/test/app_list_test_helper.h"
#include "ash/app_list/views/app_list_view.h" #include "ash/app_list/views/app_list_view.h"
#include "ash/focus_cycler.h" #include "ash/focus_cycler.h"
#include "ash/home_screen/drag_window_from_shelf_controller.h"
#include "ash/home_screen/home_launcher_gesture_handler.h" #include "ash/home_screen/home_launcher_gesture_handler.h"
#include "ash/home_screen/home_screen_controller.h" #include "ash/home_screen/home_screen_controller.h"
#include "ash/keyboard/ui/keyboard_ui.h" #include "ash/keyboard/ui/keyboard_ui.h"
...@@ -3738,6 +3739,121 @@ TEST_F(HotseatShelfLayoutManagerTest, HotseatHidesWhenSwipedToBezel) { ...@@ -3738,6 +3739,121 @@ TEST_F(HotseatShelfLayoutManagerTest, HotseatHidesWhenSwipedToBezel) {
EXPECT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state()); EXPECT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
} }
class ShelfLayoutManagerWindowDraggingTest : public ShelfLayoutManagerTestBase {
public:
ShelfLayoutManagerWindowDraggingTest() = default;
~ShelfLayoutManagerWindowDraggingTest() override = default;
// AshTestBase:
void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
chromeos::switches::kShelfHotseat);
scoped_feature_list_.InitAndEnableFeature(
features::kDragFromShelfToHomeOrOverview);
AshTestBase::SetUp();
TabletModeControllerTestApi().EnterTabletMode();
base::RunLoop().RunUntilIdle();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerWindowDraggingTest);
};
// Test that when swiping up on the shelf, we may or may not drag up the MRU
// window.
TEST_F(ShelfLayoutManagerWindowDraggingTest, DraggedMRUWindow) {
const gfx::Rect shelf_widget_bounds =
GetShelfWidget()->GetWindowBoundsInScreen();
const int hotseat_size = ShelfConfig::Get()->hotseat_size();
// Starts the drag from the center of the shelf's bottom.
gfx::Point start = shelf_widget_bounds.bottom_center();
StartScroll(start);
// We need at least one window to work with.
EXPECT_FALSE(GetShelfLayoutManager()->window_drag_controller_for_testing());
UpdateScroll(-shelf_widget_bounds.height() - hotseat_size);
EndScroll(/*is_fling=*/false, 0.f);
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
StartScroll(start);
DragWindowFromShelfController* window_drag_controller =
GetShelfLayoutManager()->window_drag_controller_for_testing();
EXPECT_TRUE(window_drag_controller);
EXPECT_EQ(window_drag_controller->dragged_window(), window.get());
UpdateScroll(-shelf_widget_bounds.height() - hotseat_size);
EndScroll(/*is_fling=*/false, 0.f);
EXPECT_FALSE(GetShelfLayoutManager()->window_drag_controller_for_testing());
// The window needs to be visible to drag up.
window->Hide();
StartScroll(start);
EXPECT_FALSE(GetShelfLayoutManager()->window_drag_controller_for_testing());
UpdateScroll(-shelf_widget_bounds.height() - hotseat_size);
EndScroll(/*is_fling=*/false, 0.f);
// In splitview, depends on the drag position, the active dragged window might
// be different.
window->Show();
auto window2 = AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
SplitViewController* split_view_controller =
SplitViewController::Get(Shell::GetPrimaryRootWindow());
split_view_controller->SnapWindow(window.get(), SplitViewController::LEFT);
split_view_controller->SnapWindow(window2.get(), SplitViewController::RIGHT);
StartScroll(shelf_widget_bounds.bottom_left());
window_drag_controller =
GetShelfLayoutManager()->window_drag_controller_for_testing();
EXPECT_TRUE(window_drag_controller);
EXPECT_EQ(window_drag_controller->dragged_window(), window.get());
EndScroll(/*is_fling=*/false, 0.f);
EXPECT_FALSE(GetShelfLayoutManager()->window_drag_controller_for_testing());
StartScroll(shelf_widget_bounds.bottom_right());
window_drag_controller =
GetShelfLayoutManager()->window_drag_controller_for_testing();
EXPECT_TRUE(window_drag_controller);
EXPECT_EQ(window_drag_controller->dragged_window(), window2.get());
EndScroll(/*is_fling=*/false, 0.f);
split_view_controller->EndSplitView();
EXPECT_FALSE(GetShelfLayoutManager()->window_drag_controller_for_testing());
}
// Test that drag from shelf when overview is active is a no-op.
TEST_F(ShelfLayoutManagerWindowDraggingTest, NoOpInOverview) {
const gfx::Rect shelf_widget_bounds =
GetShelfWidget()->GetWindowBoundsInScreen();
std::unique_ptr<aura::Window> window1 =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
std::unique_ptr<aura::Window> window2 =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window1.get());
// Starts the drag from the center of the shelf's bottom.
OverviewController* overview_controller = Shell::Get()->overview_controller();
overview_controller->StartOverview();
gfx::Point start = shelf_widget_bounds.bottom_center();
StartScroll(start);
EXPECT_FALSE(GetShelfLayoutManager()->window_drag_controller_for_testing());
EndScroll(/*is_fling=*/false, 0.f);
// In splitview + overview case, drag from shelf in the overview side of the
// screen also does nothing.
SplitViewController* split_view_controller =
SplitViewController::Get(Shell::GetPrimaryRootWindow());
split_view_controller->SnapWindow(window1.get(), SplitViewController::LEFT);
split_view_controller->SnapWindow(window2.get(), SplitViewController::RIGHT);
overview_controller->StartOverview();
EXPECT_TRUE(split_view_controller->InSplitViewMode());
EXPECT_TRUE(overview_controller->InOverviewSession());
StartScroll(shelf_widget_bounds.bottom_right());
EXPECT_FALSE(GetShelfLayoutManager()->window_drag_controller_for_testing());
EndScroll(/*is_fling=*/false, 0.f);
}
class ShelfLayoutManagerKeyboardTest : public AshTestBase { class ShelfLayoutManagerKeyboardTest : public AshTestBase {
public: public:
ShelfLayoutManagerKeyboardTest() = default; 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