Module: wine Branch: master Commit: 6395bf962fe55d93bc3ca599d4519daccb7ab4de URL: https://gitlab.winehq.org/wine/wine/-/commit/6395bf962fe55d93bc3ca599d4519da...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Jul 19 19:51:53 2022 +0200
win32u/tests: Add tests for catching exceptions from timer proc.
We currently depend on default behaviour of suppressing exceptions from client callbacks. If we change it to fail by default, we will need a separated filter for NtUserDispatchMessage.
---
dlls/win32u/tests/win32u.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 07179e6cdb9..0985478b2f0 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -632,6 +632,50 @@ static void test_message_filter(void) ok( ret, "NtUserUnhookWindowsHook failed: %lu\n", GetLastError() ); }
+static char calls[128]; + +static void WINAPI timer_func( HWND hwnd, UINT msg, UINT_PTR id, DWORD time ) +{ + sprintf( calls + strlen( calls ), "timer%Iu,", id ); + NtUserKillTimer( hwnd, id ); + + if (!id) + { + MSG msg; + NtUserSetTimer( hwnd, 1, 1, timer_func, TIMERV_DEFAULT_COALESCING ); + while (GetMessageW( &msg, NULL, 0, 0 )) + { + TranslateMessage( &msg ); + NtUserDispatchMessage( &msg ); + if (msg.message == WM_TIMER) break; + } + } + + strcat( calls, "crash," ); + *(volatile int *)0 = 0; +} + +static void test_timer(void) +{ + HWND hwnd; + MSG msg; + + hwnd = CreateWindowExA( 0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL ); + + NtUserSetTimer( hwnd, 0, 1, timer_func, TIMERV_DEFAULT_COALESCING ); + + calls[0] = 0; + while (GetMessageW( &msg, NULL, 0, 0 )) + { + TranslateMessage( &msg ); + NtUserDispatchMessage( &msg ); + if (msg.message == WM_TIMER) break; + } + + ok( !strcmp( calls, "timer0,timer1,crash,crash," ), "calls = %s\n", calls ); + DestroyWindow( hwnd ); +} + START_TEST(win32u) { /* native win32u.dll fails if user32 is not loaded, so make sure it's fully initialized */ @@ -646,6 +690,7 @@ START_TEST(win32u) test_window_text(); test_menu(); test_message_filter(); + test_timer();
test_NtUserCloseWindowStation(); }