sti: test behavior of creation with the A/W functions versus STI_VERSION_FLAG_UNICODE (try 2)

Damjan Jovanovic damjan.jov at gmail.com
Sat Sep 26 10:59:54 CDT 2009


Changelog:
* sti: test behavior of creation with the A/W functions versus
STI_VERSION_FLAG_UNICODE

Try 2 adds a licence header, casts the return value of GetProcAddress
to (void*), and names the test file sti.c.

Does not include changes to configure.

Damjan Jovanovic
-------------- next part --------------
diff --git a/configure.ac b/configure.ac
index 0f37bc7..cc29d87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2436,6 +2436,7 @@ WINE_CONFIG_MAKEFILE([dlls/spoolss/tests/Makefile],[dlls/Maketest.rules],[dlls],
 WINE_CONFIG_MAKEFILE([dlls/stdole2.tlb/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/stdole32.tlb/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/sti/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
+WINE_CONFIG_MAKEFILE([dlls/sti/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
 WINE_CONFIG_MAKEFILE([dlls/storage.dll16/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS],[enable_win16])
 WINE_CONFIG_MAKEFILE([dlls/stress.dll16/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS],[enable_win16])
 WINE_CONFIG_MAKEFILE([dlls/strmiids/Makefile],[dlls/Makeimplib.rules],[dlls],[ALL_IMPLIB_DIRS])
diff --git a/dlls/sti/tests/Makefile.in b/dlls/sti/tests/Makefile.in
new file mode 100644
index 0000000..989a355
--- /dev/null
+++ b/dlls/sti/tests/Makefile.in
@@ -0,0 +1,15 @@
+EXTRADEFS = -DCOM_NO_WINDOWS_H
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL    = sti.dll
+IMPORTS   = ole32 kernel32
+EXTRALIBS = -luuid
+
+CTESTS = \
+	sti.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/sti/tests/sti.c b/dlls/sti/tests/sti.c
new file mode 100644
index 0000000..0c89de7
--- /dev/null
+++ b/dlls/sti/tests/sti.c
@@ -0,0 +1,157 @@
+/*
+ *    General still image implementation
+ *
+ * Copyright 2009 Damjan Jovanovic
+ *
+ * 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 <stdarg.h>
+#include <assert.h>
+#include "windef.h"
+#include "winbase.h"
+#define COBJMACROS
+#include <initguid.h>
+#include <sti.h>
+#include <guiddef.h>
+#include <devguid.h>
+#include <stdio.h>
+
+#include "wine/test.h"
+
+
+
+HMODULE sti_dll;
+HRESULT (WINAPI *pStiCreateInstance)(HINSTANCE,DWORD,PSTIW*,LPUNKNOWN);
+HRESULT (WINAPI *pStiCreateInstanceA)(HINSTANCE,DWORD,PSTIA*,LPUNKNOWN);
+HRESULT (WINAPI *pStiCreateInstanceW)(HINSTANCE,DWORD,PSTIW*,LPUNKNOWN);
+
+static BOOL init_function_pointers()
+{
+    sti_dll = LoadLibrary("sti.dll");
+    if (sti_dll)
+    {
+        pStiCreateInstance = (void*)
+            GetProcAddress(sti_dll, "StiCreateInstance");
+        pStiCreateInstanceA = (void*)
+            GetProcAddress(sti_dll, "StiCreateInstanceA");
+        pStiCreateInstanceW = (void*)
+            GetProcAddress(sti_dll, "StiCreateInstanceW");
+        return TRUE;
+    }
+    return FALSE;
+}
+
+void test_version_flag_versus_aw(void)
+{
+    HRESULT hr;
+
+    /* Who wins, the STI_VERSION_FLAG_UNICODE or the A/W function? And what about the neutral StiCreateInstance function? */
+
+    if (pStiCreateInstance)
+    {
+        PSTIW pStiW;
+        hr = pStiCreateInstance(GetModuleHandle(NULL), STI_VERSION_REAL, &pStiW, NULL);
+        if (SUCCEEDED(hr))
+        {
+            IUnknown *pUnknown;
+            hr = IUnknown_QueryInterface((IUnknown*)pStiW, &IID_IStillImageW, (void**)&pUnknown);
+            if (SUCCEEDED(hr))
+            {
+                ok(pUnknown == (IUnknown*)pStiW, "created interface was not IID_IStillImageW\n");
+                IUnknown_Release(pUnknown);
+            }
+            IUnknown_Release((IUnknown*)pStiW);
+        }
+        else
+            todo_wine ok(0, "could not create StillImageA, hr = 0x%X\n", hr);
+        hr = pStiCreateInstance(GetModuleHandle(NULL), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, &pStiW, NULL);
+        if (SUCCEEDED(hr))
+        {
+            IUnknown *pUnknown;
+            hr = IUnknown_QueryInterface((IUnknown*)pStiW, &IID_IStillImageW, (void**)&pUnknown);
+            if (SUCCEEDED(hr))
+            {
+                ok(pUnknown == (IUnknown*)pStiW, "created interface was not IID_IStillImageW\n");
+                IUnknown_Release(pUnknown);
+            }
+            IUnknown_Release((IUnknown*)pStiW);
+        }
+        else
+            todo_wine ok(0, "could not create StillImageW, hr = 0x%X\n", hr);
+    }
+    else
+        skip("No StiCreateInstance function\n");
+
+    if (pStiCreateInstanceA)
+    {
+        PSTIA pStiA;
+        hr = pStiCreateInstanceA(GetModuleHandle(NULL), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, &pStiA, NULL);
+        if (SUCCEEDED(hr))
+        {
+            IUnknown *pUnknown;
+            hr = IUnknown_QueryInterface((IUnknown*)pStiA, &IID_IStillImageA, (void**)&pUnknown);
+            if (SUCCEEDED(hr))
+            {
+                ok(pUnknown == (IUnknown*)pStiA, "created interface was not IID_IStillImageA\n");
+                IUnknown_Release(pUnknown);
+            }
+            IUnknown_Release((IUnknown*)pStiA);
+        }
+        else
+            todo_wine ok(0, "could not create StillImageA, hr = 0x%X\n", hr);
+    }
+    else
+        skip("No StiCreateInstanceA function\n");
+
+    if (pStiCreateInstanceW)
+    {
+        PSTIW pStiW;
+        hr = pStiCreateInstanceW(GetModuleHandle(NULL), STI_VERSION_REAL, &pStiW, NULL);
+        if (SUCCEEDED(hr))
+        {
+            IUnknown *pUnknown;
+            hr = IUnknown_QueryInterface((IUnknown*)pStiW, &IID_IStillImageW, (void**)&pUnknown);
+            if (SUCCEEDED(hr))
+            {
+                ok(pUnknown == (IUnknown*)pStiW, "created interface was not IID_IStillImageW\n");
+                IUnknown_Release((IUnknown*)pUnknown);
+            }
+            IUnknown_Release((IUnknown*)pStiW);
+        }
+        else
+            todo_wine ok(0, "could not create StillImageW, hr = 0x%X\n", hr);
+    }
+    else
+        skip("No StiCreateInstanceW function\n");
+}
+
+START_TEST(sti)
+{
+    if (SUCCEEDED(CoInitialize(NULL)))
+    {
+        if (init_function_pointers())
+        {
+            test_version_flag_versus_aw();
+            FreeLibrary(sti_dll);
+        }
+        else
+            skip("could not load sti.dll\n");
+        CoUninitialize();
+    }
+    else
+        skip("CoInitialize failed\n");
+}
+


More information about the wine-patches mailing list