Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: ash/wm/system_gesture_event_filter_unittest.cc

Issue 58973004: Increase tolerance for touch-snapping near the screen edges (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Increase tolerance for touch-snapping near the screen edges (test) Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/system_gesture_event_filter_unittest.cc
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc
index 14f9356b5b3ef74cbaefee5aec0e2e272145903a..cc0a1ba0b48d16f9bef39fb0e023789001fcb21e 100644
--- a/ash/wm/system_gesture_event_filter_unittest.cc
+++ b/ash/wm/system_gesture_event_filter_unittest.cc
@@ -441,7 +441,7 @@ TEST_P(SystemGestureEventFilterTest, TwoFingerDragTwoWindows) {
}
TEST_P(SystemGestureEventFilterTest, WindowsWithMaxSizeDontSnap) {
- gfx::Rect bounds(150, 150, 100, 100);
+ gfx::Rect bounds(250, 150, 100, 100);
aura::Window* root_window = Shell::GetPrimaryRootWindow();
views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds(
new MaxSizeWidgetDelegate, root_window, bounds);
@@ -450,8 +450,8 @@ TEST_P(SystemGestureEventFilterTest, WindowsWithMaxSizeDontSnap) {
const int kSteps = 15;
const int kTouchPoints = 2;
gfx::Point points[kTouchPoints] = {
- gfx::Point(150+10, 150+30),
- gfx::Point(150+30, 150+20),
+ gfx::Point(bounds.x() + 10, bounds.y() + 30),
+ gfx::Point(bounds.x() + 30, bounds.y() + 20),
};
aura::test::EventGenerator generator(root_window,
@@ -598,6 +598,62 @@ TEST_P(SystemGestureEventFilterTest, ThreeFingerGestureStopsDrag) {
toplevel->GetNativeWindow()->bounds().ToString());
}
+TEST_P(SystemGestureEventFilterTest, DragLeftNearEdgeSnaps) {
+ gfx::Rect bounds(200, 150, 400, 100);
+ aura::Window* root_window = Shell::GetPrimaryRootWindow();
+ views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds(
+ new ResizableWidgetDelegate, root_window, bounds);
+ toplevel->Show();
+
+ const int kSteps = 15;
+ const int kTouchPoints = 2;
+ gfx::Point points[kTouchPoints] = {
+ gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
+ gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
+ };
+ aura::test::EventGenerator generator(root_window,
+ toplevel->GetNativeWindow());
+
+ // Check that dragging left snaps before reaching the screen edge.
+ gfx::Rect work_area =
+ Shell::GetScreen()->GetDisplayNearestWindow(root_window).work_area();
+ int drag_x = work_area.x() + 20 - points[0].x();
+ generator.GestureMultiFingerScroll(
+ kTouchPoints, points, 120, kSteps, drag_x, 0);
+ gfx::Rect expected_bounds = gfx::Rect(
+ work_area.x(), 0, 720, work_area.height());
+ EXPECT_EQ(expected_bounds.ToString(),
+ toplevel->GetWindowBoundsInScreen().ToString());
+}
+
+TEST_P(SystemGestureEventFilterTest, DragRightNearEdgeSnaps) {
+ gfx::Rect bounds(200, 150, 400, 100);
+ aura::Window* root_window = Shell::GetPrimaryRootWindow();
+ views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds(
+ new ResizableWidgetDelegate, root_window, bounds);
+ toplevel->Show();
+
+ const int kSteps = 15;
+ const int kTouchPoints = 2;
+ gfx::Point points[kTouchPoints] = {
+ gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
+ gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
+ };
+ aura::test::EventGenerator generator(root_window,
+ toplevel->GetNativeWindow());
+
+ // Check that dragging right snaps before reaching the screen edge.
+ gfx::Rect work_area =
+ Shell::GetScreen()->GetDisplayNearestWindow(root_window).work_area();
+ int drag_x = work_area.right() - 20 - points[0].x();
+ generator.GestureMultiFingerScroll(
+ kTouchPoints, points, 120, kSteps, drag_x, 0);
+ gfx::Rect expected_bounds = gfx::Rect(
+ work_area.right() - 720, 0, 720, work_area.height());
+ EXPECT_EQ(expected_bounds.ToString(),
+ toplevel->GetWindowBoundsInScreen().ToString());
+}
+
// Tests run twice - with docked windows disabled or enabled.
INSTANTIATE_TEST_CASE_P(DockedWindowsDisabledOrEnabled,
SystemGestureEventFilterTest,
« no previous file with comments | « no previous file | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698