[PATCH 2/2] user32/tests: Add multi-threaded test for ShowWindow(SW_SHOW) on a visible window

Alexey Prokhin alexey at prokhin.ru
Thu Jun 6 13:55:35 CDT 2019


Signed-off-by: Alexey Prokhin <alexey at prokhin.ru>
---
 dlls/user32/tests/msg.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 6d0f0637ee..5bbe273792 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -5041,7 +5041,7 @@ static void test_WM_DEVICECHANGE(HWND hwnd)
     }
 }
 
-static DWORD CALLBACK show_window_thread(LPVOID arg)
+static DWORD CALLBACK hide_window_thread(LPVOID arg)
 {
    HWND hwnd = arg;
 
@@ -5051,6 +5051,16 @@ static DWORD CALLBACK show_window_thread(LPVOID arg)
    return 0;
 }
 
+static DWORD CALLBACK show_window_thread(LPVOID arg)
+{
+   HWND hwnd = arg;
+
+   /* function will not return if ShowWindow(SW_SHOW) calls SendMessage() */
+   ok(ShowWindow(hwnd, SW_SHOW) != FALSE, "ShowWindow(SW_SHOW) expected nonzero\n");
+
+   return 0;
+}
+
 /* Helper function to easier test SetWindowPos messages */
 #define test_msg_setpos( expected_list, flags, todo ) \
         test_msg_setpos_( (expected_list), (flags), (todo), __FILE__, __LINE__)
@@ -5112,7 +5122,7 @@ static void test_messages(void)
     ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
 
     /* test ShowWindow(SW_HIDE) on a hidden window -  multi-threaded */
-    hthread = CreateThread(NULL, 0, show_window_thread, hwnd, 0, &tid);
+    hthread = CreateThread(NULL, 0, hide_window_thread, hwnd, 0, &tid);
     ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
     ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
     CloseHandle(hthread);
@@ -5153,10 +5163,19 @@ static void test_messages(void)
         flush_sequence();
     }
 
+    /* test ShowWindow(SW_SHOW) on a visible window - single threaded */
     ShowWindow(hwnd, SW_SHOW);
     flush_events();
     ok_sequence(WmOptionalPaint, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
 
+    /* test ShowWindow(SW_SHOW) on a visible window - multi-threaded */
+    hthread = CreateThread(NULL, 0, show_window_thread, hwnd, 0, &tid);
+    ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
+    ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+    CloseHandle(hthread);
+    flush_events();
+    ok_sequence(WmOptionalPaint, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
+
     SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
     ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
     ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
-- 
2.17.2 (Apple Git-113)




More information about the wine-devel mailing list