Rémi Bernon : dinput8/tests: Flush events after creating window.

Alexandre Julliard julliard at winehq.org
Tue May 25 16:08:16 CDT 2021


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Tue May 25 18:48:52 2021 +0200

dinput8/tests: Flush events after creating window.

To make it more likely it gets focused on X11 and fix spurious failures.

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

---

 dlls/dinput/tests/mouse.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c
index 2e0b8cdf2e9..69051bb2a34 100644
--- a/dlls/dinput/tests/mouse.c
+++ b/dlls/dinput/tests/mouse.c
@@ -48,6 +48,21 @@ static const HRESULT SetCoop_child_window[16] =  {
     E_INVALIDARG, E_HANDLE,     E_HANDLE,     E_INVALIDARG,
     E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
 
+static void flush_events(void)
+{
+    MSG msg;
+    int diff = 200;
+    int min_timeout = 100;
+    DWORD time = GetTickCount() + diff;
+
+    while (diff > 0)
+    {
+        if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
+        diff = time - GetTickCount();
+    }
+}
+
 static void test_set_coop(IDirectInputA *pDI, HWND hwnd)
 {
     HRESULT hr;
@@ -131,6 +146,7 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd)
     hwnd2 = CreateWindowA("static", "Temporary", WS_VISIBLE, 10, 210, 200, 200, NULL, NULL, NULL,
                           NULL);
     ok(hwnd2 != NULL, "CreateWindowA failed with %u\n", GetLastError());
+    flush_events();
 
     hr = IDirectInputDevice_GetDeviceState(pMouse, sizeof(m_state), &m_state);
     ok(hr == DIERR_NOTACQUIRED, "GetDeviceState() should have failed: %08x\n", hr);




More information about the wine-cvs mailing list