Piotr Caban : propsys/tests: Added InitVariantFromGUIDAsString tests.

Alexandre Julliard julliard at winehq.org
Fri Sep 16 13:28:31 CDT 2011


Module: wine
Branch: master
Commit: 96427780894897c84646ba1a8060309b79ac4e25
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=96427780894897c84646ba1a8060309b79ac4e25

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Sep 16 11:20:18 2011 +0200

propsys/tests: Added InitVariantFromGUIDAsString tests.

---

 dlls/propsys/tests/Makefile.in |    2 +-
 dlls/propsys/tests/propsys.c   |   59 ++++++++++++++++++++++++++++++++++++++++
 include/propvarutil.h          |    2 +
 3 files changed, 62 insertions(+), 1 deletions(-)

diff --git a/dlls/propsys/tests/Makefile.in b/dlls/propsys/tests/Makefile.in
index 8db4008..312a3a9 100644
--- a/dlls/propsys/tests/Makefile.in
+++ b/dlls/propsys/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL   = propsys.dll
-IMPORTS   = propsys ole32
+IMPORTS   = propsys ole32 oleaut32
 
 C_SRCS = \
 	propsys.c
diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c
index e0895f3..1e63348 100644
--- a/dlls/propsys/tests/propsys.c
+++ b/dlls/propsys/tests/propsys.c
@@ -24,10 +24,13 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#define NONAMELESSUNION
+
 #include "windef.h"
 #include "winbase.h"
 #include "objbase.h"
 #include "propsys.h"
+#include "propvarutil.h"
 #include "initguid.h"
 #include "wine/test.h"
 
@@ -46,6 +49,13 @@ static char *show_guid(const GUID *guid, char *buf)
     return buf;
 }
 
+static int strcmp_wa(LPCWSTR strw, const char *stra)
+{
+    CHAR buf[512];
+    WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
+    return lstrcmpA(stra, buf);
+}
+
 static void test_PSStringFromPropertyKey(void)
 {
     static const WCHAR fillerW[] = {'X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X','X',
@@ -450,9 +460,58 @@ static void test_PSRefreshPropertySchema(void)
     CoUninitialize();
 }
 
+static void test_InitPropVariantFromGUIDAsString(void)
+{
+    PROPVARIANT propvar;
+    VARIANT var;
+    HRESULT hres;
+    int i;
+
+    const struct {
+        REFGUID guid;
+        const char *str;
+    } testcases[] = {
+        {&IID_NULL,             "{00000000-0000-0000-0000-000000000000}" },
+        {&dummy_guid,           "{DEADBEEF-DEAD-BEEF-DEAD-BEEFCAFEBABE}" },
+    };
+
+    hres = InitPropVariantFromGUIDAsString(NULL, &propvar);
+    ok(hres == E_FAIL, "InitPropVariantFromGUIDAsString returned %x\n", hres);
+
+    if(0) {
+        /* Returns strange data on Win7, crashes on older systems */
+        InitVariantFromGUIDAsString(NULL, &var);
+
+        /* Crashes on windows */
+        InitPropVariantFromGUIDAsString(&IID_NULL, NULL);
+        InitVariantFromGUIDAsString(&IID_NULL, NULL);
+    }
+
+    for(i=0; i<sizeof(testcases)/sizeof(testcases[0]); i++) {
+        memset(&propvar, 0, sizeof(PROPVARIANT));
+        hres = InitPropVariantFromGUIDAsString(testcases[i].guid, &propvar);
+        ok(hres == S_OK, "%d) InitPropVariantFromGUIDAsString returned %x\n", i, hres);
+        ok(propvar.vt == VT_LPWSTR, "%d) propvar.vt = %d\n", i, propvar.vt);
+        ok(!strcmp_wa(propvar.u.pwszVal, testcases[i].str), "%d) propvar.u.pwszVal = %s\n",
+                i, wine_dbgstr_w(propvar.u.pwszVal));
+        CoTaskMemFree(propvar.u.pwszVal);
+
+        memset(&var, 0, sizeof(VARIANT));
+        hres = InitVariantFromGUIDAsString(testcases[i].guid, &var);
+        ok(hres == S_OK, "%d) InitVariantFromGUIDAsString returned %x\n", i, hres);
+        ok(V_VT(&var) == VT_BSTR, "%d) V_VT(&var) = %d\n", i, V_VT(&var));
+        ok(SysStringLen(V_BSTR(&var)) == 38, "SysStringLen returned %d\n",
+                SysStringLen(V_BSTR(&var)));
+        ok(!strcmp_wa(V_BSTR(&var), testcases[i].str), "%d) V_BSTR(&var) = %s\n",
+                i, wine_dbgstr_w(V_BSTR(&var)));
+        VariantClear(&var);
+    }
+}
+
 START_TEST(propsys)
 {
     test_PSStringFromPropertyKey();
     test_PSPropertyKeyFromString();
     test_PSRefreshPropertySchema();
+    test_InitPropVariantFromGUIDAsString();
 }
diff --git a/include/propvarutil.h b/include/propvarutil.h
index e830885..4d2a9b4 100644
--- a/include/propvarutil.h
+++ b/include/propvarutil.h
@@ -37,6 +37,8 @@ typedef int PROPVAR_CHANGE_FLAGS;
 
 HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
                                      PROPVAR_CHANGE_FLAGS flags, VARTYPE vt);
+HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar);
+HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar);
 
 
 #ifdef __cplusplus




More information about the wine-cvs mailing list