Also, add todo'd conformance tests for converting to and from `VT_ARRAY | VT_UI1` values.
-- v2: propsys/tests: Add test for PropVariantToGUID with VT_ARRAY | VT_UI1 values.
From: Vibhav Pant vibhavp@gmail.com
--- dlls/propsys/tests/propsys.c | 86 ++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index 948ae3969aa..25675d67e50 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -1613,11 +1613,97 @@ static void test_PropVariantChangeType_R8(void) "Unexpected value %f.\n", dest.dblVal); }
+static void test_PropVariantChangeType_CLSID(void) +{ + static const struct { + const WCHAR *str; + const GUID *guid; + HRESULT hr; + } test_cases[] = { + {dummy_guid_str, &dummy_guid, S_OK}, + {L"{deadbeef-dead-beef-dead-beefcafebabe}", &dummy_guid, S_OK}, + {L"DEADBEEF-DEAD-BEEF-DEAD-BEEFCAFEBABE", NULL, E_INVALIDARG}, + {L"foo", NULL, E_INVALIDARG}, + {L"", NULL, E_INVALIDARG}, + }; + SAFEARRAYBOUND arrbounds; + PROPVARIANT src, dest; + SAFEARRAY *arr; + HRESULT hr; + void *buf; + SIZE_T i; + + for (i = 0; i < ARRAY_SIZE(test_cases); i++) + { + winetest_push_context("test_cases[%Iu]", i); + PropVariantInit(&src); + src.vt = VT_LPWSTR; + src.pwszVal = CoTaskMemAlloc((wcslen(test_cases[i].str) + 1) * sizeof(WCHAR)); + wcscpy(src.pwszVal, test_cases[i].str); + hr = PropVariantChangeType(&dest, &src, 0, VT_CLSID); + todo_wine + ok(hr == test_cases[i].hr, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + ok(dest.vt == VT_CLSID, "Unexecpted type %d.\n", dest.vt); + ok(IsEqualGUID(dest.puuid, test_cases[i].guid), "Unexpected value %s.\n", debugstr_guid(dest.puuid)); + } + + PropVariantClear(&src); + PropVariantClear(&dest); + src.vt = VT_BSTR; + src.bstrVal = SysAllocString(test_cases[i].str); + hr = PropVariantChangeType(&dest, &src, 0, VT_CLSID); + todo_wine + ok(hr == test_cases[i].hr, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + ok(dest.vt == VT_CLSID, "Unexpected type %d.\n", dest.vt); + ok(IsEqualGUID(dest.puuid, test_cases[i].guid), "Unexpected value %s.\n", debugstr_guid(dest.puuid)); + } + PropVariantClear(&src); + PropVariantClear(&dest); + winetest_pop_context(); + } + + arrbounds.lLbound = 0; + arrbounds.cElements = sizeof(GUID); + arr = SafeArrayCreate(VT_UI1, 1, &arrbounds); + ok(!!arr, "SafeArrayCreate failed.\n"); + hr = SafeArrayAccessData(arr, &buf); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + memcpy(buf, &dummy_guid, sizeof(GUID)); + hr = SafeArrayUnaccessData(arr); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + src.vt = VT_ARRAY | VT_UI1; + src.parray = arr; + hr = PropVariantChangeType(&dest, &src, 0, VT_CLSID); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + ok(dest.vt == VT_CLSID, "Unexpected type %d.\n", dest.vt); + ok(IsEqualGUID(dest.puuid, &dummy_guid), "Unexpected value %s.\n", debugstr_guid(dest.puuid)); + } + PropVariantClear(&src); + PropVariantClear(&dest); + + hr = InitPropVariantFromCLSID(&dummy_guid, &src); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = PropVariantChangeType(&dest, &src, 0, VT_CLSID); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(dest.vt == VT_CLSID, "Unexpected type %d.\n", dest.vt); + ok(IsEqualGUID(dest.puuid, &dummy_guid), "Unexpected value %s.\n", debugstr_guid(dest.puuid)); + PropVariantClear(&src); + PropVariantClear(&dest); +} + static void test_PropVariantChangeType(void) { test_PropVariantChangeType_LPWSTR(); test_PropVariantChangeType_UI4(); test_PropVariantChangeType_R8(); + test_PropVariantChangeType_CLSID(); }
static void test_InitPropVariantFromCLSID(void)
From: Vibhav Pant vibhavp@gmail.com
--- dlls/propsys/propvar.c | 8 ++++++++ dlls/propsys/tests/propsys.c | 6 ++---- 2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c index 342764a661c..e92e82744a4 100644 --- a/dlls/propsys/propvar.c +++ b/dlls/propsys/propvar.c @@ -767,6 +767,14 @@ HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT p return hr; }
+ case VT_CLSID: + { + GUID guid; + if (SUCCEEDED((hr = PropVariantToGUID(propvarSrc, &guid)))) + hr = InitPropVariantFromCLSID(&guid, ppropvarDest); + return hr; + } + default: FIXME("Unhandled dest type: %d\n", vt); return E_FAIL; diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index 25675d67e50..fe688920646 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -1641,8 +1641,7 @@ static void test_PropVariantChangeType_CLSID(void) src.pwszVal = CoTaskMemAlloc((wcslen(test_cases[i].str) + 1) * sizeof(WCHAR)); wcscpy(src.pwszVal, test_cases[i].str); hr = PropVariantChangeType(&dest, &src, 0, VT_CLSID); - todo_wine - ok(hr == test_cases[i].hr, "Unexpected hr %#lx.\n", hr); + ok(hr == test_cases[i].hr, "Unexpected hr %#lx.\n", hr); if (SUCCEEDED(hr)) { ok(dest.vt == VT_CLSID, "Unexecpted type %d.\n", dest.vt); @@ -1654,8 +1653,7 @@ static void test_PropVariantChangeType_CLSID(void) src.vt = VT_BSTR; src.bstrVal = SysAllocString(test_cases[i].str); hr = PropVariantChangeType(&dest, &src, 0, VT_CLSID); - todo_wine - ok(hr == test_cases[i].hr, "Unexpected hr %#lx.\n", hr); + ok(hr == test_cases[i].hr, "Unexpected hr %#lx.\n", hr); if (SUCCEEDED(hr)) { ok(dest.vt == VT_CLSID, "Unexpected type %d.\n", dest.vt);
From: Vibhav Pant vibhavp@gmail.com
--- dlls/propsys/tests/propsys.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index fe688920646..c00b5c0deb5 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -566,7 +566,10 @@ static void test_InitPropVariantFromBuffer(void)
static void test_PropVariantToGUID(void) { + SAFEARRAYBOUND arrbounds; PROPVARIANT propvar; + SAFEARRAY *arr; + void *buf; VARIANT var; GUID guid; HRESULT hres; @@ -635,6 +638,25 @@ static void test_PropVariantToGUID(void) ok(hres == S_OK, "PropVariantToGUID failed %lx\n", hres); ok(IsEqualGUID(&dummy_guid, &guid), "incorrect GUID created: %s\n", wine_dbgstr_guid(&guid)); PropVariantClear(&propvar); + + arrbounds.lLbound = 0; + arrbounds.cElements = sizeof(GUID); + arr = SafeArrayCreate(VT_UI1, 1, &arrbounds); + ok(!!arr, "SafeArrayCreate failed\n"); + hres = SafeArrayAccessData(arr, &buf); + ok(hres == S_OK, "SafeArrayAccessData failed %lx\n", hres); + memcpy(buf, &dummy_guid, sizeof(GUID)); + hres = SafeArrayUnaccessData(arr); + ok(hres == S_OK, "SafeArrayUnaccessData failed %lx\n", hres); + propvar.vt = VT_ARRAY | VT_UI1; + propvar.parray = arr; + memset(&guid, 0, sizeof(guid)); + hres = PropVariantToGUID(&propvar, &guid); + todo_wine + ok(hres == S_OK, "PropVariantToGUID failed %lx\n", hres); + if (SUCCEEDED(hres)) + ok(IsEqualGUID(&guid, &dummy_guid), "incorrect GUID created: %s\n", debugstr_guid(&guid)); + PropVariantClear(&propvar); }
static void test_PropVariantToStringAlloc(void)
This merge request was approved by Nikolay Sivov.