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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/test.h"
23 #ifdef NONAMELESSUNION
29 static HRESULT (WINAPI
*pFmtIdToPropStgName
)(const FMTID
*, LPOLESTR
);
30 static HRESULT (WINAPI
*pPropStgNameToFmtId
)(const LPOLESTR
, FMTID
*);
31 static HRESULT (WINAPI
*pStgCreatePropSetStg
)(IStorage
*, DWORD
, IPropertySetStorage
**);
33 static void init_function_pointers(void)
35 HMODULE hmod
= GetModuleHandleA("ole32.dll");
39 pFmtIdToPropStgName
= (void*)GetProcAddress(hmod
, "FmtIdToPropStgName");
40 pPropStgNameToFmtId
= (void*)GetProcAddress(hmod
, "PropStgNameToFmtId");
41 pStgCreatePropSetStg
= (void*)GetProcAddress(hmod
, "StgCreatePropSetStg");
44 /* FIXME: this creates an ANSI storage, try to find conditions under which
45 * Unicode translation fails
47 static void testProps(void)
49 static const WCHAR szDot
[] = { '.',0 };
50 static const WCHAR szPrefix
[] = { 's','t','g',0 };
51 static const WCHAR propName
[] = { 'p','r','o','p',0 };
52 static const char val
[] = "l33t auth0r";
53 WCHAR filename
[MAX_PATH
];
55 IStorage
*storage
= NULL
;
56 IPropertySetStorage
*propSetStorage
= NULL
;
57 IPropertyStorage
*propertyStorage
= NULL
;
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(SUCCEEDED(hr
), "StgCreateDocfile failed: 0x%08lx\n", hr
);
70 if(!pStgCreatePropSetStg
) return;
71 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
72 ok(SUCCEEDED(hr
), "StgCreatePropSetStg failed: 0x%08lx\n", hr
);
74 hr
= IPropertySetStorage_Create(propSetStorage
,
75 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_ANSI
,
76 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
78 ok(SUCCEEDED(hr
), "IPropertySetStorage_Create failed: 0x%08lx\n", hr
);
80 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 0, NULL
, NULL
, 0);
81 ok(SUCCEEDED(hr
), "WriteMultiple with 0 args failed: 0x%08lx\n", hr
);
82 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, NULL
, NULL
, 0);
83 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
85 /* test setting one that I can't set */
86 spec
.ulKind
= PRSPEC_PROPID
;
87 U(spec
).propid
= PID_DICTIONARY
;
88 PropVariantClear(&var
);
91 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
92 ok(hr
== STG_E_INVALIDPARAMETER
,
93 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\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%08lx\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%08lx\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(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\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(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
126 /* set a string value */
127 spec
.ulKind
= PRSPEC_PROPID
;
128 U(spec
).propid
= PIDSI_AUTHOR
;
130 U(var
).pszVal
= (LPSTR
)val
;
131 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
132 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
135 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 0, NULL
, NULL
);
136 ok(SUCCEEDED(hr
), "ReadMultiple with 0 args failed: 0x%08lx\n", hr
);
137 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, NULL
, NULL
);
138 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
140 spec
.ulKind
= PRSPEC_PROPID
;
141 U(spec
).propid
= PID_FIRST_USABLE
;
142 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
143 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
144 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 1,
145 "Didn't get expected type or value for property (got type %d, value %ld)\n",
146 var
.vt
, U(var
).lVal
);
148 spec
.ulKind
= PRSPEC_LPWSTR
;
149 U(spec
).lpwstr
= (LPOLESTR
)propName
;
150 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
151 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
152 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 2,
153 "Didn't get expected type or value for property (got type %d, value %ld)\n",
154 var
.vt
, U(var
).lVal
);
155 /* read string value */
156 spec
.ulKind
= PRSPEC_PROPID
;
157 U(spec
).propid
= PIDSI_AUTHOR
;
158 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
159 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
160 ok(var
.vt
== VT_LPSTR
&& !lstrcmpA(U(var
).pszVal
, val
),
161 "Didn't get expected type or value for property (got type %d, value %s)\n",
162 var
.vt
, U(var
).pszVal
);
165 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 0, NULL
);
166 ok(SUCCEEDED(hr
), "DeleteMultiple with 0 args failed: 0x%08lx\n", hr
);
167 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, NULL
);
168 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
169 /* contrary to what the docs say, you can't delete the dictionary */
170 spec
.ulKind
= PRSPEC_PROPID
;
171 U(spec
).propid
= PID_DICTIONARY
;
172 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, &spec
);
173 ok(hr
== STG_E_INVALIDPARAMETER
,
174 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr
);
175 /* now delete the first value.. */
176 U(spec
).propid
= PID_FIRST_USABLE
;
177 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, &spec
);
178 ok(SUCCEEDED(hr
), "DeleteMultiple failed: 0x%08lx\n", hr
);
179 /* and check that it's no longer readable */
180 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
181 ok(hr
== S_FALSE
, "Expected S_FALSE, got 0x%08lx\n", hr
);
183 hr
= IPropertyStorage_Commit(propertyStorage
, STGC_DEFAULT
);
184 ok(SUCCEEDED(hr
), "Commit failed: 0x%08lx\n", hr
);
186 /* check reverting */
187 spec
.ulKind
= PRSPEC_PROPID
;
188 U(spec
).propid
= PID_FIRST_USABLE
;
189 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
190 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
191 hr
= IPropertyStorage_Revert(propertyStorage
);
192 ok(SUCCEEDED(hr
), "Revert failed: 0x%08lx\n", hr
);
193 /* now check that it's still not there */
194 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
195 ok(hr
== S_FALSE
, "Expected S_FALSE, got 0x%08lx\n", hr
);
196 /* set an integer value again */
197 spec
.ulKind
= PRSPEC_PROPID
;
198 U(spec
).propid
= PID_FIRST_USABLE
;
201 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
202 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
204 hr
= IPropertyStorage_Commit(propertyStorage
, STGC_DEFAULT
);
205 ok(SUCCEEDED(hr
), "Commit failed: 0x%08lx\n", hr
);
206 /* set it to a string value */
208 U(var
).pszVal
= (LPSTR
)val
;
209 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
210 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
212 hr
= IPropertyStorage_Revert(propertyStorage
);
213 ok(SUCCEEDED(hr
), "Revert failed: 0x%08lx\n", hr
);
214 /* Oddly enough, there's no guarantee that a successful revert actually
215 * implies the value wasn't saved. Maybe transactional mode needs to be
219 IPropertyStorage_Release(propertyStorage
);
220 propertyStorage
= NULL
;
221 IPropertySetStorage_Release(propSetStorage
);
222 propSetStorage
= NULL
;
223 IStorage_Release(storage
);
226 /* now open it again */
227 hr
= StgOpenStorage(filename
, NULL
, STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
,
229 ok(SUCCEEDED(hr
), "StgOpenStorage failed: 0x%08lx\n", hr
);
231 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
232 ok(SUCCEEDED(hr
), "StgCreatePropSetStg failed: 0x%08lx\n", hr
);
234 hr
= IPropertySetStorage_Open(propSetStorage
, &FMTID_SummaryInformation
,
235 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
, &propertyStorage
);
236 ok(SUCCEEDED(hr
), "IPropertySetStorage_Open failed: 0x%08lx\n", hr
);
238 /* check properties again */
239 spec
.ulKind
= PRSPEC_LPWSTR
;
240 U(spec
).lpwstr
= (LPOLESTR
)propName
;
241 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
242 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
243 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 2,
244 "Didn't get expected type or value for property (got type %d, value %ld)\n",
245 var
.vt
, U(var
).lVal
);
246 spec
.ulKind
= PRSPEC_PROPID
;
247 U(spec
).propid
= PIDSI_AUTHOR
;
248 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
249 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
250 ok(var
.vt
== VT_LPSTR
&& !lstrcmpA(U(var
).pszVal
, val
),
251 "Didn't get expected type or value for property (got type %d, value %s)\n",
252 var
.vt
, U(var
).pszVal
);
254 IPropertyStorage_Release(propertyStorage
);
255 IPropertySetStorage_Release(propSetStorage
);
256 IStorage_Release(storage
);
258 DeleteFileW(filename
);
261 void testCodepage(void)
263 static const WCHAR szDot
[] = { '.',0 };
264 static const WCHAR szPrefix
[] = { 's','t','g',0 };
265 static const WCHAR wval
[] = { 'h','i',0 };
267 IStorage
*storage
= NULL
;
268 IPropertySetStorage
*propSetStorage
= NULL
;
269 IPropertyStorage
*propertyStorage
= NULL
;
272 WCHAR fileName
[MAX_PATH
];
274 if(!GetTempFileNameW(szDot
, szPrefix
, 0, fileName
))
277 hr
= StgCreateDocfile(fileName
,
278 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, &storage
);
279 ok(SUCCEEDED(hr
), "StgCreateDocfile failed: 0x%08lx\n", hr
);
281 if(!pStgCreatePropSetStg
) return;
282 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
283 ok(SUCCEEDED(hr
), "StgCreatePropSetStg failed: 0x%08lx\n", hr
);
285 hr
= IPropertySetStorage_Create(propSetStorage
,
286 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_DEFAULT
,
287 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
289 ok(SUCCEEDED(hr
), "IPropertySetStorage_Create failed: 0x%08lx\n", hr
);
291 PropVariantInit(&var
);
292 spec
.ulKind
= PRSPEC_PROPID
;
293 U(spec
).propid
= PID_CODEPAGE
;
294 /* check code page before it's been explicitly set */
295 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
296 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
297 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
298 "Didn't get expected type or value for property\n");
299 /* Set the code page to ascii */
302 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
303 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
304 /* check code page */
305 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
306 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
307 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1252,
308 "Didn't get expected type or value for property\n");
309 /* Set code page to Unicode */
311 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
312 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
313 /* check code page */
314 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
315 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
316 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
317 "Didn't get expected type or value for property\n");
318 /* Set a string value */
319 spec
.ulKind
= PRSPEC_PROPID
;
320 U(spec
).propid
= PID_FIRST_USABLE
;
322 U(var
).pszVal
= "hi";
323 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
324 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
325 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
326 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
327 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, "hi"),
328 "Didn't get expected type or value for property\n");
329 /* This seemingly non-sensical test is to show that the string is indeed
330 * interpreted according to the current system code page, not according to
331 * the property set's code page. (If the latter were true, the whole
332 * string would be maintained. As it is, only the first character is.)
334 U(var
).pszVal
= (LPSTR
)wval
;
335 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
336 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
337 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
338 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
339 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, "h"),
340 "Didn't get expected type or value for property\n");
341 /* now that a property's been set, you can't change the code page */
342 spec
.ulKind
= PRSPEC_PROPID
;
343 U(spec
).propid
= PID_CODEPAGE
;
346 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
347 ok(hr
== STG_E_INVALIDPARAMETER
,
348 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr
);
350 IPropertyStorage_Release(propertyStorage
);
351 IPropertySetStorage_Release(propSetStorage
);
352 IStorage_Release(storage
);
354 DeleteFileW(fileName
);
356 /* same tests, but with PROPSETFLAG_ANSI */
357 hr
= StgCreateDocfile(fileName
,
358 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, &storage
);
359 ok(SUCCEEDED(hr
), "StgCreateDocfile failed: 0x%08lx\n", hr
);
361 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
362 ok(SUCCEEDED(hr
), "StgCreatePropSetStg failed: 0x%08lx\n", hr
);
364 hr
= IPropertySetStorage_Create(propSetStorage
,
365 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_ANSI
,
366 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
368 ok(SUCCEEDED(hr
), "IPropertySetStorage_Create failed: 0x%08lx\n", hr
);
370 /* check code page before it's been explicitly set */
371 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
372 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
373 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1252,
374 "Didn't get expected type or value for property\n");
375 /* Set code page to Unicode */
377 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
378 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
379 /* check code page */
380 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
381 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
382 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
383 "Didn't get expected type or value for property\n");
384 /* This test is commented out for documentation. It fails under Wine,
385 * and I expect it would under Windows as well, yet it succeeds. There's
386 * obviously something about string conversion I don't understand.
389 static const char strVal
[] = { 0x81, 0xff, 0x04, 0 };
390 /* Set code page to 950 (Traditional Chinese) */
392 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
393 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
394 /* Try writing an invalid string: lead byte 0x81 is unused in Traditional
397 spec
.ulKind
= PRSPEC_PROPID
;
398 U(spec
).propid
= PID_FIRST_USABLE
;
400 U(var
).pszVal
= (LPSTR
)strVal
;
401 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
402 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
403 /* Check returned string */
404 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
405 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
406 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, strVal
),
407 "Didn't get expected type or value for property\n");
410 IPropertyStorage_Release(propertyStorage
);
411 IPropertySetStorage_Release(propSetStorage
);
412 IStorage_Release(storage
);
414 DeleteFileW(fileName
);
417 static void testFmtId(void)
419 WCHAR szSummaryInfo
[] = { 5,'S','u','m','m','a','r','y',
420 'I','n','f','o','r','m','a','t','i','o','n',0 };
421 WCHAR szDocSummaryInfo
[] = { 5,'D','o','c','u','m','e','n','t',
422 'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',
424 WCHAR szIID_IPropSetStg
[] = { 5,'0','j','a','a','a','a','a',
425 'a','A','a','a','a','a','a','d','a','A','a','a','a','a','a','a','a','G',
431 if (pFmtIdToPropStgName
) {
432 hr
= pFmtIdToPropStgName(NULL
, name
);
433 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
434 hr
= pFmtIdToPropStgName(&FMTID_SummaryInformation
, NULL
);
435 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
436 hr
= pFmtIdToPropStgName(&FMTID_SummaryInformation
, name
);
437 ok(SUCCEEDED(hr
), "FmtIdToPropStgName failed: 0x%08lx\n", hr
);
438 ok(!memcmp(name
, szSummaryInfo
, (lstrlenW(szSummaryInfo
) + 1) *
439 sizeof(WCHAR
)), "Got wrong name for FMTID_SummaryInformation\n");
440 hr
= pFmtIdToPropStgName(&FMTID_DocSummaryInformation
, name
);
441 ok(SUCCEEDED(hr
), "FmtIdToPropStgName failed: 0x%08lx\n", hr
);
442 ok(!memcmp(name
, szDocSummaryInfo
, (lstrlenW(szDocSummaryInfo
) + 1) *
443 sizeof(WCHAR
)), "Got wrong name for FMTID_DocSummaryInformation\n");
444 hr
= pFmtIdToPropStgName(&FMTID_UserDefinedProperties
, name
);
445 ok(SUCCEEDED(hr
), "FmtIdToPropStgName failed: 0x%08lx\n", hr
);
446 ok(!memcmp(name
, szDocSummaryInfo
, (lstrlenW(szDocSummaryInfo
) + 1) *
447 sizeof(WCHAR
)), "Got wrong name for FMTID_DocSummaryInformation\n");
448 hr
= pFmtIdToPropStgName(&IID_IPropertySetStorage
, name
);
449 ok(SUCCEEDED(hr
), "FmtIdToPropStgName failed: 0x%08lx\n", hr
);
450 ok(!memcmp(name
, szIID_IPropSetStg
, (lstrlenW(szIID_IPropSetStg
) + 1) *
451 sizeof(WCHAR
)), "Got wrong name for IID_IPropertySetStorage\n");
454 if(pPropStgNameToFmtId
) {
455 /* test args first */
456 hr
= pPropStgNameToFmtId(NULL
, NULL
);
457 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
458 hr
= pPropStgNameToFmtId(NULL
, &fmtid
);
459 ok(hr
== STG_E_INVALIDNAME
, "Expected STG_E_INVALIDNAME, got 0x%08lx\n",
461 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, NULL
);
462 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
463 /* test the known format IDs */
464 hr
= pPropStgNameToFmtId(szSummaryInfo
, &fmtid
);
465 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
466 ok(!memcmp(&fmtid
, &FMTID_SummaryInformation
, sizeof(fmtid
)),
467 "Got unexpected FMTID, expected FMTID_SummaryInformation\n");
468 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, &fmtid
);
469 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
470 ok(!memcmp(&fmtid
, &FMTID_DocSummaryInformation
, sizeof(fmtid
)),
471 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
472 /* test another GUID */
473 hr
= pPropStgNameToFmtId(szIID_IPropSetStg
, &fmtid
);
474 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
475 ok(!memcmp(&fmtid
, &IID_IPropertySetStorage
, sizeof(fmtid
)),
476 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
477 /* now check case matching */
478 CharUpperW(szDocSummaryInfo
+ 1);
479 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, &fmtid
);
480 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
481 ok(!memcmp(&fmtid
, &FMTID_DocSummaryInformation
, sizeof(fmtid
)),
482 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
483 CharUpperW(szIID_IPropSetStg
+ 1);
484 hr
= pPropStgNameToFmtId(szIID_IPropSetStg
, &fmtid
);
485 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
486 ok(!memcmp(&fmtid
, &IID_IPropertySetStorage
, sizeof(fmtid
)),
487 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
493 init_function_pointers();