Hello, the attached patch consists of a test case for following bug: http://bugs.winehq.org/show_bug.cgi?id=12104
This test shows how cygwin's setup checks if a WM_SIZE message was received (by the custom window proc). In wine only the property page gets such a message - not the sheet. If I got it right, tests which would fail in wine are prefixed with todo_wine? I want to ask if this patch looks right for inclusion and if the location (dlls/comctl32/tests/) is right? Kind regards, Bernhard
From e89af2359528a559deec7cc35cbc017ab977f079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= <bernha...@vr-web.de> Date: Sun, 24 Oct 2010 13:17:01 +0200 Subject: Test for window messages of a property sheet with custom dialog proc. (As seen in bug 12104 - Cygwin's setup.exe doesn't resize properly) --- dlls/comctl32/tests/propsheet.c | 122 +++++++++++++++++++++++++++++++++++++++ dlls/comctl32/tests/resources.h | 1 + dlls/comctl32/tests/rsrc.rc | 7 ++ 3 files changed, 130 insertions(+), 0 deletions(-) diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c index bfbaaa0..6232442 100644 --- a/dlls/comctl32/tests/propsheet.c +++ b/dlls/comctl32/tests/propsheet.c @@ -525,6 +525,127 @@ static void test_custom_default_button(void) DestroyWindow(hdlg); } +static WNDPROC oldWndProc; +static BOOL clientRectValid; +struct message_entry { + UINT msg; + CHAR source[10]; +}; +static const struct message_entry message_array[] = { + { PSCB_PRECREATE, "sheet_cb" }, + { PSCB_INITIALIZED, "sheet_cb" }, + { WM_WINDOWPOSCHANGING, "sheet_wp" }, + { WM_NCCALCSIZE, "sheet_wp" }, + { WM_WINDOWPOSCHANGED, "sheet_wp" }, + { WM_MOVE, "sheet_wp" }, + { WM_SIZE, "sheet_wp" } +}; + +static void check_message(HWND hwnd, UINT msg, PCHAR source) +{ + static UINT msg_count; + + /*trace("check_message: msg[0x%08x] received by %s\n", msg, source);*/ + + if (msg_count < sizeof(message_array)/sizeof(message_array[0])) + { + /* disabled because todo_wine would fail because some messages arrive correct in wine + ok(message_array[msg_count].msg == msg, + "received message 0x%x when expecting 0x%x\n", + msg, message_array[msg_count].msg); + ok(strcmp(message_array[msg_count].source, source) == 0, + "receiver is %s when expecting %s\n", + source, message_array[msg_count].source); + */ + + msg_count++; + } +} + +static LRESULT CALLBACK sheet_callback_messages_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + check_message(hwnd, msg, "sheet_wp"); + + switch (msg) + { + case WM_SIZE: + /*trace("sheet_callback_messages_proc: clientRectValid[%d]\n", clientRectValid);*/ + clientRectValid = TRUE; + break; + case WM_CTLCOLORSTATIC: + keybd_event(VK_ESCAPE, 0, 0, 0); + break; + } + + return CallWindowProc (oldWndProc, hwnd, msg, wParam, lParam); +} + +static int CALLBACK sheet_callback_messages(HWND hwnd, UINT msg, LPARAM lparam) +{ + check_message(hwnd, msg, "sheet_cb"); + + switch (msg) + { + case PSCB_INITIALIZED: + oldWndProc = (WNDPROC)GetWindowLongPtr (hwnd, GWLP_WNDPROC); + SetWindowLongPtr (hwnd, GWLP_WNDPROC, (LONG_PTR)&sheet_callback_messages_proc); + return TRUE; + } + + return TRUE; +} + +static INT_PTR CALLBACK page_dlg_proc_messages(HWND hwnd, UINT msg, WPARAM wparam, + LPARAM lparam) +{ + check_message(hwnd, msg, "page"); + + return FALSE; +} + +static void test_messages(void) +{ + HPROPSHEETPAGE hpsp[1]; + PROPSHEETPAGEA psp; + PROPSHEETHEADERA psh; + HWND hdlg; + + memset(&psp, 0, sizeof(psp)); + psp.dwSize = sizeof(psp); + psp.dwFlags = 0; + psp.hInstance = GetModuleHandleA(NULL); + U(psp).pszTemplate = MAKEINTRESOURCE(IDD_PROP_PAGE_MESSAGE_TEST); + U2(psp).pszIcon = NULL; + psp.pfnDlgProc = page_dlg_proc_messages; + psp.lParam = 0; + + hpsp[0] = CreatePropertySheetPageA(&psp); + + memset(&psh, 0, sizeof(psh)); + psh.dwSize = sizeof(psh); + psh.dwFlags = PSH_NOAPPLYNOW | PSH_WIZARD | PSH_USECALLBACK + /*| PSH_MODELESS */ | PSH_USEICONID; + psh.pszCaption = "test caption"; + psh.nPages = 1; + psh.hwndParent = GetDesktopWindow(); + U3(psh).phpage = hpsp; + psh.pfnCallback = sheet_callback_messages; + + hdlg = (HWND)PropertySheetA(&psh); + if (hdlg == INVALID_HANDLE_VALUE) + { + win_skip("comctl32 4.70 needs dwSize adjustment\n"); + psh.dwSize = sizeof(psh) - sizeof(HBITMAP) - sizeof(HPALETTE) - sizeof(HBITMAP); + hdlg = (HWND)PropertySheetA(&psh); + } + ShowWindow(hdlg,SW_NORMAL); + + todo_wine + ok(clientRectValid, "The required WM_SIZE was never sent to the sheet.\n"); + + DestroyWindow(hdlg); +} + START_TEST(propsheet) { test_title(); @@ -533,4 +654,5 @@ START_TEST(propsheet) test_wiznavigation(); test_buttons(); test_custom_default_button(); + test_messages(); } diff --git a/dlls/comctl32/tests/resources.h b/dlls/comctl32/tests/resources.h index beabce5..e5217f1 100644 --- a/dlls/comctl32/tests/resources.h +++ b/dlls/comctl32/tests/resources.h @@ -37,6 +37,7 @@ #define IDD_PROP_PAGE_EXIT 33 #define IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON 34 +#define IDD_PROP_PAGE_MESSAGE_TEST 35 #define IDC_PS_EDIT1 1000 #define IDC_PS_EDIT2 1001 diff --git a/dlls/comctl32/tests/rsrc.rc b/dlls/comctl32/tests/rsrc.rc index db76d58..76b3642 100644 --- a/dlls/comctl32/tests/rsrc.rc +++ b/dlls/comctl32/tests/rsrc.rc @@ -64,6 +64,13 @@ FONT 8, "MS Shell Dlg" LTEXT "This has been a test property sheet!", -1, 10, 6, 170, 8 } +IDD_PROP_PAGE_MESSAGE_TEST DIALOG DISCARDABLE 0, 0, 339, 179 +STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_CHILD | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Message Test" +BEGIN + LTEXT "Some Text",-1,115,1,195,24 +END + STRINGTABLE { IDS_TBADD1 "abc" -- 1.7.1