26#define NONAMELESSUNION
36DEFINE_GUID(PKEY_WineTest, 0x7b317433, 0xdfa3, 0x4c44, 0xad, 0x3e, 0x2f, 0x80, 0x4b, 0x90, 0xdb, 0xf4);
37DEFINE_GUID(DUMMY_GUID1, 0x12345678, 0x1234,0x1234, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19);
39#define EXPECT_REF(obj,ref) _expect_ref((IUnknown *)obj, ref, __LINE__)
44 rc = IUnknown_Release(
obj);
45 ok_(__FILE__,
line)(rc ==
ref,
"expected refcount %d, got %d\n",
ref, rc);
58 &IID_IPropertyStoreCache, (
void**)&propcache);
59 ok(
hr ==
S_OK,
"CoCreateInstance failed, hr=%x\n",
hr);
63 skip(
"CLSID_InMemoryPropertyStore not supported\n");
67 hr = IPropertyStoreCache_GetCount(propcache,
NULL);
70 hr = IPropertyStoreCache_GetCount(propcache, &
count);
71 ok(
hr ==
S_OK,
"GetCount failed, hr=%x\n",
hr);
72 ok(
count == 0,
"GetCount returned %i, expected 0\n",
count);
74 hr = IPropertyStoreCache_Commit(propcache);
77 hr = IPropertyStoreCache_Commit(propcache);
80 hr = IPropertyStoreCache_GetAt(propcache, 0, &pkey);
83 pkey.fmtid = PKEY_WineTest;
86 memset(&propvar, 0,
sizeof(propvar));
88 propvar.u.lVal = 12345;
93 hr = IPropertyStoreCache_SetValue(propcache,
NULL, &propvar);
96 hr = IPropertyStoreCache_SetValue(propcache, &pkey,
NULL);
100 hr = IPropertyStoreCache_SetValue(propcache, &pkey, &propvar);
101 ok(
hr ==
S_OK,
"SetValue failed, hr=%x\n",
hr);
103 hr = IPropertyStoreCache_GetCount(propcache, &
count);
104 ok(
hr ==
S_OK,
"GetCount failed, hr=%x\n",
hr);
105 ok(
count == 1,
"GetCount returned %i, expected 0\n",
count);
107 memset(&pkey, 0,
sizeof(pkey));
109 hr = IPropertyStoreCache_GetAt(propcache, 0, &pkey);
111 ok(
IsEqualGUID(&pkey.fmtid, &PKEY_WineTest),
"got wrong pkey\n");
112 ok(pkey.pid == 4,
"got pid of %i, expected 4\n", pkey.pid);
114 pkey.fmtid = PKEY_WineTest;
117 memset(&propvar, 0,
sizeof(propvar));
122 hr = IPropertyStoreCache_GetValue(propcache,
NULL, &propvar);
126 hr = IPropertyStoreCache_GetValue(propcache, &pkey,
NULL);
129 hr = IPropertyStoreCache_GetValue(propcache, &pkey, &propvar);
130 ok(
hr ==
S_OK,
"GetValue failed, hr=%x\n",
hr);
131 ok(propvar.vt ==
VT_I4,
"expected VT_I4, got %d\n", propvar.vt);
132 ok(propvar.u.lVal == 12345,
"expected 12345, got %d\n", propvar.u.lVal);
134 pkey.fmtid = PKEY_WineTest;
139 hr = IPropertyStoreCache_GetValue(propcache, &pkey, &propvar);
140 ok(
hr ==
S_OK,
"GetValue failed, hr=%x\n",
hr);
141 ok(propvar.vt ==
VT_EMPTY,
"expected VT_EMPTY, got %d\n", propvar.vt);
144 hr = IPropertyStoreCache_GetState(propcache, &pkey, &
state);
146 ok(
state == PSC_NORMAL,
"expected PSC_NORMAL, got %d\n",
state);
150 hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &
state);
152 ok(propvar.vt ==
VT_EMPTY,
"expected VT_EMPTY, got %d\n", propvar.vt);
153 ok(
state == PSC_NORMAL,
"expected PSC_NORMAL, got %d\n",
state);
156 hr = IPropertyStoreCache_SetState(propcache, &pkey, PSC_NORMAL);
160 pkey.fmtid = PKEY_WineTest;
164 hr = IPropertyStoreCache_GetState(propcache, &pkey, &
state);
165 ok(
hr ==
S_OK,
"GetState failed, hr=%x\n",
hr);
166 ok(
state == PSC_NORMAL,
"expected PSC_NORMAL, got %d\n",
state);
168 hr = IPropertyStoreCache_SetState(propcache, &pkey, 10);
169 ok(
hr ==
S_OK,
"SetState failed, hr=%x\n",
hr);
172 hr = IPropertyStoreCache_GetState(propcache, &pkey, &
state);
173 ok(
hr ==
S_OK,
"GetState failed, hr=%x\n",
hr);
177 propvar.u.lVal = 12346;
178 hr = IPropertyStoreCache_SetValueAndState(propcache, &pkey, &propvar, 5);
179 ok(
hr ==
S_OK,
"SetValueAndState failed, hr=%x\n",
hr);
181 memset(&propvar, 0,
sizeof(propvar));
183 hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &
state);
184 ok(
hr ==
S_OK,
"GetValueAndState failed, hr=%x\n",
hr);
185 ok(propvar.vt ==
VT_I4,
"expected VT_I4, got %d\n", propvar.vt);
186 ok(propvar.u.lVal == 12346,
"expected 12346, got %d\n", propvar.vt);
190 pkey.fmtid = PKEY_WineTest;
194 propvar.u.lVal = 12347;
195 hr = IPropertyStoreCache_SetValueAndState(propcache, &pkey, &propvar, PSC_DIRTY);
196 ok(
hr ==
S_OK,
"SetValueAndState failed, hr=%x\n",
hr);
198 memset(&propvar, 0,
sizeof(propvar));
200 hr = IPropertyStoreCache_GetValueAndState(propcache, &pkey, &propvar, &
state);
201 ok(
hr ==
S_OK,
"GetValueAndState failed, hr=%x\n",
hr);
202 ok(propvar.vt ==
VT_I4,
"expected VT_I4, got %d\n", propvar.vt);
203 ok(propvar.u.lVal == 12347,
"expected 12347, got %d\n", propvar.vt);
204 ok(
state == PSC_DIRTY,
"expected PSC_DIRTY, got %d\n",
state);
206 IPropertyStoreCache_Release(propcache);
218 &IID_IPropertyStore, (
void**)&propstore);
219 ok(
hr ==
S_OK,
"CoCreateInstance failed, hr=%x\n",
hr);
221 hr = IPropertyStore_QueryInterface(propstore, &IID_IPersistSerializedPropStorage,
222 (
void**)&serialized);
227 IPropertyStore_Release(propstore);
228 skip(
"IPersistSerializedPropStorage not supported\n");
232 hr = IPersistSerializedPropStorage_GetPropertyStorage(serialized,
NULL, &result_size);
235 hr = IPersistSerializedPropStorage_GetPropertyStorage(serialized, &
result,
NULL);
238 hr = IPersistSerializedPropStorage_GetPropertyStorage(serialized, &
result, &result_size);
239 ok(
hr ==
S_OK,
"GetPropertyStorage failed, hr=%x\n",
hr);
243 ok(result_size == 0,
"expected 0 bytes, got %i\n", result_size);
248 hr = IPersistSerializedPropStorage_SetPropertyStorage(serialized,
NULL, 4);
251 hr = IPersistSerializedPropStorage_SetPropertyStorage(serialized,
NULL, 0);
252 ok(
hr ==
S_OK,
"SetPropertyStorage failed, hr=%x\n",
hr);
254 hr = IPropertyStore_GetCount(propstore, &result_size);
255 ok(
hr ==
S_OK,
"GetCount failed, hr=%x\n",
hr);
256 ok(result_size == 0,
"expecting 0, got %d\n", result_size);
258 IPropertyStore_Release(propstore);
259 IPersistSerializedPropStorage_Release(serialized);
272 ok(
hr ==
S_OK,
"PSCreateMemoryPropertyStore failed: 0x%08x.\n",
hr);
273 ok(propstore !=
NULL,
"got %p.\n", propstore);
283 IPersistSerializedPropStorage_Release(serialized);
287 ok(
hr ==
S_OK,
"PSCreateMemoryPropertyStore failed: 0x%08x.\n",
hr);
288 ok(propstorecache !=
NULL,
"got %p.\n", propstore);
289 ok(propstorecache != (
IPropertyStoreCache *)propstore,
"pointer are equal: %p, %p.\n", propstorecache, propstore);
294 ok(
hr ==
S_OK,
"PSCreateMemoryPropertyStore failed: 0x%08x.\n",
hr);
295 ok(propstore1 !=
NULL,
"got %p.\n", propstore);
296 ok(propstore1 != propstore,
"pointer are equal: %p, %p.\n", propstore1, propstore);
301 IPropertyStore_Release(propstore1);
302 IPropertyStore_Release(propstore);
303 IPropertyStoreCache_Release(propstorecache);
310 PROPVARIANT propvar, ret_propvar;
315 ok(
hr ==
S_OK,
"PSCreateMemoryPropertyStore failed: 0x%08x.\n",
hr);
316 ok(propstore !=
NULL,
"got %p.\n", propstore);
318 hr = IPropertyStore_GetCount(propstore, &
count);
319 ok(
hr ==
S_OK,
"IPropertyStore_GetCount failed: 0x%08x.\n",
hr);
320 ok(!
count,
"got wrong property count: %d, expected 0.\n",
count);
322 PropVariantInit(&propvar);
324 U(propvar).lVal = 123;
325 propkey.fmtid = DUMMY_GUID1;
327 hr = IPropertyStore_SetValue(propstore, &propkey, &propvar);
328 ok(
hr ==
S_OK,
"IPropertyStore_SetValue failed: 0x%08x.\n",
hr);
329 hr = IPropertyStore_Commit(propstore);
330 ok(
hr ==
S_OK,
"IPropertyStore_Commit failed: 0x%08x.\n",
hr);
331 hr = IPropertyStore_GetCount(propstore, &
count);
332 ok(
hr ==
S_OK,
"IPropertyStore_GetCount failed: 0x%08x.\n",
hr);
333 ok(
count == 1,
"got wrong property count: %d, expected 1.\n",
count);
334 PropVariantInit(&ret_propvar);
335 ret_propvar.vt =
VT_I4;
336 hr = IPropertyStore_GetValue(propstore, &propkey, &ret_propvar);
337 ok(
hr ==
S_OK,
"IPropertyStore_GetValue failed: 0x%08x.\n",
hr);
338 ok(ret_propvar.vt ==
VT_I4,
"got wrong property type: %x.\n", ret_propvar.vt);
339 ok(
U(ret_propvar).lVal == 123,
"got wrong value: %d, expected 123.\n",
U(ret_propvar).lVal);
343 PropVariantInit(&propvar);
344 propkey.fmtid = DUMMY_GUID1;
346 hr = IPropertyStore_SetValue(propstore, &propkey, &propvar);
347 ok(
hr ==
S_OK,
"IPropertyStore_SetValue failed: 0x%08x.\n",
hr);
348 hr = IPropertyStore_Commit(propstore);
349 ok(
hr ==
S_OK,
"IPropertyStore_Commit failed: 0x%08x.\n",
hr);
350 hr = IPropertyStore_GetCount(propstore, &
count);
351 ok(
hr ==
S_OK,
"IPropertyStore_GetCount failed: 0x%08x.\n",
hr);
352 ok(
count == 1,
"got wrong property count: %d, expected 1.\n",
count);
353 PropVariantInit(&ret_propvar);
354 hr = IPropertyStore_GetValue(propstore, &propkey, &ret_propvar);
355 ok(
hr ==
S_OK,
"IPropertyStore_GetValue failed: 0x%08x.\n",
hr);
356 ok(ret_propvar.vt ==
VT_EMPTY,
"got wrong property type: %x.\n", ret_propvar.vt);
357 ok(!
U(ret_propvar).lVal,
"got wrong value: %d, expected 0.\n",
U(ret_propvar).lVal);
361 IPropertyStore_Release(propstore);
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
GLuint GLuint GLsizei count
VOID WINAPI CoTaskMemFree(LPVOID ptr)
static void test_inmemorystore(void)
static void test_propertystore(void)
static void _expect_ref(IUnknown *obj, ULONG ref, int line)
#define EXPECT_REF(obj, ref)
static void test_persistserialized(void)
static void test_PSCreateMemoryPropertyStore(void)
struct tagSERIALIZEDROPSTORAGE SERIALIZEDPROPSTORAGE
HRESULT WINAPI PSCreateMemoryPropertyStore(REFIID riid, void **ppv)
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
#define IsEqualGUID(rguid1, rguid2)
#define TYPE_E_ELEMENTNOTFOUND