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 static HRESULT (WINAPI
*pFmtIdToPropStgName
)(const FMTID
*, LPOLESTR
);
24 static HRESULT (WINAPI
*pPropStgNameToFmtId
)(const LPOLESTR
, FMTID
*);
25 static HRESULT (WINAPI
*pStgCreatePropSetStg
)(IStorage
*, DWORD
, IPropertySetStorage
**);
27 static void init_function_pointers(void)
29 HMODULE hmod
= GetModuleHandleA("ole32.dll");
33 pFmtIdToPropStgName
= (void*)GetProcAddress(hmod
, "FmtIdToPropStgName");
34 pPropStgNameToFmtId
= (void*)GetProcAddress(hmod
, "PropStgNameToFmtId");
35 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 const WCHAR propName
[] = { 'p','r','o','p',0 };
46 static const char val
[] = "l33t auth0r";
47 WCHAR filename
[MAX_PATH
];
49 IStorage
*storage
= NULL
;
50 IPropertySetStorage
*propSetStorage
= NULL
;
51 IPropertyStorage
*propertyStorage
= NULL
;
55 if(!GetTempFileNameW(szDot
, szPrefix
, 0, filename
))
58 DeleteFileW(filename
);
60 hr
= StgCreateDocfile(filename
,
61 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, &storage
);
62 ok(SUCCEEDED(hr
), "StgCreateDocfile failed: 0x%08lx\n", hr
);
64 if(!pStgCreatePropSetStg
) return;
65 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
66 ok(SUCCEEDED(hr
), "StgCreatePropSetStg failed: 0x%08lx\n", hr
);
68 hr
= IPropertySetStorage_Create(propSetStorage
,
69 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_ANSI
,
70 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
72 ok(SUCCEEDED(hr
), "IPropertySetStorage_Create failed: 0x%08lx\n", hr
);
74 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 0, NULL
, NULL
, 0);
75 ok(SUCCEEDED(hr
), "WriteMultiple with 0 args failed: 0x%08lx\n", hr
);
76 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, NULL
, NULL
, 0);
77 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
79 /* test setting one that I can't set */
80 spec
.ulKind
= PRSPEC_PROPID
;
81 U(spec
).propid
= PID_DICTIONARY
;
82 PropVariantClear(&var
);
85 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
86 ok(hr
== STG_E_INVALIDPARAMETER
,
87 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr
);
89 /* test setting one by name with an invalid propidNameFirst */
90 spec
.ulKind
= PRSPEC_LPWSTR
;
91 U(spec
).lpwstr
= (LPOLESTR
)propName
;
92 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
,
94 ok(hr
== STG_E_INVALIDPARAMETER
,
95 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr
);
97 /* test setting behavior (case-sensitive) */
98 spec
.ulKind
= PRSPEC_PROPID
;
99 U(spec
).propid
= PID_BEHAVIOR
;
101 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
102 ok(hr
== STG_E_INVALIDPARAMETER
,
103 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr
);
105 /* set one by value.. */
106 spec
.ulKind
= PRSPEC_PROPID
;
107 U(spec
).propid
= PID_FIRST_USABLE
;
109 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
110 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
112 /* set one by name */
113 spec
.ulKind
= PRSPEC_LPWSTR
;
114 U(spec
).lpwstr
= (LPOLESTR
)propName
;
116 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
,
118 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
120 /* set a string value */
121 spec
.ulKind
= PRSPEC_PROPID
;
122 U(spec
).propid
= PIDSI_AUTHOR
;
124 U(var
).pszVal
= (LPSTR
)val
;
125 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
126 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
129 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 0, NULL
, NULL
);
130 ok(SUCCEEDED(hr
), "ReadMultiple with 0 args failed: 0x%08lx\n", hr
);
131 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, NULL
, NULL
);
132 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
134 spec
.ulKind
= PRSPEC_PROPID
;
135 U(spec
).propid
= PID_FIRST_USABLE
;
136 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
137 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
138 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 1,
139 "Didn't get expected type or value for property (got type %d, value %ld)\n",
140 var
.vt
, U(var
).lVal
);
142 spec
.ulKind
= PRSPEC_LPWSTR
;
143 U(spec
).lpwstr
= (LPOLESTR
)propName
;
144 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
145 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
146 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 2,
147 "Didn't get expected type or value for property (got type %d, value %ld)\n",
148 var
.vt
, U(var
).lVal
);
149 /* read string value */
150 spec
.ulKind
= PRSPEC_PROPID
;
151 U(spec
).propid
= PIDSI_AUTHOR
;
152 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
153 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
154 ok(var
.vt
== VT_LPSTR
&& !lstrcmpA(U(var
).pszVal
, val
),
155 "Didn't get expected type or value for property (got type %d, value %s)\n",
156 var
.vt
, U(var
).pszVal
);
159 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 0, NULL
);
160 ok(SUCCEEDED(hr
), "DeleteMultiple with 0 args failed: 0x%08lx\n", hr
);
161 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, NULL
);
162 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
163 /* contrary to what the docs say, you can't delete the dictionary */
164 spec
.ulKind
= PRSPEC_PROPID
;
165 U(spec
).propid
= PID_DICTIONARY
;
166 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, &spec
);
167 ok(hr
== STG_E_INVALIDPARAMETER
,
168 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr
);
169 /* now delete the first value.. */
170 U(spec
).propid
= PID_FIRST_USABLE
;
171 hr
= IPropertyStorage_DeleteMultiple(propertyStorage
, 1, &spec
);
172 ok(SUCCEEDED(hr
), "DeleteMultiple failed: 0x%08lx\n", hr
);
173 /* and check that it's no longer readable */
174 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
175 ok(hr
== S_FALSE
, "Expected S_FALSE, got 0x%08lx\n", hr
);
177 hr
= IPropertyStorage_Commit(propertyStorage
, STGC_DEFAULT
);
178 ok(SUCCEEDED(hr
), "Commit failed: 0x%08lx\n", hr
);
180 /* check reverting */
181 spec
.ulKind
= PRSPEC_PROPID
;
182 U(spec
).propid
= PID_FIRST_USABLE
;
183 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
184 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
185 hr
= IPropertyStorage_Revert(propertyStorage
);
186 ok(SUCCEEDED(hr
), "Revert failed: 0x%08lx\n", hr
);
187 /* now check that it's still not there */
188 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
189 ok(hr
== S_FALSE
, "Expected S_FALSE, got 0x%08lx\n", hr
);
190 /* set an integer value again */
191 spec
.ulKind
= PRSPEC_PROPID
;
192 U(spec
).propid
= PID_FIRST_USABLE
;
195 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
196 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
198 hr
= IPropertyStorage_Commit(propertyStorage
, STGC_DEFAULT
);
199 ok(SUCCEEDED(hr
), "Commit failed: 0x%08lx\n", hr
);
200 /* set it to a string value */
202 U(var
).pszVal
= (LPSTR
)val
;
203 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
204 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
206 hr
= IPropertyStorage_Revert(propertyStorage
);
207 ok(SUCCEEDED(hr
), "Revert failed: 0x%08lx\n", hr
);
208 /* Oddly enough, there's no guarantee that a successful revert actually
209 * implies the value wasn't saved. Maybe transactional mode needs to be
213 IPropertyStorage_Release(propertyStorage
);
214 propertyStorage
= NULL
;
215 IPropertySetStorage_Release(propSetStorage
);
216 propSetStorage
= NULL
;
217 IStorage_Release(storage
);
220 /* now open it again */
221 hr
= StgOpenStorage(filename
, NULL
, STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
,
223 ok(SUCCEEDED(hr
), "StgOpenStorage failed: 0x%08lx\n", hr
);
225 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
226 ok(SUCCEEDED(hr
), "StgCreatePropSetStg failed: 0x%08lx\n", hr
);
228 hr
= IPropertySetStorage_Open(propSetStorage
, &FMTID_SummaryInformation
,
229 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
, &propertyStorage
);
230 ok(SUCCEEDED(hr
), "IPropertySetStorage_Open failed: 0x%08lx\n", hr
);
232 /* check properties again */
233 spec
.ulKind
= PRSPEC_LPWSTR
;
234 U(spec
).lpwstr
= (LPOLESTR
)propName
;
235 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
236 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
237 ok(var
.vt
== VT_I4
&& U(var
).lVal
== 2,
238 "Didn't get expected type or value for property (got type %d, value %ld)\n",
239 var
.vt
, U(var
).lVal
);
240 spec
.ulKind
= PRSPEC_PROPID
;
241 U(spec
).propid
= PIDSI_AUTHOR
;
242 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
243 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
244 ok(var
.vt
== VT_LPSTR
&& !lstrcmpA(U(var
).pszVal
, val
),
245 "Didn't get expected type or value for property (got type %d, value %s)\n",
246 var
.vt
, U(var
).pszVal
);
248 IPropertyStorage_Release(propertyStorage
);
249 IPropertySetStorage_Release(propSetStorage
);
250 IStorage_Release(storage
);
252 DeleteFileW(filename
);
255 static void testCodepage(void)
257 static const WCHAR szDot
[] = { '.',0 };
258 static const WCHAR szPrefix
[] = { 's','t','g',0 };
259 static const WCHAR wval
[] = { 'h','i',0 };
261 IStorage
*storage
= NULL
;
262 IPropertySetStorage
*propSetStorage
= NULL
;
263 IPropertyStorage
*propertyStorage
= NULL
;
266 WCHAR fileName
[MAX_PATH
];
268 if(!GetTempFileNameW(szDot
, szPrefix
, 0, fileName
))
271 hr
= StgCreateDocfile(fileName
,
272 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, &storage
);
273 ok(SUCCEEDED(hr
), "StgCreateDocfile failed: 0x%08lx\n", hr
);
275 if(!pStgCreatePropSetStg
) return;
276 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
277 ok(SUCCEEDED(hr
), "StgCreatePropSetStg failed: 0x%08lx\n", hr
);
279 hr
= IPropertySetStorage_Create(propSetStorage
,
280 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_DEFAULT
,
281 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
283 ok(SUCCEEDED(hr
), "IPropertySetStorage_Create failed: 0x%08lx\n", hr
);
285 PropVariantInit(&var
);
286 spec
.ulKind
= PRSPEC_PROPID
;
287 U(spec
).propid
= PID_CODEPAGE
;
288 /* check code page before it's been explicitly set */
289 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
290 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
291 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
292 "Didn't get expected type or value for property\n");
293 /* Set the code page to ascii */
296 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
297 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
298 /* check code page */
299 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
300 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
301 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1252,
302 "Didn't get expected type or value for property\n");
303 /* Set code page to Unicode */
305 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
306 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
307 /* check code page */
308 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
309 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
310 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
311 "Didn't get expected type or value for property\n");
312 /* Set a string value */
313 spec
.ulKind
= PRSPEC_PROPID
;
314 U(spec
).propid
= PID_FIRST_USABLE
;
316 U(var
).pszVal
= "hi";
317 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
318 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
319 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
320 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
321 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, "hi"),
322 "Didn't get expected type or value for property\n");
323 /* This seemingly non-sensical test is to show that the string is indeed
324 * interpreted according to the current system code page, not according to
325 * the property set's code page. (If the latter were true, the whole
326 * string would be maintained. As it is, only the first character is.)
328 U(var
).pszVal
= (LPSTR
)wval
;
329 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
330 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
331 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
332 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
333 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, "h"),
334 "Didn't get expected type or value for property\n");
335 /* now that a property's been set, you can't change the code page */
336 spec
.ulKind
= PRSPEC_PROPID
;
337 U(spec
).propid
= PID_CODEPAGE
;
340 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
341 ok(hr
== STG_E_INVALIDPARAMETER
,
342 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr
);
344 IPropertyStorage_Release(propertyStorage
);
345 IPropertySetStorage_Release(propSetStorage
);
346 IStorage_Release(storage
);
348 DeleteFileW(fileName
);
350 /* same tests, but with PROPSETFLAG_ANSI */
351 hr
= StgCreateDocfile(fileName
,
352 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_CREATE
, 0, &storage
);
353 ok(SUCCEEDED(hr
), "StgCreateDocfile failed: 0x%08lx\n", hr
);
355 hr
= pStgCreatePropSetStg(storage
, 0, &propSetStorage
);
356 ok(SUCCEEDED(hr
), "StgCreatePropSetStg failed: 0x%08lx\n", hr
);
358 hr
= IPropertySetStorage_Create(propSetStorage
,
359 &FMTID_SummaryInformation
, NULL
, PROPSETFLAG_ANSI
,
360 STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
,
362 ok(SUCCEEDED(hr
), "IPropertySetStorage_Create failed: 0x%08lx\n", hr
);
364 /* check code page before it's been explicitly set */
365 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
366 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
367 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1252,
368 "Didn't get expected type or value for property\n");
369 /* Set code page to Unicode */
371 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
372 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
373 /* check code page */
374 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
375 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
376 ok(var
.vt
== VT_I2
&& U(var
).iVal
== 1200,
377 "Didn't get expected type or value for property\n");
378 /* This test is commented out for documentation. It fails under Wine,
379 * and I expect it would under Windows as well, yet it succeeds. There's
380 * obviously something about string conversion I don't understand.
383 static const char strVal
[] = { 0x81, 0xff, 0x04, 0 };
384 /* Set code page to 950 (Traditional Chinese) */
386 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
387 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
388 /* Try writing an invalid string: lead byte 0x81 is unused in Traditional
391 spec
.ulKind
= PRSPEC_PROPID
;
392 U(spec
).propid
= PID_FIRST_USABLE
;
394 U(var
).pszVal
= (LPSTR
)strVal
;
395 hr
= IPropertyStorage_WriteMultiple(propertyStorage
, 1, &spec
, &var
, 0);
396 ok(SUCCEEDED(hr
), "WriteMultiple failed: 0x%08lx\n", hr
);
397 /* Check returned string */
398 hr
= IPropertyStorage_ReadMultiple(propertyStorage
, 1, &spec
, &var
);
399 ok(SUCCEEDED(hr
), "ReadMultiple failed: 0x%08lx\n", hr
);
400 ok(var
.vt
== VT_LPSTR
&& !strcmp(U(var
).pszVal
, strVal
),
401 "Didn't get expected type or value for property\n");
404 IPropertyStorage_Release(propertyStorage
);
405 IPropertySetStorage_Release(propSetStorage
);
406 IStorage_Release(storage
);
408 DeleteFileW(fileName
);
411 static void testFmtId(void)
413 WCHAR szSummaryInfo
[] = { 5,'S','u','m','m','a','r','y',
414 'I','n','f','o','r','m','a','t','i','o','n',0 };
415 WCHAR szDocSummaryInfo
[] = { 5,'D','o','c','u','m','e','n','t',
416 'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',
418 WCHAR szIID_IPropSetStg
[] = { 5,'0','j','a','a','a','a','a',
419 'a','A','a','a','a','a','a','d','a','A','a','a','a','a','a','a','a','G',
425 if (pFmtIdToPropStgName
) {
426 hr
= pFmtIdToPropStgName(NULL
, name
);
427 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
428 hr
= pFmtIdToPropStgName(&FMTID_SummaryInformation
, NULL
);
429 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
430 hr
= pFmtIdToPropStgName(&FMTID_SummaryInformation
, name
);
431 ok(SUCCEEDED(hr
), "FmtIdToPropStgName failed: 0x%08lx\n", hr
);
432 ok(!memcmp(name
, szSummaryInfo
, (lstrlenW(szSummaryInfo
) + 1) *
433 sizeof(WCHAR
)), "Got wrong name for FMTID_SummaryInformation\n");
434 hr
= pFmtIdToPropStgName(&FMTID_DocSummaryInformation
, name
);
435 ok(SUCCEEDED(hr
), "FmtIdToPropStgName failed: 0x%08lx\n", hr
);
436 ok(!memcmp(name
, szDocSummaryInfo
, (lstrlenW(szDocSummaryInfo
) + 1) *
437 sizeof(WCHAR
)), "Got wrong name for FMTID_DocSummaryInformation\n");
438 hr
= pFmtIdToPropStgName(&FMTID_UserDefinedProperties
, name
);
439 ok(SUCCEEDED(hr
), "FmtIdToPropStgName failed: 0x%08lx\n", hr
);
440 ok(!memcmp(name
, szDocSummaryInfo
, (lstrlenW(szDocSummaryInfo
) + 1) *
441 sizeof(WCHAR
)), "Got wrong name for FMTID_DocSummaryInformation\n");
442 hr
= pFmtIdToPropStgName(&IID_IPropertySetStorage
, name
);
443 ok(SUCCEEDED(hr
), "FmtIdToPropStgName failed: 0x%08lx\n", hr
);
444 ok(!memcmp(name
, szIID_IPropSetStg
, (lstrlenW(szIID_IPropSetStg
) + 1) *
445 sizeof(WCHAR
)), "Got wrong name for IID_IPropertySetStorage\n");
448 if(pPropStgNameToFmtId
) {
449 /* test args first */
450 hr
= pPropStgNameToFmtId(NULL
, NULL
);
451 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
452 hr
= pPropStgNameToFmtId(NULL
, &fmtid
);
453 ok(hr
== STG_E_INVALIDNAME
, "Expected STG_E_INVALIDNAME, got 0x%08lx\n",
455 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, NULL
);
456 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got 0x%08lx\n", hr
);
457 /* test the known format IDs */
458 hr
= pPropStgNameToFmtId(szSummaryInfo
, &fmtid
);
459 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
460 ok(!memcmp(&fmtid
, &FMTID_SummaryInformation
, sizeof(fmtid
)),
461 "Got unexpected FMTID, expected FMTID_SummaryInformation\n");
462 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, &fmtid
);
463 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
464 ok(!memcmp(&fmtid
, &FMTID_DocSummaryInformation
, sizeof(fmtid
)),
465 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
466 /* test another GUID */
467 hr
= pPropStgNameToFmtId(szIID_IPropSetStg
, &fmtid
);
468 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
469 ok(!memcmp(&fmtid
, &IID_IPropertySetStorage
, sizeof(fmtid
)),
470 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
471 /* now check case matching */
472 CharUpperW(szDocSummaryInfo
+ 1);
473 hr
= pPropStgNameToFmtId(szDocSummaryInfo
, &fmtid
);
474 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
475 ok(!memcmp(&fmtid
, &FMTID_DocSummaryInformation
, sizeof(fmtid
)),
476 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
477 CharUpperW(szIID_IPropSetStg
+ 1);
478 hr
= pPropStgNameToFmtId(szIID_IPropSetStg
, &fmtid
);
479 ok(SUCCEEDED(hr
), "PropStgNameToFmtId failed: 0x%08lx\n", hr
);
480 ok(!memcmp(&fmtid
, &IID_IPropertySetStorage
, sizeof(fmtid
)),
481 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
487 init_function_pointers();