[2/5] comctl32: Add and fix tests for invalid TaskDialogIndirect arguments
Joachim Priesner
joachim.priesner at web.de
Thu Feb 19 06:22:53 CST 2015
---
dlls/comctl32/taskdialog.c | 5 ++++
dlls/comctl32/tests/taskdialog.c | 61 +++++++++++++++++++++++++++++++---------
2 files changed, 53 insertions(+), 13 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..af1563a 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -23,22 +23,42 @@
#include "wine/test.h"
#include "v6util.h"
-static void test_TaskDialogIndirect(void)
+HMODULE hComctl32;
+HRESULT (WINAPI *pTaskDialogIndirect)(const TASKDIALOGCONFIG*, int*, int*, BOOL*);
+
+static void test_TaskDialogIndirect_ProcAddr(void)
{
- HINSTANCE hinst;
- void *ptr, *ptr2;
+ void *ptr = GetProcAddress(hComctl32, (const CHAR*)345);
+ ok(ptr == pTaskDialogIndirect, "got wrong pointer for ordinal 345, %p expected %p\n", ptr, pTaskDialogIndirect);
+}
- hinst = LoadLibraryA("comctl32.dll");
+static void test_TaskDialogIndirect_InvalidParameters(void)
+{
+ HRESULT result;
+ TASKDIALOGCONFIG config;
+ int nButton;
- 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);
+
+ 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);
- 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);
}
START_TEST(taskdialog)
@@ -49,7 +69,22 @@ START_TEST(taskdialog)
if (!load_v6_module(&ctx_cookie, &hCtx))
return;
- test_TaskDialogIndirect();
+ 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_ProcAddr();
+ test_TaskDialogIndirect_InvalidParameters();
unload_v6_module(ctx_cookie, hCtx);
}
--
1.8.4.5
More information about the wine-patches
mailing list