1 /* IPropertyStorage unit tests
2 * Copyright 2005 Juan Lang
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
24 #define PID_BEHAVIOR 0x80000003
27 static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
28 static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
29 static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
31 static void init_function_pointers(void)
33 HMODULE hmod = GetModuleHandleA("ole32.dll");
37 pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
38 pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
39 pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
42 /* FIXME: this creates an ANSI storage, try to find conditions under which
43 * Unicode translation fails
45 static void testProps(void)
47 static const WCHAR szDot[] = { '.',0 };
48 static const WCHAR szPrefix[] = { 's','t','g',0 };
49 static const WCHAR propName[] = { 'p','r','o','p',0 };
50 static const char val[] = "l33t auth0r";
51 WCHAR filename[MAX_PATH];
53 IStorage *storage = NULL;
54 IPropertySetStorage *propSetStorage = NULL;
55 IPropertyStorage *propertyStorage = NULL;
59 unsigned char clipcontent[] = "foobar";
61 if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
64 DeleteFileW(filename);
66 hr = StgCreateDocfile(filename,
67 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
68 ok(hr == S_OK, "StgCreateDocfile failed: 0x%08lx\n", hr);
70 if(!pStgCreatePropSetStg)
72 IStorage_Release(storage);
73 DeleteFileW(filename);
76 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
77 ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08lx\n", hr);
79 hr = IPropertySetStorage_Create(propSetStorage,
80 &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
81 STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
83 ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
85 hr = IPropertyStorage_WriteMultiple(propertyStorage, 0, NULL, NULL, 0);
86 ok(hr == S_OK, "WriteMultiple with 0 args failed: 0x%08lx\n", hr);
87 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, NULL, NULL, 0);
88 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
90 /* test setting one that I can't set */
91 spec.ulKind = PRSPEC_PROPID;
92 U(spec).propid = PID_DICTIONARY;
93 PropVariantClear(&var);
96 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
97 ok(hr == STG_E_INVALIDPARAMETER,
98 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
100 /* test setting one by name with an invalid propidNameFirst */
101 spec.ulKind = PRSPEC_LPWSTR;
102 U(spec).lpwstr = (LPOLESTR)propName;
103 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
105 ok(hr == STG_E_INVALIDPARAMETER,
106 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
108 /* test setting behavior (case-sensitive) */
109 spec.ulKind = PRSPEC_PROPID;
110 U(spec).propid = PID_BEHAVIOR;
112 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
113 ok(hr == STG_E_INVALIDPARAMETER,
114 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
116 /* set one by value.. */
117 spec.ulKind = PRSPEC_PROPID;
118 U(spec).propid = PID_FIRST_USABLE;
120 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
121 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
123 /* set one by name */
124 spec.ulKind = PRSPEC_LPWSTR;
125 U(spec).lpwstr = (LPOLESTR)propName;
127 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
129 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
131 /* set a string value */
132 spec.ulKind = PRSPEC_PROPID;
133 U(spec).propid = PIDSI_AUTHOR;
135 U(var).pszVal = (LPSTR)val;
136 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
137 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
139 /* set a clipboard value */
140 spec.ulKind = PRSPEC_PROPID;
141 U(spec).propid = PIDSI_THUMBNAIL;
143 clipdata.cbSize = sizeof clipcontent + sizeof (ULONG);
144 clipdata.ulClipFmt = CF_ENHMETAFILE;
145 clipdata.pClipData = clipcontent;
146 U(var).pclipdata = &clipdata;
147 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
148 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
152 hr = IPropertyStorage_ReadMultiple(propertyStorage, 0, NULL, NULL);
153 ok(hr == S_FALSE, "ReadMultiple with 0 args failed: 0x%08lx\n", hr);
154 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, NULL, NULL);
155 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
157 spec.ulKind = PRSPEC_PROPID;
158 U(spec).propid = PID_FIRST_USABLE;
159 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
160 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
161 ok(var.vt == VT_I4 && U(var).lVal == 1,
162 "Didn't get expected type or value for property (got type %d, value %ld)\n",
163 var.vt, U(var).lVal);
165 spec.ulKind = PRSPEC_LPWSTR;
166 U(spec).lpwstr = (LPOLESTR)propName;
167 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
168 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
169 ok(var.vt == VT_I4 && U(var).lVal == 2,
170 "Didn't get expected type or value for property (got type %d, value %ld)\n",
171 var.vt, U(var).lVal);
172 /* read string value */
173 spec.ulKind = PRSPEC_PROPID;
174 U(spec).propid = PIDSI_AUTHOR;
175 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
176 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
177 ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
178 "Didn't get expected type or value for property (got type %d, value %s)\n",
179 var.vt, U(var).pszVal);
181 /* read clipboard format */
182 spec.ulKind = PRSPEC_PROPID;
183 U(spec).propid = PIDSI_THUMBNAIL;
184 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
185 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
186 ok(var.vt == VT_CF, "variant type wrong\n");
187 ok(U(var).pclipdata->ulClipFmt == CF_ENHMETAFILE,
188 "clipboard type wrong\n");
189 ok(U(var).pclipdata->cbSize == sizeof clipcontent + sizeof (ULONG),
190 "clipboard size wrong\n");
191 ok(!memcmp(U(var).pclipdata->pClipData, clipcontent, sizeof clipcontent),
192 "clipboard contents wrong\n");
193 ok(S_OK == PropVariantClear(&var), "failed to clear variant\n");
196 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 0, NULL);
197 ok(hr == S_OK, "DeleteMultiple with 0 args failed: 0x%08lx\n", hr);
198 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, NULL);
199 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
200 /* contrary to what the docs say, you can't delete the dictionary */
201 spec.ulKind = PRSPEC_PROPID;
202 U(spec).propid = PID_DICTIONARY;
203 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
204 ok(hr == STG_E_INVALIDPARAMETER,
205 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
206 /* now delete the first value.. */
207 U(spec).propid = PID_FIRST_USABLE;
208 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
209 ok(hr == S_OK, "DeleteMultiple failed: 0x%08lx\n", hr);
210 /* and check that it's no longer readable */
211 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
212 ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08lx\n", hr);
214 hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
215 ok(hr == S_OK, "Commit failed: 0x%08lx\n", hr);
217 /* check reverting */
218 spec.ulKind = PRSPEC_PROPID;
219 U(spec).propid = PID_FIRST_USABLE;
220 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
221 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
222 hr = IPropertyStorage_Revert(propertyStorage);
223 ok(hr == S_OK, "Revert failed: 0x%08lx\n", hr);
224 /* now check that it's still not there */
225 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
226 ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08lx\n", hr);
227 /* set an integer value again */
228 spec.ulKind = PRSPEC_PROPID;
229 U(spec).propid = PID_FIRST_USABLE;
232 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
233 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
235 hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
236 ok(hr == S_OK, "Commit failed: 0x%08lx\n", hr);
237 /* set it to a string value */
239 U(var).pszVal = (LPSTR)val;
240 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
241 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
243 hr = IPropertyStorage_Revert(propertyStorage);
244 ok(hr == S_OK, "Revert failed: 0x%08lx\n", hr);
245 /* Oddly enough, there's no guarantee that a successful revert actually
246 * implies the value wasn't saved. Maybe transactional mode needs to be
250 IPropertyStorage_Release(propertyStorage);
251 propertyStorage = NULL;
252 IPropertySetStorage_Release(propSetStorage);
253 propSetStorage = NULL;
254 IStorage_Release(storage);
257 /* now open it again */
258 hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
260 ok(hr == S_OK, "StgOpenStorage failed: 0x%08lx\n", hr);
262 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
263 ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08lx\n", hr);
265 hr = IPropertySetStorage_Open(propSetStorage, &FMTID_SummaryInformation,
266 STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
267 ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08lx\n", hr);
269 /* check properties again */
270 spec.ulKind = PRSPEC_LPWSTR;
271 U(spec).lpwstr = (LPOLESTR)propName;
272 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
273 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
274 ok(var.vt == VT_I4 && U(var).lVal == 2,
275 "Didn't get expected type or value for property (got type %d, value %ld)\n",
276 var.vt, U(var).lVal);
277 spec.ulKind = PRSPEC_PROPID;
278 U(spec).propid = PIDSI_AUTHOR;
279 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
280 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
281 ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
282 "Didn't get expected type or value for property (got type %d, value %s)\n",
283 var.vt, U(var).pszVal);
285 IPropertyStorage_Release(propertyStorage);
286 IPropertySetStorage_Release(propSetStorage);
287 IStorage_Release(storage);
289 DeleteFileW(filename);
292 static void testCodepage(void)
294 static const WCHAR szDot[] = { '.',0 };
295 static const WCHAR szPrefix[] = { 's','t','g',0 };
296 static CHAR aval[] = "hi";
297 static const WCHAR wval[] = { 'h','i',0 };
299 IStorage *storage = NULL;
300 IPropertySetStorage *propSetStorage = NULL;
301 IPropertyStorage *propertyStorage = NULL;
304 WCHAR fileName[MAX_PATH];
306 if(!GetTempFileNameW(szDot, szPrefix, 0, fileName))
309 hr = StgCreateDocfile(fileName,
310 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
311 ok(hr == S_OK, "StgCreateDocfile failed: 0x%08lx\n", hr);
313 if(!pStgCreatePropSetStg)
315 IStorage_Release(storage);
316 DeleteFileW(fileName);
319 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
320 ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08lx\n", hr);
322 hr = IPropertySetStorage_Create(propSetStorage,
323 &FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT,
324 STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
326 ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
328 PropVariantInit(&var);
329 spec.ulKind = PRSPEC_PROPID;
330 U(spec).propid = PID_CODEPAGE;
331 /* check code page before it's been explicitly set */
332 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
333 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
334 ok(var.vt == VT_I2 && U(var).iVal == 1200,
335 "Didn't get expected type or value for property\n");
336 /* Set the code page to ascii */
339 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
340 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
341 /* check code page */
342 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
343 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
344 ok(var.vt == VT_I2 && U(var).iVal == 1252,
345 "Didn't get expected type or value for property\n");
346 /* Set code page to Unicode */
348 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
349 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
350 /* check code page */
351 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
352 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
353 ok(var.vt == VT_I2 && U(var).iVal == 1200,
354 "Didn't get expected type or value for property\n");
355 /* Set a string value */
356 spec.ulKind = PRSPEC_PROPID;
357 U(spec).propid = PID_FIRST_USABLE;
359 U(var).pszVal = aval;
360 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
361 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
362 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
363 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
364 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "hi"),
365 "Didn't get expected type or value for property\n");
366 /* This seemingly non-sensical test is to show that the string is indeed
367 * interpreted according to the current system code page, not according to
368 * the property set's code page. (If the latter were true, the whole
369 * string would be maintained. As it is, only the first character is.)
371 U(var).pszVal = (LPSTR)wval;
372 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
373 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
374 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
375 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
376 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "h"),
377 "Didn't get expected type or value for property\n");
378 /* now that a property's been set, you can't change the code page */
379 spec.ulKind = PRSPEC_PROPID;
380 U(spec).propid = PID_CODEPAGE;
383 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
384 ok(hr == STG_E_INVALIDPARAMETER,
385 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
387 IPropertyStorage_Release(propertyStorage);
388 IPropertySetStorage_Release(propSetStorage);
389 IStorage_Release(storage);
391 DeleteFileW(fileName);
393 /* same tests, but with PROPSETFLAG_ANSI */
394 hr = StgCreateDocfile(fileName,
395 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
396 ok(hr == S_OK, "StgCreateDocfile failed: 0x%08lx\n", hr);
398 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
399 ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08lx\n", hr);
401 hr = IPropertySetStorage_Create(propSetStorage,
402 &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
403 STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
405 ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
407 /* check code page before it's been explicitly set */
408 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
409 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
410 ok(var.vt == VT_I2 && U(var).iVal == 1252,
411 "Didn't get expected type or value for property\n");
412 /* Set code page to Unicode */
414 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
415 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
416 /* check code page */
417 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
418 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
419 ok(var.vt == VT_I2 && U(var).iVal == 1200,
420 "Didn't get expected type or value for property\n");
421 /* This test is commented out for documentation. It fails under Wine,
422 * and I expect it would under Windows as well, yet it succeeds. There's
423 * obviously something about string conversion I don't understand.
426 static const unsigned char strVal[] = { 0x81, 0xff, 0x04, 0 };
427 /* Set code page to 950 (Traditional Chinese) */
429 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
430 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
431 /* Try writing an invalid string: lead byte 0x81 is unused in Traditional
434 spec.ulKind = PRSPEC_PROPID;
435 U(spec).propid = PID_FIRST_USABLE;
437 U(var).pszVal = (LPSTR)strVal;
438 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
439 ok(hr == S_OK, "WriteMultiple failed: 0x%08lx\n", hr);
440 /* Check returned string */
441 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
442 ok(hr == S_OK, "ReadMultiple failed: 0x%08lx\n", hr);
443 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, (LPCSTR)strVal),
444 "Didn't get expected type or value for property\n");
447 IPropertyStorage_Release(propertyStorage);
448 IPropertySetStorage_Release(propSetStorage);
449 IStorage_Release(storage);
451 DeleteFileW(fileName);
454 static void testFmtId(void)
456 WCHAR szSummaryInfo[] = { 5,'S','u','m','m','a','r','y',
457 'I','n','f','o','r','m','a','t','i','o','n',0 };
458 WCHAR szDocSummaryInfo[] = { 5,'D','o','c','u','m','e','n','t',
459 'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',
461 WCHAR szIID_IPropSetStg[] = { 5,'0','j','a','a','a','a','a',
462 'a','A','a','a','a','a','a','d','a','A','a','a','a','a','a','a','a','G',
468 if (pFmtIdToPropStgName) {
469 hr = pFmtIdToPropStgName(NULL, name);
470 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
471 hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, NULL);
472 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
473 hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, name);
474 ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08lx\n", hr);
475 ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) *
476 sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n");
477 hr = pFmtIdToPropStgName(&FMTID_DocSummaryInformation, name);
478 ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08lx\n", hr);
479 ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
480 sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
481 hr = pFmtIdToPropStgName(&FMTID_UserDefinedProperties, name);
482 ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08lx\n", hr);
483 ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
484 sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
485 hr = pFmtIdToPropStgName(&IID_IPropertySetStorage, name);
486 ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08lx\n", hr);
487 ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) *
488 sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n");
491 if(pPropStgNameToFmtId) {
492 /* test args first */
493 hr = pPropStgNameToFmtId(NULL, NULL);
494 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
495 hr = pPropStgNameToFmtId(NULL, &fmtid);
496 ok(hr == STG_E_INVALIDNAME, "Expected STG_E_INVALIDNAME, got 0x%08lx\n",
498 hr = pPropStgNameToFmtId(szDocSummaryInfo, NULL);
499 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
500 /* test the known format IDs */
501 hr = pPropStgNameToFmtId(szSummaryInfo, &fmtid);
502 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08lx\n", hr);
503 ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)),
504 "Got unexpected FMTID, expected FMTID_SummaryInformation\n");
505 hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
506 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08lx\n", hr);
507 ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
508 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
509 /* test another GUID */
510 hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
511 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08lx\n", hr);
512 ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
513 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
514 /* now check case matching */
515 CharUpperW(szDocSummaryInfo + 1);
516 hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
517 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08lx\n", hr);
518 ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
519 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
520 CharUpperW(szIID_IPropSetStg + 1);
521 hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
522 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08lx\n", hr);
523 ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
524 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
530 init_function_pointers();