[PATCH v2] user32/tests: Add more tests for GetMouseMovePointsEx.

Myah Caron qsniyg at protonmail.com
Sat Sep 12 10:55:12 CDT 2020


Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=36873
Signed-off-by: Myah Caron <qsniyg at protonmail.com>
---
v2: Ensure the timestamps are likely to be accurate before testing.

Original notes below:

So far, this is the only salvagable part of a patchset I was working on to implement GetMouseMovePointsEx.

Though I haven't tested this yet, according to what I understood from MSDN, the list of points is stored in
user space, not kernel space:

>The GetMouseMovePointsEx function will return points that eventually were dispatched not only to the calling
>thread but also to other threads.

My current belief (please correct me if you have any better ideas!) is that a separate internal wine message
will be needed to implement it, as I was unable to abuse any of the existing ones to add this functionality
(none contained all necessary fields).

Regarding this patch, the tests check the following:

 - The last 64 points
 - The last 32 points after 32 points
 - Same, but with an explicit timestamp
 - Same, after a new point with the same coordinates have been added
 - Same, but using the timestamp for the new point


 dlls/user32/tests/input.c | 137 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 136 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 1809c147cbd..a8097820181 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -1477,10 +1477,12 @@ static void test_GetMouseMovePointsEx(void)
 {
 #define BUFLIM  64
 #define MYERROR 0xdeadbeef
-    int count, retval;
+    int count, retval, last_error;
+    DWORD old_time, old_time1, new_time, new_time1;
     MOUSEMOVEPOINT in;
     MOUSEMOVEPOINT out[200];
     POINT point;
+    int i, j, expected;

     /* Get a valid content for the input struct */
     if(!GetCursorPos(&point)) {
@@ -1605,6 +1607,139 @@ static void test_GetMouseMovePointsEx(void)
     ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
        "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());

+    old_time = GetTickCount();
+    for (i = 0; i < 64; i++) {
+        SetCursorPos((i+1)*2, (i+1));
+    }
+    old_time1 = GetTickCount();
+
+    count = 64;
+    in.x = (63+1)*2;
+    in.y = (63+1);
+    in.time = 0;
+
+    SetLastError(MYERROR);
+    retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
+    last_error = GetLastError();
+    todo_wine ok(retval == 64, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
+    if (retval == -1) {
+        ok(last_error == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", last_error);
+    } else {
+        for (i = 0; i < retval; i++) {
+            j = retval - i - 1;
+
+            expected = (i + 1) * 2;
+            ok(out[j].x == expected, "expected [%d].x = %d, got %d\n", j, expected, out[j].x);
+
+            expected = i + 1;
+            ok(out[j].y == expected, "expected [%d].y = %d, got %d\n", j, expected, out[j].y);
+        }
+    }
+
+    in.x = (31+1)*2;
+    in.y = (31+1);
+    in.time = 0;
+
+    SetLastError(MYERROR);
+    retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
+    last_error = GetLastError();
+    todo_wine ok(retval == 32, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
+    if (retval == -1) {
+        ok(last_error == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", last_error);
+    } else {
+        for (i = 0; i < retval; i++) {
+            j = retval - i - 1;
+
+            expected = (i + 1) * 2;
+            ok(out[j].x == expected, "expected [%d].x = %d, got %d\n", j, expected, out[j].x);
+
+            expected = i + 1;
+            ok(out[j].y == expected, "expected [%d].y = %d, got %d\n", j, expected, out[j].y);
+        }
+    }
+
+    if (old_time == old_time1) {
+        in.time = old_time;
+
+        SetLastError(MYERROR);
+        retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
+        last_error = GetLastError();
+        todo_wine ok(retval == 32, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
+        if (retval == -1) {
+            ok(last_error == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", last_error);
+        } else {
+            for (i = 0; i < retval; i++) {
+                j = retval - i - 1;
+
+                expected = (i + 1) * 2;
+                ok(out[j].x == expected, "expected [%d].x = %d, got %d\n", j, expected, out[j].x);
+
+                expected = i + 1;
+                ok(out[j].y == expected, "expected [%d].y = %d, got %d\n", j, expected, out[j].y);
+            }
+        }
+    } else {
+        skip("Unable to accurately fetch old timestamp (%d, %d)\n", old_time, old_time1);
+    }
+
+    Sleep(2);
+
+    new_time = GetTickCount();
+    SetCursorPos(in.x, in.y);
+    new_time1 = GetTickCount();
+
+    SetLastError(MYERROR);
+    retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
+    last_error = GetLastError();
+    todo_wine ok(retval == 31, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
+    if (retval == -1) {
+        ok(last_error == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", last_error);
+    } else {
+        for (i = 0; i < retval; i++) {
+            j = retval - i - 1;
+
+            expected = (i + 2) * 2;
+            ok(out[j].x == expected, "expected [%d].x = %d, got %d\n", j, expected, out[j].x);
+
+            expected = i + 2;
+            ok(out[j].y == expected, "expected [%d].y = %d, got %d\n", j, expected, out[j].y);
+        }
+    }
+
+    if (new_time == new_time1) {
+        in.time = new_time;
+
+        SetLastError(MYERROR);
+        retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
+        last_error = GetLastError();
+        todo_wine ok(retval == 64, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
+        if (retval == -1) {
+            ok(last_error == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", last_error);
+        } else {
+            for (i = 0; i < retval; i++) {
+                j = retval - i - 1;
+
+                if (j == 0)
+                    expected = in.x;
+                else if (j == 63)
+                    expected = 4;
+                else
+                    expected = (i + 2) * 2;
+                ok(out[j].x == expected, "expected [%d].x = %d, got %d\n", j, expected, out[j].x);
+
+                if (j == 0)
+                    expected = in.y;
+                else if (j == 63)
+                    expected = 2;
+                else
+                    expected = i + 2;
+                ok(out[j].y == expected, "expected [%d].y = %d, got %d\n", j, expected, out[j].y);
+            }
+        }
+    } else {
+        skip("Unable to accurately fetch new timestamp (%d, %d)\n", new_time, new_time1);
+    }
+
 #undef BUFLIM
 #undef MYERROR
 }
--
2.28.0





More information about the wine-devel mailing list