[2/5] comctl32: Add and fix tests for invalid TaskDialogIndirect arguments (try 2)
Joachim Priesner
joachim.priesner at web.de
Mon Feb 23 06:41:44 CST 2015
Try 2 that fixes issues found by Nikolay Sivov. Also add a test for an
invalid resource string passed as pszContent, which does not yet pass on
Wine (but will be fixed in the next patch of this series).
---
dlls/comctl32/taskdialog.c | 5 ++++
dlls/comctl32/tests/taskdialog.c | 64 +++++++++++++++++++++++++++++++++-------
2 files changed, 59 insertions(+), 10 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..bfec670 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -23,22 +23,52 @@
#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;
+
+ ptr = GetProcAddress(hComctl32, (const CHAR*)345);
+ ok(ptr == pTaskDialogIndirect, "got wrong pointer for ordinal 345, %p expected %p\n", ptr, pTaskDialogIndirect);
+
+ 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);
- hinst = LoadLibraryA("comctl32.dll");
+ 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);
- ptr = GetProcAddress(hinst, "TaskDialogIndirect");
- if (!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);
+
+ /* Skip this test on Wine. Cannot use todo_wine because the TaskDialogIndirect call
+ * does not fail, leading to a modal dialog being displayed. */
+ if (strcmp(winetest_platform, "wine"))
{
- win_skip("TaskDialogIndirect not exported by name\n");
- return;
+ config.cbSize = sizeof(TASKDIALOGCONFIG);
+ config.hInstance = GetModuleHandleW(NULL);
+ config.pszContent = MAKEINTRESOURCEW(-1000); /* invalid resource */
+ result = pTaskDialogIndirect(&config, NULL, NULL, NULL);
+ ok(HRESULT_CODE(result) == ERROR_RESOURCE_NAME_NOT_FOUND, "invalid pszContent: "
+ "got result %#x, expected ERROR_RESOURCE_NAME_NOT_FOUND\n", result);
}
-
- ptr2 = GetProcAddress(hinst, (const CHAR*)345);
- ok(ptr == ptr2, "got wrong pointer for ordinal 345, %p expected %p\n", ptr2, ptr);
}
START_TEST(taskdialog)
@@ -49,6 +79,20 @@ START_TEST(taskdialog)
if (!load_v6_module(&ctx_cookie, &hCtx))
return;
+ hComctl32 = LoadLibraryA("comctl32.dll");
+ if (!hComctl32)
+ {
+ skip("Failed to load comctl32.dll. Skipping the test\n");
+ return;
+ }
+
+ 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
More information about the wine-patches
mailing list