From: Qian Hong Subject: [PATCH 2/2] user32/tests: Test exception handling for timer callbacks. Message-Id: <54533AE5.4020908@codeweavers.com> Date: Fri, 31 Oct 2014 15:31:49 +0800 --- dlls/user32/tests/msg.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 90b87cb..190cd8b 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -8412,6 +8412,13 @@ static void CALLBACK callback_count(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWOR count++; } +static DWORD exception; +static void CALLBACK callback_exception(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + count++; + RaiseException(exception, 0, 0, NULL); +} + static DWORD WINAPI timer_thread_proc(LPVOID x) { struct timer_info *info = x; @@ -8542,6 +8549,42 @@ static void test_timers_no_wnd(void) /* Note: SetSystemTimer doesn't support a NULL window, see test_timers */ } +static void test_timers_exception(DWORD code) +{ + UINT_PTR id; + MSG msg; + + exception = code; + count = 0; + id = SetTimer(NULL, 0, 300, callback_exception); + ok(id != 0, "did not get id from SetTimer.\n"); + + Sleep(150); + while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + ok(count == 0, "did not get zero count as expected (%i).\n", count); + Sleep(200); + while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + ok(count == 1, "did not get one count as expected (%i).\n", count); + KillTimer(NULL, id); + Sleep(350); + while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + ok(count == 1, "killing timer did not work (%i).\n", count); +} + +static void test_timers_exceptions(void) +{ + test_timers_exception(EXCEPTION_ACCESS_VIOLATION); + test_timers_exception(EXCEPTION_DATATYPE_MISALIGNMENT); + test_timers_exception(EXCEPTION_BREAKPOINT); + test_timers_exception(EXCEPTION_SINGLE_STEP); + test_timers_exception(EXCEPTION_ARRAY_BOUNDS_EXCEEDED); + test_timers_exception(EXCEPTION_FLT_DENORMAL_OPERAND); + test_timers_exception(EXCEPTION_FLT_DIVIDE_BY_ZERO); + test_timers_exception(EXCEPTION_FLT_INEXACT_RESULT); + test_timers_exception(EXCEPTION_ILLEGAL_INSTRUCTION); + test_timers_exception(0xE000BEEF); /* customer exception */ +} + /* Various win events with arbitrary parameters */ static const struct message WmWinEventsSeq[] = { { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 }, @@ -14583,6 +14626,7 @@ START_TEST(msg) test_accelerators(); test_timers(); test_timers_no_wnd(); + test_timers_exceptions(); if (hCBT_hook) test_set_hook(); test_DestroyWindow(); test_DispatchMessage();