From 3f9aec17cd7ecb01ea72747d7f9e1f6572b1303b Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Tue, 26 Aug 2008 09:55:05 -0500 Subject: [PATCH] user32: Add test demonstrating the WM_PAINT loop. --- dlls/user32/tests/msg.c | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 7480e1b375a..62cc2dce881 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1584,6 +1584,7 @@ static int after_end_dialog, test_def_id; static int sequence_cnt, sequence_size; static struct message* sequence; static int log_all_parent_messages; +static int paint_loop_done; /* user32 functions */ static HWND (WINAPI *pGetAncestor)(HWND,UINT); @@ -7039,6 +7040,31 @@ static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LP return ret; } +LRESULT WINAPI PaintLoopProcA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_CREATE: return 0; + case WM_PAINT: + { + MSG msg2; + static int i = 0; + + i++; + if (PeekMessageA(&msg2, 0, 0, 0, 1)) + { + TranslateMessage(&msg2); + DispatchMessage(&msg2); + } + i--; + if ( i == 0) + paint_loop_done = 1; + return DefWindowProcA(hWnd,msg,wParam,lParam); + } + } + return DefWindowProcA(hWnd,msg,wParam,lParam); +} + static BOOL RegisterWindowClasses(void) { WNDCLASSA cls; @@ -7072,6 +7098,10 @@ static BOOL RegisterWindowClasses(void) cls.lpszClassName = "SimpleWindowClass"; if(!RegisterClassA(&cls)) return FALSE; + cls.lpfnWndProc = PaintLoopProcA; + cls.lpszClassName = "PaintLoopWindowClass"; + if(!RegisterClassA(&cls)) return FALSE; + cls.style = CS_NOCLOSE; cls.lpszClassName = "NoCloseWindowClass"; if(!RegisterClassA(&cls)) return FALSE; @@ -11033,6 +11063,31 @@ static void test_menu_messages(void) DestroyMenu(hmenu); } + +static void test_paintingloop(void) +{ + HWND hwnd; + + paint_loop_done = 0; + hwnd = CreateWindowExA(0x0,"PaintLoopWindowClass", + "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW, + 100, 100, 100, 100, 0, 0, 0, NULL ); + ok(hwnd != 0, "PaintLoop window error %u\n", GetLastError()); + ShowWindow(hwnd,SW_NORMAL); + SetFocus(hwnd); + + while (!paint_loop_done) + { + MSG msg; + if (PeekMessageA(&msg, 0, 0, 0, 1)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + DestroyWindow(hwnd); +} + START_TEST(msg) { BOOL ret; @@ -11116,6 +11171,7 @@ START_TEST(msg) test_nullCallback(); test_dbcs_wm_char(); test_menu_messages(); + test_paintingloop(); /* keep it the last test, under Windows it tends to break the tests * which rely on active/foreground windows being correct. */