comctl32/tests: Added first TaskDialog test.

Patrick Gauthier webmaster at korosoft.net
Sun Jun 12 20:51:03 CDT 2011


This tests for the existence of the function and whether the ordinals are right.
---
 dlls/comctl32/tests/Makefile.in |    1 +
 dlls/comctl32/tests/taskdlg.c   |   86 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 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..6f53cce
--- /dev/null
+++ b/dlls/comctl32/tests/taskdlg.c
@@ -0,0 +1,86 @@
+/* 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"
+#include "v6util.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 HMODULE g_hModComCtl32;
+static TASKDIALOGINDIRECTPROC g_pTaskDialogIndirect;
+
+static void test_existence(void)
+{
+    TASKDIALOGPROC pTdProcNamed, pTdProcOrdinal;
+    TASKDIALOGINDIRECTPROC pTdiProcNamed, pTdiProcOrdinal;
+        
+    /* Make sure the function exists and that it has the correct ordinal */
+    pTdProcNamed = (TASKDIALOGPROC) GetProcAddress(g_hModComCtl32, "TaskDialog");
+    pTdProcOrdinal = (TASKDIALOGPROC) GetProcAddress(g_hModComCtl32, (LPCSTR)344);
+    
+    pTdiProcNamed = (TASKDIALOGINDIRECTPROC) GetProcAddress(g_hModComCtl32, "TaskDialogIndirect");
+    pTdiProcOrdinal = (TASKDIALOGINDIRECTPROC) GetProcAddress(g_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)
+{
+    ULONG_PTR cookie;
+    HANDLE hCtx;
+
+    /* Enter activation context and load v6 */
+    if (!load_v6_module(&cookie, &hCtx))
+        return;
+    
+    g_hModComCtl32 = LoadLibraryA("COMCTL32");
+    ok(g_hModComCtl32 != NULL, "Failed to load COMCTL32 v6!");
+    if (!g_hModComCtl32)
+    {
+        unload_v6_module(cookie, hCtx);
+        return;
+    }
+    
+    /* Tests */
+    test_existence();
+    
+    /* Unload v6 and exit activation context */
+    FreeLibrary(g_hModComCtl32);
+    unload_v6_module(cookie, hCtx);
+}
-- 
1.7.5.3


--Boundary_(ID_0hJsgEZbQes7qBthIj4xnw)--



More information about the wine-patches mailing list