From: Joachim Priesner Subject: [2/5] comctl32: Add and fix tests for invalid TaskDialogIndirect arguments (try 3) Message-Id: <201502261656.55596.joachim.priesner@web.de> Date: Thu, 26 Feb 2015 16:56:54 +0100 Try 3 that fixes more issues found by Nikolay Sivov and removes the tests for the invalid resource string. --- dlls/comctl32/taskdialog.c | 5 +++++ dlls/comctl32/tests/taskdialog.c | 48 +++++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 760a984..84e3e76 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -32,6 +32,11 @@ HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, int *pnBu INT ret; FIXME("%p, %p, %p, %p\n", pTaskConfig, pnButton, pnRadioButton, pfVerificationFlagChecked); + if (pnButton) *pnButton = 0; + + if (!pTaskConfig || pTaskConfig->cbSize != sizeof(TASKDIALOGCONFIG)) + return E_INVALIDARG; + if (pTaskConfig->dwCommonButtons & TDCBF_YES_BUTTON && pTaskConfig->dwCommonButtons & TDCBF_NO_BUTTON && pTaskConfig->dwCommonButtons & TDCBF_CANCEL_BUTTON) diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c index 81260a3..7e53fee 100644 --- a/dlls/comctl32/tests/taskdialog.c +++ b/dlls/comctl32/tests/taskdialog.c @@ -23,22 +23,40 @@ #include "wine/test.h" #include "v6util.h" +HMODULE hComctl32; +HRESULT (WINAPI *pTaskDialogIndirect)(const TASKDIALOGCONFIG*, int*, int*, BOOL*); + static void test_TaskDialogIndirect(void) { - HINSTANCE hinst; - void *ptr, *ptr2; + HRESULT result; + TASKDIALOGCONFIG config; + int nButton; + void *ptr; - hinst = LoadLibraryA("comctl32.dll"); + ptr = GetProcAddress(hComctl32, (const CHAR*)345); + ok(ptr == pTaskDialogIndirect, "got wrong pointer for ordinal 345, %p expected %p\n", ptr, pTaskDialogIndirect); - ptr = GetProcAddress(hinst, "TaskDialogIndirect"); - if (!ptr) - { - win_skip("TaskDialogIndirect not exported by name\n"); - return; - } + nButton = 1; + result = pTaskDialogIndirect(NULL, &nButton, NULL, NULL); + ok(result == E_INVALIDARG, + "pTaskConfig == NULL: got result %#x, expected E_INVALIDARG\n", result); + ok(nButton == 0, "pTaskConfig == NULL: got nButton = %#x, expected 0\n", nButton); + + ZeroMemory(&config, sizeof(TASKDIALOGCONFIG)); + config.cbSize = 0; + result = pTaskDialogIndirect(&config, NULL, NULL, NULL); + ok(result == E_INVALIDARG, + "pTaskConfig.size == 0: got result %#x, expected E_INVALIDARG\n", result); - ptr2 = GetProcAddress(hinst, (const CHAR*)345); - ok(ptr == ptr2, "got wrong pointer for ordinal 345, %p expected %p\n", ptr2, ptr); + config.cbSize = sizeof(TASKDIALOGCONFIG) - 1; + result = pTaskDialogIndirect(&config, NULL, NULL, NULL); + ok(result == E_INVALIDARG, "pTaskConfig.size == sizeof(TASKDIALOGCONFIG) - 1: " + "got result %#x, expected E_INVALIDARG\n", result); + + config.cbSize = sizeof(TASKDIALOGCONFIG) + 1; + result = pTaskDialogIndirect(&config, NULL, NULL, NULL); + ok(result == E_INVALIDARG, "pTaskConfig.size == sizeof(TASKDIALOGCONFIG) + 1: " + "got result %#x, expected E_INVALIDARG\n", result); } START_TEST(taskdialog) @@ -49,6 +67,14 @@ START_TEST(taskdialog) if (!load_v6_module(&ctx_cookie, &hCtx)) return; + hComctl32 = GetModuleHandleA("comctl32.dll"); + pTaskDialogIndirect = (void*)GetProcAddress(hComctl32, "TaskDialogIndirect"); + if (!pTaskDialogIndirect) + { + win_skip("TaskDialogIndirect() is missing. Skipping the tests\n"); + return; + } + test_TaskDialogIndirect(); unload_v6_module(ctx_cookie, hCtx); -- 1.8.4.5