[PATCH v2 1/6] user32/tests: Make test_unicode_wm_char robust against superfluous messages.

Jinoh Kang jinoh.kang.kr at gmail.com
Wed Apr 20 11:02:24 CDT 2022


Commit e445303ab45 (user32/tests: Make a few more messages optional.,
2014-03-20) modified test_unicode_wm_char so that it skips non-essential
messages (e.g. WM_DWMNCRENDERINGCHANGED) from GetMessageW.

Extend this for messages from GetMessageA as well.

Also, handle the case where no messages other than WM_QUIT are received
at all.

Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
---

Notes:
    v1 -> v2: add patch, fixes intermittent test failures on w1064

 dlls/user32/tests/msg.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index a2adf56565d..918ee97bfa5 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -15182,6 +15182,16 @@ static void test_dbcs_wm_char(void)
     DestroyWindow(hwnd2);
 }
 
+static BOOL get_next_msg( BOOL (*WINAPI getmessage)(MSG *, HWND, UINT, UINT),
+                          MSG *msg, HWND hwnd )
+{
+    while ((*getmessage)( msg, hwnd, 0, 0 ))
+    {
+        if (!ignore_message( msg->message )) return TRUE;
+    }
+    return FALSE;
+}
+
 static void test_unicode_wm_char(void)
 {
     HWND hwnd;
@@ -15212,11 +15222,7 @@ static void test_unicode_wm_char(void)
 
     PostMessageW( hwnd, WM_CHAR, 0x3b1, 0 );
 
-    while (GetMessageW( &msg, hwnd, 0, 0 ))
-    {
-        if (!ignore_message( msg.message )) break;
-    }
-
+    ok( get_next_msg( GetMessageW, &msg, hwnd ), "expected a recongized message\n" );
     ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
     ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
     ok( msg.wParam == 0x3b1, "bad wparam %Ix\n", msg.wParam );
@@ -15236,7 +15242,7 @@ static void test_unicode_wm_char(void)
     /* greek alpha -> 'a' in cp1252 */
     PostMessageW( hwnd, WM_CHAR, 0x3b1, 0 );
 
-    ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
+    ok( get_next_msg( GetMessageA, &msg, hwnd ), "expected a recognized message\n" );
     ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
     ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
     ok( msg.wParam == 0x61, "bad wparam %Ix\n", msg.wParam );
@@ -15257,7 +15263,7 @@ static void test_unicode_wm_char(void)
     /* greek alpha -> 0xe1 in cp1253 */
     PostMessageW( hwnd, WM_CHAR, 0x3b1, 0 );
 
-    ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
+    ok( get_next_msg( GetMessageA, &msg, hwnd ), "expected a recognized message\n" );
     ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
     ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
     ok( msg.wParam == 0xe1, "bad wparam %Ix\n", msg.wParam );
-- 
2.34.1




More information about the wine-devel mailing list