comctl32/tests: Added first TaskDialog test.

Patrick Gauthier webmaster at korosoft.net
Sat Jun 11 23:49:51 CDT 2011


This tests for the existence of the function and whether the ordinals right.
---
 dlls/comctl32/tests/Makefile.in |    1 +
 dlls/comctl32/tests/taskdlg.c   |   76 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 0 deletions(-)
 create mode 100644 dlls/comctl32/tests/taskdlg.c

diff --git a/dlls/comctl32/tests/Makefile.in b/dlls/comctl32/tests/Makefile.in
index cb4f3ff..4d2234a 100644
--- a/dlls/comctl32/tests/Makefile.in
+++ b/dlls/comctl32/tests/Makefile.in
@@ -18,6 +18,7 @@ C_SRCS = \
 	status.c \
 	subclass.c \
 	tab.c \
+	taskdlg.c \
 	toolbar.c \
 	tooltips.c \
 	trackbar.c \
diff --git a/dlls/comctl32/tests/taskdlg.c b/dlls/comctl32/tests/taskdlg.c
new file mode 100644
index 0000000..edc8e18
--- /dev/null
+++ b/dlls/comctl32/tests/taskdlg.c
@@ -0,0 +1,76 @@
+/* Unit test suite for Task Dialogs.
+ *
+ * Copyright 2011 Patrick Gauthier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windows.h>
+#include <commctrl.h>
+#include <assert.h>
+
+#include "wine/test.h"
+
+typedef HRESULT (WINAPI* TASKDIALOGPROC)(HWND, HINSTANCE, PCWSTR, PCWSTR, PCWSTR, TASKDIALOG_COMMON_BUTTON_FLAGS, PCWSTR, int*);
+typedef HRESULT (WINAPI* TASKDIALOGINDIRECTPROC)(const TASKDIALOGCONFIG*, int*, int* pnRadioButton, BOOL*);
+
+static TASKDIALOGINDIRECTPROC g_pTaskDialogIndirect;
+
+static void test_existence(void)
+{
+    static const WCHAR szComCtl32[] =
+        { 'C', 'O', 'M', 'C', 'T', 'L', '3', '2', 0 };
+
+    HMODULE hModComCtl32;
+    TASKDIALOGPROC pTdProcNamed, pTdProcOrdinal;
+    TASKDIALOGINDIRECTPROC pTdiProcNamed, pTdiProcOrdinal;
+    
+    /* Make sure the function exists and that it has the correct ordinal */
+    hModComCtl32 = GetModuleHandleW(szComCtl32);
+    ok(hModComCtl32 != NULL, "COMCTL32.DLL is not loaded!\n");
+    if (!hModComCtl32) return;
+
+    pTdProcNamed = (TASKDIALOGPROC) GetProcAddress(hModComCtl32, "TaskDialog");
+    pTdProcOrdinal = (TASKDIALOGPROC) GetProcAddress(hModComCtl32, (LPCSTR)344);
+    
+    pTdiProcNamed = (TASKDIALOGINDIRECTPROC) GetProcAddress(hModComCtl32, "TaskDialogIndirect");
+    pTdiProcOrdinal = (TASKDIALOGINDIRECTPROC) GetProcAddress(hModComCtl32, (LPCSTR)345);
+        
+    /* If both named functions are absent, we are most likely running on a */
+    /* version of windows that does not support them, so skip the test. */
+    if (!(pTdProcNamed && pTdiProcNamed))
+    {
+        win_skip("TaskDialog APIs not present!\n");
+        return;
+    }
+    
+    /* Make sure the named and ordinal function pointers are the same. For */
+    /* some reason, the PSDK's .lib files makes them be imported by ordinal */
+    /* (tested on VS2008) */
+    ok(pTdProcNamed == pTdProcOrdinal, "TaskDialog != #344\n");
+    ok(pTdiProcNamed == pTdiProcOrdinal, "TaskDialogIndirect != #345\n");
+    
+    /* Store the function pointer for further tests */
+    g_pTaskDialogIndirect = pTdiProcNamed;
+}
+
+START_TEST(taskdlg)
+{
+    /* Force COMCTL32 to be loaded */
+    InitCommonControls();
+    
+    /* Tests */
+    test_existence();
+}
-- 
1.7.5.3


--Boundary_(ID_j6QFcBTWOzdL0PXccTWCpA)--



More information about the wine-patches mailing list