ole32: Add the external references that the server gave to us to any existing ifproxy,
[wine] / dlls / ole32 / tests / stg_prop.c
1 /* IPropertyStorage unit tests
2  * Copyright 2005 Juan Lang
3  *
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.
8  *
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.
13  *
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
17  */
18 #include <stdio.h>
19 #define COBJMACROS
20 #include "objbase.h"
21 #include "wine/test.h"
22
23 #ifndef PID_BEHAVIOR
24 #define PID_BEHAVIOR 0x80000003
25 #endif
26
27 static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
28 static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
29 static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
30
31 static void init_function_pointers(void)
32 {
33     HMODULE hmod = GetModuleHandleA("ole32.dll");
34
35     if(hmod)
36     {
37         pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
38         pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
39         pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
40     }
41 }
42 /* FIXME: this creates an ANSI storage, try to find conditions under which
43  * Unicode translation fails
44  */
45 static void testProps(void)
46 {
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];
52     HRESULT hr;
53     IStorage *storage = NULL;
54     IPropertySetStorage *propSetStorage = NULL;
55     IPropertyStorage *propertyStorage = NULL;
56     PROPSPEC spec;
57     PROPVARIANT var;
58     CLIPDATA clipdata;
59     unsigned char clipcontent[] = "foobar";
60
61     if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
62         return;
63
64     DeleteFileW(filename);
65
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);
69
70     if(!pStgCreatePropSetStg)
71     {
72         IStorage_Release(storage);
73         DeleteFileW(filename);
74         return;
75     }
76     hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
77     ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
78
79     hr = IPropertySetStorage_Create(propSetStorage,
80      &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
81      STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
82      &propertyStorage);
83     ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
84
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);
89
90     /* test setting one that I can't set */
91     spec.ulKind = PRSPEC_PROPID;
92     U(spec).propid = PID_DICTIONARY;
93     var.vt = VT_I4;
94     U(var).lVal = 1;
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);
98
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,
103      PID_DICTIONARY);
104     ok(hr == STG_E_INVALIDPARAMETER,
105      "Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
106
107     /* test setting behavior (case-sensitive) */
108     spec.ulKind = PRSPEC_PROPID;
109     U(spec).propid = PID_BEHAVIOR;
110     U(var).lVal = 1;
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);
114
115     /* set one by value.. */
116     spec.ulKind = PRSPEC_PROPID;
117     U(spec).propid = PID_FIRST_USABLE;
118     U(var).lVal = 1;
119     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
120     ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
121
122     /* set one by name */
123     spec.ulKind = PRSPEC_LPWSTR;
124     U(spec).lpwstr = (LPOLESTR)propName;
125     U(var).lVal = 2;
126     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
127      PID_FIRST_USABLE);
128     ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
129
130     /* set a string value */
131     spec.ulKind = PRSPEC_PROPID;
132     U(spec).propid = PIDSI_AUTHOR;
133     var.vt = VT_LPSTR;
134     U(var).pszVal = val;
135     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
136     ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
137
138     /* set a clipboard value */
139     spec.ulKind = PRSPEC_PROPID;
140     U(spec).propid = PIDSI_THUMBNAIL;
141     var.vt = VT_CF;
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);
148
149
150     /* check reading */
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);
155     /* read by propid */
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);
163     /* read by name */
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);
179
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");
193
194     /* check deleting */
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);
212
213     hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
214     ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
215
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;
229     var.vt = VT_I4;
230     U(var).lVal = 1;
231     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
232     ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
233     /* commit it */
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 */
237     var.vt = VT_LPSTR;
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);
241     /* revert it */
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
246      * used for that?
247      */
248
249     IPropertyStorage_Release(propertyStorage);
250     propertyStorage = NULL;
251     IPropertySetStorage_Release(propSetStorage);
252     propSetStorage = NULL;
253     IStorage_Release(storage);
254     storage = NULL;
255
256     /* now open it again */
257     hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
258      NULL, 0, &storage);
259     ok(hr == S_OK, "StgOpenStorage failed: 0x%08x\n", hr);
260
261     hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
262     ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
263
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);
267
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);
283
284     IPropertyStorage_Release(propertyStorage);
285     IPropertySetStorage_Release(propSetStorage);
286     IStorage_Release(storage);
287
288     DeleteFileW(filename);
289 }
290
291 static void testCodepage(void)
292 {
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 };
297     HRESULT hr;
298     IStorage *storage = NULL;
299     IPropertySetStorage *propSetStorage = NULL;
300     IPropertyStorage *propertyStorage = NULL;
301     PROPSPEC spec;
302     PROPVARIANT var;
303     WCHAR fileName[MAX_PATH];
304
305     if(!GetTempFileNameW(szDot, szPrefix, 0, fileName))
306         return;
307
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);
311
312     if(!pStgCreatePropSetStg)
313     {
314         IStorage_Release(storage);
315         DeleteFileW(fileName);
316         return;
317     }
318     hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
319     ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
320
321     hr = IPropertySetStorage_Create(propSetStorage,
322      &FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT,
323      STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
324      &propertyStorage);
325     ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
326
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 */
336     var.vt = VT_I2;
337     U(var).iVal = 1252;
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 */
346     U(var).iVal = 1200;
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;
357     var.vt = VT_LPSTR;
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.)
369      */
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;
380     var.vt = VT_I2;
381     U(var).iVal = 1200;
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);
385
386     IPropertyStorage_Release(propertyStorage);
387     IPropertySetStorage_Release(propSetStorage);
388     IStorage_Release(storage);
389
390     DeleteFileW(fileName);
391
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);
396
397     hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
398     ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
399
400     hr = IPropertySetStorage_Create(propSetStorage,
401      &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
402      STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
403      &propertyStorage);
404     ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
405
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 */
412     U(var).iVal = 1200;
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.
423      */
424     if(0) {
425     static unsigned char strVal[] = { 0x81, 0xff, 0x04, 0 };
426     /* Set code page to 950 (Traditional Chinese) */
427     U(var).iVal = 950;
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
431      * Chinese.
432      */
433     spec.ulKind = PRSPEC_PROPID;
434     U(spec).propid = PID_FIRST_USABLE;
435     var.vt = VT_LPSTR;
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");
444     }
445
446     IPropertyStorage_Release(propertyStorage);
447     IPropertySetStorage_Release(propSetStorage);
448     IStorage_Release(storage);
449
450     DeleteFileW(fileName);
451 }
452
453 static void testFmtId(void)
454 {
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',
459         0 };
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',
462         'c',0 };
463     WCHAR name[32];
464     FMTID fmtid;
465     HRESULT hr;
466
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");
488     }
489
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",
496      hr);
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");
524     }
525 }
526
527 START_TEST(stg_prop)
528 {
529     init_function_pointers();
530     testProps();
531     testCodepage();
532     testFmtId();
533 }