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 WCHAR propName[] = { 'p','r','o','p',0 };
50 static 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%08x\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%08x\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%08x\n", hr);
85 hr = IPropertyStorage_WriteMultiple(propertyStorage, 0, NULL, NULL, 0);
86 ok(hr == S_OK, "WriteMultiple with 0 args failed: 0x%08x\n", hr);
87 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, NULL, NULL, 0);
88 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
90 /* test setting one that I can't set */
91 spec.ulKind = PRSPEC_PROPID;
92 U(spec).propid = PID_DICTIONARY;
95 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
96 ok(hr == STG_E_INVALIDPARAMETER,
97 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
99 /* test setting one by name with an invalid propidNameFirst */
100 spec.ulKind = PRSPEC_LPWSTR;
101 U(spec).lpwstr = (LPOLESTR)propName;
102 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
104 ok(hr == STG_E_INVALIDPARAMETER,
105 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
107 /* test setting behavior (case-sensitive) */
108 spec.ulKind = PRSPEC_PROPID;
109 U(spec).propid = PID_BEHAVIOR;
111 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
112 ok(hr == STG_E_INVALIDPARAMETER,
113 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
115 /* set one by value.. */
116 spec.ulKind = PRSPEC_PROPID;
117 U(spec).propid = PID_FIRST_USABLE;
119 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
120 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
122 /* set one by name */
123 spec.ulKind = PRSPEC_LPWSTR;
124 U(spec).lpwstr = (LPOLESTR)propName;
126 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
128 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
130 /* set a string value */
131 spec.ulKind = PRSPEC_PROPID;
132 U(spec).propid = PIDSI_AUTHOR;
135 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
136 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
138 /* set a clipboard value */
139 spec.ulKind = PRSPEC_PROPID;
140 U(spec).propid = PIDSI_THUMBNAIL;
142 clipdata.cbSize = sizeof clipcontent + sizeof (ULONG);
143 clipdata.ulClipFmt = CF_ENHMETAFILE;
144 clipdata.pClipData = clipcontent;
145 U(var).pclipdata = &clipdata;
146 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
147 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
151 hr = IPropertyStorage_ReadMultiple(propertyStorage, 0, NULL, NULL);
152 ok(hr == S_FALSE, "ReadMultiple with 0 args failed: 0x%08x\n", hr);
153 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, NULL, NULL);
154 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
156 spec.ulKind = PRSPEC_PROPID;
157 U(spec).propid = PID_FIRST_USABLE;
158 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
159 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
160 ok(var.vt == VT_I4 && U(var).lVal == 1,
161 "Didn't get expected type or value for property (got type %d, value %ld)\n",
162 var.vt, U(var).lVal);
164 spec.ulKind = PRSPEC_LPWSTR;
165 U(spec).lpwstr = (LPOLESTR)propName;
166 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
167 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
168 ok(var.vt == VT_I4 && U(var).lVal == 2,
169 "Didn't get expected type or value for property (got type %d, value %ld)\n",
170 var.vt, U(var).lVal);
171 /* read string value */
172 spec.ulKind = PRSPEC_PROPID;
173 U(spec).propid = PIDSI_AUTHOR;
174 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
175 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
176 ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
177 "Didn't get expected type or value for property (got type %d, value %s)\n",
178 var.vt, U(var).pszVal);
180 /* read clipboard format */
181 spec.ulKind = PRSPEC_PROPID;
182 U(spec).propid = PIDSI_THUMBNAIL;
183 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
184 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08x\n", hr);
185 ok(var.vt == VT_CF, "variant type wrong\n");
186 ok(U(var).pclipdata->ulClipFmt == CF_ENHMETAFILE,
187 "clipboard type wrong\n");
188 ok(U(var).pclipdata->cbSize == sizeof clipcontent + sizeof (ULONG),
189 "clipboard size wrong\n");
190 ok(!memcmp(U(var).pclipdata->pClipData, clipcontent, sizeof clipcontent),
191 "clipboard contents wrong\n");
192 ok(S_OK == PropVariantClear(&var), "failed to clear variant\n");
195 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 0, NULL);
196 ok(hr == S_OK, "DeleteMultiple with 0 args failed: 0x%08x\n", hr);
197 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, NULL);
198 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
199 /* contrary to what the docs say, you can't delete the dictionary */
200 spec.ulKind = PRSPEC_PROPID;
201 U(spec).propid = PID_DICTIONARY;
202 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
203 ok(hr == STG_E_INVALIDPARAMETER,
204 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
205 /* now delete the first value.. */
206 U(spec).propid = PID_FIRST_USABLE;
207 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
208 ok(hr == S_OK, "DeleteMultiple failed: 0x%08x\n", hr);
209 /* and check that it's no longer readable */
210 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
211 ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08x\n", hr);
213 hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
214 ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
216 /* check reverting */
217 spec.ulKind = PRSPEC_PROPID;
218 U(spec).propid = PID_FIRST_USABLE;
219 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
220 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
221 hr = IPropertyStorage_Revert(propertyStorage);
222 ok(hr == S_OK, "Revert failed: 0x%08x\n", hr);
223 /* now check that it's still not there */
224 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
225 ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08x\n", hr);
226 /* set an integer value again */
227 spec.ulKind = PRSPEC_PROPID;
228 U(spec).propid = PID_FIRST_USABLE;
231 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
232 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
234 hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
235 ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
236 /* set it to a string value */
238 U(var).pszVal = (LPSTR)val;
239 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
240 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
242 hr = IPropertyStorage_Revert(propertyStorage);
243 ok(hr == S_OK, "Revert failed: 0x%08x\n", hr);
244 /* Oddly enough, there's no guarantee that a successful revert actually
245 * implies the value wasn't saved. Maybe transactional mode needs to be
249 IPropertyStorage_Release(propertyStorage);
250 propertyStorage = NULL;
251 IPropertySetStorage_Release(propSetStorage);
252 propSetStorage = NULL;
253 IStorage_Release(storage);
256 /* now open it again */
257 hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
259 ok(hr == S_OK, "StgOpenStorage failed: 0x%08x\n", hr);
261 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
262 ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
264 hr = IPropertySetStorage_Open(propSetStorage, &FMTID_SummaryInformation,
265 STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
266 ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08x\n", hr);
268 /* check properties again */
269 spec.ulKind = PRSPEC_LPWSTR;
270 U(spec).lpwstr = (LPOLESTR)propName;
271 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
272 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
273 ok(var.vt == VT_I4 && U(var).lVal == 2,
274 "Didn't get expected type or value for property (got type %d, value %ld)\n",
275 var.vt, U(var).lVal);
276 spec.ulKind = PRSPEC_PROPID;
277 U(spec).propid = PIDSI_AUTHOR;
278 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
279 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
280 ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
281 "Didn't get expected type or value for property (got type %d, value %s)\n",
282 var.vt, U(var).pszVal);
284 IPropertyStorage_Release(propertyStorage);
285 IPropertySetStorage_Release(propSetStorage);
286 IStorage_Release(storage);
288 DeleteFileW(filename);
291 static void testCodepage(void)
293 static const WCHAR szDot[] = { '.',0 };
294 static const WCHAR szPrefix[] = { 's','t','g',0 };
295 static CHAR aval[] = "hi";
296 static WCHAR wval[] = { 'h','i',0 };
298 IStorage *storage = NULL;
299 IPropertySetStorage *propSetStorage = NULL;
300 IPropertyStorage *propertyStorage = NULL;
303 WCHAR fileName[MAX_PATH];
305 if(!GetTempFileNameW(szDot, szPrefix, 0, fileName))
308 hr = StgCreateDocfile(fileName,
309 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
310 ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
312 if(!pStgCreatePropSetStg)
314 IStorage_Release(storage);
315 DeleteFileW(fileName);
318 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
319 ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
321 hr = IPropertySetStorage_Create(propSetStorage,
322 &FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT,
323 STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
325 ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
327 PropVariantInit(&var);
328 spec.ulKind = PRSPEC_PROPID;
329 U(spec).propid = PID_CODEPAGE;
330 /* check code page before it's been explicitly set */
331 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
332 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
333 ok(var.vt == VT_I2 && U(var).iVal == 1200,
334 "Didn't get expected type or value for property\n");
335 /* Set the code page to ascii */
338 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
339 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
340 /* check code page */
341 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
342 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
343 ok(var.vt == VT_I2 && U(var).iVal == 1252,
344 "Didn't get expected type or value for property\n");
345 /* Set code page to Unicode */
347 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
348 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
349 /* check code page */
350 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
351 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
352 ok(var.vt == VT_I2 && U(var).iVal == 1200,
353 "Didn't get expected type or value for property\n");
354 /* Set a string value */
355 spec.ulKind = PRSPEC_PROPID;
356 U(spec).propid = PID_FIRST_USABLE;
358 U(var).pszVal = aval;
359 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
360 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
361 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
362 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
363 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "hi"),
364 "Didn't get expected type or value for property\n");
365 /* This seemingly non-sensical test is to show that the string is indeed
366 * interpreted according to the current system code page, not according to
367 * the property set's code page. (If the latter were true, the whole
368 * string would be maintained. As it is, only the first character is.)
370 U(var).pszVal = (LPSTR)wval;
371 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
372 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
373 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
374 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
375 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "h"),
376 "Didn't get expected type or value for property\n");
377 /* now that a property's been set, you can't change the code page */
378 spec.ulKind = PRSPEC_PROPID;
379 U(spec).propid = PID_CODEPAGE;
382 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
383 ok(hr == STG_E_INVALIDPARAMETER,
384 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
386 IPropertyStorage_Release(propertyStorage);
387 IPropertySetStorage_Release(propSetStorage);
388 IStorage_Release(storage);
390 DeleteFileW(fileName);
392 /* same tests, but with PROPSETFLAG_ANSI */
393 hr = StgCreateDocfile(fileName,
394 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
395 ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
397 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
398 ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
400 hr = IPropertySetStorage_Create(propSetStorage,
401 &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
402 STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
404 ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
406 /* check code page before it's been explicitly set */
407 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
408 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
409 ok(var.vt == VT_I2 && U(var).iVal == 1252,
410 "Didn't get expected type or value for property\n");
411 /* Set code page to Unicode */
413 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
414 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
415 /* check code page */
416 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
417 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
418 ok(var.vt == VT_I2 && U(var).iVal == 1200,
419 "Didn't get expected type or value for property\n");
420 /* This test is commented out for documentation. It fails under Wine,
421 * and I expect it would under Windows as well, yet it succeeds. There's
422 * obviously something about string conversion I don't understand.
425 static unsigned char strVal[] = { 0x81, 0xff, 0x04, 0 };
426 /* Set code page to 950 (Traditional Chinese) */
428 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
429 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
430 /* Try writing an invalid string: lead byte 0x81 is unused in Traditional
433 spec.ulKind = PRSPEC_PROPID;
434 U(spec).propid = PID_FIRST_USABLE;
436 U(var).pszVal = (LPSTR)strVal;
437 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
438 ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
439 /* Check returned string */
440 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
441 ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
442 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, (LPCSTR)strVal),
443 "Didn't get expected type or value for property\n");
446 IPropertyStorage_Release(propertyStorage);
447 IPropertySetStorage_Release(propSetStorage);
448 IStorage_Release(storage);
450 DeleteFileW(fileName);
453 static void testFmtId(void)
455 WCHAR szSummaryInfo[] = { 5,'S','u','m','m','a','r','y',
456 'I','n','f','o','r','m','a','t','i','o','n',0 };
457 WCHAR szDocSummaryInfo[] = { 5,'D','o','c','u','m','e','n','t',
458 'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',
460 WCHAR szIID_IPropSetStg[] = { 5,'0','j','a','a','a','a','a',
461 'a','A','a','a','a','a','a','d','a','A','a','a','a','a','a','a','a','G',
467 if (pFmtIdToPropStgName) {
468 hr = pFmtIdToPropStgName(NULL, name);
469 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
470 hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, NULL);
471 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
472 hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, name);
473 ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
474 ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) *
475 sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n");
476 hr = pFmtIdToPropStgName(&FMTID_DocSummaryInformation, name);
477 ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
478 ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
479 sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
480 hr = pFmtIdToPropStgName(&FMTID_UserDefinedProperties, name);
481 ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
482 ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
483 sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
484 hr = pFmtIdToPropStgName(&IID_IPropertySetStorage, name);
485 ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
486 ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) *
487 sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n");
490 if(pPropStgNameToFmtId) {
491 /* test args first */
492 hr = pPropStgNameToFmtId(NULL, NULL);
493 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
494 hr = pPropStgNameToFmtId(NULL, &fmtid);
495 ok(hr == STG_E_INVALIDNAME, "Expected STG_E_INVALIDNAME, got 0x%08x\n",
497 hr = pPropStgNameToFmtId(szDocSummaryInfo, NULL);
498 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
499 /* test the known format IDs */
500 hr = pPropStgNameToFmtId(szSummaryInfo, &fmtid);
501 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
502 ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)),
503 "Got unexpected FMTID, expected FMTID_SummaryInformation\n");
504 hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
505 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
506 ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
507 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
508 /* test another GUID */
509 hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
510 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
511 ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
512 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
513 /* now check case matching */
514 CharUpperW(szDocSummaryInfo + 1);
515 hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
516 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
517 ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
518 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
519 CharUpperW(szIID_IPropSetStg + 1);
520 hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
521 ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
522 ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
523 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
529 init_function_pointers();