[PATCH 2/3] user32/tests: test ClipCursor and SetCursorPos.

Lauri Kenttä lauri.kentta at gmail.com
Mon Jan 18 17:34:15 CST 2010


Test that ClipCursor moves the cursor inside the clip rectangle and that
SetCursorPos doesn't move it out.
---
 dlls/user32/tests/input.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index d82ef3c..7713ff6 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -1246,6 +1246,35 @@ static LRESULT CALLBACK hook_proc2( int code, WPARAM wparam, LPARAM lparam )
     return CallNextHookEx( 0, code, wparam, lparam );
 }
 
+static void test_mouse_clipping(void)
+{
+    POINT pt;
+    RECT rc;
+
+    /* Check that SetCursorPos functions normally. */
+    SetCursorPos(40, 50);
+    GetCursorPos(&pt);
+    ok(pt.x == 40 && pt.y == 50, "Wrong new pos: (%d,%d)\n", pt.x, pt.y);
+
+    /* Check that ClipCursor really clips the cursor right away. */
+    SetRect(&rc, 50, 60, 151, 161);
+    ClipCursor(&rc);
+    GetCursorPos(&pt);
+    ok(pt.x == 50 && pt.y == 60, "Wrong new pos: (%d,%d)\n", pt.x, pt.y);
+
+    /* Check that SetCursorPos still functions normally. */
+    SetCursorPos(60, 70);
+    GetCursorPos(&pt);
+    ok(pt.x == 60 && pt.y == 70, "Wrong new pos: (%d,%d)\n", pt.x, pt.y);
+
+    /* Check that ClipCursor affects SetCursorPos. */
+    SetCursorPos(200, 200);
+    GetCursorPos(&pt);
+    ok(pt.x == 150 && pt.y == 160, "Wrong new pos: (%d,%d)\n", pt.x, pt.y);
+
+    ClipCursor(NULL);
+}
+
 static void test_mouse_ll_hook(void)
 {
     HWND hwnd;
@@ -1585,6 +1614,7 @@ START_TEST(input)
     else win_skip("SendInput is not available\n");
 
     test_keynames();
+    test_mouse_clipping();
     test_mouse_ll_hook();
     test_key_map();
     test_ToUnicode();
-- 
1.6.6




More information about the wine-patches mailing list