Rémi Bernon : user32/tests: Add inter-thread rawinput message tests.

Alexandre Julliard julliard at winehq.org
Tue Jun 23 15:52:53 CDT 2020


Module: wine
Branch: master
Commit: 8c7c0c5504f838253646ac5f47c9be178091de99
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8c7c0c5504f838253646ac5f47c9be178091de99

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Mon Jun 15 12:05:41 2020 +0200

user32/tests: Add inter-thread rawinput message tests.

The rawinput messages are received on the target window if is from the
same process as the foreground window, it doesn't need to be the
foreground window itself, or use RIDEV_INPUTSINK.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

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

diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 172bcc3c8d..5fdc3ff36d 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -1874,16 +1874,87 @@ struct rawinput_test rawinput_tests[] =
     { TRUE,  FALSE, 0,                TRUE,  TRUE,  TRUE, /* todos: */ FALSE, FALSE, FALSE },
     { TRUE,  TRUE,  0,                TRUE,  TRUE,  TRUE, /* todos: */ FALSE, FALSE, FALSE },
     { TRUE,  TRUE,  RIDEV_NOLEGACY,  FALSE,  TRUE,  TRUE, /* todos: */  TRUE, FALSE, FALSE },
+
+    /* same-process foreground tests */
+    { TRUE,  FALSE, 0,               FALSE, FALSE, FALSE, /* todos: */ FALSE, FALSE, FALSE },
+    { TRUE,  TRUE,  0,               FALSE,  TRUE,  TRUE, /* todos: */ FALSE, FALSE, FALSE },
 };
 
+struct rawinput_test_thread_params
+{
+    HANDLE ready;
+    HANDLE start;
+    HANDLE done;
+};
+
+static DWORD WINAPI rawinput_test_thread(void *arg)
+{
+    struct rawinput_test_thread_params *params = arg;
+    POINT pt;
+    HWND hwnd = NULL;
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(rawinput_tests); ++i)
+    {
+        WaitForSingleObject(params->ready, INFINITE);
+        ResetEvent(params->ready);
+
+        switch (i)
+        {
+        case 4:
+        case 5:
+            GetCursorPos(&pt);
+
+            hwnd = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP,
+                                 pt.x - 50, pt.y - 50, 100, 100, 0, NULL, NULL, NULL);
+            ok(hwnd != 0, "CreateWindow failed\n");
+            empty_message_queue();
+
+            /* FIXME: Try to workaround X11/Win32 focus inconsistencies and
+             * make the window visible and foreground as hard as possible. */
+            ShowWindow(hwnd, SW_SHOW);
+            SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
+            SetForegroundWindow(hwnd);
+            UpdateWindow(hwnd);
+            empty_message_queue();
+
+            mouse_event(MOUSEEVENTF_MOVE, 5, 0, 0, 0);
+            empty_message_queue();
+            break;
+        }
+
+        SetEvent(params->start);
+
+        WaitForSingleObject(params->done, INFINITE);
+        ResetEvent(params->done);
+        if (hwnd) DestroyWindow(hwnd);
+    }
+
+    return 0;
+}
+
 static void test_rawinput(void)
 {
+    struct rawinput_test_thread_params params;
     RAWINPUTDEVICE raw_devices[1];
+    HANDLE thread;
     DWORD ret;
     POINT pt, newpt;
     HWND hwnd;
     int i;
 
+    params.ready = CreateEventA(NULL, FALSE, FALSE, NULL);
+    ok(params.ready != NULL, "CreateEvent failed\n");
+
+    params.start = CreateEventA(NULL, FALSE, FALSE, NULL);
+    ok(params.start != NULL, "CreateEvent failed\n");
+
+    params.done = CreateEventA(NULL, FALSE, FALSE, NULL);
+    ok(params.done != NULL, "CreateEvent failed\n");
+
+    thread = CreateThread(NULL, 0, rawinput_test_thread, &params, 0, NULL);
+    ok(thread != NULL, "CreateThread failed\n");
+
     SetCursorPos(100, 100);
     empty_message_queue();
 
@@ -1922,9 +1993,15 @@ static void test_rawinput(void)
             ok(GetLastError() == 0xdeadbeef, "%d: RegisterRawInputDevices returned %08x\n", i, GetLastError());
         }
 
-        mouse_event(MOUSEEVENTF_MOVE, 5, 0, 0, 0);
+        SetEvent(params.ready);
+        WaitForSingleObject(params.start, INFINITE);
+        ResetEvent(params.start);
+
+        if (i <= 3) mouse_event(MOUSEEVENTF_MOVE, 5, 0, 0, 0);
         empty_message_queue();
 
+        SetEvent(params.done);
+
         todo_wine_if(rawinput_tests[i].todo_legacy)
         ok(rawinput_test_received_legacy == rawinput_tests[i].expect_legacy,
            "%d: %sexpected WM_MOUSEMOVE message\n", i, rawinput_tests[i].expect_legacy ? "" : "un");
@@ -1951,6 +2028,13 @@ static void test_rawinput(void)
 
         DestroyWindow(hwnd);
     }
+
+    WaitForSingleObject(thread, INFINITE);
+
+    CloseHandle(params.done);
+    CloseHandle(params.start);
+    CloseHandle(params.ready);
+    CloseHandle(thread);
 }
 
 static void test_key_map(void)




More information about the wine-cvs mailing list