comctl32/tests: Added a test that checks whether setting a custom default button in a property sheet works
Alexandru Băluț
alexandru.balut at gmail.com
Sat May 29 17:22:06 CDT 2010
(now with patch attached)
On Sun, May 30, 2010 at 00:12, Alexandru Băluț <alexandru.balut at gmail.com>wrote:
> The test I added checks that in a property sheet the custom default button
> is pressed when the ENTER key is pressed and a different control, a
> combobox, has the keyboard focus. The test succeeds when running on Vista,
> and fails when running on Wine, that's why I added "todo_wine" before it.
>
> This problem is described in bug 22862: "Setting the default button in a
> PropertySheetPage does not work".
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20100530/98a0502d/attachment.htm>
-------------- next part --------------
From c4244d9ad3a4cc35fd8230b04c266699ae00f0ae Mon Sep 17 00:00:00 2001
From: Alex Balut <alexandru.balut at gmail.com>
Date: Sat, 29 May 2010 23:12:06 +0200
Subject: Added a test that checks if setting a custom default button in a property sheet works
---
dlls/comctl32/tests/propsheet.c | 90 +++++++++++++++++++++++++++++++++++++++
dlls/comctl32/tests/resources.h | 5 ++
dlls/comctl32/tests/rsrc.rc | 8 +++
3 files changed, 103 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c
index bf40db4..ca0dc1d 100644
--- a/dlls/comctl32/tests/propsheet.c
+++ b/dlls/comctl32/tests/propsheet.c
@@ -371,6 +371,7 @@ static void test_wiznavigation(void)
DestroyWindow(hdlg);
}
+
static void test_buttons(void)
{
HPROPSHEETPAGE hpsp[1];
@@ -436,6 +437,94 @@ static void test_buttons(void)
DestroyWindow(hdlg);
}
+BOOL add_button_has_been_pressed;
+
+INT_PTR CALLBACK
+page_with_custom_default_button_dlg_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ switch (msg)
+ {
+ case WM_COMMAND:
+ switch(LOWORD(wparam))
+ {
+ case IDC_PS_PUSHBUTTON1:
+ switch(HIWORD(wparam))
+ {
+ case BN_CLICKED:
+ add_button_has_been_pressed = TRUE;
+ return TRUE;
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static void test_custom_default_button(void)
+{
+ HWND hdlg;
+ PROPSHEETPAGEA psp[1];
+ PROPSHEETHEADERA psh;
+ MSG msg;
+ LRESULT result;
+
+ psp[0].dwSize = sizeof (PROPSHEETPAGEA);
+ psp[0].dwFlags = PSP_USETITLE;
+ psp[0].hInstance = GetModuleHandleA(NULL);
+ U(psp[0]).pszTemplate = MAKEINTRESOURCE(IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON);
+ U2(psp[0]).pszIcon = NULL;
+ psp[0].pfnDlgProc = page_with_custom_default_button_dlg_proc;
+ psp[0].pszTitle = "Page1";
+ psp[0].lParam = 0;
+
+ psh.dwSize = sizeof (PROPSHEETHEADERA);
+ psh.dwFlags = PSH_PROPSHEETPAGE | PSH_MODELESS;
+ psh.hwndParent = GetDesktopWindow();
+ psh.hInstance = GetModuleHandleA(NULL);
+ U(psh).pszIcon = NULL;
+ psh.pszCaption = "PropertySheet1";
+ psh.nPages = 1;
+ U3(psh).ppsp = psp;
+ U2(psh).nStartPage = 0;
+
+ /* The goal of the test is to make sure that the Add button is pressed
+ * when the ENTER key is pressed and a different control, a combobox,
+ * has the keyboard focus. */
+ add_button_has_been_pressed = FALSE;
+
+ /* Create the modeless property sheet. */
+ hdlg = (HWND)PropertySheetA(&psh);
+ ok(hdlg != INVALID_HANDLE_VALUE, "Cannot create the property sheet\n");
+
+ /* Set the Add button as the default button. */
+ SendMessage(hdlg, DM_SETDEFID, (WPARAM)IDC_PS_PUSHBUTTON1, 0);
+
+ /* Make sure the default button is the Add button. */
+ result = SendMessage(hdlg, DM_GETDEFID, 0, 0);
+ ok(DC_HASDEFID == HIWORD(result), "The property sheet does not have a default button\n");
+ ok(IDC_PS_PUSHBUTTON1 == LOWORD(result), "The default button is not the Add button\n");
+
+ /* At this point, the combobox should have keyboard focus, so we press ENTER.
+ * Pull the lever, Kronk! */
+ keybd_event(VK_RETURN, 0, 0, 0);
+
+ /* Process all the messages in the queue for this thread. */
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if (!PropSheet_IsDialogMessage(hdlg, &msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ todo_wine
+ ok(add_button_has_been_pressed, "The Add button has not been pressed!\n");
+
+ DestroyWindow(hdlg);
+}
+
START_TEST(propsheet)
{
test_title();
@@ -443,4 +532,5 @@ START_TEST(propsheet)
test_disableowner();
test_wiznavigation();
test_buttons();
+ test_custom_default_button();
}
diff --git a/dlls/comctl32/tests/resources.h b/dlls/comctl32/tests/resources.h
index 8459fc8..beabce5 100644
--- a/dlls/comctl32/tests/resources.h
+++ b/dlls/comctl32/tests/resources.h
@@ -36,9 +36,14 @@
#define IDD_PROP_PAGE_RADIO 32
#define IDD_PROP_PAGE_EXIT 33
+#define IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON 34
+
#define IDC_PS_EDIT1 1000
#define IDC_PS_EDIT2 1001
#define IDC_PS_RADIO1 1010
#define IDC_PS_RADIO2 1011
+#define IDC_PS_COMBO1 1020
+#define IDC_PS_PUSHBUTTON1 1021
+
#endif /* __WINE_COMCTL32_TEST_RESOURCES_H */
diff --git a/dlls/comctl32/tests/rsrc.rc b/dlls/comctl32/tests/rsrc.rc
index 06e382e..c817acd 100644
--- a/dlls/comctl32/tests/rsrc.rc
+++ b/dlls/comctl32/tests/rsrc.rc
@@ -79,3 +79,11 @@ IDB_BITMAP_128x15 BITMAP bmp128x15.bmp
/* @makedep: bmp80x15.bmp */
IDB_BITMAP_80x15 BITMAP bmp80x15.bmp
+
+IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON DIALOG DISCARDABLE 5, 43, 227, 215
+STYLE WS_CHILD | WS_DISABLED
+FONT 8, "MS Shell Dlg"
+{
+ COMBOBOX IDC_PS_COMBO1, 16, 68, 140, 14, CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Add", IDC_PS_PUSHBUTTON1, 164, 68, 40, 13
+}
--
1.7.0.4
More information about the wine-patches
mailing list