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");
34 pFmtIdToPropStgName
= (void*)GetProcAddress(hmod
, "FmtIdToPropStgName");
35 pPropStgNameToFmtId
= (void*)GetProcAddress(hmod
, "PropStgNameToFmtId");
36 pStgCreatePropSetStg
= (void*)GetProcAddress(hmod
, "StgCreatePropSetStg");
38 /* FIXME: this creates an ANSI storage, try to find conditions under which
39 * Unicode translation fails
41 static void testProps(void)
43 static const WCHAR szDot
[] = { '.',0 };
44 static const WCHAR szPrefix
[] = { 's','t','g',0 };
45 static WCHAR propName
[] = { 'p','r','o','p',0 };
46 static char val
[] = "l33t auth0r";
47 WCHAR filename
[MAX_PATH
];
49 IStorage
*storage
= NULL
;
50 IPropertySetStorage
*propSetStorage
= NULL
;
51 IPropertyStorage
*propertyStorage
= NULL
;
55 unsigned char clipcontent
[] = "foobar";
57 if(!GetTempFileNameW(szDot
, szPrefix
, 0, filename
))
60 DeleteFileW(filename
);
62 hr
= StgCreateDocfile(filename
,
63 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, &storage
);
64 ok(hr
== S_OK
, "StgCreateDocfile failed: 0x%08x\n", hr
);
66 if(!pStgCreatePropSetStg
)
68 IStorage_Release(storage
);
69 DeleteFileW(filename
);
72 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
73 ok(hr
== S_OK
, "StgCreatePropSetStg failed: 0x%08x\n", hr
);
75 hr
= IPropertySetStorage_Create(propSetStorage
,
76 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_ANSI
,
77 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
79 ok(hr
== S_OK
, "IPropertySetStorage_Create failed: 0x%08x\n", hr
);
81 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 0, NULL
, NULL
, 0);
82 ok(hr
== S_OK
, "WriteMultiple with 0 args failed: 0x%08x\n", hr
);
83 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, NULL
, NULL
, 0);
84 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08x\n", hr
);
86 /* test setting one that I can't set */
87 spec
.ulKind
= PRSPEC_PROPID
;
88 U(spec
).propid
= PID_DICTIONARY
;
91 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
92 ok(hr
== STG_E_INVALIDPARAMETER
,
93 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr
);
95 /* test setting one by name with an invalid propidNameFirst */
96 spec
.ulKind
= PRSPEC_LPWSTR
;
97 U(spec
).lpwstr
= (LPOLESTR
)propName
;
98 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
,
100 ok(hr
== STG_E_INVALIDPARAMETER
,
101 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr
);
103 /* test setting behavior (case-sensitive) */
104 spec
.ulKind
= PRSPEC_PROPID
;
105 U(spec
).propid
= PID_BEHAVIOR
;
107 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
108 ok(hr
== STG_E_INVALIDPARAMETER
,
109 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr
);
111 /* set one by value.. */
112 spec
.ulKind
= PRSPEC_PROPID
;
113 U(spec
).propid
= PID_FIRST_USABLE
;
115 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
116 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
118 /* set one by name */
119 spec
.ulKind
= PRSPEC_LPWSTR
;
120 U(spec
).lpwstr
= (LPOLESTR
)propName
;
122 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
,
124 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
126 /* set a string value */
127 spec
.ulKind
= PRSPEC_PROPID
;
128 U(spec
).propid
= PIDSI_AUTHOR
;
131 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
132 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
134 /* set a clipboard value */
135 spec
.ulKind
= PRSPEC_PROPID
;
136 U(spec
).propid
= PIDSI_THUMBNAIL
;
138 clipdata
.cbSize
= sizeof clipcontent
+ sizeof (ULONG
);
139 clipdata
.ulClipFmt
= CF_ENHMETAFILE
;
140 clipdata
.pClipData
= clipcontent
;
141 U(var
).pclipdata
= &clipdata
;
142 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
143 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
147 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 0, NULL
, NULL
);
148 ok(hr
== S_FALSE
, "ReadMultiple with 0 args failed: 0x%08x\n", hr
);
149 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, NULL
, NULL
);
150 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08x\n", hr
);
152 spec
.ulKind
= PRSPEC_PROPID
;
153 U(spec
).propid
= PID_FIRST_USABLE
;
154 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
155 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
156 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 1,
157 "Didn't get expected type or value for property (got type %d, value %ld)\n",
158 var
.vt
, U(var
).lVal
);
160 spec
.ulKind
= PRSPEC_LPWSTR
;
161 U(spec
).lpwstr
= (LPOLESTR
)propName
;
162 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
163 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
164 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 2,
165 "Didn't get expected type or value for property (got type %d, value %ld)\n",
166 var
.vt
, U(var
).lVal
);
167 /* read string value */
168 spec
.ulKind
= PRSPEC_PROPID
;
169 U(spec
).propid
= PIDSI_AUTHOR
;
170 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
171 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
172 ok(var
.vt
== VT_LPSTR
&& !lstrcmpA(U(var
).pszVal
, val
),
173 "Didn't get expected type or value for property (got type %d, value %s)\n",
174 var
.vt
, U(var
).pszVal
);
176 /* read clipboard format */
177 spec
.ulKind
= PRSPEC_PROPID
;
178 U(spec
).propid
= PIDSI_THUMBNAIL
;
179 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
180 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08x\n", hr
);
181 ok(var
.vt
== VT_CF
, "variant type wrong\n");
182 ok(U(var
).pclipdata
->ulClipFmt
== CF_ENHMETAFILE
,
183 "clipboard type wrong\n");
184 ok(U(var
).pclipdata
->cbSize
== sizeof clipcontent
+ sizeof (ULONG
),
185 "clipboard size wrong\n");
186 ok(!memcmp(U(var
).pclipdata
->pClipData
, clipcontent
, sizeof clipcontent
),
187 "clipboard contents wrong\n");
188 ok(S_OK
== PropVariantClear(&var
), "failed to clear variant\n");
191 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 0, NULL
);
192 ok(hr
== S_OK
, "DeleteMultiple with 0 args failed: 0x%08x\n", hr
);
193 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, NULL
);
194 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08x\n", hr
);
195 /* contrary to what the docs say, you can't delete the dictionary */
196 spec
.ulKind
= PRSPEC_PROPID
;
197 U(spec
).propid
= PID_DICTIONARY
;
198 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, &spec
);
199 ok(hr
== STG_E_INVALIDPARAMETER
,
200 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr
);
201 /* now delete the first value.. */
202 U(spec
).propid
= PID_FIRST_USABLE
;
203 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, &spec
);
204 ok(hr
== S_OK
, "DeleteMultiple failed: 0x%08x\n", hr
);
205 /* and check that it's no longer readable */
206 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
207 ok(hr
== S_FALSE
, "Expected S_FALSE, got 0x%08x\n", hr
);
209 hr
= IPropertyStorage_Commit(propertyStorage
, STGC_DEFAULT
);
210 ok(hr
== S_OK
, "Commit failed: 0x%08x\n", hr
);
212 /* check reverting */
213 spec
.ulKind
= PRSPEC_PROPID
;
214 U(spec
).propid
= PID_FIRST_USABLE
;
215 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
216 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
217 hr
= IPropertyStorage_Revert(propertyStorage
);
218 ok(hr
== S_OK
, "Revert failed: 0x%08x\n", hr
);
219 /* now check that it's still not there */
220 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
221 ok(hr
== S_FALSE
, "Expected S_FALSE, got 0x%08x\n", hr
);
222 /* set an integer value again */
223 spec
.ulKind
= PRSPEC_PROPID
;
224 U(spec
).propid
= PID_FIRST_USABLE
;
227 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
228 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
230 hr
= IPropertyStorage_Commit(propertyStorage
, STGC_DEFAULT
);
231 ok(hr
== S_OK
, "Commit failed: 0x%08x\n", hr
);
232 /* set it to a string value */
234 U(var
).pszVal
= (LPSTR
)val
;
235 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
236 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
238 hr
= IPropertyStorage_Revert(propertyStorage
);
239 ok(hr
== S_OK
, "Revert failed: 0x%08x\n", hr
);
240 /* Oddly enough, there's no guarantee that a successful revert actually
241 * implies the value wasn't saved. Maybe transactional mode needs to be
245 IPropertyStorage_Release(propertyStorage
);
246 propertyStorage
= NULL
;
247 IPropertySetStorage_Release(propSetStorage
);
248 propSetStorage
= NULL
;
249 IStorage_Release(storage
);
252 /* now open it again */
253 hr
= StgOpenStorage(filename
, NULL
, STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
,
255 ok(hr
== S_OK
, "StgOpenStorage failed: 0x%08x\n", hr
);
257 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
258 ok(hr
== S_OK
, "StgCreatePropSetStg failed: 0x%08x\n", hr
);
260 hr
= IPropertySetStorage_Open(propSetStorage
, &FMTID_SummaryInformation
,
261 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
, &propertyStorage
);
262 ok(hr
== S_OK
, "IPropertySetStorage_Open failed: 0x%08x\n", hr
);
264 /* check properties again */
265 spec
.ulKind
= PRSPEC_LPWSTR
;
266 U(spec
).lpwstr
= (LPOLESTR
)propName
;
267 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
268 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
269 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 2,
270 "Didn't get expected type or value for property (got type %d, value %ld)\n",
271 var
.vt
, U(var
).lVal
);
272 spec
.ulKind
= PRSPEC_PROPID
;
273 U(spec
).propid
= PIDSI_AUTHOR
;
274 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
275 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
276 ok(var
.vt
== VT_LPSTR
&& !lstrcmpA(U(var
).pszVal
, val
),
277 "Didn't get expected type or value for property (got type %d, value %s)\n",
278 var
.vt
, U(var
).pszVal
);
280 IPropertyStorage_Release(propertyStorage
);
281 IPropertySetStorage_Release(propSetStorage
);
282 IStorage_Release(storage
);
284 DeleteFileW(filename
);
287 static void testCodepage(void)
289 static const WCHAR szDot
[] = { '.',0 };
290 static const WCHAR szPrefix
[] = { 's','t','g',0 };
291 static CHAR aval
[] = "hi";
292 static WCHAR wval
[] = { 'h','i',0 };
294 IStorage
*storage
= NULL
;
295 IPropertySetStorage
*propSetStorage
= NULL
;
296 IPropertyStorage
*propertyStorage
= NULL
;
299 WCHAR fileName
[MAX_PATH
];
301 if(!GetTempFileNameW(szDot
, szPrefix
, 0, fileName
))
304 hr
= StgCreateDocfile(fileName
,
305 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, &storage
);
306 ok(hr
== S_OK
, "StgCreateDocfile failed: 0x%08x\n", hr
);
308 if(!pStgCreatePropSetStg
)
310 IStorage_Release(storage
);
311 DeleteFileW(fileName
);
314 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
315 ok(hr
== S_OK
, "StgCreatePropSetStg failed: 0x%08x\n", hr
);
317 hr
= IPropertySetStorage_Create(propSetStorage
,
318 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_DEFAULT
,
319 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
321 ok(hr
== S_OK
, "IPropertySetStorage_Create failed: 0x%08x\n", hr
);
323 PropVariantInit(&var
);
324 spec
.ulKind
= PRSPEC_PROPID
;
325 U(spec
).propid
= PID_CODEPAGE
;
326 /* check code page before it's been explicitly set */
327 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
328 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
329 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
330 "Didn't get expected type or value for property\n");
331 /* Set the code page to ascii */
334 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
335 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
336 /* check code page */
337 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
338 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
339 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1252,
340 "Didn't get expected type or value for property\n");
341 /* Set code page to Unicode */
343 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
344 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
345 /* check code page */
346 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
347 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
348 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
349 "Didn't get expected type or value for property\n");
350 /* Set a string value */
351 spec
.ulKind
= PRSPEC_PROPID
;
352 U(spec
).propid
= PID_FIRST_USABLE
;
354 U(var
).pszVal
= aval
;
355 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
356 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
357 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
358 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
359 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, "hi"),
360 "Didn't get expected type or value for property\n");
361 /* This seemingly non-sensical test is to show that the string is indeed
362 * interpreted according to the current system code page, not according to
363 * the property set's code page. (If the latter were true, the whole
364 * string would be maintained. As it is, only the first character is.)
366 U(var
).pszVal
= (LPSTR
)wval
;
367 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
368 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
369 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
370 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
371 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, "h"),
372 "Didn't get expected type or value for property\n");
373 /* now that a property's been set, you can't change the code page */
374 spec
.ulKind
= PRSPEC_PROPID
;
375 U(spec
).propid
= PID_CODEPAGE
;
378 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
379 ok(hr
== STG_E_INVALIDPARAMETER
,
380 "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr
);
382 IPropertyStorage_Release(propertyStorage
);
383 IPropertySetStorage_Release(propSetStorage
);
384 IStorage_Release(storage
);
386 DeleteFileW(fileName
);
388 /* same tests, but with PROPSETFLAG_ANSI */
389 hr
= StgCreateDocfile(fileName
,
390 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, &storage
);
391 ok(hr
== S_OK
, "StgCreateDocfile failed: 0x%08x\n", hr
);
393 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
394 ok(hr
== S_OK
, "StgCreatePropSetStg failed: 0x%08x\n", hr
);
396 hr
= IPropertySetStorage_Create(propSetStorage
,
397 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_ANSI
,
398 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
400 ok(hr
== S_OK
, "IPropertySetStorage_Create failed: 0x%08x\n", hr
);
402 /* check code page before it's been explicitly set */
403 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
404 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
405 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1252,
406 "Didn't get expected type or value for property\n");
407 /* Set code page to Unicode */
409 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
410 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
411 /* check code page */
412 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
413 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
414 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
415 "Didn't get expected type or value for property\n");
416 /* This test is commented out for documentation. It fails under Wine,
417 * and I expect it would under Windows as well, yet it succeeds. There's
418 * obviously something about string conversion I don't understand.
421 static unsigned char strVal
[] = { 0x81, 0xff, 0x04, 0 };
422 /* Set code page to 950 (Traditional Chinese) */
424 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
425 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
426 /* Try writing an invalid string: lead byte 0x81 is unused in Traditional
429 spec
.ulKind
= PRSPEC_PROPID
;
430 U(spec
).propid
= PID_FIRST_USABLE
;
432 U(var
).pszVal
= (LPSTR
)strVal
;
433 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
434 ok(hr
== S_OK
, "WriteMultiple failed: 0x%08x\n", hr
);
435 /* Check returned string */
436 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
437 ok(hr
== S_OK
, "ReadMultiple failed: 0x%08x\n", hr
);
438 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, (LPCSTR
)strVal
),
439 "Didn't get expected type or value for property\n");
442 IPropertyStorage_Release(propertyStorage
);
443 IPropertySetStorage_Release(propSetStorage
);
444 IStorage_Release(storage
);
446 DeleteFileW(fileName
);
449 static void testFmtId(void)
451 WCHAR szSummaryInfo
[] = { 5,'S','u','m','m','a','r','y',
452 'I','n','f','o','r','m','a','t','i','o','n',0 };
453 WCHAR szDocSummaryInfo
[] = { 5,'D','o','c','u','m','e','n','t',
454 'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',
456 WCHAR szIID_IPropSetStg
[] = { 5,'0','j','a','a','a','a','a',
457 'a','A','a','a','a','a','a','d','a','A','a','a','a','a','a','a','a','G',
463 if (pFmtIdToPropStgName
) {
464 hr
= pFmtIdToPropStgName(NULL
, name
);
465 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08x\n", hr
);
466 hr
= pFmtIdToPropStgName(&FMTID_SummaryInformation
, NULL
);
467 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08x\n", hr
);
468 hr
= pFmtIdToPropStgName(&FMTID_SummaryInformation
, name
);
469 ok(hr
== S_OK
, "FmtIdToPropStgName failed: 0x%08x\n", hr
);
470 ok(!memcmp(name
, szSummaryInfo
, (lstrlenW(szSummaryInfo
) + 1) *
471 sizeof(WCHAR
)), "Got wrong name for FMTID_SummaryInformation\n");
472 hr
= pFmtIdToPropStgName(&FMTID_DocSummaryInformation
, name
);
473 ok(hr
== S_OK
, "FmtIdToPropStgName failed: 0x%08x\n", hr
);
474 ok(!memcmp(name
, szDocSummaryInfo
, (lstrlenW(szDocSummaryInfo
) + 1) *
475 sizeof(WCHAR
)), "Got wrong name for FMTID_DocSummaryInformation\n");
476 hr
= pFmtIdToPropStgName(&FMTID_UserDefinedProperties
, 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(&IID_IPropertySetStorage
, name
);
481 ok(hr
== S_OK
, "FmtIdToPropStgName failed: 0x%08x\n", hr
);
482 ok(!memcmp(name
, szIID_IPropSetStg
, (lstrlenW(szIID_IPropSetStg
) + 1) *
483 sizeof(WCHAR
)), "Got wrong name for IID_IPropertySetStorage\n");
486 if(pPropStgNameToFmtId
) {
487 /* test args first */
488 hr
= pPropStgNameToFmtId(NULL
, NULL
);
489 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08x\n", hr
);
490 hr
= pPropStgNameToFmtId(NULL
, &fmtid
);
491 ok(hr
== STG_E_INVALIDNAME
, "Expected STG_E_INVALIDNAME, got 0x%08x\n",
493 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, NULL
);
494 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08x\n", hr
);
495 /* test the known format IDs */
496 hr
= pPropStgNameToFmtId(szSummaryInfo
, &fmtid
);
497 ok(hr
== S_OK
, "PropStgNameToFmtId failed: 0x%08x\n", hr
);
498 ok(!memcmp(&fmtid
, &FMTID_SummaryInformation
, sizeof(fmtid
)),
499 "Got unexpected FMTID, expected FMTID_SummaryInformation\n");
500 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, &fmtid
);
501 ok(hr
== S_OK
, "PropStgNameToFmtId failed: 0x%08x\n", hr
);
502 ok(!memcmp(&fmtid
, &FMTID_DocSummaryInformation
, sizeof(fmtid
)),
503 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
504 /* test another GUID */
505 hr
= pPropStgNameToFmtId(szIID_IPropSetStg
, &fmtid
);
506 ok(hr
== S_OK
, "PropStgNameToFmtId failed: 0x%08x\n", hr
);
507 ok(!memcmp(&fmtid
, &IID_IPropertySetStorage
, sizeof(fmtid
)),
508 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
509 /* now check case matching */
510 CharUpperW(szDocSummaryInfo
+ 1);
511 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, &fmtid
);
512 ok(hr
== S_OK
, "PropStgNameToFmtId failed: 0x%08x\n", hr
);
513 ok(!memcmp(&fmtid
, &FMTID_DocSummaryInformation
, sizeof(fmtid
)),
514 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
515 CharUpperW(szIID_IPropSetStg
+ 1);
516 hr
= pPropStgNameToFmtId(szIID_IPropSetStg
, &fmtid
);
517 ok(hr
== S_OK
, "PropStgNameToFmtId failed: 0x%08x\n", hr
);
518 ok(!memcmp(&fmtid
, &IID_IPropertySetStorage
, sizeof(fmtid
)),
519 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
525 init_function_pointers();