Commit 1ab3884b authored by Christos Froussios's avatar Christos Froussios Committed by Commit Bot

Revert "overview: Initial patch for overview swipe to close."

This reverts commit 209edd56.

Reason for revert: The test SplitViewWindowSelectorTest.DragToClose
is flaky (mostly failing) on builder Linux Chromium OS ASan LSan Tests
e.g.
https://ci.chromium.org/buildbot/chromium.memory/Linux%20Chromium%20OS%20ASan%20LSan%20Tests%20%281%29/27234

Original change's description:
> overview: Initial patch for overview swipe to close.
>
> Adds ability to drag the overview item up or fling the item up to close
> the window. A later cl will add the fling animation. The feature is
> hidden behind a newly added flag.
>
> Test: added test coverage
> Bug: 828646
> Change-Id: I8e66fb3ed2a642deb6a833f30e9b7674d56b0fee
> Reviewed-on: https://chromium-review.googlesource.com/1014490
> Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
> Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
> Commit-Queue: Sammie Quon <sammiequon@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#554651}

TBR=oshima@chromium.org,xdai@chromium.org,sammiequon@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 828646, 838061
Change-Id: I3eaedf6f764120131b4da729c7425056ef2bd018
Reviewed-on: https://chromium-review.googlesource.com/1033673
Commit-Queue: Christos Froussios <cfroussios@chromium.org>
Reviewed-by: default avatarChristos Froussios <cfroussios@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554710}
parent eb9f2b56
......@@ -22,9 +22,6 @@ const base::Feature kNewOverviewAnimations{"NewOverviewAnimations",
const base::Feature kNewOverviewUi{"NewOverviewUi",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kOverviewSwipeToClose{"OverviewSwipeToClose",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kPersistentWindowBounds{"PersistentWindowBounds",
base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -36,11 +36,6 @@ ASH_PUBLIC_EXPORT extern const base::Feature kNewOverviewAnimations;
// https://crbug.com/821608.
ASH_PUBLIC_EXPORT extern const base::Feature kNewOverviewUi;
// Enables swipe to close in overview mode.
// TODO(sammiequon): Remove this after the feature is fully launched.
// https://crbug.com/828646.
ASH_PUBLIC_EXPORT extern const base::Feature kOverviewSwipeToClose;
// Enables persistent window bounds in multi-displays scenario.
// TODO(warx): Remove this after the feature is fully launched.
// https://crbug.com/805046.
......
......@@ -106,11 +106,6 @@ bool IsNewOverviewUi() {
return base::FeatureList::IsEnabled(features::kNewOverviewUi);
}
bool IsOverviewSwipeToCloseEnabled() {
return base::FeatureList::IsEnabled(features::kNewOverviewUi) &&
base::FeatureList::IsEnabled(features::kOverviewSwipeToClose);
}
std::unique_ptr<views::Widget> CreateBackgroundWidget(aura::Window* root_window,
ui::LayerType layer_type,
SkColor background_color,
......
......@@ -36,8 +36,6 @@ bool IsNewOverviewAnimationsEnabled();
// obsolete. See https://crbug.com/782320.
bool IsNewOverviewUi();
bool IsOverviewSwipeToCloseEnabled();
// Creates and returns a background translucent widget parented in
// |root_window|'s default container and having |background_color|.
// When |border_thickness| is non-zero, a border is created having
......
......@@ -8,14 +8,12 @@
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/wm/overview/overview_utils.h"
#include "ash/wm/overview/scoped_transform_overview_window.h"
#include "ash/wm/overview/window_selector.h"
#include "ash/wm/overview/window_selector_item.h"
#include "ash/wm/splitview/split_view_constants.h"
#include "ash/wm/splitview/split_view_drag_indicators.h"
#include "ash/wm/window_positioning_utils.h"
#include "base/numerics/ranges.h"
#include "ui/aura/window.h"
#include "ui/wm/core/coordinate_conversion.h"
......@@ -27,18 +25,6 @@ namespace {
// to indicate its selection.
constexpr float kDragWindowScale = 0.04f;
// The amount of distance from the start of drag the item needs to be dragged
// vertically for it to be closed on release.
constexpr float kDragToCloseDistanceThresholdDp = 160.f;
// If an item is in drag to close mode, dragging it more than this amount
// horizontally will change the item to drag to snap mode.
constexpr int kDragToSnapDistanceThresholdDp = 100;
// Flings with less velocity than this will not close the dragged item.
constexpr float kFlingToCloseVelocityThreshold = 3000.f;
constexpr float kItemMinOpacity = 0.4f;
} // namespace
OverviewWindowDragController::OverviewWindowDragController(
......@@ -52,11 +38,14 @@ void OverviewWindowDragController::InitiateDrag(
WindowSelectorItem* item,
const gfx::Point& location_in_screen) {
item_ = item;
previous_event_location_ = location_in_screen;
initial_event_location_ = location_in_screen;
started_in_snap_region_ =
GetSnapPosition(location_in_screen) != SplitViewController::NONE;
current_drag_behavior_ = DragBehavior::kUndefined;
// No need to track the initial event location if the event does not start in
// a snap region.
initial_event_location_ =
GetSnapPosition(location_in_screen) == SplitViewController::NONE
? base::nullopt
: base::make_optional(location_in_screen);
}
void OverviewWindowDragController::Drag(const gfx::Point& location_in_screen) {
......@@ -68,82 +57,31 @@ void OverviewWindowDragController::Drag(const gfx::Point& location_in_screen) {
std::abs(distance.y()) < kMinimumDragOffset) {
return;
}
if (IsOverviewSwipeToCloseEnabled() &&
std::abs(distance.x()) < std::abs(distance.y())) {
current_drag_behavior_ = DragBehavior::kDragToClose;
original_opacity_ = item_->GetOpacity();
did_move_ = true;
} else {
StartSplitViewDragMode(location_in_screen);
}
}
// Update the drag behavior if needed.
int x_offset = 0;
if (current_drag_behavior_ == DragBehavior::kDragToClose &&
std::abs(location_in_screen.x() - initial_event_location_.x()) >
kDragToSnapDistanceThresholdDp) {
// If the window has moved enough in a horizontal direction while in drag
// to close mode, enter drag to snap mode. Reposition the window selector
// item to be centered at the latest event location.
item_->SetOpacity(original_opacity_);
x_offset = location_in_screen.x() - initial_event_location_.x();
current_drag_behavior_ = DragBehavior::kDragToSnap;
}
// Update the state based on the drag behavior.
if (current_drag_behavior_ == DragBehavior::kDragToClose) {
// Update |item_|'s opacity based on its distance. |item_|'s x coordinate
// should not change while in drag to close state.
float val = std::abs(static_cast<float>(location_in_screen.y()) -
initial_event_location_.y()) /
kDragToCloseDistanceThresholdDp;
val = base::ClampToRange(val, 0.f, 1.f);
float opacity = original_opacity_;
if (opacity > kItemMinOpacity) {
opacity = original_opacity_ - val * (original_opacity_ - kItemMinOpacity);
}
item_->SetOpacity(opacity);
} else if (current_drag_behavior_ == DragBehavior::kDragToSnap) {
UpdateDragIndicatorsAndWindowGrid(location_in_screen);
if (x_offset == 0)
x_offset = location_in_screen.x() - previous_event_location_.x();
StartSplitViewDragMode(location_in_screen);
}
// Update the dragged |item_|'s bounds accordingly.
gfx::Rect bounds(item_->target_bounds());
bounds.Offset(x_offset,
bounds.Offset(location_in_screen.x() - previous_event_location_.x(),
location_in_screen.y() - previous_event_location_.y());
item_->SetBounds(bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
previous_event_location_ = location_in_screen;
UpdateDragIndicatorsAndWindowGrid(location_in_screen);
}
void OverviewWindowDragController::CompleteDrag(
const gfx::Point& location_in_screen) {
// Update window grid bounds and |snap_position_| in case the screen
// orientation was changed.
if (current_drag_behavior_ == DragBehavior::kDragToSnap) {
UpdateDragIndicatorsAndWindowGrid(location_in_screen);
window_selector_->SetSplitViewDragIndicatorsIndicatorState(
IndicatorState::kNone, gfx::Point());
}
UpdateDragIndicatorsAndWindowGrid(location_in_screen);
window_selector_->SetSplitViewDragIndicatorsIndicatorState(
IndicatorState::kNone, gfx::Point());
if (!did_move_) {
ActivateDraggedWindow();
} else if (current_drag_behavior_ == DragBehavior::kDragToClose) {
// If we are in drag to close mode close the window if it has been dragged
// enough, otherwise reposition it and set its opacity back to its original
// value.
if (std::abs((location_in_screen - initial_event_location_).y()) >
kDragToCloseDistanceThresholdDp) {
item_->CloseWindow();
} else {
item_->SetOpacity(original_opacity_);
window_selector_->PositionWindows(/*animate=*/true);
}
} else {
DCHECK_EQ(current_drag_behavior_, DragBehavior::kDragToSnap);
did_move_ = false;
// If the window was dragged around but should not be snapped, move it back
// to overview window grid.
if (!ShouldUpdateDragIndicatorsOrSnap(location_in_screen) ||
......@@ -154,9 +92,7 @@ void OverviewWindowDragController::CompleteDrag(
SnapWindow(snap_position_);
}
}
did_move_ = false;
item_ = nullptr;
current_drag_behavior_ = DragBehavior::kNoDrag;
}
void OverviewWindowDragController::StartSplitViewDragMode(
......@@ -169,7 +105,6 @@ void OverviewWindowDragController::StartSplitViewDragMode(
OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
did_move_ = true;
current_drag_behavior_ = DragBehavior::kDragToSnap;
window_selector_->SetSplitViewDragIndicatorsIndicatorState(
split_view_controller_->CanSnap(item_->GetWindow())
? IndicatorState::kDragArea
......@@ -177,22 +112,6 @@ void OverviewWindowDragController::StartSplitViewDragMode(
location_in_screen);
}
void OverviewWindowDragController::Fling(const gfx::Point& location_in_screen,
float velocity_x,
float velocity_y) {
if (current_drag_behavior_ == DragBehavior::kDragToClose ||
current_drag_behavior_ == DragBehavior::kUndefined) {
if (std::abs(velocity_y) > kFlingToCloseVelocityThreshold) {
item_->CloseWindow();
return;
}
}
// If the fling velocity was not high enough, or flings should be ignored,
// treat it as a scroll end event.
CompleteDrag(location_in_screen);
}
void OverviewWindowDragController::ActivateDraggedWindow() {
// If no drag was initiated (e.g., a click/tap on the overview window),
// activate the window. If the split view is active and has a left window,
......@@ -212,17 +131,15 @@ void OverviewWindowDragController::ActivateDraggedWindow() {
window_selector_->SelectWindow(item_);
split_view_controller_->ShowAppCannotSnapToast();
}
current_drag_behavior_ = DragBehavior::kNoDrag;
}
void OverviewWindowDragController::ResetGesture() {
window_selector_->PositionWindows(/*animate=*/true);
window_selector_->SetSplitViewDragIndicatorsIndicatorState(
IndicatorState::kNone, gfx::Point());
// This function gets called after a long press release, which bypasses
// CompleteDrag but stops dragging as well, so reset |item_|.
// This function gets called on long press, which bypasses CompleteDrag but
// stops dragging as well, so reset |item_|.
item_ = nullptr;
current_drag_behavior_ = DragBehavior::kNoDrag;
}
void OverviewWindowDragController::ResetWindowSelector() {
......@@ -288,23 +205,23 @@ void OverviewWindowDragController::UpdateDragIndicatorsAndWindowGrid(
bool OverviewWindowDragController::ShouldUpdateDragIndicatorsOrSnap(
const gfx::Point& event_location) {
if (!started_in_snap_region_)
if (initial_event_location_ == base::nullopt)
return true;
auto snap_position = GetSnapPosition(event_location);
if (snap_position == SplitViewController::NONE) {
// If the event started in a snap region, but has since moved out set
// |started_in_snap_region_| to false. |event_location| is guarenteed to not
// |initial_event_location_| to |event_location| which is guarenteed to not
// be in a snap region so that the drag indicators are shown correctly and
// the snap mechanism works normally for the rest of the drag.
started_in_snap_region_ = false;
initial_event_location_ = base::nullopt;
return true;
}
// The drag indicators can update or the item can snap even if the drag events
// are in the snap region, if the event has travelled past the threshold in
// the direction of the attempted snap region.
const gfx::Vector2d distance = event_location - initial_event_location_;
const gfx::Vector2d distance = event_location - *initial_event_location_;
// Check the x-axis distance for landscape, y-axis distance for portrait.
int distance_scalar =
split_view_controller_->IsCurrentScreenOrientationLandscape()
......
......@@ -10,6 +10,7 @@
#include "ash/ash_export.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "base/macros.h"
#include "base/optional.h"
#include "ui/gfx/geometry/point.h"
namespace ash {
......@@ -24,16 +25,6 @@ class WindowSelectorItem;
// window about to be snapped.
class ASH_EXPORT OverviewWindowDragController {
public:
enum class DragBehavior {
kNoDrag, // No drag has started.
kUndefined, // Drag has started, but it is undecided whether we want to
// drag to snap or drag to close yet.
kDragToSnap, // On drag complete, the window will be snapped, if it meets
// requirements.
kDragToClose, // On drag complete, the window will be closed, if it meets
// requirements.
};
// The minimum offset that will be considered as a drag event.
static constexpr int kMinimumDragOffset = 5;
// The minimum offset that an item must be moved before it is considered a
......@@ -48,9 +39,6 @@ class ASH_EXPORT OverviewWindowDragController {
void Drag(const gfx::Point& location_in_screen);
void CompleteDrag(const gfx::Point& location_in_screen);
void StartSplitViewDragMode(const gfx::Point& location_in_screen);
void Fling(const gfx::Point& location_in_screen,
float velocity_x,
float velocity_y);
void ActivateDraggedWindow();
void ResetGesture();
......@@ -62,8 +50,6 @@ class ASH_EXPORT OverviewWindowDragController {
WindowSelectorItem* item() { return item_; }
DragBehavior current_drag_behavior() { return current_drag_behavior_; }
private:
// Updates visuals for the user while dragging items around.
void UpdateDragIndicatorsAndWindowGrid(const gfx::Point& location_in_screen);
......@@ -88,22 +74,13 @@ class ASH_EXPORT OverviewWindowDragController {
// The drag target window in the overview mode.
WindowSelectorItem* item_ = nullptr;
DragBehavior current_drag_behavior_ = DragBehavior::kNoDrag;
// The location of the previous mouse/touch/gesture event in screen.
gfx::Point previous_event_location_;
// The location of the initial mouse/touch/gesture event in screen.
gfx::Point initial_event_location_;
// False if the initial drag location was not a snap region, or if the it
// The location of the initial mouse/touch/gesture event in screen. It is
// nullopt if the initial drag location was not a snap region, or if the it
// was a snap region but the drag has since moved out.
bool started_in_snap_region_ = false;
// The opacity of |item_| changes if we are in drag to close mode. Store the
// orginal opacity of |item_| and restore it to the item when we leave drag
// to close mode.
float original_opacity_ = 1.f;
base::Optional<gfx::Point> initial_event_location_;
// Set to true once the bounds of |item_| change.
bool did_move_ = false;
......
......@@ -637,18 +637,6 @@ void WindowSelector::StartSplitViewDragMode(
window_drag_controller_->StartSplitViewDragMode(location_in_screen);
}
void WindowSelector::Fling(WindowSelectorItem* item,
const gfx::Point& location_in_screen,
float velocity_x,
float velocity_y) {
// Its possible a fling event is not paired with a tap down event. Ignore
// these flings.
if (!window_drag_controller_ || item != window_drag_controller_->item())
return;
window_drag_controller_->Fling(location_in_screen, velocity_x, velocity_y);
}
void WindowSelector::ActivateDraggedWindow() {
window_drag_controller_->ActivateDraggedWindow();
}
......
......@@ -121,10 +121,6 @@ class ASH_EXPORT WindowSelector : public display::DisplayObserver,
void CompleteDrag(WindowSelectorItem* item,
const gfx::Point& location_in_screen);
void StartSplitViewDragMode(const gfx::Point& location_in_screen);
void Fling(WindowSelectorItem* item,
const gfx::Point& location_in_screen,
float velocity_x,
float velocity_y);
void ActivateDraggedWindow();
void ResetDraggedWindowGesture();
......
......@@ -248,10 +248,6 @@ class ShieldButton : public views::Button {
listener()->HandleDragEvent(location);
break;
case ui::ET_SCROLL_FLING_START:
listener()->HandleFlingStartEvent(location,
event->details().velocity_x(),
event->details().velocity_y());
break;
case ui::ET_GESTURE_SCROLL_END:
listener()->HandleReleaseEvent(location);
break;
......@@ -998,6 +994,7 @@ void WindowSelectorItem::HandleReleaseEvent(
const gfx::Point& location_in_screen) {
if (!IsDragItem())
return;
window_grid_->SetSelectionWidgetVisibility(true);
window_selector_->CompleteDrag(this, location_in_screen);
}
......@@ -1014,13 +1011,6 @@ void WindowSelectorItem::HandleLongPressEvent(
window_selector_->StartSplitViewDragMode(location_in_screen);
}
void WindowSelectorItem::HandleFlingStartEvent(
const gfx::Point& location_in_screen,
float velocity_x,
float velocity_y) {
window_selector_->Fling(this, location_in_screen, velocity_x, velocity_y);
}
void WindowSelectorItem::ActivateDraggedWindow() {
if (!IsDragItem())
return;
......@@ -1113,19 +1103,6 @@ void WindowSelectorItem::SetShadowBounds(
shadow_->SetContentBounds(bounds_in_item);
}
void WindowSelectorItem::SetOpacity(float opacity) {
item_widget_->SetOpacity(opacity);
if (background_view_ && !IsNewOverviewUi()) {
background_view_->AnimateBackgroundOpacity(
selected_ ? 0.f : kHeaderOpacity * opacity);
}
transform_window_.SetOpacity(opacity);
}
float WindowSelectorItem::GetOpacity() {
return item_widget_->GetNativeWindow()->layer()->opacity();
}
bool WindowSelectorItem::ShouldAnimateWhenEntering() const {
if (!IsNewOverviewAnimationsEnabled())
return true;
......@@ -1203,6 +1180,15 @@ void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds,
transform_window_.SetTransform(root_window_, transform);
}
void WindowSelectorItem::SetOpacity(float opacity) {
item_widget_->SetOpacity(opacity);
if (background_view_ && !IsNewOverviewUi()) {
background_view_->AnimateBackgroundOpacity(
selected_ ? 0.f : kHeaderOpacity * opacity);
}
transform_window_.SetOpacity(opacity);
}
void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
background_view_ = new RoundedContainerView(this, kLabelBackgroundRadius,
transform_window_.GetTopColor());
......
......@@ -184,9 +184,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
void HandleReleaseEvent(const gfx::Point& location_in_screen);
void HandleDragEvent(const gfx::Point& location_in_screen);
void HandleLongPressEvent(const gfx::Point& location_in_screen);
void HandleFlingStartEvent(const gfx::Point& location_in_screen,
float velocity_x,
float velocity_y);
void ActivateDraggedWindow();
void ResetDraggedWindowGesture();
......@@ -203,10 +200,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
// the shadow is hidden.
void SetShadowBounds(base::Optional<gfx::Rect> bounds_in_screen);
// Changes the opacity of all the windows the item owns.
void SetOpacity(float opacity);
float GetOpacity();
void set_should_animate_when_entering(bool should_animate) {
should_animate_when_entering_ = should_animate;
}
......@@ -265,6 +258,9 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
void SetItemBounds(const gfx::Rect& target_bounds,
OverviewAnimationType animation_type);
// Changes the opacity of all the windows the item owns.
void SetOpacity(float opacity);
// Creates the window label.
void CreateWindowLabel(const base::string16& title);
......
......@@ -13,7 +13,6 @@
#include "ash/display/screen_orientation_controller.h"
#include "ash/display/screen_orientation_controller_test_api.h"
#include "ash/drag_drop/drag_drop_controller.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/config.h"
#include "ash/public/cpp/window_properties.h"
......@@ -46,7 +45,6 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/user_action_tester.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/aura/client/aura_constants.h"
......@@ -3320,122 +3318,6 @@ TEST_F(SplitViewWindowSelectorTest, Dragging) {
EXPECT_TRUE(IsPreviewAreaShowing());
}
// Verify the correct behavior when dragging windows in overview mode.
TEST_F(SplitViewWindowSelectorTest, OverviewDragControllerBehavior) {
aura::Env::GetInstance()->set_throttle_input_on_resize_for_testing(false);
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kOverviewSwipeToClose);
std::unique_ptr<aura::Window> window1 = CreateTestWindow();
std::unique_ptr<aura::Window> window2 = CreateTestWindow();
ToggleOverview();
ASSERT_TRUE(window_selector_controller()->IsSelecting());
WindowSelectorItem* window_item1 = GetWindowItemForWindow(0, window1.get());
WindowSelectorItem* window_item2 = GetWindowItemForWindow(0, window2.get());
// Verify that if a drag is orginally horizontal, the drag behavior is drag to
// snap.
using DragBehavior = OverviewWindowDragController::DragBehavior;
ui::test::EventGenerator& generator = GetEventGenerator();
generator.set_current_location(window_item1->target_bounds().CenterPoint());
generator.PressTouch();
OverviewWindowDragController* drag_controller =
window_selector()->window_drag_controller();
EXPECT_EQ(DragBehavior::kUndefined, drag_controller->current_drag_behavior());
generator.MoveTouchBy(20, 0);
EXPECT_EQ(DragBehavior::kDragToSnap,
drag_controller->current_drag_behavior());
generator.ReleaseTouch();
EXPECT_EQ(DragBehavior::kNoDrag, drag_controller->current_drag_behavior());
// Verify that if a drag is orginally vertical, the drag behavior is drag to
// close.
generator.set_current_location(window_item2->target_bounds().CenterPoint());
generator.PressTouch();
drag_controller = window_selector()->window_drag_controller();
EXPECT_EQ(DragBehavior::kUndefined, drag_controller->current_drag_behavior());
// Use small increments otherwise a fling event will be fired.
for (int j = 0; j < 20; ++j)
generator.MoveTouchBy(0, 1);
EXPECT_EQ(DragBehavior::kDragToClose,
drag_controller->current_drag_behavior());
// Verify that if the drag has a large enough horizontal displacement we will
// enter drag to snap state.
generator.MoveTouchBy(200, 0);
EXPECT_EQ(DragBehavior::kDragToSnap,
drag_controller->current_drag_behavior());
generator.ReleaseTouch();
EXPECT_EQ(DragBehavior::kNoDrag, drag_controller->current_drag_behavior());
}
// Verify that if the window item has been dragged enough vertically, the window
// will be closed.
TEST_F(SplitViewWindowSelectorTest, DragToClose) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kOverviewSwipeToClose);
// This test requires a widget.
const gfx::Rect bounds(400, 400);
std::unique_ptr<views::Widget> widget1(CreateWindowWidget(bounds));
ToggleOverview();
ASSERT_TRUE(window_selector_controller()->IsSelecting());
WindowSelectorItem* window_item1 =
GetWindowItemForWindow(0, widget1->GetNativeWindow());
ASSERT_TRUE(window_item1);
// This drag has not covered enough distance, so the widget is not closed and
// we remain in overview mode. Use scroll sequences with large time and steps
// to avoid triggering a fling event.
ui::test::EventGenerator& generator = GetEventGenerator();
const gfx::Point start = window_item1->target_bounds().CenterPoint();
generator.GestureScrollSequence(start, start + gfx::Vector2d(0, 100),
base::TimeDelta::FromMilliseconds(100), 100);
RunAllPendingInMessageLoop();
ASSERT_TRUE(window_selector());
// Verify that the second drag has enough vertical distance, so the widget
// will be closed and overview mode will be exited.
generator.GestureScrollSequence(start, start + gfx::Vector2d(0, 300),
base::TimeDelta::FromMilliseconds(100), 100);
RunAllPendingInMessageLoop();
EXPECT_FALSE(window_selector());
}
// Verify that if the window item has been flung enough vertically, the window
// will be closed.
TEST_F(SplitViewWindowSelectorTest, FlingToClose) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kOverviewSwipeToClose);
// This test requires a widget.
const gfx::Rect bounds(400, 400);
std::unique_ptr<views::Widget> widget1(CreateWindowWidget(bounds));
ToggleOverview();
ASSERT_TRUE(window_selector_controller()->IsSelecting());
EXPECT_EQ(1u, window_selector()->grid_list_for_testing()[0]->size());
WindowSelectorItem* window_item1 =
GetWindowItemForWindow(0, widget1->GetNativeWindow());
ASSERT_TRUE(window_item1);
// Verify that flinging the item closes it, and since it is the last item in
// overview mode, overview mode is exited.
ui::test::EventGenerator& generator = GetEventGenerator();
const gfx::Point start = window_item1->target_bounds().CenterPoint();
generator.GestureScrollSequence(start, start + gfx::Vector2d(0, 200),
base::TimeDelta::FromMilliseconds(10), 5);
RunAllPendingInMessageLoop();
EXPECT_FALSE(window_selector());
}
// Verify the window grid size changes as expected when dragging items around in
// overview mode when split view is enabled.
TEST_F(SplitViewWindowSelectorTest, WindowGridSizeWhileDraggingWithSplitView) {
......
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