Hi.
Some time ago I tried to fix bug http://bugs.winehq.org/show_bug.cgi?id=16876 . It's about wrong return codes of PropertySheet call.
The question is about a proper way of testing this.
I tried to exit just after creation in PSCB_INITIALIZED handler, it looks like it shows a problem, but I'm not sure is it a correct way or not.
I'd like to see some advices about that
Thanks.
rom 56c14340af9ac298bde22cf207fca7c8ae95957c Mon Sep 17 00:00:00 2001 From: Nikolay Sivov bunglehead@gmail.com Date: Sat, 23 May 2009 19:21:08 +0400 Subject: Some propsheet tests
--- dlls/comctl32/tests/propsheet.c | 128 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 128 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c index 4164f68..37b89fd 100644 --- a/dlls/comctl32/tests/propsheet.c +++ b/dlls/comctl32/tests/propsheet.c @@ -199,9 +199,137 @@ static void test_disableowner(void) DestroyWindow(parent); }
+#define PSM_PRESSBUTTON_CALLBACK(id) \ +static int CALLBACK psm_pressbutton_callback_##id (HWND hwnd, UINT msg, LPARAM lparam) \ +{\ + switch(msg)\ + {\ + case PSCB_INITIALIZED:\ + {\ + PostMessage(NULL, PSM_PRESSBUTTON, PSBTN_##id, (LPARAM)0);\ + return FALSE;\ + }\ + }\ + return FALSE;\ +} + +PSM_PRESSBUTTON_CALLBACK(OK) +PSM_PRESSBUTTON_CALLBACK(CANCEL) +PSM_PRESSBUTTON_CALLBACK(APPLYNOW) +PSM_PRESSBUTTON_CALLBACK(BACK) +PSM_PRESSBUTTON_CALLBACK(FINISH) +PSM_PRESSBUTTON_CALLBACK(HELP) +PSM_PRESSBUTTON_CALLBACK(NEXT) + +static void test_singlepressbutton(INT id, INT expected, BOOL modal, BOOL todo, int line) +{ + HPROPSHEETPAGE hpsp[1]; + PROPSHEETPAGEA psp; + PROPSHEETHEADERA psh; + HWND hdlg; + INT ret; + DWORD r; + + memset(&psp, 0, sizeof(psp)); + psp.dwSize = sizeof(psp); + psp.dwFlags = 0; + psp.hInstance = GetModuleHandleW(NULL); + U(psp).pszTemplate = "prop_page1"; + U2(psp).pszIcon = NULL; + psp.pfnDlgProc = NULL; + psp.lParam = 0; + + hpsp[0] = CreatePropertySheetPageA(&psp); + + memset(&psh, 0, sizeof(psh)); + psh.dwSize = sizeof(psh); + psh.pszCaption = "test caption"; + psh.nPages = 1; + U3(psh).phpage = hpsp; + + if (modal) + { + /* modal sheet */ + psh.dwFlags = PSH_USECALLBACK; + psh.hwndParent = NULL; + switch(id) + { + case PSBTN_BACK: + psh.pfnCallback = psm_pressbutton_callback_BACK; + break; + case PSBTN_NEXT: + psh.pfnCallback = psm_pressbutton_callback_NEXT; + break; + case PSBTN_FINISH: + psh.pfnCallback = psm_pressbutton_callback_FINISH; + break; + case PSBTN_OK: + psh.pfnCallback = psm_pressbutton_callback_OK; + break; + case PSBTN_APPLYNOW: + psh.pfnCallback = psm_pressbutton_callback_APPLYNOW; + break; + case PSBTN_CANCEL: + psh.pfnCallback = psm_pressbutton_callback_CANCEL; + break; + case PSBTN_HELP: + psh.pfnCallback = psm_pressbutton_callback_HELP; + break; + } + + ret = PropertySheetA(&psh); + if (todo) + { + todo_wine ok_(__FILE__, line)(ret == expected, "Expected %d result, got %d\n", expected, ret); + } + else + ok_(__FILE__, line)(ret == expected, "Expected %d result, got %d\n", expected, ret); + } + else + { + /* modeless sheet */ + psh.dwFlags = PSH_MODELESS; + psh.hwndParent = GetDesktopWindow(); + + hdlg = (HWND)PropertySheetA(&psh); + ok(IsWindow(hdlg), "Expected dialog handle, got %p\n", hdlg); + + SendMessage(hdlg, PSM_PRESSBUTTON, PSBTN_FINISH, 0); + ok(IsWindow(hdlg), "Expected dialog handle, got %p\n", hdlg); + r = SendMessage(hdlg, PSM_GETRESULT, 0, 0); + if (todo) + { + todo_wine ok_(__FILE__, line)(r == expected, "Expected %d result, got %d\n", expected, r); + } + else + ok_(__FILE__, line)(r == expected, "Expected %d result, got %d\n", expected, r); + + DestroyWindow(hdlg); + } +} + +static void test_psmpressbutton(void) +{ + test_singlepressbutton(PSBTN_BACK, 0, TRUE, TRUE, __LINE__); + test_singlepressbutton(PSBTN_BACK, IDOK, FALSE, FALSE, __LINE__); + test_singlepressbutton(PSBTN_NEXT, 0, TRUE, TRUE, __LINE__); + test_singlepressbutton(PSBTN_NEXT, IDOK, FALSE, FALSE, __LINE__); + test_singlepressbutton(PSBTN_FINISH, 0, TRUE, TRUE, __LINE__); + test_singlepressbutton(PSBTN_FINISH, IDOK, FALSE, FALSE, __LINE__); + test_singlepressbutton(PSBTN_OK, 0, TRUE, TRUE, __LINE__); + test_singlepressbutton(PSBTN_OK, IDOK, FALSE, FALSE, __LINE__); + test_singlepressbutton(PSBTN_CANCEL, 0, TRUE, TRUE, __LINE__); + test_singlepressbutton(PSBTN_CANCEL, IDOK, FALSE, FALSE, __LINE__); + test_singlepressbutton(PSBTN_APPLYNOW, 0, TRUE, TRUE, __LINE__); + test_singlepressbutton(PSBTN_APPLYNOW, IDOK, FALSE, FALSE, __LINE__); + test_singlepressbutton(PSBTN_HELP, 0, TRUE, TRUE, __LINE__); + test_singlepressbutton(PSBTN_HELP, IDOK, FALSE, FALSE, __LINE__); +} + START_TEST(propsheet) { test_title(); test_nopage(); test_disableowner(); + test_psmpressbutton(); }