[PATCH] user32/tests: check that SetCursorPos doesn't call hooks. (try 2)

Lauri Kenttä lauri.kentta at gmail.com
Thu Jan 21 04:31:36 CST 2010


SetCursorPos should not call mouse low-level hooks.

Try 2: Fixed coding style and simplified the check.
---
 dlls/user32/tests/input.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 7713ff6..31db001 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -1198,6 +1198,7 @@ static void test_keynames(void)
 
 static POINT pt_old, pt_new;
 static BOOL clipped;
+static int call_times;
 #define STEP 3
 
 static LRESULT CALLBACK hook_proc1( int code, WPARAM wparam, LPARAM lparam )
@@ -1231,6 +1232,8 @@ static LRESULT CALLBACK hook_proc2( int code, WPARAM wparam, LPARAM lparam )
     MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
     POINT pt;
 
+    ++call_times;
+
     if (code == HC_ACTION)
     {
         ok(hook->pt.x == pt_new.x && hook->pt.y == pt_new.y,
@@ -1347,6 +1350,18 @@ static void test_mouse_ll_hook(void)
     GetCursorPos(&pt);
     ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
 
+    /* Check that SetCursorPos doesn't call hooks.
+     * Check twice: first moving to old coordinates, then to new. */
+    SetCursorPos(10, 10);
+
+    call_times = 0;
+    SetCursorPos(10, 10);
+    ok(call_times == 0, "Hooks called\n");
+
+    call_times = 0;
+    SetCursorPos(20, 20);
+    ok(call_times == 0, "Hooks called\n");
+
     UnhookWindowsHookEx(hook2);
 done:
     DestroyWindow(hwnd);
-- 
1.6.6




More information about the wine-patches mailing list