ReactOS  0.4.14-dev-41-g31d7680
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  _PMemoryAllocator_vtable
 
struct  _PMemoryAllocator
 

Macros

#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 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 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

◆ PROP_INV

#define PROP_INV   0x7f

Definition at line 28 of file propvariant.c.

◆ PROP_TODO

#define PROP_TODO   0x80

Definition at line 35 of file propvariant.c.

◆ PROP_V0

#define PROP_V0   0

Definition at line 30 of file propvariant.c.

◆ PROP_V1

#define PROP_V1   1

Definition at line 32 of file propvariant.c.

◆ PROP_V1A

#define PROP_V1A   2

Definition at line 34 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 133 of file propvariant.c.

134 {
135  int idx = vt & VT_TYPEMASK;
136  BYTE flags;
137  const char *modifier;
138 
139  if(vt & VT_BYREF)
140  {
141  flags = valid_types[idx].byref;
142  modifier = "byref";
143  }
144  else if(vt & VT_ARRAY)
145  {
146  flags = valid_types[idx].with_array;
147  modifier = "array";
148  }
149  else if(vt & VT_VECTOR)
150  {
151  flags = valid_types[idx].with_vector;
152  modifier = "vector";
153  }
154  else
155  {
156  flags = valid_types[idx].simple;
157  modifier = "simple";
158  }
159 
160  if(flags == PROP_INV)
161  {
162  if (copy && (vt & VT_VECTOR))
163  ok(hr == DISP_E_BADVARTYPE || hr == STG_E_INVALIDPARAMETER, "%s (%s): got %08x (line %d)\n", wine_vtypes[idx], modifier, hr, line);
164  else
165  ok(hr == (copy ? DISP_E_BADVARTYPE : STG_E_INVALIDPARAMETER), "%s (%s): got %08x (line %d)\n", wine_vtypes[idx], modifier, hr, line);
166  }
167  else if(flags == PROP_V0)
168  ok(hr == S_OK, "%s (%s): got %08x\n", wine_vtypes[idx], modifier, hr);
170  {
171  if(hr != S_OK)
172  win_skip("%s (%s): unsupported\n", wine_vtypes[idx], modifier);
173  else ok(hr == S_OK, "%s (%s): got %08x\n", wine_vtypes[idx], modifier, hr);
174  }
175 }
HRESULT hr
Definition: shlfolder.c:183
#define PROP_TODO
Definition: propvariant.c:35
#define PROP_V0
Definition: propvariant.c:30
unsigned int idx
Definition: utils.c:41
Definition: parser.c:48
#define todo_wine_if(is_todo)
Definition: test.h:155
#define PROP_INV
Definition: propvariant.c:28
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:85
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:2580
GLbitfield flags
Definition: glext.h:7161
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
unsigned char BYTE
Definition: mem.h:68
#define S_OK
Definition: intsafe.h:59
#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
static const char * wine_vtypes[VT_CLSID+1]
Definition: propvariant.c:119
static const struct valid_mapping valid_types[]
#define win_skip
Definition: test.h:141

Referenced by test_validtypes().

◆ PMemoryAllocator_Allocate()

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

Definition at line 348 of file propvariant.c.

349 {
350  return CoTaskMemAlloc(cbSize);
351 }
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406

Referenced by setup_vtable().

◆ PMemoryAllocator_Free()

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

Definition at line 353 of file propvariant.c.

354 {
355  CoTaskMemFree(pv);
356 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422

Referenced by setup_vtable().

◆ setup_vtable()

static void setup_vtable ( struct _PMemoryAllocator_vtable vtable)
static

Definition at line 396 of file propvariant.c.

397 {
398  vtable->Allocate = PMemoryAllocator_Allocate;
400 }
static void * vtable[]
Definition: typelib.c:1231
static void WINAPI PMemoryAllocator_Free(PMemoryAllocator *_this, void *pv)
Definition: propvariant.c:353
static void *WINAPI PMemoryAllocator_Allocate(PMemoryAllocator *_this, ULONG cbSize)
Definition: propvariant.c:348

Referenced by test_propertytovariant().

◆ START_TEST()

START_TEST ( propvariant  )

Definition at line 590 of file propvariant.c.

591 {
592  test_validtypes();
593  test_copy();
596 }
static void test_varianttoproperty(void)
Definition: propvariant.c:496
static void test_propertytovariant(void)
Definition: propvariant.c:437
static void test_copy(void)
Definition: propvariant.c:301
static void test_validtypes(void)
Definition: propvariant.c:177

◆ test_copy()

static void test_copy ( void  )
static

Definition at line 301 of file propvariant.c.

302 {
303  static char szTestString[] = "Test String";
304  static WCHAR wszTestString[] = {'T','e','s','t',' ','S','t','r','i','n','g',0};
305  PROPVARIANT propvarSrc;
306  PROPVARIANT propvarDst;
307  HRESULT hr;
308 
309  propvarSrc.vt = VT_BSTR;
310  U(propvarSrc).bstrVal = SysAllocString(wszTestString);
311 
312  hr = PropVariantCopy(&propvarDst, &propvarSrc);
313  ok(hr == S_OK, "PropVariantCopy(...VT_BSTR...) failed\n");
314  ok(!lstrcmpW(U(propvarSrc).bstrVal, U(propvarDst).bstrVal), "BSTR not copied properly\n");
316  ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n");
317  hr = PropVariantClear(&propvarDst);
318  ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n");
319 
320  propvarSrc.vt = VT_LPWSTR;
321  U(propvarSrc).pwszVal = wszTestString;
322  hr = PropVariantCopy(&propvarDst, &propvarSrc);
323  ok(hr == S_OK, "PropVariantCopy(...VT_LPWSTR...) failed\n");
324  ok(!lstrcmpW(U(propvarSrc).pwszVal, U(propvarDst).pwszVal), "Wide string not copied properly\n");
325  hr = PropVariantClear(&propvarDst);
326  ok(hr == S_OK, "PropVariantClear(...VT_LPWSTR...) failed\n");
327  memset(&propvarSrc, 0, sizeof(propvarSrc));
328 
329  propvarSrc.vt = VT_LPSTR;
330  U(propvarSrc).pszVal = szTestString;
331  hr = PropVariantCopy(&propvarDst, &propvarSrc);
332  ok(hr == S_OK, "PropVariantCopy(...VT_LPSTR...) failed\n");
333  ok(!strcmp(U(propvarSrc).pszVal, U(propvarDst).pszVal), "String not copied properly\n");
334  hr = PropVariantClear(&propvarDst);
335  ok(hr == S_OK, "PropVariantClear(...VT_LPSTR...) failed\n");
336  memset(&propvarSrc, 0, sizeof(propvarSrc));
337 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: ole2.c:2952
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define U(x)
Definition: wordpad.c:44
static REFPROPVARIANT propvarSrc
Definition: suminfo.c:85
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc)
Definition: ole2.c:3068
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_propertytovariant()

static void test_propertytovariant ( void  )
static

Definition at line 437 of file propvariant.c.

438 {
439  HANDLE hole32;
440  BOOLEAN (__stdcall *pStgConvertPropertyToVariant)(const SERIALIZEDPROPERTYVALUE*,USHORT,PROPVARIANT*,PMemoryAllocator*);
441  PROPVARIANT propvar;
444  BOOLEAN ret;
445  static const WCHAR test_string[] = {'t','e','s','t',0};
446 
447  hole32 = GetModuleHandleA("ole32");
448 
449  pStgConvertPropertyToVariant = (void*)GetProcAddress(hole32, "StgConvertPropertyToVariant");
450 
451  if (!pStgConvertPropertyToVariant)
452  {
453  win_skip("StgConvertPropertyToVariant not available\n");
454  return;
455  }
456 
458  allocator.vt = &vtable;
459 
460  ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_empty,
461  CP_WINUNICODE, &propvar, &allocator);
462 
463  ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
464  ok(propvar.vt == VT_EMPTY, "unexpected vt %x\n", propvar.vt);
465 
466  ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_null,
467  CP_WINUNICODE, &propvar, &allocator);
468 
469  ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
470  ok(propvar.vt == VT_NULL, "unexpected vt %x\n", propvar.vt);
471 
472  ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_i4,
473  CP_WINUNICODE, &propvar, &allocator);
474 
475  ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
476  ok(propvar.vt == VT_I4, "unexpected vt %x\n", propvar.vt);
477  ok(U(propvar).lVal == 0xfeabcdef, "unexpected lVal %x\n", U(propvar).lVal);
478 
479  ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_bstr_wc,
480  CP_WINUNICODE, &propvar, &allocator);
481 
482  ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
483  ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
484  ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
485  PropVariantClear(&propvar);
486 
487  ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_bstr_mb,
488  CP_UTF8, &propvar, &allocator);
489 
490  ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
491  ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
492  ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
493  PropVariantClear(&propvar);
494 }
Definition: compat.h:1939
static void * vtable[]
Definition: typelib.c:1231
SERIALIZEDPROPERTYVALUE
Definition: propidl.idl:439
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: ole2.c:2952
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define U(x)
Definition: wordpad.c:44
static const char serialized_bstr_mb[]
Definition: propvariant.c:429
static const char serialized_empty[]
Definition: propvariant.c:404
#define CP_UTF8
Definition: nls.h:20
static const char serialized_null[]
Definition: propvariant.c:409
unsigned char BOOLEAN
static void setup_vtable(struct _PMemoryAllocator_vtable *vtable)
Definition: propvariant.c:396
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define __stdcall
Definition: typedefs.h:25
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static const char serialized_bstr_wc[]
Definition: propvariant.c:420
static const char serialized_i4[]
Definition: propvariant.c:414
unsigned short USHORT
Definition: pedump.c:61
#define ok(value,...)
Definition: atltest.h:57
#define CP_WINUNICODE
Definition: ddeml.h:33
void test_string()
Definition: test_string.cpp:38
#define BOOLEAN
Definition: pedump.c:73
#define GetProcAddress(x, y)
Definition: compat.h:410
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_validtypes()

static void test_validtypes ( void  )
static

Definition at line 177 of file propvariant.c.

178 {
179  PROPVARIANT propvar, copy, uninit;
180  HRESULT hr;
181  unsigned int i, ret;
182 
183  memset(&uninit, 0x77, sizeof(uninit));
184 
185  memset(&propvar, 0x55, sizeof(propvar));
186  hr = PropVariantClear(&propvar);
187  ok(hr == STG_E_INVALIDPARAMETER, "expected STG_E_INVALIDPARAMETER, got %08x\n", hr);
188  ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
189  ok(U(propvar).uhVal.QuadPart == 0, "expected 0, got %#x/%#x\n",
190  U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
191 
192  for (i = 0; i < ARRAY_SIZE(valid_types); i++)
193  {
194  VARTYPE vt;
195 
196  memset(&propvar, 0x55, sizeof(propvar));
197  if (i == VT_RECORD)
198  memset(&propvar, 0, sizeof(propvar));
199  else if (i == VT_BLOB || i == VT_BLOB_OBJECT)
200  {
201  U(propvar).blob.cbSize = 0;
202  U(propvar).blob.pBlobData = NULL;
203  }
204  else
205  U(propvar).pszVal = NULL;
206  vt = propvar.vt = i;
207  memset(&copy, 0x77, sizeof(copy));
208  hr = PropVariantCopy(&copy, &propvar);
209  expect(hr, vt, TRUE, __LINE__);
210  if (hr == S_OK)
211  {
212  ok(copy.vt == propvar.vt, "expected %d, got %d\n", propvar.vt, copy.vt);
213  ok(U(copy).uhVal.QuadPart == U(propvar).uhVal.QuadPart, "%u: expected %#x/%#x, got %#x/%#x\n",
214  i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart,
215  U(copy).uhVal.u.LowPart, U(copy).uhVal.u.HighPart);
216  }
217  else
218  {
219  ret = memcmp(&copy, &uninit, sizeof(copy));
220  ok(!ret || broken(ret) /* win2000 */, "%d: copy should stay unchanged\n", i);
221  }
222  hr = PropVariantClear(&propvar);
223  expect(hr, vt, FALSE, __LINE__);
224  ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
225  ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
226  i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
227 
228  memset(&propvar, 0x55, sizeof(propvar));
229  U(propvar).pszVal = NULL;
230  vt = propvar.vt = i | VT_ARRAY;
231  memset(&copy, 0x77, sizeof(copy));
232  hr = PropVariantCopy(&copy, &propvar);
233  expect(hr, vt, TRUE, __LINE__);
234  if (hr == S_OK)
235  {
236  ok(copy.vt == propvar.vt, "expected %d, got %d\n", propvar.vt, copy.vt);
237  ok(U(copy).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
238  i, U(copy).uhVal.u.LowPart, U(copy).uhVal.u.HighPart);
239  }
240  else
241  {
242  ret = memcmp(&copy, &uninit, sizeof(copy));
243  ok(!ret || broken(ret) /* win2000 */, "%d: copy should stay unchanged\n", i);
244  }
245  hr = PropVariantClear(&propvar);
246  expect(hr, vt, FALSE, __LINE__);
247  ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
248  ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
249  i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
250 
251  memset(&propvar, 0x55, sizeof(propvar));
252  U(propvar).caub.cElems = 0;
253  U(propvar).caub.pElems = NULL;
254  vt = propvar.vt = i | VT_VECTOR;
255  memset(&copy, 0x77, sizeof(copy));
256  hr = PropVariantCopy(&copy, &propvar);
257  expect(hr, vt, TRUE, __LINE__);
258  if (hr == S_OK)
259  {
260  ok(copy.vt == propvar.vt, "expected %d, got %d\n", propvar.vt, copy.vt);
261  ok(!U(copy).caub.cElems, "%u: expected 0, got %d\n", i, U(copy).caub.cElems);
262  ok(!U(copy).caub.pElems, "%u: expected NULL, got %p\n", i, U(copy).caub.pElems);
263  }
264  else
265  {
266  ret = memcmp(&copy, &uninit, sizeof(copy));
267  ok(!ret || broken(ret) /* win2000 */, "%d: copy should stay unchanged\n", i);
268  }
269  hr = PropVariantClear(&propvar);
270  expect(hr, vt, FALSE, __LINE__);
271  ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
272  ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
273  i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
274 
275  memset(&propvar, 0x55, sizeof(propvar));
276  U(propvar).pszVal = NULL;
277  vt = propvar.vt = i | VT_BYREF;
278  memset(&copy, 0x77, sizeof(copy));
279  hr = PropVariantCopy(&copy, &propvar);
280  expect(hr, vt, TRUE, __LINE__);
281  if (hr == S_OK)
282  {
283  ok(copy.vt == propvar.vt, "expected %d, got %d\n", propvar.vt, copy.vt);
284  ok(U(copy).uhVal.QuadPart == U(propvar).uhVal.QuadPart, "%u: expected %#x/%#x, got %#x/%#x\n",
285  i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart,
286  U(copy).uhVal.u.LowPart, U(copy).uhVal.u.HighPart);
287  }
288  else
289  {
290  ret = memcmp(&copy, &uninit, sizeof(copy));
291  ok(!ret || broken(ret) /* win2000 */, "%d: copy should stay unchanged\n", i);
292  }
293  hr = PropVariantClear(&propvar);
294  expect(hr, vt, FALSE, __LINE__);
295  ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
296  ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
297  i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
298  }
299 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: ole2.c:2952
#define U(x)
Definition: wordpad.c:44
static void expect(HRESULT hr, VARTYPE vt, BOOL copy, int line)
Definition: propvariant.c:133
void uninit(_In_ device_extension *Vcb)
Definition: btrfs.c:1970
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
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc)
Definition: ole2.c:3068
LONG HRESULT
Definition: typedefs.h:77
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:85
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:2580
int ret
#define broken(x)
Definition: _sntprintf.h:21
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
unsigned short VARTYPE
Definition: compat.h:1895
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define memset(x, y, z)
Definition: compat.h:39
static const struct valid_mapping valid_types[]

Referenced by START_TEST().

◆ test_varianttoproperty()

static void test_varianttoproperty ( void  )
static

Definition at line 496 of file propvariant.c.

497 {
498  HANDLE hole32;
499  PROPVARIANT propvar;
500  SERIALIZEDPROPERTYVALUE *propvalue, *own_propvalue;
501  SERIALIZEDPROPERTYVALUE* (__stdcall *pStgConvertVariantToProperty)(
502  const PROPVARIANT*,USHORT,SERIALIZEDPROPERTYVALUE*,ULONG*,PROPID,BOOLEAN,ULONG*);
503  ULONG len;
504  static const WCHAR test_string[] = {'t','e','s','t',0};
505  BSTR test_string_bstr;
506 
507  hole32 = GetModuleHandleA("ole32");
508 
509  pStgConvertVariantToProperty = (void*)GetProcAddress(hole32, "StgConvertVariantToProperty");
510 
511  if (!pStgConvertVariantToProperty)
512  {
513  win_skip("StgConvertVariantToProperty not available\n");
514  return;
515  }
516 
517  own_propvalue = HeapAlloc(GetProcessHeap(), 0, sizeof(SERIALIZEDPROPERTYVALUE) + 20);
518 
519  PropVariantInit(&propvar);
520 
521  propvar.vt = VT_I4;
522  U(propvar).lVal = 0xfeabcdef;
523 
524  len = 0xdeadbeef;
525  propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, NULL, &len,
526  0, FALSE, 0);
527 
528  ok(propvalue == NULL, "got nonnull propvalue\n");
529  todo_wine ok(len == 8, "unexpected length %d\n", len);
530 
531  if (len == 0xdeadbeef)
532  {
533  HeapFree(GetProcessHeap(), 0, own_propvalue);
534  return;
535  }
536 
537  len = 20;
538  propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, own_propvalue, &len,
539  0, FALSE, 0);
540 
541  ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
542  ok(len == 8, "unexpected length %d\n", len);
543  ok(!memcmp(propvalue, serialized_i4, 8), "got wrong data\n");
544 
545  propvar.vt = VT_EMPTY;
546  len = 20;
547  own_propvalue->dwType = 0xdeadbeef;
548  propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, own_propvalue, &len,
549  0, FALSE, 0);
550 
551  ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
552  ok(len == 4 || broken(len == 0) /* before Vista */, "unexpected length %d\n", len);
553  if (len) ok(!memcmp(propvalue, serialized_empty, 4), "got wrong data\n");
554  else ok(propvalue->dwType == 0xdeadbeef, "unexpected type %d\n", propvalue->dwType);
555 
556  propvar.vt = VT_NULL;
557  len = 20;
558  propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, own_propvalue, &len,
559  0, FALSE, 0);
560 
561  ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
562  ok(len == 4, "unexpected length %d\n", len);
563  ok(!memcmp(propvalue, serialized_null, 4), "got wrong data\n");
564 
565  test_string_bstr = SysAllocString(test_string);
566 
567  propvar.vt = VT_BSTR;
568  U(propvar).bstrVal = test_string_bstr;
569  len = 20;
570  propvalue = pStgConvertVariantToProperty(&propvar, CP_WINUNICODE, own_propvalue, &len,
571  0, FALSE, 0);
572 
573  ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
574  ok(len == 20, "unexpected length %d\n", len);
575  ok(!memcmp(propvalue, serialized_bstr_wc, 20), "got wrong data\n");
576 
577  len = 20;
578  propvalue = pStgConvertVariantToProperty(&propvar, CP_UTF8, own_propvalue, &len,
579  0, FALSE, 0);
580 
581  ok(propvalue == own_propvalue, "unexpected propvalue %p\n", propvalue);
582  ok(len == 16, "unexpected length %d\n", len);
583  ok(!memcmp(propvalue, serialized_bstr_mb, 16), "got wrong data\n");
584 
585  SysFreeString(test_string_bstr);
586 
587  HeapFree(GetProcessHeap(), 0, own_propvalue);
588 }
Definition: compat.h:1939
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
SERIALIZEDPROPERTYVALUE
Definition: propidl.idl:439
#define U(x)
Definition: wordpad.c:44
OLECHAR * BSTR
Definition: compat.h:1934
static const CLSID IPropertyStorage UINT *static const PROPSPEC PROPVARIANT *static UINT const PROPSPEC PROPVARIANT PROPID
Definition: shellole.c:77
static const char serialized_bstr_mb[]
Definition: propvariant.c:429
static const char serialized_empty[]
Definition: propvariant.c:404
#define CP_UTF8
Definition: nls.h:20
static const char serialized_null[]
Definition: propvariant.c:409
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define __stdcall
Definition: typedefs.h:25
#define todo_wine
Definition: test.h:154
GLenum GLsizei len
Definition: glext.h:6722
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static const char serialized_bstr_wc[]
Definition: propvariant.c:420
#define broken(x)
Definition: _sntprintf.h:21
static const char serialized_i4[]
Definition: propvariant.c:414
unsigned short USHORT
Definition: pedump.c:61
#define ok(value,...)
Definition: atltest.h:57
#define CP_WINUNICODE
Definition: ddeml.h:33
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
void test_string()
Definition: test_string.cpp:38
unsigned int ULONG
Definition: retypes.h:1
#define GetProcAddress(x, y)
Definition: compat.h:410
#define win_skip
Definition: test.h:141
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by START_TEST().

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 429 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 420 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 404 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 414 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 409 of file propvariant.c.

Referenced by test_propertytovariant(), and test_varianttoproperty().

◆ 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 119 of file propvariant.c.

Referenced by expect().