Commit f64ae172 authored by bruthig's avatar bruthig Committed by Commit bot

Removed the "Swipe to close in overview" feature.

BUG=393668

Review URL: https://codereview.chromium.org/965813003

Cr-Commit-Position: refs/heads/master@{#318706}
parent a4550d6f
...@@ -64,10 +64,6 @@ const char kAshEnablePowerButtonQuickLock[] = ...@@ -64,10 +64,6 @@ const char kAshEnablePowerButtonQuickLock[] =
// Enables software based mirroring. // Enables software based mirroring.
const char kAshEnableSoftwareMirroring[] = "ash-enable-software-mirroring"; const char kAshEnableSoftwareMirroring[] = "ash-enable-software-mirroring";
// Enables gesture swipe to close windows while in Overview mode.
const char kAshEnableSwipeToCloseInOverviewMode[] =
"ash-enable-swipe-to-close-in-overview-mode";
// Enables touch view testing. // Enables touch view testing.
// TODO(skuhne): Remove TOGGLE_TOUCH_VIEW_TESTING accelerator once this // TODO(skuhne): Remove TOGGLE_TOUCH_VIEW_TESTING accelerator once this
// flag is removed. // flag is removed.
......
...@@ -33,7 +33,6 @@ ASH_EXPORT extern const char kAshEnableMagnifierKeyScroller[]; ...@@ -33,7 +33,6 @@ ASH_EXPORT extern const char kAshEnableMagnifierKeyScroller[];
ASH_EXPORT extern const char kAshEnableMirroredScreen[]; ASH_EXPORT extern const char kAshEnableMirroredScreen[];
ASH_EXPORT extern const char kAshEnablePowerButtonQuickLock[]; ASH_EXPORT extern const char kAshEnablePowerButtonQuickLock[];
ASH_EXPORT extern const char kAshEnableSoftwareMirroring[]; ASH_EXPORT extern const char kAshEnableSoftwareMirroring[];
ASH_EXPORT extern const char kAshEnableSwipeToCloseInOverviewMode[];
ASH_EXPORT extern const char kAshEnableSystemSounds[]; ASH_EXPORT extern const char kAshEnableSystemSounds[];
ASH_EXPORT extern const char kAshEnableTouchViewTesting[]; ASH_EXPORT extern const char kAshEnableTouchViewTesting[];
ASH_EXPORT extern const char kAshHideNotificationsForFactory[]; ASH_EXPORT extern const char kAshHideNotificationsForFactory[];
......
...@@ -14,8 +14,6 @@ enum OverviewAnimationType { ...@@ -14,8 +14,6 @@ enum OverviewAnimationType {
OVERVIEW_ANIMATION_NONE, OVERVIEW_ANIMATION_NONE,
// Used to fade in the close button and label. // Used to fade in the close button and label.
OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN,
// Used to fade out the close button.
OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT,
// Used to position windows when entering/exiting overview mode and when a // Used to position windows when entering/exiting overview mode and when a
// window is closed while overview mode is active. // window is closed while overview mode is active.
OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS, OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS,
...@@ -23,12 +21,7 @@ enum OverviewAnimationType { ...@@ -23,12 +21,7 @@ enum OverviewAnimationType {
OVERVIEW_ANIMATION_HIDE_WINDOW, OVERVIEW_ANIMATION_HIDE_WINDOW,
// Used to restore windows to their original position when exiting overview // Used to restore windows to their original position when exiting overview
// mode. // mode.
OVERVIEW_ANIMATION_RESTORE_WINDOW, OVERVIEW_ANIMATION_RESTORE_WINDOW
// Used to animate windows when a user performs a touch drag gesture.
OVERVIEW_ANIMATION_SCROLL_SELECTOR_ITEM,
// Used to animate windows back in to position when a touch drag gesture is
// cancelled.
OVERVIEW_ANIMATION_CANCEL_SELECTOR_ITEM_SCROLL
}; };
} // namespace ash } // namespace ash
......
...@@ -20,22 +20,15 @@ const int kTransitionMilliseconds = 200; ...@@ -20,22 +20,15 @@ const int kTransitionMilliseconds = 200;
// The time duration for widgets to fade in. // The time duration for widgets to fade in.
const int kFadeInMilliseconds = 80; const int kFadeInMilliseconds = 80;
// The time duration for widgets to fade out.
const int kFadeOutMilliseconds = 100;
base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) { base::TimeDelta GetAnimationDuration(OverviewAnimationType animation_type) {
switch (animation_type) { switch (animation_type) {
case OVERVIEW_ANIMATION_NONE: case OVERVIEW_ANIMATION_NONE:
case OVERVIEW_ANIMATION_SCROLL_SELECTOR_ITEM:
return base::TimeDelta(); return base::TimeDelta();
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN: case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds); return base::TimeDelta::FromMilliseconds(kFadeInMilliseconds);
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT:
return base::TimeDelta::FromMilliseconds(kFadeOutMilliseconds);
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
case OVERVIEW_ANIMATION_RESTORE_WINDOW: case OVERVIEW_ANIMATION_RESTORE_WINDOW:
case OVERVIEW_ANIMATION_HIDE_WINDOW: case OVERVIEW_ANIMATION_HIDE_WINDOW:
case OVERVIEW_ANIMATION_CANCEL_SELECTOR_ITEM_SCROLL:
return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds);
} }
NOTREACHED(); NOTREACHED();
...@@ -51,7 +44,6 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( ...@@ -51,7 +44,6 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings(
switch (animation_type) { switch (animation_type) {
case OVERVIEW_ANIMATION_NONE: case OVERVIEW_ANIMATION_NONE:
case OVERVIEW_ANIMATION_SCROLL_SELECTOR_ITEM:
animation_settings_.SetPreemptionStrategy( animation_settings_.SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
break; break;
...@@ -63,10 +55,6 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( ...@@ -63,10 +55,6 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings(
animation_settings_.SetPreemptionStrategy( animation_settings_.SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
break; break;
case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT:
animation_settings_.SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
break;
case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS: case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
case OVERVIEW_ANIMATION_RESTORE_WINDOW: case OVERVIEW_ANIMATION_RESTORE_WINDOW:
animation_settings_.SetPreemptionStrategy( animation_settings_.SetPreemptionStrategy(
...@@ -77,11 +65,6 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings( ...@@ -77,11 +65,6 @@ ScopedOverviewAnimationSettings::ScopedOverviewAnimationSettings(
animation_settings_.SetPreemptionStrategy( animation_settings_.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
break; break;
case OVERVIEW_ANIMATION_CANCEL_SELECTOR_ITEM_SCROLL:
animation_settings_.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
animation_settings_.SetTweenType(gfx::Tween::EASE_IN_OUT);
break;
} }
animation_settings_.SetTransitionDuration( animation_settings_.SetTransitionDuration(
GetAnimationDuration(animation_type)); GetAnimationDuration(animation_type));
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <vector> #include <vector>
#include "ash/ash_switches.h"
#include "ash/metrics/user_metrics_recorder.h" #include "ash/metrics/user_metrics_recorder.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/session/session_state_delegate.h" #include "ash/session/session_state_delegate.h"
...@@ -16,15 +15,12 @@ ...@@ -16,15 +15,12 @@
#include "ash/wm/overview/window_selector.h" #include "ash/wm/overview/window_selector.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
namespace ash { namespace ash {
WindowSelectorController::WindowSelectorController() WindowSelectorController::WindowSelectorController() {
: swipe_to_close_enabled_(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshEnableSwipeToCloseInOverviewMode)) {
} }
WindowSelectorController::~WindowSelectorController() { WindowSelectorController::~WindowSelectorController() {
......
...@@ -48,8 +48,6 @@ class ASH_EXPORT WindowSelectorController ...@@ -48,8 +48,6 @@ class ASH_EXPORT WindowSelectorController
// are visible during overview mode. // are visible during overview mode.
bool IsRestoringMinimizedWindows() const; bool IsRestoringMinimizedWindows() const;
bool swipe_to_close_enabled() const { return swipe_to_close_enabled_; }
// WindowSelectorDelegate: // WindowSelectorDelegate:
void OnSelectionEnded() override; void OnSelectionEnded() override;
...@@ -62,9 +60,6 @@ class ASH_EXPORT WindowSelectorController ...@@ -62,9 +60,6 @@ class ASH_EXPORT WindowSelectorController
scoped_ptr<WindowSelector> window_selector_; scoped_ptr<WindowSelector> window_selector_;
base::Time last_selection_time_; base::Time last_selection_time_;
// Tracks whether the "Swipe-to-close" feature is enabled.
bool swipe_to_close_enabled_;
DISALLOW_COPY_AND_ASSIGN(WindowSelectorController); DISALLOW_COPY_AND_ASSIGN(WindowSelectorController);
}; };
......
...@@ -37,13 +37,6 @@ namespace ash { ...@@ -37,13 +37,6 @@ namespace ash {
namespace { namespace {
// The minimum fling velocity which will cause a window to be closed. Unit is
// pixels per second.
const float kMinimumFlingVelocity = 4000.0f;
// The minimum opacity used during touch scroll gestures.
const float kMinimumOpacity = 0.2f;
// In the conceptual overview table, the window margin is the space reserved // In the conceptual overview table, the window margin is the space reserved
// around the window within the cell. This margin does not overlap so the // around the window within the cell. This margin does not overlap so the
// closest distance between adjacent windows will be twice this amount. // closest distance between adjacent windows will be twice this amount.
...@@ -91,24 +84,6 @@ void SetupFadeInAfterLayout(aura::Window* window) { ...@@ -91,24 +84,6 @@ void SetupFadeInAfterLayout(aura::Window* window) {
layer->SetOpacity(1.0f); layer->SetOpacity(1.0f);
} }
// Convenience method to fade out a window using the animation settings defined
// by OverviewAnimationType::OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT.
void SetupFadeOut(aura::Window* window) {
ScopedOverviewAnimationSettings animation_settings(
OverviewAnimationType::OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_OUT,
window);
window->layer()->SetOpacity(0.0f);
}
// Calculates the window opacity from the given scroll |distance| and the
// |min opacity_distance|.
float CalculateOpacityFromScrollDistance(int distance,
int min_opacity_distance) {
float opacity =
1.0f - static_cast<float>(abs(distance)) / min_opacity_distance;
return std::min(1.0f, std::max(kMinimumOpacity, opacity));
}
// An image button with a close window icon. // An image button with a close window icon.
class OverviewCloseButton : public views::ImageButton { class OverviewCloseButton : public views::ImageButton {
public: public:
...@@ -136,10 +111,9 @@ OverviewCloseButton::~OverviewCloseButton() { ...@@ -136,10 +111,9 @@ OverviewCloseButton::~OverviewCloseButton() {
} // namespace } // namespace
WindowSelectorItem::OverviewLabelButton::OverviewLabelButton( WindowSelectorItem::OverviewLabelButton::OverviewLabelButton(
WindowSelectorItem* selector_item, views::ButtonListener* listener,
const base::string16& text) const base::string16& text)
: LabelButton(selector_item, text), : LabelButton(listener, text),
selector_item_(selector_item),
top_padding_(0) { top_padding_(0) {
} }
...@@ -152,12 +126,6 @@ gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() { ...@@ -152,12 +126,6 @@ gfx::Rect WindowSelectorItem::OverviewLabelButton::GetChildAreaBounds() {
return bounds; return bounds;
} }
void WindowSelectorItem::OverviewLabelButton::OnGestureEvent(
ui::GestureEvent* event) {
selector_item_->OnGestureEvent(event);
views::LabelButton::OnGestureEvent(event);
}
WindowSelectorItem::WindowSelectorItem(aura::Window* window) WindowSelectorItem::WindowSelectorItem(aura::Window* window)
: dimmed_(false), : dimmed_(false),
root_window_(window->GetRootWindow()), root_window_(window->GetRootWindow()),
...@@ -260,72 +228,6 @@ void WindowSelectorItem::ButtonPressed(views::Button* sender, ...@@ -260,72 +228,6 @@ void WindowSelectorItem::ButtonPressed(views::Button* sender,
wm::GetWindowState(transform_window_.window())->Activate(); wm::GetWindowState(transform_window_.window())->Activate();
} }
void WindowSelectorItem::OnGestureEvent(ui::GestureEvent* event) {
if (!Shell::GetInstance()
->window_selector_controller()
->swipe_to_close_enabled())
return;
int delta_x = 0;
if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN)
scroll_x_origin_ = event->x();
else
delta_x = event->x() - scroll_x_origin_;
switch (event->type()) {
case ui::ET_GESTURE_SCROLL_BEGIN: {
// We need to call SetHandled() for the ET_GESTURE_SCROLL_BEGIN event so
// that future ET_GESTURE_SCROLL_* events are sent here.
event->SetHandled();
close_button_->SetEnabled(false);
SetupFadeOut(close_button_widget_.GetNativeWindow());
break;
}
case ui::ET_GESTURE_SCROLL_UPDATE: {
event->SetHandled();
ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
transform_window_.BeginScopedAnimation(
OverviewAnimationType::OVERVIEW_ANIMATION_SCROLL_SELECTOR_ITEM,
&animation_settings);
gfx::Transform new_transform;
new_transform.Translate(delta_x, 0);
new_transform.PreconcatTransform(
transform_window_.get_overview_transform());
transform_window_.SetTransform(root_window(), new_transform);
const float opacity = CalculateOpacityFromScrollDistance(
delta_x, GetMinimumCloseDistance());
transform_window_.SetOpacity(opacity);
break;
}
case ui::ET_GESTURE_SCROLL_END: {
event->SetHandled();
if (abs(delta_x) > GetMinimumCloseDistance()) {
transform_window_.Close();
break;
}
ResetScrolledWindow();
break;
}
case ui::ET_SCROLL_FLING_START: {
event->SetHandled();
if (abs(delta_x) > GetMinimumCloseDistance() ||
fabs(event->details().velocity_x()) > kMinimumFlingVelocity) {
transform_window_.Close();
break;
}
ResetScrolledWindow();
break;
}
case ui::ET_GESTURE_END:
scroll_x_origin_ = 0;
break;
default:
break;
}
}
void WindowSelectorItem::OnWindowDestroying(aura::Window* window) { void WindowSelectorItem::OnWindowDestroying(aura::Window* window) {
window->RemoveObserver(this); window->RemoveObserver(this);
transform_window_.OnWindowDestroyed(); transform_window_.OnWindowDestroyed();
...@@ -338,20 +240,6 @@ void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) { ...@@ -338,20 +240,6 @@ void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) {
UpdateCloseButtonAccessibilityName(); UpdateCloseButtonAccessibilityName();
} }
void WindowSelectorItem::ResetScrolledWindow() {
ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
transform_window_.BeginScopedAnimation(
OverviewAnimationType::OVERVIEW_ANIMATION_CANCEL_SELECTOR_ITEM_SCROLL,
&animation_settings);
transform_window_.SetTransform(root_window(),
transform_window_.get_overview_transform());
transform_window_.SetOpacity(1.0);
SetupFadeInAfterLayout(close_button_widget_.GetNativeWindow());
close_button_->SetEnabled(true);
}
void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds, void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds,
OverviewAnimationType animation_type) { OverviewAnimationType animation_type) {
DCHECK(root_window_ == GetWindow()->GetRootWindow()); DCHECK(root_window_ == GetWindow()->GetRootWindow());
...@@ -456,8 +344,4 @@ void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { ...@@ -456,8 +344,4 @@ void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
GetWindow()->title())); GetWindow()->title()));
} }
int WindowSelectorItem::GetMinimumCloseDistance() const {
return target_bounds_.size().width() / 2;
}
} // namespace ash } // namespace ash
...@@ -33,25 +33,18 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -33,25 +33,18 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
public: public:
class OverviewLabelButton : public views::LabelButton { class OverviewLabelButton : public views::LabelButton {
public: public:
OverviewLabelButton(WindowSelectorItem* selector_item, OverviewLabelButton(views::ButtonListener* listener,
const base::string16& text); const base::string16& text);
~OverviewLabelButton() override; ~OverviewLabelButton() override;
void set_top_padding(int top_padding) { top_padding_ = top_padding; } void set_top_padding(int top_padding) { top_padding_ = top_padding; }
// views::LabelButton:
void OnGestureEvent(ui::GestureEvent* event) override;
protected: protected:
// views::LabelButton: // views::LabelButton:
gfx::Rect GetChildAreaBounds() override; gfx::Rect GetChildAreaBounds() override;
private: private:
// The WindowSelectorItem that the touch gestures are delegated to.
// Not owned.
WindowSelectorItem* selector_item_;
// Padding on top of the button. // Padding on top of the button.
int top_padding_; int top_padding_;
...@@ -101,9 +94,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -101,9 +94,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
const gfx::Rect& target_bounds() const { return target_bounds_; } const gfx::Rect& target_bounds() const { return target_bounds_; }
// Handles the gestures on the Window
void OnGestureEvent(ui::GestureEvent* event);
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
...@@ -137,14 +127,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -137,14 +127,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
// Updates the close buttons accessibility name. // Updates the close buttons accessibility name.
void UpdateCloseButtonAccessibilityName(); void UpdateCloseButtonAccessibilityName();
// Animates the |transform_window_| back to it's original overview mode
// position.
void ResetScrolledWindow();
// Returns the minimum distance at which a scroll gesture will cause this
// selector item to be closed.
int GetMinimumCloseDistance() const;
// True if the item is being shown in the overview, false if it's being // True if the item is being shown in the overview, false if it's being
// filtered. // filtered.
bool dimmed_; bool dimmed_;
...@@ -176,10 +158,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -176,10 +158,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
// close_button_widget_. // close_button_widget_.
views::ImageButton* close_button_; views::ImageButton* close_button_;
// The original X location for a scroll begin event. |original_x_| is in the
// local coordinate space of |window_label_button_view_|.
float scroll_x_origin_;
DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
}; };
......
...@@ -3,11 +3,9 @@ ...@@ -3,11 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
#include <algorithm> #include <algorithm>
#include <map>
#include <vector> #include <vector>
#include "ash/accessibility_delegate.h" #include "ash/accessibility_delegate.h"
#include "ash/ash_switches.h"
#include "ash/drag_drop/drag_drop_controller.h" #include "ash/drag_drop/drag_drop_controller.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
...@@ -73,18 +71,6 @@ void CancelDrag(DragDropController* controller, bool* canceled) { ...@@ -73,18 +71,6 @@ void CancelDrag(DragDropController* controller, bool* canceled) {
} }
} }
// A short drag distance that will not cause an overview item to close.
const int kShortDragDistance = 10;
// A far drag distance that will cause an overview item to close.
const int kFarDragDistance = 200;
// A slow fling velocity that should not cause selctor items to close.
const int kSlowFlingVelocity = 2000;
// A fast fling velocity that should cause selector items to close.
const int kFastFlingVelocity = 5000;
} // namespace } // namespace
// TODO(bruthig): Move all non-simple method definitions out of class // TODO(bruthig): Move all non-simple method definitions out of class
...@@ -279,24 +265,6 @@ class WindowSelectorTest : public test::AshTestBase { ...@@ -279,24 +265,6 @@ class WindowSelectorTest : public test::AshTestBase {
DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest);
}; };
class WindowSelectorSwipeToCloseEnabledTest : public WindowSelectorTest {
public:
WindowSelectorSwipeToCloseEnabledTest() {}
~WindowSelectorSwipeToCloseEnabledTest() override {}
// WindowSelectorTest:
void SetUp() override;
private:
DISALLOW_COPY_AND_ASSIGN(WindowSelectorSwipeToCloseEnabledTest);
};
void WindowSelectorSwipeToCloseEnabledTest::SetUp() {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kAshEnableSwipeToCloseInOverviewMode);
WindowSelectorTest::SetUp();
}
// Tests that an a11y alert is sent on entering overview mode. // Tests that an a11y alert is sent on entering overview mode.
TEST_F(WindowSelectorTest, A11yAlertOnOverviewMode) { TEST_F(WindowSelectorTest, A11yAlertOnOverviewMode) {
gfx::Rect bounds(0, 0, 400, 400); gfx::Rect bounds(0, 0, 400, 400);
...@@ -1274,210 +1242,4 @@ TEST_F(WindowSelectorTest, CancelOverviewOnTap) { ...@@ -1274,210 +1242,4 @@ TEST_F(WindowSelectorTest, CancelOverviewOnTap) {
EXPECT_FALSE(IsSelecting()); EXPECT_FALSE(IsSelecting());
} }
// Verify swipe to close doesn't work when swipe to close is not enabled.
TEST_F(WindowSelectorTest, WindowTapDragFarDistance) {
scoped_ptr<views::Widget> widget =
CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
ToggleOverview();
ASSERT_TRUE(IsSelecting());
aura::Window* window = widget->GetNativeWindow();
gfx::Rect bounds = ToNearestRect(GetTransformedBoundsInRootWindow(window));
ui::test::EventGenerator event_generator(window->GetRootWindow());
ASSERT_FALSE(widget->IsClosed());
gfx::Point start(bounds.CenterPoint());
gfx::Point end(start.x() - kFarDragDistance, start.y());
event_generator.GestureScrollSequence(
start, end, base::TimeDelta::FromMilliseconds(10), 5);
EXPECT_FALSE(widget->IsClosed());
RunAllPendingInMessageLoop();
EXPECT_TRUE(IsSelecting());
}
// Verify the window moves and fades as it is dragged.
TEST_F(WindowSelectorSwipeToCloseEnabledTest,
VerifyWindowBehaviourDuringTapDrag) {
scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400)));
ToggleOverview();
gfx::Rect bounds =
ToNearestRect(GetTransformedBoundsInRootWindow(window.get()));
ui::test::EventGenerator event_generator(window->GetRootWindow());
const gfx::Point drag_start_point(bounds.CenterPoint());
const gfx::Point drag_left_point(drag_start_point.x() - kFarDragDistance,
drag_start_point.y());
const gfx::Point drag_right_point(drag_start_point.x() + kFarDragDistance,
drag_start_point.y());
const int drag_left_delta_x = drag_start_point.x() - drag_left_point.x();
const int drag_right_delta_x = drag_start_point.x() - drag_right_point.x();
const gfx::Rect original_bounds = window->GetBoundsInScreen();
ASSERT_EQ(1.0f, window->layer()->opacity());
event_generator.set_current_location(drag_start_point);
event_generator.PressTouch();
EXPECT_EQ(1.0f, window->layer()->opacity());
event_generator.MoveTouch(drag_left_point);
EXPECT_EQ(original_bounds.x() - drag_left_delta_x,
window->GetBoundsInScreen().x());
EXPECT_EQ(original_bounds.y(), window->GetBoundsInScreen().y());
EXPECT_LT(window->layer()->opacity(), 0.5f);
event_generator.MoveTouch(drag_start_point);
EXPECT_EQ(original_bounds.x(), window->GetBoundsInScreen().x());
EXPECT_EQ(original_bounds.y(), window->GetBoundsInScreen().y());
EXPECT_EQ(1.0f, window->layer()->opacity());
event_generator.MoveTouch(drag_right_point);
EXPECT_EQ(original_bounds.x() - drag_right_delta_x,
window->GetBoundsInScreen().x());
EXPECT_EQ(original_bounds.y(), window->GetBoundsInScreen().y());
EXPECT_LT(window->layer()->opacity(), 0.5f);
}
// Test dragging a window a short distance.
TEST_F(WindowSelectorSwipeToCloseEnabledTest, WindowTapDragShortDistance) {
scoped_ptr<views::Widget> widget =
CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
ToggleOverview();
aura::Window* window = widget->GetNativeWindow();
gfx::Rect bounds = ToNearestRect(GetTransformedBoundsInRootWindow(window));
ui::test::EventGenerator event_generator(window->GetRootWindow());
ASSERT_FALSE(widget->IsClosed());
gfx::Point start(bounds.CenterPoint());
gfx::Point end(start.x() - kShortDragDistance, start.y());
event_generator.GestureScrollSequence(
start, end, base::TimeDelta::FromMilliseconds(10), 5);
EXPECT_FALSE(widget->IsClosed());
RunAllPendingInMessageLoop();
EXPECT_TRUE(IsSelecting());
}
// Test dragging a window a far distance.
TEST_F(WindowSelectorSwipeToCloseEnabledTest, WindowTapDragFarDistance) {
scoped_ptr<views::Widget> widget =
CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
ToggleOverview();
ASSERT_TRUE(IsSelecting());
aura::Window* window = widget->GetNativeWindow();
gfx::Rect bounds = ToNearestRect(GetTransformedBoundsInRootWindow(window));
ui::test::EventGenerator event_generator(window->GetRootWindow());
ASSERT_FALSE(widget->IsClosed());
gfx::Point start(bounds.CenterPoint());
gfx::Point end(start.x() - kFarDragDistance, start.y());
event_generator.GestureScrollSequence(
start, end, base::TimeDelta::FromMilliseconds(10), 5);
EXPECT_TRUE(widget->IsClosed());
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsSelecting());
}
// Test a slow velocity fling.
TEST_F(WindowSelectorSwipeToCloseEnabledTest, SlowVelocityFling) {
scoped_ptr<views::Widget> widget =
CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
ToggleOverview();
aura::Window* window = widget->GetNativeWindow();
gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
ui::test::EventGenerator event_generator(window->GetRootWindow());
ASSERT_FALSE(widget->IsClosed());
gfx::Point start(bounds.CenterPoint().x(), bounds.CenterPoint().y());
gfx::Point end(start.x() - kShortDragDistance, start.y());
const base::TimeDelta kScrollDuration =
event_generator.CalculateScrollDurationForFlingVelocity(
start, end, kSlowFlingVelocity, 10);
event_generator.GestureScrollSequence(start, end, kScrollDuration, 10);
EXPECT_FALSE(widget->IsClosed());
RunAllPendingInMessageLoop();
EXPECT_TRUE(IsSelecting());
}
// Test a fast velocity fling.
TEST_F(WindowSelectorSwipeToCloseEnabledTest, FastVelocityFling) {
scoped_ptr<views::Widget> widget =
CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
ToggleOverview();
ASSERT_TRUE(IsSelecting());
aura::Window* window = widget->GetNativeWindow();
gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
ui::test::EventGenerator event_generator(window->GetRootWindow());
ASSERT_FALSE(widget->IsClosed());
gfx::Point start(bounds.CenterPoint().x(), bounds.CenterPoint().y());
gfx::Point end(start.x() - kShortDragDistance, start.y());
const base::TimeDelta kScrollDuration =
event_generator.CalculateScrollDurationForFlingVelocity(
start, end, kFastFlingVelocity, 10);
event_generator.GestureScrollSequence(start, end, kScrollDuration, 10);
EXPECT_TRUE(widget->IsClosed());
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsSelecting());
}
// Test a fast velocity fling.
TEST_F(WindowSelectorSwipeToCloseEnabledTest, SlowVelocityFlingAtAFarDistance) {
scoped_ptr<views::Widget> widget =
CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
ToggleOverview();
ASSERT_TRUE(IsSelecting());
aura::Window* window = widget->GetNativeWindow();
gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
ui::test::EventGenerator event_generator(window->GetRootWindow());
ASSERT_FALSE(widget->IsClosed());
gfx::Point start(bounds.CenterPoint().x(), bounds.CenterPoint().y());
gfx::Point end(start.x() - kFarDragDistance, start.y());
const base::TimeDelta kScrollDuration =
event_generator.CalculateScrollDurationForFlingVelocity(
start, end, kSlowFlingVelocity, 10);
event_generator.GestureScrollSequence(start, end, kScrollDuration, 10);
EXPECT_TRUE(widget->IsClosed());
RunAllPendingInMessageLoop();
EXPECT_FALSE(IsSelecting());
}
} // namespace ash } // namespace ash
...@@ -6174,12 +6174,6 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -6174,12 +6174,6 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_DISABLE_TOUCH_FEEDBACK_DESCRIPTION" desc="Description for the flag that disables additional visual feedback for touch."> <message name="IDS_FLAGS_DISABLE_TOUCH_FEEDBACK_DESCRIPTION" desc="Description for the flag that disables additional visual feedback for touch.">
Certain UI components will stop displaying visual feedback upon touch interactions. Certain UI components will stop displaying visual feedback upon touch interactions.
</message> </message>
<message name="IDS_FLAGS_ASH_ENABLE_SWIPE_TO_CLOSE_IN_OVERVIEW_MODE_NAME" desc="Title for the flag to enable swipe gestures to close windows while in overview mode.">
Swipe to dismiss windows in overview mode.
</message>
<message name="IDS_FLAGS_ASH_ENABLE_SWIPE_TO_CLOSE_IN_OVERVIEW_MODE_DESCRIPTION" desc="Description for the flag to enable swipe gestures to close windows while in overview mode.">
Enable swipe gesture to dismiss windows in overview mode.
</message>
<message name="IDS_FLAGS_ASH_DISABLE_TEXT_FILTERING_IN_OVERVIEW_MODE_NAME" desc="Title for the flag to disable window filtering in overview mode by inputing text"> <message name="IDS_FLAGS_ASH_DISABLE_TEXT_FILTERING_IN_OVERVIEW_MODE_NAME" desc="Title for the flag to disable window filtering in overview mode by inputing text">
Disable text filtering in Overview Mode. Disable text filtering in Overview Mode.
</message> </message>
......
...@@ -953,14 +953,6 @@ const Experiment kExperiments[] = { ...@@ -953,14 +953,6 @@ const Experiment kExperiments[] = {
kOsAll, kOsAll,
SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts), SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
}, },
{
"ash-enable-swipe-to-close-in-overview-mode",
IDS_FLAGS_ASH_ENABLE_SWIPE_TO_CLOSE_IN_OVERVIEW_MODE_NAME,
IDS_FLAGS_ASH_ENABLE_SWIPE_TO_CLOSE_IN_OVERVIEW_MODE_DESCRIPTION,
// TODO(bruthig): Add kOsWin when http://crbug.com/333758 is resolved.
kOsCrOS,
SINGLE_VALUE_TYPE(ash::switches::kAshEnableSwipeToCloseInOverviewMode),
},
{ "ash-enable-touch-view-testing", { "ash-enable-touch-view-testing",
IDS_FLAGS_ASH_ENABLE_TOUCH_VIEW_TESTING_NAME, IDS_FLAGS_ASH_ENABLE_TOUCH_VIEW_TESTING_NAME,
IDS_FLAGS_ASH_ENABLE_TOUCH_VIEW_TESTING_DESCRIPTION, IDS_FLAGS_ASH_ENABLE_TOUCH_VIEW_TESTING_DESCRIPTION,
......
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