wined3d: Implement more GLSL instructions and a little cleanup.
[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 static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
24 static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
25 static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
26
27 static void init_function_pointers(void)
28 {
29     HMODULE hmod = GetModuleHandleA("ole32.dll");
30
31     if(hmod)
32     {
33         pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
34         pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
35         pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
36     }
37 }
38 /* FIXME: this creates an ANSI storage, try to find conditions under which
39  * Unicode translation fails
40  */
41 static void testProps(void)
42 {
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];
48     HRESULT hr;
49     IStorage *storage = NULL;
50     IPropertySetStorage *propSetStorage = NULL;
51     IPropertyStorage *propertyStorage = NULL;
52     PROPSPEC spec;
53     PROPVARIANT var;
54
55     if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
56         return;
57
58     DeleteFileW(filename);
59
60     hr = StgCreateDocfile(filename,
61      STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
62     ok(SUCCEEDED(hr), "StgCreateDocfile failed: 0x%08lx\n", hr);
63
64     if(!pStgCreatePropSetStg)
65     {
66         IStorage_Release(storage);
67         DeleteFileW(filename);
68         return;
69     }
70     hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
71     ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
72
73     hr = IPropertySetStorage_Create(propSetStorage,
74      &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
75      STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
76      &propertyStorage);
77     ok(SUCCEEDED(hr), "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
78
79     hr = IPropertyStorage_WriteMultiple(propertyStorage, 0, NULL, NULL, 0);
80     ok(SUCCEEDED(hr), "WriteMultiple with 0 args failed: 0x%08lx\n", hr);
81     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, NULL, NULL, 0);
82     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
83
84     /* test setting one that I can't set */
85     spec.ulKind = PRSPEC_PROPID;
86     U(spec).propid = PID_DICTIONARY;
87     PropVariantClear(&var);
88     var.vt = VT_I4;
89     U(var).lVal = 1;
90     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
91     ok(hr == STG_E_INVALIDPARAMETER,
92      "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
93
94     /* test setting one by name with an invalid propidNameFirst */
95     spec.ulKind = PRSPEC_LPWSTR;
96     U(spec).lpwstr = (LPOLESTR)propName;
97     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
98      PID_DICTIONARY);
99     ok(hr == STG_E_INVALIDPARAMETER,
100      "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
101
102     /* test setting behavior (case-sensitive) */
103     spec.ulKind = PRSPEC_PROPID;
104     U(spec).propid = PID_BEHAVIOR;
105     U(var).lVal = 1;
106     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
107     ok(hr == STG_E_INVALIDPARAMETER,
108      "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
109
110     /* set one by value.. */
111     spec.ulKind = PRSPEC_PROPID;
112     U(spec).propid = PID_FIRST_USABLE;
113     U(var).lVal = 1;
114     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
115     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
116
117     /* set one by name */
118     spec.ulKind = PRSPEC_LPWSTR;
119     U(spec).lpwstr = (LPOLESTR)propName;
120     U(var).lVal = 2;
121     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
122      PID_FIRST_USABLE);
123     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
124
125     /* set a string value */
126     spec.ulKind = PRSPEC_PROPID;
127     U(spec).propid = PIDSI_AUTHOR;
128     var.vt = VT_LPSTR;
129     U(var).pszVal = (LPSTR)val;
130     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
131     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
132
133     /* check reading */
134     hr = IPropertyStorage_ReadMultiple(propertyStorage, 0, NULL, NULL);
135     ok(SUCCEEDED(hr), "ReadMultiple with 0 args failed: 0x%08lx\n", hr);
136     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, NULL, NULL);
137     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
138     /* read by propid */
139     spec.ulKind = PRSPEC_PROPID;
140     U(spec).propid = PID_FIRST_USABLE;
141     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
142     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
143     ok(var.vt == VT_I4 && U(var).lVal == 1,
144      "Didn't get expected type or value for property (got type %d, value %ld)\n",
145      var.vt, U(var).lVal);
146     /* read by name */
147     spec.ulKind = PRSPEC_LPWSTR;
148     U(spec).lpwstr = (LPOLESTR)propName;
149     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
150     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
151     ok(var.vt == VT_I4 && U(var).lVal == 2,
152      "Didn't get expected type or value for property (got type %d, value %ld)\n",
153      var.vt, U(var).lVal);
154     /* read string value */
155     spec.ulKind = PRSPEC_PROPID;
156     U(spec).propid = PIDSI_AUTHOR;
157     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
158     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
159     ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
160      "Didn't get expected type or value for property (got type %d, value %s)\n",
161      var.vt, U(var).pszVal);
162
163     /* check deleting */
164     hr = IPropertyStorage_DeleteMultiple(propertyStorage, 0, NULL);
165     ok(SUCCEEDED(hr), "DeleteMultiple with 0 args failed: 0x%08lx\n", hr);
166     hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, NULL);
167     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
168     /* contrary to what the docs say, you can't delete the dictionary */
169     spec.ulKind = PRSPEC_PROPID;
170     U(spec).propid = PID_DICTIONARY;
171     hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
172     ok(hr == STG_E_INVALIDPARAMETER,
173      "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
174     /* now delete the first value.. */
175     U(spec).propid = PID_FIRST_USABLE;
176     hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
177     ok(SUCCEEDED(hr), "DeleteMultiple failed: 0x%08lx\n", hr);
178     /* and check that it's no longer readable */
179     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
180     ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08lx\n", hr);
181
182     hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
183     ok(SUCCEEDED(hr), "Commit failed: 0x%08lx\n", hr);
184
185     /* check reverting */
186     spec.ulKind = PRSPEC_PROPID;
187     U(spec).propid = PID_FIRST_USABLE;
188     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
189     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
190     hr = IPropertyStorage_Revert(propertyStorage);
191     ok(SUCCEEDED(hr), "Revert failed: 0x%08lx\n", hr);
192     /* now check that it's still not there */
193     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
194     ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08lx\n", hr);
195     /* set an integer value again */
196     spec.ulKind = PRSPEC_PROPID;
197     U(spec).propid = PID_FIRST_USABLE;
198     var.vt = VT_I4;
199     U(var).lVal = 1;
200     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
201     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
202     /* commit it */
203     hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
204     ok(SUCCEEDED(hr), "Commit failed: 0x%08lx\n", hr);
205     /* set it to a string value */
206     var.vt = VT_LPSTR;
207     U(var).pszVal = (LPSTR)val;
208     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
209     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
210     /* revert it */
211     hr = IPropertyStorage_Revert(propertyStorage);
212     ok(SUCCEEDED(hr), "Revert failed: 0x%08lx\n", hr);
213     /* Oddly enough, there's no guarantee that a successful revert actually
214      * implies the value wasn't saved.  Maybe transactional mode needs to be
215      * used for that?
216      */
217
218     IPropertyStorage_Release(propertyStorage);
219     propertyStorage = NULL;
220     IPropertySetStorage_Release(propSetStorage);
221     propSetStorage = NULL;
222     IStorage_Release(storage);
223     storage = NULL;
224
225     /* now open it again */
226     hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
227      NULL, 0, &storage);
228     ok(SUCCEEDED(hr), "StgOpenStorage failed: 0x%08lx\n", hr);
229
230     hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
231     ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
232
233     hr = IPropertySetStorage_Open(propSetStorage, &FMTID_SummaryInformation,
234      STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
235     ok(SUCCEEDED(hr), "IPropertySetStorage_Open failed: 0x%08lx\n", hr);
236
237     /* check properties again */
238     spec.ulKind = PRSPEC_LPWSTR;
239     U(spec).lpwstr = (LPOLESTR)propName;
240     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
241     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
242     ok(var.vt == VT_I4 && U(var).lVal == 2,
243      "Didn't get expected type or value for property (got type %d, value %ld)\n",
244      var.vt, U(var).lVal);
245     spec.ulKind = PRSPEC_PROPID;
246     U(spec).propid = PIDSI_AUTHOR;
247     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
248     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
249     ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
250      "Didn't get expected type or value for property (got type %d, value %s)\n",
251      var.vt, U(var).pszVal);
252
253     IPropertyStorage_Release(propertyStorage);
254     IPropertySetStorage_Release(propSetStorage);
255     IStorage_Release(storage);
256
257     DeleteFileW(filename);
258 }
259
260 static void testCodepage(void)
261 {
262     static const WCHAR szDot[] = { '.',0 };
263     static const WCHAR szPrefix[] = { 's','t','g',0 };
264     static CHAR aval[] = "hi";
265     static const WCHAR wval[] = { 'h','i',0 };
266     HRESULT hr;
267     IStorage *storage = NULL;
268     IPropertySetStorage *propSetStorage = NULL;
269     IPropertyStorage *propertyStorage = NULL;
270     PROPSPEC spec;
271     PROPVARIANT var;
272     WCHAR fileName[MAX_PATH];
273
274     if(!GetTempFileNameW(szDot, szPrefix, 0, fileName))
275         return;
276
277     hr = StgCreateDocfile(fileName,
278      STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
279     ok(SUCCEEDED(hr), "StgCreateDocfile failed: 0x%08lx\n", hr);
280
281     if(!pStgCreatePropSetStg)
282     {
283         IStorage_Release(storage);
284         DeleteFileW(fileName);
285         return;
286     }
287     hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
288     ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
289
290     hr = IPropertySetStorage_Create(propSetStorage,
291      &FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT,
292      STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
293      &propertyStorage);
294     ok(SUCCEEDED(hr), "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
295
296     PropVariantInit(&var);
297     spec.ulKind = PRSPEC_PROPID;
298     U(spec).propid = PID_CODEPAGE;
299     /* check code page before it's been explicitly set */
300     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
301     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
302     ok(var.vt == VT_I2 && U(var).iVal == 1200,
303      "Didn't get expected type or value for property\n");
304     /* Set the code page to ascii */
305     var.vt = VT_I2;
306     U(var).iVal = 1252;
307     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
308     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
309     /* check code page */
310     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
311     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
312     ok(var.vt == VT_I2 && U(var).iVal == 1252,
313      "Didn't get expected type or value for property\n");
314     /* Set code page to Unicode */
315     U(var).iVal = 1200;
316     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
317     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
318     /* check code page */
319     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
320     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
321     ok(var.vt == VT_I2 && U(var).iVal == 1200,
322      "Didn't get expected type or value for property\n");
323     /* Set a string value */
324     spec.ulKind = PRSPEC_PROPID;
325     U(spec).propid = PID_FIRST_USABLE;
326     var.vt = VT_LPSTR;
327     U(var).pszVal = aval;
328     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
329     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
330     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
331     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
332     ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "hi"),
333      "Didn't get expected type or value for property\n");
334     /* This seemingly non-sensical test is to show that the string is indeed
335      * interpreted according to the current system code page, not according to
336      * the property set's code page.  (If the latter were true, the whole
337      * string would be maintained.  As it is, only the first character is.)
338      */
339     U(var).pszVal = (LPSTR)wval;
340     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
341     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
342     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
343     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
344     ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "h"),
345      "Didn't get expected type or value for property\n");
346     /* now that a property's been set, you can't change the code page */
347     spec.ulKind = PRSPEC_PROPID;
348     U(spec).propid = PID_CODEPAGE;
349     var.vt = VT_I2;
350     U(var).iVal = 1200;
351     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
352     ok(hr == STG_E_INVALIDPARAMETER,
353      "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
354
355     IPropertyStorage_Release(propertyStorage);
356     IPropertySetStorage_Release(propSetStorage);
357     IStorage_Release(storage);
358
359     DeleteFileW(fileName);
360
361     /* same tests, but with PROPSETFLAG_ANSI */
362     hr = StgCreateDocfile(fileName,
363      STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
364     ok(SUCCEEDED(hr), "StgCreateDocfile failed: 0x%08lx\n", hr);
365
366     hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
367     ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
368
369     hr = IPropertySetStorage_Create(propSetStorage,
370      &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
371      STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
372      &propertyStorage);
373     ok(SUCCEEDED(hr), "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
374
375     /* check code page before it's been explicitly set */
376     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
377     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
378     ok(var.vt == VT_I2 && U(var).iVal == 1252,
379      "Didn't get expected type or value for property\n");
380     /* Set code page to Unicode */
381     U(var).iVal = 1200;
382     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
383     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
384     /* check code page */
385     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
386     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
387     ok(var.vt == VT_I2 && U(var).iVal == 1200,
388      "Didn't get expected type or value for property\n");
389     /* This test is commented out for documentation.  It fails under Wine,
390      * and I expect it would under Windows as well, yet it succeeds.  There's
391      * obviously something about string conversion I don't understand.
392      */
393     if(0) {
394     static const char strVal[] = { 0x81, 0xff, 0x04, 0 };
395     /* Set code page to 950 (Traditional Chinese) */
396     U(var).iVal = 950;
397     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
398     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
399     /* Try writing an invalid string: lead byte 0x81 is unused in Traditional
400      * Chinese.
401      */
402     spec.ulKind = PRSPEC_PROPID;
403     U(spec).propid = PID_FIRST_USABLE;
404     var.vt = VT_LPSTR;
405     U(var).pszVal = (LPSTR)strVal;
406     hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
407     ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
408     /* Check returned string */
409     hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
410     ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
411     ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, strVal),
412      "Didn't get expected type or value for property\n");
413     }
414
415     IPropertyStorage_Release(propertyStorage);
416     IPropertySetStorage_Release(propSetStorage);
417     IStorage_Release(storage);
418
419     DeleteFileW(fileName);
420 }
421
422 static void testFmtId(void)
423 {
424     WCHAR szSummaryInfo[] = { 5,'S','u','m','m','a','r','y',
425         'I','n','f','o','r','m','a','t','i','o','n',0 };
426     WCHAR szDocSummaryInfo[] = { 5,'D','o','c','u','m','e','n','t',
427         'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',
428         0 };
429     WCHAR szIID_IPropSetStg[] = { 5,'0','j','a','a','a','a','a',
430         'a','A','a','a','a','a','a','d','a','A','a','a','a','a','a','a','a','G',
431         'c',0 };
432     WCHAR name[32];
433     FMTID fmtid;
434     HRESULT hr;
435
436     if (pFmtIdToPropStgName) {
437     hr = pFmtIdToPropStgName(NULL, name);
438     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
439     hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, NULL);
440     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
441     hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, name);
442     ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
443     ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) *
444      sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n");
445     hr = pFmtIdToPropStgName(&FMTID_DocSummaryInformation, name);
446     ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
447     ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
448      sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
449     hr = pFmtIdToPropStgName(&FMTID_UserDefinedProperties, name);
450     ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
451     ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
452      sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
453     hr = pFmtIdToPropStgName(&IID_IPropertySetStorage, name);
454     ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
455     ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) *
456      sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n");
457     }
458
459     if(pPropStgNameToFmtId) {
460     /* test args first */
461     hr = pPropStgNameToFmtId(NULL, NULL);
462     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
463     hr = pPropStgNameToFmtId(NULL, &fmtid);
464     ok(hr == STG_E_INVALIDNAME, "Expected STG_E_INVALIDNAME, got 0x%08lx\n",
465      hr);
466     hr = pPropStgNameToFmtId(szDocSummaryInfo, NULL);
467     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
468     /* test the known format IDs */
469     hr = pPropStgNameToFmtId(szSummaryInfo, &fmtid);
470     ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
471     ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)),
472      "Got unexpected FMTID, expected FMTID_SummaryInformation\n");
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     /* test another GUID */
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");
482     /* now check case matching */
483     CharUpperW(szDocSummaryInfo + 1);
484     hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
485     ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
486     ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
487      "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
488     CharUpperW(szIID_IPropSetStg + 1);
489     hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
490     ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
491     ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
492      "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
493     }
494 }
495
496 START_TEST(stg_prop)
497 {
498     init_function_pointers();
499     testProps();
500     testCodepage();
501     testFmtId();
502 }