From ca52392bf198bfd712d79847a7439c9fbe545943 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Tue, 31 May 2005 13:39:24 +0000 Subject: [PATCH] Added test case for infinite loops on RDW_REDRAWNOW. --- dlls/user/tests/win.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/dlls/user/tests/win.c b/dlls/user/tests/win.c index 43f4f4e787c..a3519be2292 100644 --- a/dlls/user/tests/win.c +++ b/dlls/user/tests/win.c @@ -2917,6 +2917,67 @@ static void test_AdjustWindowRect() } #undef SHOWSYSMETRIC + +/* Global variables to trigger exit from loop */ +static int redrawComplete, WMPAINT_count; + +static LRESULT WINAPI redraw_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch (msg) + { + case WM_PAINT: + trace("doing WM_PAINT %d\n", WMPAINT_count); + WMPAINT_count++; + if (WMPAINT_count > 10 && redrawComplete == 0) { + PAINTSTRUCT ps; + BeginPaint(hwnd, &ps); + EndPaint(hwnd, &ps); + return 1; + } + return 0; + break; + } + return DefWindowProc(hwnd, msg, wparam, lparam); +} + +/* Ensure we exit from RedrawNow regardless of invalidated area */ +static void test_redrawnow() { + + WNDCLASSA cls; + HWND hwndMain; + + cls.style = CS_DBLCLKS; + cls.lpfnWndProc = redraw_window_procA; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleA(0); + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = "RedrawWindowClass"; + + if(!RegisterClassA(&cls)) { + trace("Register failed %ld\n", GetLastError()); + return; + } + + hwndMain = CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, 100, 100, NULL, NULL, 0, NULL); + + ok( WMPAINT_count == 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count); + ShowWindow(hwndMain, SW_SHOW); + ok( WMPAINT_count == 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count); + RedrawWindow(hwndMain, NULL,NULL,RDW_UPDATENOW | RDW_ALLCHILDREN); + ok( WMPAINT_count == 1, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count); + redrawComplete = TRUE; + ok( WMPAINT_count < 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count); + + /* clean up */ + DestroyWindow( hwndMain); +} + + START_TEST(win) { pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" ); @@ -2986,4 +3047,5 @@ START_TEST(win) test_AdjustWindowRect(); test_window_styles(); + test_redrawnow(); }