[10/18] comctl32: TaskDialog - Changed the way tests work, allow them to send messages
Fabian Maurer
dark.shadow4 at web.de
Fri Feb 24 14:04:04 CST 2017
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
dlls/comctl32/tests/taskdialog.c | 71 ++++++++++++++++++++++++++++++++++++----
1 file changed, 65 insertions(+), 6 deletions(-)
diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c
index 5b593ecd90..e02fe41817 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -36,13 +36,22 @@ static HRESULT (WINAPI *pTaskDialogIndirect)(const TASKDIALOGCONFIG *, int *, in
typedef struct
{
- UINT msg;
- WPARAM wparam;
- LPARAM lparam;
+ UINT msg;
+ WPARAM wparam;
+ LPARAM lparam;
+ HRESULT ret;
struct list entry;
}message_data;
+typedef struct
+{
+ UINT message;
+ WPARAM wparam;
+ LPARAM lparam;
+ const CHAR *title_target; /* control text, 0 means it's send to the dialog form instead */
+}message_send_data;
+
static struct list messages = LIST_INIT(messages);
/* Message lists to test against */
@@ -55,6 +64,33 @@ static const message_data mes_simple_show[] = {
{ TDN_NO_MORE_MESSAGES }
};
+
+/* Our only way to get a button handle, since GetDlgItem and FindWindowEx don't work for the official taskdialog */
+
+static HWND taskdialog_child;
+BOOL CALLBACK enum_taskdialog_children_proc(HWND hwnd, LPARAM lParam)
+{
+ CHAR text[100];
+ const CHAR *title = (const CHAR *)lParam;
+
+ GetWindowTextA(hwnd, text, sizeof(text));
+
+ if(lstrcmpA(text, title) == 0)
+ {
+ taskdialog_child = hwnd;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static HWND get_child_from_title(HWND hwnd_parent, const CHAR *title)
+{
+ taskdialog_child = NULL;
+ EnumChildWindows(hwnd_parent, enum_taskdialog_children_proc, (LPARAM)title);
+ return taskdialog_child;
+}
+
/* Functions handling message processing */
static void message_add(UINT msg, WPARAM wparam, LPARAM lparam)
@@ -125,19 +161,42 @@ static void ok_sequence_(const message_data *expected_list, const char *file, in
}
static LONG_PTR backup_ref_data; /* Copy of dwRefData to test against */
+static const message_data *message_list;
+static const message_send_data *message_send_list;
static HRESULT CALLBACK TaskDialogCallbackProc(HWND hwnd, UINT uNotification, WPARAM wParam,
LPARAM lParam, LONG_PTR dwRefData)
{
+ int max_messages = 0;
+ int message_number = list_count(&messages);
+
message_add(uNotification, wParam, lParam);
ok(backup_ref_data == dwRefData, "dwRefData is wrong, expected %lu, got %lu\n", backup_ref_data, dwRefData);
- if(uNotification == TDN_CREATED)
+ if(uNotification == TDN_CREATED) /* Send test messages */
{
- PostMessageW(hwnd, WM_KEYDOWN, VK_RETURN, 0);
+ const message_send_data *message = message_send_list;
+ while(message->message) /* Iterate over all messages */
+ {
+ if(message->title_target)
+ {
+ HWND hwndChild = get_child_from_title(hwnd, message->title_target);
+ ok(hwndChild != NULL, "Can't find child window.\n");
+ PostMessageW(hwndChild, message->message, message->wparam, message->lparam);
+ }
+ else
+ PostMessageW(hwnd, message->message, message->wparam, message->lparam);
+
+ message++;
+ }
}
- return S_OK;
+
+ /* Return the value we specified for that message */
+ while(message_list[max_messages].msg != TDN_NO_MORE_MESSAGES) max_messages++;
+ if(message_number < max_messages)
+ return message_list[message_number].ret;
+ return S_OK; /* Fallback in case we got a message mismatch */
}
static void test_TaskDialogIndirect(void)
--
2.11.1
More information about the wine-patches
mailing list