Chromium Code Reviews| Index: ash/wm/gestures/overview_gesture_handler_unittest.cc |
| diff --git a/ash/wm/gestures/overview_gesture_handler_unittest.cc b/ash/wm/gestures/overview_gesture_handler_unittest.cc |
| index bba37173b707c02e48fa75f01172a56895eecc61..9355c6a79a625da38dbdec0d186b2e154f1bfd32 100644 |
| --- a/ash/wm/gestures/overview_gesture_handler_unittest.cc |
| +++ b/ash/wm/gestures/overview_gesture_handler_unittest.cc |
| @@ -2,11 +2,14 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "ash/wm/gestures/overview_gesture_handler.h" |
| + |
| #include "ash/common/wm/overview/window_selector_controller.h" |
| #include "ash/common/wm_shell.h" |
| #include "ash/root_window_controller.h" |
| #include "ash/shell.h" |
| #include "ash/test/ash_test_base.h" |
| +#include "ash/wm/window_util.h" |
| #include "ui/aura/test/test_window_delegate.h" |
| #include "ui/aura/test/test_windows.h" |
| #include "ui/aura/window.h" |
| @@ -29,6 +32,14 @@ class OverviewGestureHandlerTest : public test::AshTestBase { |
| return WmShell::Get()->window_selector_controller()->IsSelecting(); |
| } |
| + float vertical_threshold_pixels() const { |
| + return OverviewGestureHandler::vertical_threshold_pixels_; |
| + } |
| + |
| + float horizontal_threshold_pixels() const { |
| + return OverviewGestureHandler::horizontal_threshold_pixels_; |
| + } |
| + |
| private: |
| aura::test::TestWindowDelegate delegate_; |
| @@ -43,26 +54,68 @@ TEST_F(OverviewGestureHandlerTest, VerticalSwipes) { |
| std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| ui::test::EventGenerator generator(root_window, root_window); |
| + const float long_swipe = 2 * vertical_threshold_pixels(); |
| generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| - 0, -500, 100, 3); |
| + 0, -long_swipe, 100, 3); |
| EXPECT_TRUE(IsSelecting()); |
| // Swiping up again does nothing. |
| generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| - 0, -500, 100, 3); |
| + 0, -long_swipe, 100, 3); |
| EXPECT_TRUE(IsSelecting()); |
| // Swiping down exits. |
| generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| - 0, 500, 100, 3); |
| + 0, long_swipe, 100, 3); |
| EXPECT_FALSE(IsSelecting()); |
| // Swiping down again does nothing. |
| generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| - 0, 500, 100, 3); |
| + 0, long_swipe, 100, 3); |
| EXPECT_FALSE(IsSelecting()); |
| } |
| +// Tests a swipe up with three fingers to enter overview and a swipe right or |
|
tdanderson
2017/02/08 23:14:19
The OverviewGestureHandlerTest.VerticalSwipes test
varkha
2017/02/09 21:54:42
Done.
|
| +// left to move selection. |
| +TEST_F(OverviewGestureHandlerTest, VerticalThenHorizontalSwipe) { |
| + gfx::Rect bounds(0, 0, 400, 400); |
| + aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| + std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| + std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| + std::unique_ptr<aura::Window> window3(CreateWindow(bounds)); |
| + std::unique_ptr<aura::Window> window4(CreateWindow(bounds)); |
| + std::unique_ptr<aura::Window> window5(CreateWindow(bounds)); |
| + ui::test::EventGenerator generator(root_window, root_window); |
| + const float vertical_swipe = 2 * vertical_threshold_pixels(); |
| + const float horizontal_swipe = horizontal_threshold_pixels(); |
| + generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| + 0, -vertical_swipe, 100, 3); |
| + EXPECT_TRUE(IsSelecting()); |
| + |
| + // Long swipe right moves selection to the fourth window. |
| + generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| + horizontal_swipe * 4, 0, 100, 3); |
| + EXPECT_TRUE(IsSelecting()); |
| + |
| + // Short swipe left (3 fingers) moves selection to the third window. |
| + generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| + -horizontal_swipe, 0, 100, 3); |
| + EXPECT_TRUE(IsSelecting()); |
| + |
| + // Short swipe left (2 fingers) moves selection to the second window. |
| + generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| + -horizontal_swipe, 0, 100, 2); |
| + EXPECT_TRUE(IsSelecting()); |
| + |
| + // Swiping down exits and selects the currently-highlighted window. |
| + generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| + 0, vertical_swipe, 100, 3); |
| + EXPECT_FALSE(IsSelecting()); |
| + |
| + // Second MRU window is selected (i.e. |window4|). |
| + EXPECT_EQ(window4.get(), wm::GetActiveWindow()); |
| +} |
| + |
| // Tests that a mostly horizontal swipe does not trigger overview. |
|
tdanderson
2017/02/08 23:14:19
nit: while you're here it would be good to reword
varkha
2017/02/09 21:54:42
Done.
|
| TEST_F(OverviewGestureHandlerTest, HorizontalSwipes) { |
| gfx::Rect bounds(0, 0, 400, 400); |
| @@ -70,12 +123,13 @@ TEST_F(OverviewGestureHandlerTest, HorizontalSwipes) { |
| std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| ui::test::EventGenerator generator(root_window, root_window); |
| + const float long_swipe = 2 * vertical_threshold_pixels(); |
| generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| - 600, -500, 100, 3); |
| + long_swipe + 100, -long_swipe, 100, 3); |
| EXPECT_FALSE(IsSelecting()); |
| generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| - -600, -500, 100, 3); |
| + -long_swipe - 100, -long_swipe, 100, 3); |
| EXPECT_FALSE(IsSelecting()); |
| } |