ReactOS 0.4.15-dev-7674-gc0b4db1
propvariant.c File Reference
#include "windows.h"
#include "wtypes.h"
#include "ddeml.h"
#include "wine/test.h"
Include dependency graph for propvariant.c:

Go to the source code of this file.

Classes

struct  valid_mapping
 
struct  unk_impl
 
struct  _PMemoryAllocator_vtable
 
struct  _PMemoryAllocator
 

Macros

#define COBJMACROS
 
#define PROP_INV   0x7f
 
#define PROP_V0   0
 
#define PROP_V1   1
 
#define PROP_V1A   2
 
#define PROP_TODO   0x80
 

Typedefs

typedef struct _PMemoryAllocator PMemoryAllocator
 

Functions

static void expect (HRESULT hr, VARTYPE vt, BOOL copy, int line)
 
static void test_validtypes (void)
 
static struct unk_implimpl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI unk_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI unk_AddRef (IUnknown *iface)
 
static ULONG WINAPI unk_Release (IUnknown *iface)
 
static void test_copy (void)
 
static void *WINAPI PMemoryAllocator_Allocate (PMemoryAllocator *_this, ULONG cbSize)
 
static void WINAPI PMemoryAllocator_Free (PMemoryAllocator *_this, void *pv)
 
static void setup_vtable (struct _PMemoryAllocator_vtable *vtable)
 
static void test_propertytovariant (void)
 
static void test_varianttoproperty (void)
 
 START_TEST (propvariant)
 

Variables

static const struct valid_mapping valid_types []
 
static const charwine_vtypes [VT_CLSID+1]
 
static const IUnknownVtbl unk_vtbl
 
static const char serialized_empty []
 
static const char serialized_null []
 
static const char serialized_i4 []
 
static const char serialized_bstr_wc []
 
static const char serialized_bstr_mb []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file propvariant.c.

◆ PROP_INV

#define PROP_INV   0x7f

Definition at line 33 of file propvariant.c.

◆ PROP_TODO

#define PROP_TODO   0x80

Definition at line 40 of file propvariant.c.

◆ PROP_V0

#define PROP_V0   0

Definition at line 35 of file propvariant.c.

◆ PROP_V1

#define PROP_V1   1

Definition at line 37 of file propvariant.c.

◆ PROP_V1A

#define PROP_V1A   2

Definition at line 39 of file propvariant.c.

Typedef Documentation

◆ PMemoryAllocator

Function Documentation

◆ expect()

static void expect ( HRESULT  hr,
VARTYPE  vt,
BOOL  copy,
int  line 
)
static

Definition at line 138 of file propvariant.c.

139{
140 int idx = vt & VT_TYPEMASK;
141 BYTE flags;
142 const char *modifier;
143
144 if(vt & VT_BYREF)
145 {
146 flags = valid_types[idx].byref;
147 modifier = "byref";
148 }
149 else if(vt & VT_ARRAY)
150 {
151 flags = valid_types[idx].with_array;
152 modifier = "array";
153 }
154 else if(vt & VT_VECTOR)
155 {
156 flags = valid_types[idx].with_vector;
157 modifier = "vector";
158 }
159 else
160 {
161 flags = valid_types[idx].simple;
162 modifier = "simple";
163 }
164
165 if(flags == PROP_INV)
166 {
167 if (copy && (vt & VT_VECTOR))
168 ok(hr == DISP_E_BADVARTYPE || hr == STG_E_INVALIDPARAMETER, "%s (%s): got %08x (line %d)\n", wine_vtypes[idx], modifier, hr, line);
169 else
170 ok(hr == (copy ? DISP_E_BADVARTYPE : STG_E_INVALIDPARAMETER), "%s (%s): got %08x (line %d)\n", wine_vtypes[idx], modifier, hr, line);
171 }
172 else if(flags == PROP_V0)
173 ok(hr == S_OK, "%s (%s): got %08x\n", wine_vtypes[idx], modifier, hr);
175 {
176 if(hr != S_OK)
177 win_skip("%s (%s): unsupported\n", wine_vtypes[idx], modifier);
178 else ok(hr == S_OK, "%s (%s): got %08x\n", wine_vtypes[idx], modifier, hr);
179 }
180}
#define ok(value,...)
Definition: atltest.h:57
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
unsigned int idx
Definition: utils.c:41
@ VT_TYPEMASK
Definition: compat.h:2346
@ VT_BYREF
Definition: compat.h:2342
@ VT_ARRAY
Definition: compat.h:2341
@ VT_VECTOR
Definition: compat.h:2340
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:86
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:52
#define todo_wine_if(is_todo)
Definition: custom.c:76
#define PROP_V0
Definition: propvariant.c:35
#define PROP_INV
Definition: propvariant.c:33
static const struct valid_mapping valid_types[]
static const char * wine_vtypes[VT_CLSID+1]
Definition: propvariant.c:124
#define PROP_TODO
Definition: propvariant.c:40
#define win_skip
Definition: test.h:160
HRESULT hr
Definition: shlfolder.c:183
Definition: parser.c:49
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:2580
unsigned char BYTE
Definition: xxhash.c:193

◆ impl_from_IUnknown()

static struct unk_impl * impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 312 of file propvariant.c.

313{
314 return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
315}
Definition: api.c:544
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by unk_AddRef(), unk_QueryInterface(), and unk_Release().

◆ PMemoryAllocator_Allocate()

static void *WINAPI PMemoryAllocator_Allocate ( PMemoryAllocator _this,
ULONG  cbSize 
)
static

Definition at line 434 of file propvariant.c.

435{
436 return CoTaskMemAlloc(cbSize);
437}
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

Referenced by setup_vtable().

◆ PMemoryAllocator_Free()

static void WINAPI PMemoryAllocator_Free ( PMemoryAllocator _this,
void pv 
)
static

Definition at line 439 of file propvariant.c.

440{
441 CoTaskMemFree(pv);
442}
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442

Referenced by setup_vtable().

◆ setup_vtable()

static void setup_vtable ( struct _PMemoryAllocator_vtable vtable)
static

Definition at line 482 of file propvariant.c.

483{
486}
static void * vtable[]
Definition: typelib.c:1231
static void WINAPI PMemoryAllocator_Free(PMemoryAllocator *_this, void *pv)
Definition: propvariant.c:439
static void *WINAPI PMemoryAllocator_Allocate(PMemoryAllocator *_this, ULONG cbSize)
Definition: propvariant.c:434

Referenced by test_propertytovariant().

◆ START_TEST()

START_TEST ( propvariant  )

Definition at line 676 of file propvariant.c.

677{
679 test_copy();
682}
static void test_validtypes(void)
Definition: propvariant.c:182
static void test_copy(void)
Definition: propvariant.c:350
static void test_varianttoproperty(void)
Definition: propvariant.c:582
static void test_propertytovariant(void)
Definition: propvariant.c:523

◆ test_copy()

static void test_copy ( void  )
static

Definition at line 350 of file propvariant.c.

351{
352 static char szTestString[] = "Test String";
353 static WCHAR wszTestString[] = {'T','e','s','t',' ','S','t','r','i','n','g',0};
354 struct unk_impl unk_obj = {{&unk_vtbl}, 1};
355 PROPVARIANT propvarSrc;
356 PROPVARIANT propvarDst;
357 SAFEARRAY *sa;
358 SAFEARRAYBOUND sabound;
359 LONG saindex;
360 HRESULT hr;
361
362 propvarSrc.vt = VT_BSTR;
363 U(propvarSrc).bstrVal = SysAllocString(wszTestString);
364
365 hr = PropVariantCopy(&propvarDst, &propvarSrc);
366 ok(hr == S_OK, "PropVariantCopy(...VT_BSTR...) failed\n");
367 ok(!lstrcmpW(U(propvarSrc).bstrVal, U(propvarDst).bstrVal), "BSTR not copied properly\n");
369 ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n");
370 hr = PropVariantClear(&propvarDst);
371 ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n");
372
374 U(propvarSrc).pwszVal = wszTestString;
375 hr = PropVariantCopy(&propvarDst, &propvarSrc);
376 ok(hr == S_OK, "PropVariantCopy(...VT_LPWSTR...) failed\n");
377 ok(!lstrcmpW(U(propvarSrc).pwszVal, U(propvarDst).pwszVal), "Wide string not copied properly\n");
378 hr = PropVariantClear(&propvarDst);
379 ok(hr == S_OK, "PropVariantClear(...VT_LPWSTR...) failed\n");
380 memset(&propvarSrc, 0, sizeof(propvarSrc));
381
382 propvarSrc.vt = VT_LPSTR;
383 U(propvarSrc).pszVal = szTestString;
384 hr = PropVariantCopy(&propvarDst, &propvarSrc);
385 ok(hr == S_OK, "PropVariantCopy(...VT_LPSTR...) failed\n");
386 ok(!strcmp(U(propvarSrc).pszVal, U(propvarDst).pszVal), "String not copied properly\n");
387 hr = PropVariantClear(&propvarDst);
388 ok(hr == S_OK, "PropVariantClear(...VT_LPSTR...) failed\n");
389 memset(&propvarSrc, 0, sizeof(propvarSrc));
390
392 U(propvarSrc).punkVal = &unk_obj.IUnknown_iface;
393 hr = PropVariantCopy(&propvarDst, &propvarSrc);
394 ok(hr == S_OK, "PropVariantCopy(...VT_UNKNOWN...) failed: 0x%08x.\n", hr);
395 ok(U(propvarDst).punkVal == &unk_obj.IUnknown_iface, "Got wrong IUnknown pointer\n");
396 ok(unk_obj.ref == 2, "got wrong refcount: %d.\n", unk_obj.ref);
397 hr = PropVariantClear(&propvarDst);
398 ok(hr == S_OK, "PropVariantClear(...VT_UNKNOWN...) failed: 0x%08x.\n", hr);
399 ok(unk_obj.ref == 1, "got wrong refcount: %d.\n", unk_obj.ref);
400 memset(&propvarSrc, 0, sizeof(propvarSrc));
401
402 sabound.lLbound = 0;
403 sabound.cElements = 2;
404 sa = SafeArrayCreate(VT_UNKNOWN, 1, &sabound);
405 saindex = 0;
406 SafeArrayPutElement(sa, &saindex, &unk_obj.IUnknown_iface);
407 saindex = 1;
408 SafeArrayPutElement(sa, &saindex, &unk_obj.IUnknown_iface);
409 ok(unk_obj.ref == 3, "got wrong refcount: %d.\n", unk_obj.ref);
410
412 U(propvarSrc).parray = sa;
413 hr = PropVariantCopy(&propvarDst, &propvarSrc);
414 ok(hr == S_OK, "PropVariantCopy(...VT_ARRAY|VT_UNKNOWN...) failed: 0x%08x.\n", hr);
415 ok(unk_obj.ref == 5, "got wrong refcount: %d.\n", unk_obj.ref);
416 hr = PropVariantClear(&propvarDst);
417 ok(hr == S_OK, "PropVariantClear(...VT_ARRAY|VT_UNKNOWN...) failed: 0x%08x.\n", hr);
418 ok(unk_obj.ref == 3, "got wrong refcount: %d.\n", unk_obj.ref);
420 ok(hr == S_OK, "PropVariantClear(...VT_ARRAY|VT_UNKNOWN...) failed: 0x%08x.\n", hr);
421 ok(unk_obj.ref == 1, "got wrong refcount: %d.\n", unk_obj.ref);
422 memset(&propvarSrc, 0, sizeof(propvarSrc));
423}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define U(x)
Definition: wordpad.c:45
@ VT_BSTR
Definition: compat.h:2303
@ VT_LPSTR
Definition: compat.h:2324
@ VT_UNKNOWN
Definition: compat.h:2308
@ VT_LPWSTR
Definition: compat.h:2325
static REFPROPVARIANT propvarSrc
Definition: suminfo.c:85
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: ole2.c:2968
HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc)
Definition: ole2.c:3086
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:600
HRESULT WINAPI SafeArrayPutElement(SAFEARRAY *psa, LONG *rgIndices, void *pvData)
Definition: safearray.c:864
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
long LONG
Definition: pedump.c:60
static const IUnknownVtbl unk_vtbl
Definition: propvariant.c:343
#define memset(x, y, z)
Definition: compat.h:39
IUnknown IUnknown_iface
Definition: api.c:545
LONG ref
Definition: api.c:546
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_propertytovariant()

static void test_propertytovariant ( void  )
static

Definition at line 523 of file propvariant.c.

524{
525 HANDLE hole32;
526 BOOLEAN (__stdcall *pStgConvertPropertyToVariant)(const SERIALIZEDPROPERTYVALUE*,USHORT,PROPVARIANT*,PMemoryAllocator*);
527 PROPVARIANT propvar;
530 BOOLEAN ret;
531 static const WCHAR test_string[] = {'t','e','s','t',0};
532
533 hole32 = GetModuleHandleA("ole32");
534
535 pStgConvertPropertyToVariant = (void*)GetProcAddress(hole32, "StgConvertPropertyToVariant");
536
537 if (!pStgConvertPropertyToVariant)
538 {
539 win_skip("StgConvertPropertyToVariant not available\n");
540 return;
541 }
542
544 allocator.vt = &vtable;
545
546 ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_empty,
547 CP_WINUNICODE, &propvar, &allocator);
548
549 ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
550 ok(propvar.vt == VT_EMPTY, "unexpected vt %x\n", propvar.vt);
551
552 ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_null,
553 CP_WINUNICODE, &propvar, &allocator);
554
555 ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
556 ok(propvar.vt == VT_NULL, "unexpected vt %x\n", propvar.vt);
557
558 ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_i4,
559 CP_WINUNICODE, &propvar, &allocator);
560
561 ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
562 ok(propvar.vt == VT_I4, "unexpected vt %x\n", propvar.vt);
563 ok(U(propvar).lVal == 0xfeabcdef, "unexpected lVal %x\n", U(propvar).lVal);
564
565 ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_bstr_wc,
566 CP_WINUNICODE, &propvar, &allocator);
567
568 ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
569 ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
570 ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
571 PropVariantClear(&propvar);
572
573 ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_bstr_mb,
574 CP_UTF8, &propvar, &allocator);
575
576 ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
577 ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
578 ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
579 PropVariantClear(&propvar);
580}
unsigned char BOOLEAN
#define CP_WINUNICODE
Definition: ddeml.h:33
#define GetProcAddress(x, y)
Definition: compat.h:753
@ VT_NULL
Definition: compat.h:2296
@ VT_I4
Definition: compat.h:2298
@ VT_EMPTY
Definition: compat.h:2295
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define BOOLEAN
Definition: pedump.c:73
unsigned short USHORT
Definition: pedump.c:61
SERIALIZEDPROPERTYVALUE
Definition: propidl.idl:439
static void setup_vtable(struct _PMemoryAllocator_vtable *vtable)
Definition: propvariant.c:482
static const char serialized_bstr_mb[]
Definition: propvariant.c:515
static const char serialized_empty[]
Definition: propvariant.c:490
static const char serialized_null[]
Definition: propvariant.c:495
static const char serialized_bstr_wc[]
Definition: propvariant.c:506
static const char serialized_i4[]
Definition: propvariant.c:500
#define CP_UTF8
Definition: nls.h:20
void test_string()
Definition: test_string.cpp:38
#define __stdcall
Definition: typedefs.h:25
int ret

Referenced by START_TEST().

◆ test_validtypes()

static void test_validtypes ( void  )
static

Definition at line 182 of file propvariant.c.

183{
184 PROPVARIANT propvar, copy, uninit;
185 HRESULT hr;
186 unsigned int i, ret;
187
188 memset(&uninit, 0x77, sizeof(uninit));
189
190 memset(&propvar, 0x55, sizeof(propvar));
191 hr = PropVariantClear(&propvar);
192 ok(hr == STG_E_INVALIDPARAMETER, "expected STG_E_INVALIDPARAMETER, got %08x\n", hr);
193 ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
194 ok(U(propvar).uhVal.QuadPart == 0, "expected 0, got %#x/%#x\n",
195 U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
196
197 for (i = 0; i < ARRAY_SIZE(valid_types); i++)
198 {
199 VARTYPE vt;
200
201 memset(&propvar, 0x55, sizeof(propvar));
202 if (i == VT_RECORD)
203 memset(&propvar, 0, sizeof(propvar));
204 else if (i == VT_BLOB || i == VT_BLOB_OBJECT)
205 {
206 U(propvar).blob.cbSize = 0;
207 U(propvar).blob.pBlobData = NULL;
208 }
209 else
210 U(propvar).pszVal = NULL;
211 vt = propvar.vt = i;
212 memset(&copy, 0x77, sizeof(copy));
213 hr = PropVariantCopy(&copy, &propvar);
214 expect(hr, vt, TRUE, __LINE__);
215 if (hr == S_OK)
216 {
217 ok(copy.vt == propvar.vt, "expected %d, got %d\n", propvar.vt, copy.vt);
218 ok(U(copy).uhVal.QuadPart == U(propvar).uhVal.QuadPart, "%u: expected %#x/%#x, got %#x/%#x\n",
219 i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart,
220 U(copy).uhVal.u.LowPart, U(copy).uhVal.u.HighPart);
221 }
222 else
223 {
224 ret = memcmp(&copy, &uninit, sizeof(copy));
225 ok(!ret || broken(ret) /* win2000 */, "%d: copy should stay unchanged\n", i);
226 }
227 hr = PropVariantClear(&propvar);
228 expect(hr, vt, FALSE, __LINE__);
229 ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
230 ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
231 i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
232
233 memset(&propvar, 0x55, sizeof(propvar));
234 U(propvar).pszVal = NULL;
235 vt = propvar.vt = i | VT_ARRAY;
236 memset(&copy, 0x77, sizeof(copy));
237 hr = PropVariantCopy(&copy, &propvar);
238 expect(hr, vt, TRUE, __LINE__);
239 if (hr == S_OK)
240 {
241 ok(copy.vt == propvar.vt, "expected %d, got %d\n", propvar.vt, copy.vt);
242 ok(U(copy).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
243 i, U(copy).uhVal.u.LowPart, U(copy).uhVal.u.HighPart);
244 }
245 else
246 {
247 ret = memcmp(&copy, &uninit, sizeof(copy));
248 ok(!ret || broken(ret) /* win2000 */, "%d: copy should stay unchanged\n", i);
249 }
250 hr = PropVariantClear(&propvar);
251 expect(hr, vt, FALSE, __LINE__);
252 ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
253 ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
254 i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
255
256 memset(&propvar, 0x55, sizeof(propvar));
257 U(propvar).caub.cElems = 0;
258 U(propvar).caub.pElems = NULL;
259 vt = propvar.vt = i | VT_VECTOR;
260 memset(&copy, 0x77, sizeof(copy));
261 hr = PropVariantCopy(&copy, &propvar);
262 expect(hr, vt, TRUE, __LINE__);
263 if (hr == S_OK)
264 {
265 ok(copy.vt == propvar.vt, "expected %d, got %d\n", propvar.vt, copy.vt);
266 ok(!U(copy).caub.cElems, "%u: expected 0, got %d\n", i, U(copy).caub.cElems);
267 ok(!U(copy).caub.pElems, "%u: expected NULL, got %p\n", i, U(copy).caub.pElems);
268 }
269 else
270 {
271 ret = memcmp(&copy, &uninit, sizeof(copy));
272 ok(!ret || broken(ret) /* win2000 */, "%d: copy should stay unchanged\n", i);
273 }
274 hr = PropVariantClear(&propvar);
275 expect(hr, vt, FALSE, __LINE__);
276 ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
277 ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
278 i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
279
280 memset(&propvar, 0x55, sizeof(propvar));
281 U(propvar).pszVal = NULL;
282 vt = propvar.vt = i | VT_BYREF;
283 memset(&copy, 0x77, sizeof(copy));
284 hr = PropVariantCopy(&copy, &propvar);
285 expect(hr, vt, TRUE, __LINE__);
286 if (hr == S_OK)
287 {
288 ok(copy.vt == propvar.vt, "expected %d, got %d\n", propvar.vt, copy.vt);
289 ok(U(copy).uhVal.QuadPart == U(propvar).uhVal.QuadPart, "%u: expected %#x/%#x, got %#x/%#x\n",
290 i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart,
291 U(copy).uhVal.u.LowPart, U(copy).uhVal.u.HighPart);
292 }
293 else
294 {
295 ret = memcmp(&copy, &uninit, sizeof(copy));
296 ok(!ret || broken(ret) /* win2000 */, "%d: copy should stay unchanged\n", i);
297 }
298 hr = PropVariantClear(&propvar);
299 expect(hr, vt, FALSE, __LINE__);
300 ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
301 ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
302 i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
303 }
304}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define broken(x)
Definition: _sntprintf.h:21
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ARRAY_SIZE(A)
Definition: main.h:33
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned short VARTYPE
Definition: compat.h:2254
@ VT_BLOB
Definition: compat.h:2330
@ VT_BLOB_OBJECT
Definition: compat.h:2335
@ VT_RECORD
Definition: compat.h:2326
void uninit(_In_ device_extension *Vcb)
Definition: btrfs.c:2001
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by START_TEST().

◆ test_varianttoproperty()

static void test_varianttoproperty ( void  )
static

Definition at line 582 of file propvariant.c.

583{
584 HANDLE hole32;
585 PROPVARIANT propvar;
586 SERIALIZEDPROPERTYVALUE *propvalue, *own_propvalue;
587 SERIALIZEDPROPERTYVALUE* (__stdcall *pStgConvertVariantToProperty)(
589 ULONG len;
590 static const WCHAR test_string[] = {'t','e','s','t',0};
591 BSTR test_string_bstr;
592
593 hole32 = GetModuleHandleA("ole32");
594
595 pStgConvertVariantToProperty = (void*)GetProcAddress(hole32, "StgConvertVariantToProperty");
596
597 if (!pStgConvertVariantToProperty)
598 {
599 win_skip("StgConvertVariantToProperty not available\n");
600 return;
601 }
602
603 own_propvalue = HeapAlloc(GetProcessHeap(), 0, sizeof(SERIALIZEDPROPERTYVALUE) + 20);
604
605 PropVariantInit(&propvar);
606
607 propvar.vt = VT_I4;
608 U(propvar).lVal = 0xfeabcdef;
609
610 len = 0xdeadbeef;
611 propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, NULL, &len,
612 0, FALSE, 0);
613
614 ok(propvalue == NULL, "got nonnull propvalue\n");
615 todo_wine ok(len == 8, "unexpected length %d\n", len);
616
617 if (len == 0xdeadbeef)
618 {
619 HeapFree(GetProcessHeap(), 0, own_propvalue);
620 return;
621 }
622
623 len = 20;
624 propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, own_propvalue, &len,
625 0, FALSE, 0);
626
627 ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
628 ok(len == 8, "unexpected length %d\n", len);
629 ok(!memcmp(propvalue, serialized_i4, 8), "got wrong data\n");
630
631 propvar.vt = VT_EMPTY;
632 len = 20;
633 own_propvalue->dwType = 0xdeadbeef;
634 propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, own_propvalue, &len,
635 0, FALSE, 0);
636
637 ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
638 ok(len == 4 || broken(len == 0) /* before Vista */, "unexpected length %d\n", len);
639 if (len) ok(!memcmp(propvalue, serialized_empty, 4), "got wrong data\n");
640 else ok(propvalue->dwType == 0xdeadbeef, "unexpected type %d\n", propvalue->dwType);
641
642 propvar.vt = VT_NULL;
643 len = 20;
644 propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, own_propvalue, &len,
645 0, FALSE, 0);
646
647 ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
648 ok(len == 4, "unexpected length %d\n", len);
649 ok(!memcmp(propvalue, serialized_null, 4), "got wrong data\n");
650
651 test_string_bstr = SysAllocString(test_string);
652
653 propvar.vt = VT_BSTR;
654 U(propvar).bstrVal = test_string_bstr;
655 len = 20;
656 propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, own_propvalue, &len,
657 0, FALSE, 0);
658
659 ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
660 ok(len == 20, "unexpected length %d\n", len);
661 ok(!memcmp(propvalue, serialized_bstr_wc, 20), "got wrong data\n");
662
663 len = 20;
664 propvalue = pStgConvertVariantToProperty(&propvar, CP_UTF8, own_propvalue, &len,
665 0, FALSE, 0);
666
667 ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
668 ok(len == 16, "unexpected length %d\n", len);
669 ok(!memcmp(propvalue, serialized_bstr_mb, 16), "got wrong data\n");
670
671 SysFreeString(test_string_bstr);
672
673 HeapFree(GetProcessHeap(), 0, own_propvalue);
674}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
OLECHAR * BSTR
Definition: compat.h:2293
#define HeapFree(x, y, z)
Definition: compat.h:735
GLenum GLsizei len
Definition: glext.h:6722
#define todo_wine
Definition: custom.c:79
static const CLSID IPropertyStorage UINT *static const PROPSPEC PROPVARIANT *static UINT const PROPSPEC PROPVARIANT PROPID
Definition: shellole.c:78
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ unk_AddRef()

static ULONG WINAPI unk_AddRef ( IUnknown iface)
static

Definition at line 327 of file propvariant.c.

328{
329 struct unk_impl *This = impl_from_IUnknown(iface);
330 if(winetest_debug > 1)
331 trace("Call to unk_AddRef()\n");
332 return InterlockedIncrement(&This->ref);
333}
#define InterlockedIncrement
Definition: armddk.h:53
#define trace
Definition: atltest.h:70
static struct unk_impl * impl_from_IUnknown(IUnknown *iface)
Definition: propvariant.c:312
int winetest_debug

◆ unk_QueryInterface()

static HRESULT WINAPI unk_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 317 of file propvariant.c.

318{
319 struct unk_impl *This = impl_from_IUnknown(iface);
320 if(winetest_debug > 1)
321 trace("Call to unk_QueryInterface()\n");
322 *ppv = &This->IUnknown_iface;
323 IUnknown_AddRef(iface);
324 return S_OK;
325}
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ unk_Release()

static ULONG WINAPI unk_Release ( IUnknown iface)
static

Definition at line 335 of file propvariant.c.

336{
337 struct unk_impl *This = impl_from_IUnknown(iface);
338 if(winetest_debug > 1)
339 trace("Call to unk_Release()\n");
340 return InterlockedDecrement(&This->ref);
341}
#define InterlockedDecrement
Definition: armddk.h:52

Variable Documentation

◆ serialized_bstr_mb

const char serialized_bstr_mb[]
static
Initial value:
= {
8,0,
0,0,
5,0,0,0,
't','e','s','t',
0,0,0,0
}

Definition at line 515 of file propvariant.c.

Referenced by test_propertytovariant(), and test_varianttoproperty().

◆ serialized_bstr_wc

const char serialized_bstr_wc[]
static
Initial value:
= {
8,0,
0,0,
10,0,0,0,
't',0,'e',0,
's',0,'t',0,
0,0,0,0
}

Definition at line 506 of file propvariant.c.

Referenced by test_propertytovariant(), and test_varianttoproperty().

◆ serialized_empty

const char serialized_empty[]
static
Initial value:
= {
0,0,
0,0,
}

Definition at line 490 of file propvariant.c.

Referenced by test_propertytovariant(), and test_varianttoproperty().

◆ serialized_i4

const char serialized_i4[]
static
Initial value:
= {
3,0,
0,0,
0xef,0xcd,0xab,0xfe
}

Definition at line 500 of file propvariant.c.

Referenced by test_propertytovariant(), and test_varianttoproperty().

◆ serialized_null

const char serialized_null[]
static
Initial value:
= {
1,0,
0,0,
}

Definition at line 495 of file propvariant.c.

Referenced by test_propertytovariant(), and test_varianttoproperty().

◆ unk_vtbl

const IUnknownVtbl unk_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI unk_Release(IUnknown *iface)
Definition: propvariant.c:335
static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: propvariant.c:317
static ULONG WINAPI unk_AddRef(IUnknown *iface)
Definition: propvariant.c:327

Definition at line 343 of file propvariant.c.

Referenced by test_copy().

◆ valid_types

const struct valid_mapping valid_types[]
static

Referenced by expect(), and test_validtypes().

◆ wine_vtypes

const char* wine_vtypes[VT_CLSID+1]
static
Initial value:
=
{
"VT_EMPTY","VT_NULL","VT_I2","VT_I4","VT_R4","VT_R8","VT_CY","VT_DATE",
"VT_BSTR","VT_DISPATCH","VT_ERROR","VT_BOOL","VT_VARIANT","VT_UNKNOWN",
"VT_DECIMAL","15","VT_I1","VT_UI1","VT_UI2","VT_UI4","VT_I8","VT_UI8",
"VT_INT","VT_UINT","VT_VOID","VT_HRESULT","VT_PTR","VT_SAFEARRAY",
"VT_CARRAY","VT_USERDEFINED","VT_LPSTR","VT_LPWSTR","32","33","34","35",
"VT_RECORD","VT_INT_PTR","VT_UINT_PTR","39","40","41","42","43","44","45",
"46","47","48","49","50","51","52","53","54","55","56","57","58","59","60",
"61","62","63","VT_FILETIME","VT_BLOB","VT_STREAM","VT_STORAGE",
"VT_STREAMED_OBJECT","VT_STORED_OBJECT","VT_BLOB_OBJECT","VT_CF","VT_CLSID"
}

Definition at line 124 of file propvariant.c.

Referenced by expect().