2 * Copyright 2010 Piotr Caban for CodeWeavers
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 #define NONAMELESSUNION
24 #include <wine/test.h>
31 DEFINE_GUID(FMTID_Test
,0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12);
32 DEFINE_GUID(FMTID_NotExisting
, 0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x13);
33 DEFINE_GUID(CLSID_ClassMoniker
, 0x0000031a,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
35 #define DEFINE_EXPECT(func) \
36 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
38 #define SET_EXPECT(func) \
39 expect_ ## func = TRUE
41 #define CHECK_EXPECT2(func) \
43 ok(expect_ ##func, "unexpected call " #func "\n"); \
44 called_ ## func = TRUE; \
47 #define CHECK_EXPECT(func) \
49 CHECK_EXPECT2(func); \
50 expect_ ## func = FALSE; \
53 #define CHECK_CALLED(func) \
55 ok(called_ ## func, "expected " #func "\n"); \
56 expect_ ## func = called_ ## func = FALSE; \
59 DEFINE_EXPECT(Create
);
60 DEFINE_EXPECT(Delete
);
62 DEFINE_EXPECT(ReadMultiple
);
63 DEFINE_EXPECT(ReadMultipleCodePage
);
64 DEFINE_EXPECT(Release
);
66 DEFINE_EXPECT(WriteMultiple
);
68 DEFINE_EXPECT(autoplay_BindToObject
);
69 DEFINE_EXPECT(autoplay_GetClassObject
);
71 static HRESULT (WINAPI
*pSHPropStgCreate
)(IPropertySetStorage
*, REFFMTID
, const CLSID
*,
72 DWORD
, DWORD
, DWORD
, IPropertyStorage
**, UINT
*);
73 static HRESULT (WINAPI
*pSHPropStgReadMultiple
)(IPropertyStorage
*, UINT
,
74 ULONG
, const PROPSPEC
*, PROPVARIANT
*);
75 static HRESULT (WINAPI
*pSHPropStgWriteMultiple
)(IPropertyStorage
*, UINT
*,
76 ULONG
, const PROPSPEC
*, PROPVARIANT
*, PROPID
);
77 static HRESULT (WINAPI
*pSHCreateQueryCancelAutoPlayMoniker
)(IMoniker
**);
78 static HRESULT (WINAPI
*pSHCreateSessionKey
)(REGSAM
, HKEY
*);
80 static void init(void)
82 HMODULE hmod
= GetModuleHandleA("shell32.dll");
84 pSHPropStgCreate
= (void*)GetProcAddress(hmod
, "SHPropStgCreate");
85 pSHPropStgReadMultiple
= (void*)GetProcAddress(hmod
, "SHPropStgReadMultiple");
86 pSHPropStgWriteMultiple
= (void*)GetProcAddress(hmod
, "SHPropStgWriteMultiple");
87 pSHCreateQueryCancelAutoPlayMoniker
= (void*)GetProcAddress(hmod
, "SHCreateQueryCancelAutoPlayMoniker");
88 pSHCreateSessionKey
= (void*)GetProcAddress(hmod
, (char*)723);
91 static HRESULT WINAPI
PropertyStorage_QueryInterface(IPropertyStorage
*This
,
92 REFIID riid
, void **ppvObject
)
94 ok(0, "unexpected call\n");
98 static ULONG WINAPI
PropertyStorage_AddRef(IPropertyStorage
*This
)
100 ok(0, "unexpected call\n");
104 static ULONG WINAPI
PropertyStorage_Release(IPropertyStorage
*This
)
106 CHECK_EXPECT(Release
);
110 static HRESULT WINAPI
PropertyStorage_ReadMultiple(IPropertyStorage
*This
, ULONG cpspec
,
111 const PROPSPEC
*rgpspec
, PROPVARIANT
*rgpropvar
)
114 CHECK_EXPECT(ReadMultipleCodePage
);
116 ok(rgpspec
!= NULL
, "rgpspec = NULL\n");
117 ok(rgpropvar
!= NULL
, "rgpropvar = NULL\n");
119 ok(rgpspec
[0].ulKind
== PRSPEC_PROPID
, "rgpspec[0].ulKind = %ld\n", rgpspec
[0].ulKind
);
120 ok(rgpspec
[0].u
.propid
== PID_CODEPAGE
, "rgpspec[0].propid = %ld\n", rgpspec
[0].u
.propid
);
122 rgpropvar
[0].vt
= VT_I2
;
123 rgpropvar
[0].iVal
= 1234;
125 CHECK_EXPECT(ReadMultiple
);
127 ok(cpspec
== 10, "cpspec = %lu\n", cpspec
);
128 ok(rgpspec
== (void*)0xdeadbeef, "rgpspec = %p\n", rgpspec
);
129 ok(rgpropvar
!= NULL
, "rgpropvar = NULL\n");
131 ok(rgpropvar
[0].vt
==0 || broken(rgpropvar
[0].vt
==VT_BSTR
), "rgpropvar[0].vt = %d\n", rgpropvar
[0].vt
);
133 rgpropvar
[0].vt
= VT_BSTR
;
134 rgpropvar
[0].bstrVal
= (void*)0xdeadbeef;
135 rgpropvar
[1].vt
= VT_LPSTR
;
136 rgpropvar
[1].pszVal
= (void*)0xdeadbeef;
137 rgpropvar
[2].vt
= VT_BYREF
|VT_I1
;
138 rgpropvar
[2].pcVal
= (void*)0xdeadbeef;
139 rgpropvar
[3].vt
= VT_BYREF
|VT_VARIANT
;
140 rgpropvar
[3].pvarVal
= (void*)0xdeadbeef;
146 static HRESULT WINAPI
PropertyStorage_WriteMultiple(IPropertyStorage
*This
, ULONG cpspec
,
147 const PROPSPEC
*rgpspec
, const PROPVARIANT
*rgpropvar
,
148 PROPID propidNameFirst
)
150 CHECK_EXPECT(WriteMultiple
);
152 ok(cpspec
== 20, "cpspec = %ld\n", cpspec
);
153 ok(rgpspec
== (void*)0xdeadbeef, "rgpspec = %p\n", rgpspec
);
154 ok(rgpropvar
== (void*)0xdeadbeef, "rgpropvar = %p\n", rgpspec
);
155 ok(propidNameFirst
== PID_FIRST_USABLE
, "propidNameFirst = %ld\n", propidNameFirst
);
159 static HRESULT WINAPI
PropertyStorage_DeleteMultiple(IPropertyStorage
*This
, ULONG cpspec
,
160 const PROPSPEC
*rgpspec
)
162 ok(0, "unexpected call\n");
166 static HRESULT WINAPI
PropertyStorage_ReadPropertyNames(IPropertyStorage
*This
, ULONG cpropid
,
167 const PROPID
*rgpropid
, LPOLESTR
*rglpwstrName
)
169 ok(0, "unexpected call\n");
173 static HRESULT WINAPI
PropertyStorage_WritePropertyNames(IPropertyStorage
*This
, ULONG cpropid
,
174 const PROPID
*rgpropid
, const LPOLESTR
*rglpwstrName
)
176 ok(0, "unexpected call\n");
180 static HRESULT WINAPI
PropertyStorage_DeletePropertyNames(IPropertyStorage
*This
, ULONG cpropid
,
181 const PROPID
*rgpropid
)
183 ok(0, "unexpected call\n");
187 static HRESULT WINAPI
PropertyStorage_Commit(IPropertyStorage
*This
, DWORD grfCommitFlags
)
189 ok(0, "unexpected call\n");
193 static HRESULT WINAPI
PropertyStorage_Revert(IPropertyStorage
*This
)
195 ok(0, "unexpected call\n");
199 static HRESULT WINAPI
PropertyStorage_Enum(IPropertyStorage
*This
, IEnumSTATPROPSTG
**ppenum
)
201 ok(0, "unexpected call\n");
205 static HRESULT WINAPI
PropertyStorage_SetTimes(IPropertyStorage
*This
, const FILETIME
*pctime
,
206 const FILETIME
*patime
, const FILETIME
*pmtime
)
208 ok(0, "unexpected call\n");
212 static HRESULT WINAPI
PropertyStorage_SetClass(IPropertyStorage
*This
, REFCLSID clsid
)
214 ok(0, "unexpected call\n");
218 static HRESULT WINAPI
PropertyStorage_Stat(IPropertyStorage
*This
, STATPROPSETSTG
*statpsstg
)
222 memset(statpsstg
, 0, sizeof(STATPROPSETSTG
));
223 memcpy(&statpsstg
->fmtid
, &FMTID_Test
, sizeof(FMTID
));
224 statpsstg
->grfFlags
= PROPSETFLAG_ANSI
;
228 static IPropertyStorageVtbl PropertyStorageVtbl
= {
229 PropertyStorage_QueryInterface
,
230 PropertyStorage_AddRef
,
231 PropertyStorage_Release
,
232 PropertyStorage_ReadMultiple
,
233 PropertyStorage_WriteMultiple
,
234 PropertyStorage_DeleteMultiple
,
235 PropertyStorage_ReadPropertyNames
,
236 PropertyStorage_WritePropertyNames
,
237 PropertyStorage_DeletePropertyNames
,
238 PropertyStorage_Commit
,
239 PropertyStorage_Revert
,
240 PropertyStorage_Enum
,
241 PropertyStorage_SetTimes
,
242 PropertyStorage_SetClass
,
246 static IPropertyStorage PropertyStorage
= { &PropertyStorageVtbl
};
248 static HRESULT WINAPI
PropertySetStorage_QueryInterface(IPropertySetStorage
*This
,
249 REFIID riid
, void **ppvObject
)
251 ok(0, "unexpected call\n");
255 static ULONG WINAPI
PropertySetStorage_AddRef(IPropertySetStorage
*This
)
257 ok(0, "unexpected call\n");
261 static ULONG WINAPI
PropertySetStorage_Release(IPropertySetStorage
*This
)
263 ok(0, "unexpected call\n");
267 static HRESULT WINAPI
PropertySetStorage_Create(IPropertySetStorage
*This
,
268 REFFMTID rfmtid
, const CLSID
*pclsid
, DWORD grfFlags
,
269 DWORD grfMode
, IPropertyStorage
**ppprstg
)
271 CHECK_EXPECT(Create
);
272 ok(IsEqualGUID(rfmtid
, &FMTID_Test
) || IsEqualGUID(rfmtid
, &FMTID_NotExisting
),
273 "Incorrect rfmtid value\n");
274 ok(pclsid
== NULL
, "pclsid != NULL\n");
275 ok(grfFlags
== PROPSETFLAG_ANSI
, "grfFlags = %lx\n", grfFlags
);
276 ok(grfMode
== STGM_READ
, "grfMode = %lx\n", grfMode
);
278 *ppprstg
= &PropertyStorage
;
282 static HRESULT WINAPI
PropertySetStorage_Open(IPropertySetStorage
*This
,
283 REFFMTID rfmtid
, DWORD grfMode
, IPropertyStorage
**ppprstg
)
287 if(IsEqualGUID(rfmtid
, &FMTID_Test
)) {
288 ok(grfMode
== STGM_READ
, "grfMode = %lx\n", grfMode
);
290 *ppprstg
= &PropertyStorage
;
294 return STG_E_FILENOTFOUND
;
297 static HRESULT WINAPI
PropertySetStorage_Delete(IPropertySetStorage
*This
,
300 CHECK_EXPECT(Delete
);
301 ok(IsEqualGUID(rfmtid
, &FMTID_Test
), "wrong rfmtid value\n");
305 static HRESULT WINAPI
PropertySetStorage_Enum(IPropertySetStorage
*This
,
306 IEnumSTATPROPSETSTG
**ppenum
)
308 ok(0, "unexpected call\n");
312 static IPropertySetStorageVtbl PropertySetStorageVtbl
= {
313 PropertySetStorage_QueryInterface
,
314 PropertySetStorage_AddRef
,
315 PropertySetStorage_Release
,
316 PropertySetStorage_Create
,
317 PropertySetStorage_Open
,
318 PropertySetStorage_Delete
,
319 PropertySetStorage_Enum
322 static IPropertySetStorage PropertySetStorage
= { &PropertySetStorageVtbl
};
324 static void test_SHPropStg_functions(void)
326 IPropertyStorage
*property_storage
;
328 PROPVARIANT read
[10];
331 if(!pSHPropStgCreate
|| !pSHPropStgReadMultiple
|| !pSHPropStgWriteMultiple
) {
332 win_skip("SHPropStg* functions are missing\n");
337 /* Crashes on Windows */
338 pSHPropStgCreate(NULL
, &FMTID_Test
, NULL
, PROPSETFLAG_DEFAULT
,
339 STGM_READ
, OPEN_EXISTING
, &property_storage
, &codepage
);
340 pSHPropStgCreate(&PropertySetStorage
, NULL
, NULL
, PROPSETFLAG_DEFAULT
,
341 STGM_READ
, OPEN_EXISTING
, &property_storage
, &codepage
);
342 pSHPropStgCreate(&PropertySetStorage
, &FMTID_Test
, NULL
, PROPSETFLAG_DEFAULT
,
343 STGM_READ
, OPEN_EXISTING
, NULL
, &codepage
);
347 SET_EXPECT(ReadMultipleCodePage
);
348 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_Test
, NULL
, PROPSETFLAG_DEFAULT
,
349 STGM_READ
, OPEN_EXISTING
, &property_storage
, &codepage
);
350 ok(codepage
== 1234, "codepage = %d\n", codepage
);
351 ok(hres
== S_OK
, "hres = %lx\n", hres
);
353 CHECK_CALLED(ReadMultipleCodePage
);
356 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_NotExisting
, NULL
,
357 PROPSETFLAG_DEFAULT
, STGM_READ
, OPEN_EXISTING
, &property_storage
, &codepage
);
358 ok(hres
== STG_E_FILENOTFOUND
, "hres = %lx\n", hres
);
365 SET_EXPECT(ReadMultipleCodePage
);
366 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_Test
, NULL
, PROPSETFLAG_ANSI
,
367 STGM_READ
, CREATE_ALWAYS
, &property_storage
, &codepage
);
368 ok(codepage
== 1234, "codepage = %d\n", codepage
);
369 ok(hres
== S_OK
, "hres = %lx\n", hres
);
371 CHECK_CALLED(Release
);
372 CHECK_CALLED(Delete
);
373 CHECK_CALLED(Create
);
374 CHECK_CALLED(ReadMultipleCodePage
);
378 SET_EXPECT(ReadMultipleCodePage
);
379 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_NotExisting
, NULL
, PROPSETFLAG_ANSI
,
380 STGM_READ
, CREATE_ALWAYS
, &property_storage
, &codepage
);
381 ok(codepage
== 1234, "codepage = %d\n", codepage
);
382 ok(hres
== S_OK
, "hres = %lx\n", hres
);
384 CHECK_CALLED(Create
);
385 CHECK_CALLED(ReadMultipleCodePage
);
388 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_Test
, &FMTID_NotExisting
,
389 PROPSETFLAG_DEFAULT
, STGM_READ
, OPEN_EXISTING
, &property_storage
, NULL
);
390 ok(hres
== S_OK
, "hres = %lx\n", hres
);
394 SET_EXPECT(ReadMultipleCodePage
);
395 SET_EXPECT(WriteMultiple
);
397 hres
= pSHPropStgWriteMultiple(property_storage
, &codepage
, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE
);
398 ok(hres
== S_OK
, "hres = %lx\n", hres
);
399 ok(codepage
== 1234, "codepage = %d\n", codepage
);
401 CHECK_CALLED(ReadMultipleCodePage
);
402 CHECK_CALLED(WriteMultiple
);
405 SET_EXPECT(ReadMultipleCodePage
);
406 SET_EXPECT(WriteMultiple
);
407 hres
= pSHPropStgWriteMultiple(property_storage
, NULL
, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE
);
408 ok(hres
== S_OK
, "hres = %lx\n", hres
);
410 CHECK_CALLED(ReadMultipleCodePage
);
411 CHECK_CALLED(WriteMultiple
);
414 SET_EXPECT(WriteMultiple
);
416 hres
= pSHPropStgWriteMultiple(property_storage
, &codepage
, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE
);
417 ok(hres
== S_OK
, "hres = %lx\n", hres
);
418 ok(codepage
== 1000, "codepage = %d\n", codepage
);
420 CHECK_CALLED(WriteMultiple
);
422 read
[0].vt
= VT_BSTR
;
423 read
[0].bstrVal
= (void*)0xdeadbeef;
424 SET_EXPECT(ReadMultiple
);
425 SET_EXPECT(ReadMultipleCodePage
);
427 hres
= pSHPropStgReadMultiple(property_storage
, 0, 10, (void*)0xdeadbeef, read
);
428 ok(hres
== S_OK
, "hres = %lx\n", hres
);
429 CHECK_CALLED(ReadMultiple
);
430 CHECK_CALLED(ReadMultipleCodePage
);
433 SET_EXPECT(ReadMultiple
);
435 hres
= pSHPropStgReadMultiple(property_storage
, 1251, 10, (void*)0xdeadbeef, read
);
436 ok(hres
== S_OK
, "hres = %lx\n", hres
);
437 CHECK_CALLED(ReadMultiple
);
441 static HRESULT WINAPI
test_activator_QI(IClassActivator
*iface
, REFIID riid
, void **ppv
)
445 if (IsEqualIID(riid
, &IID_IUnknown
) ||
446 IsEqualIID(riid
, &IID_IClassActivator
))
451 if (!*ppv
) return E_NOINTERFACE
;
453 IClassActivator_AddRef(iface
);
458 static ULONG WINAPI
test_activator_AddRef(IClassActivator
*iface
)
463 static ULONG WINAPI
test_activator_Release(IClassActivator
*iface
)
468 static HRESULT WINAPI
test_activator_GetClassObject(IClassActivator
*iface
, REFCLSID clsid
,
469 DWORD context
, LCID locale
, REFIID riid
, void **ppv
)
471 CHECK_EXPECT(autoplay_GetClassObject
);
472 ok(IsEqualGUID(clsid
, &CLSID_QueryCancelAutoPlay
), "clsid %s\n", wine_dbgstr_guid(clsid
));
473 ok(IsEqualIID(riid
, &IID_IQueryCancelAutoPlay
), "riid %s\n", wine_dbgstr_guid(riid
));
477 static const IClassActivatorVtbl test_activator_vtbl
= {
479 test_activator_AddRef
,
480 test_activator_Release
,
481 test_activator_GetClassObject
484 static IClassActivator test_activator
= { &test_activator_vtbl
};
486 static HRESULT WINAPI
test_moniker_QueryInterface(IMoniker
* iface
, REFIID riid
, void **ppvObject
)
490 if (IsEqualIID(&IID_IUnknown
, riid
) ||
491 IsEqualIID(&IID_IPersist
, riid
) ||
492 IsEqualIID(&IID_IPersistStream
, riid
) ||
493 IsEqualIID(&IID_IMoniker
, riid
))
499 return E_NOINTERFACE
;
504 static ULONG WINAPI
test_moniker_AddRef(IMoniker
* iface
)
509 static ULONG WINAPI
test_moniker_Release(IMoniker
* iface
)
514 static HRESULT WINAPI
test_moniker_GetClassID(IMoniker
* iface
, CLSID
*pClassID
)
516 ok(0, "unexpected call\n");
520 static HRESULT WINAPI
test_moniker_IsDirty(IMoniker
* iface
)
522 ok(0, "unexpected call\n");
526 static HRESULT WINAPI
test_moniker_Load(IMoniker
* iface
, IStream
* pStm
)
528 ok(0, "unexpected call\n");
532 static HRESULT WINAPI
test_moniker_Save(IMoniker
* iface
, IStream
* pStm
, BOOL fClearDirty
)
534 ok(0, "unexpected call\n");
538 static HRESULT WINAPI
test_moniker_GetSizeMax(IMoniker
* iface
, ULARGE_INTEGER
* pcbSize
)
540 ok(0, "unexpected call\n");
544 static HRESULT WINAPI
test_moniker_BindToObject(IMoniker
* iface
,
546 IMoniker
* moniker_to_left
,
550 CHECK_EXPECT(autoplay_BindToObject
);
551 ok(pbc
!= NULL
, "got %p\n", pbc
);
552 ok(moniker_to_left
== NULL
, "got %p\n", moniker_to_left
);
553 ok(IsEqualIID(riid
, &IID_IClassActivator
), "got riid %s\n", wine_dbgstr_guid(riid
));
555 if (IsEqualIID(riid
, &IID_IClassActivator
))
557 *ppv
= &test_activator
;
564 static HRESULT WINAPI
test_moniker_BindToStorage(IMoniker
* iface
,
570 ok(0, "unexpected call\n");
574 static HRESULT WINAPI
test_moniker_Reduce(IMoniker
* iface
,
576 DWORD dwReduceHowFar
,
577 IMoniker
** ppmkToLeft
,
578 IMoniker
** ppmkReduced
)
580 ok(0, "unexpected call\n");
584 static HRESULT WINAPI
test_moniker_ComposeWith(IMoniker
* iface
,
586 BOOL fOnlyIfNotGeneric
,
587 IMoniker
** ppmkComposite
)
589 ok(0, "unexpected call\n");
593 static HRESULT WINAPI
test_moniker_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
595 ok(0, "unexpected call\n");
599 static HRESULT WINAPI
test_moniker_IsEqual(IMoniker
* iface
, IMoniker
* pmkOtherMoniker
)
601 ok(0, "unexpected call\n");
605 static HRESULT WINAPI
test_moniker_Hash(IMoniker
* iface
, DWORD
* pdwHash
)
607 ok(0, "unexpected call\n");
611 static HRESULT WINAPI
test_moniker_IsRunning(IMoniker
* iface
,
614 IMoniker
* pmkNewlyRunning
)
616 ok(0, "unexpected call\n");
620 static HRESULT WINAPI
test_moniker_GetTimeOfLastChange(IMoniker
* iface
,
625 ok(0, "unexpected call\n");
629 static HRESULT WINAPI
test_moniker_Inverse(IMoniker
* iface
, IMoniker
** ppmk
)
631 ok(0, "unexpected call\n");
635 static HRESULT WINAPI
test_moniker_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
637 ok(0, "unexpected call\n");
641 static HRESULT WINAPI
test_moniker_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
643 ok(0, "unexpected call\n");
647 static HRESULT WINAPI
test_moniker_GetDisplayName(IMoniker
* iface
,
650 LPOLESTR
*ppszDisplayName
)
652 ok(0, "unexpected call\n");
656 static HRESULT WINAPI
test_moniker_ParseDisplayName(IMoniker
* iface
,
659 LPOLESTR pszDisplayName
,
663 ok(0, "unexpected call\n");
667 static HRESULT WINAPI
test_moniker_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
669 ok(0, "unexpected call\n");
673 static const IMonikerVtbl test_moniker_vtbl
=
675 test_moniker_QueryInterface
,
677 test_moniker_Release
,
678 test_moniker_GetClassID
,
679 test_moniker_IsDirty
,
682 test_moniker_GetSizeMax
,
683 test_moniker_BindToObject
,
684 test_moniker_BindToStorage
,
686 test_moniker_ComposeWith
,
688 test_moniker_IsEqual
,
690 test_moniker_IsRunning
,
691 test_moniker_GetTimeOfLastChange
,
692 test_moniker_Inverse
,
693 test_moniker_CommonPrefixWith
,
694 test_moniker_RelativePathTo
,
695 test_moniker_GetDisplayName
,
696 test_moniker_ParseDisplayName
,
697 test_moniker_IsSystemMoniker
700 static IMoniker test_moniker
= { &test_moniker_vtbl
};
702 static void test_SHCreateQueryCancelAutoPlayMoniker(void)
711 if (!pSHCreateQueryCancelAutoPlayMoniker
)
713 win_skip("SHCreateQueryCancelAutoPlayMoniker is not available, skipping tests.\n");
717 hr
= pSHCreateQueryCancelAutoPlayMoniker(NULL
);
718 ok(hr
== E_INVALIDARG
, "got 0x%08lx\n", hr
);
720 hr
= pSHCreateQueryCancelAutoPlayMoniker(&mon
);
721 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
724 hr
= IMoniker_IsSystemMoniker(mon
, &sys
);
725 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
726 ok(sys
== MKSYS_CLASSMONIKER
, "got %ld\n", sys
);
728 memset(&clsid
, 0, sizeof(clsid
));
729 hr
= IMoniker_GetClassID(mon
, &clsid
);
730 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
731 ok(IsEqualGUID(&clsid
, &CLSID_ClassMoniker
), "got %s\n", wine_dbgstr_guid(&clsid
));
733 /* extract used CLSID that implements this hook */
734 SET_EXPECT(autoplay_BindToObject
);
735 SET_EXPECT(autoplay_GetClassObject
);
737 CreateBindCtx(0, &ctxt
);
738 hr
= IMoniker_BindToObject(mon
, ctxt
, &test_moniker
, &IID_IQueryCancelAutoPlay
, (void**)&unk
);
739 ok(hr
== E_NOTIMPL
, "got 0x%08lx\n", hr
);
740 IBindCtx_Release(ctxt
);
742 CHECK_CALLED(autoplay_BindToObject
);
743 CHECK_CALLED(autoplay_GetClassObject
);
745 IMoniker_Release(mon
);
748 #define WM_EXPECTED_VALUE WM_APP
749 #define DROP_NC_AREA 1
750 #define DROP_WIDE_FILENAME 2
756 static LRESULT WINAPI
drop_window_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
759 static char expected_filename
[MAX_PATH
];
762 case WM_EXPECTED_VALUE
:
764 lstrcpynA(expected_filename
, (const char*)wparam
, sizeof(expected_filename
));
770 HDROP hDrop
= (HDROP
)wparam
;
771 char filename
[MAX_PATH
] = "dummy";
772 WCHAR filenameW
[MAX_PATH
] = L
"dummy", expected_filenameW
[MAX_PATH
];
776 winetest_push_context("%s(%lu)", wine_dbgstr_a(expected_filename
), flags
);
778 num
= DragQueryFileA(hDrop
, 0xffffffff, NULL
, 0);
779 ok(num
== 1, "expected 1, got %u\n", num
);
781 num
= DragQueryFileA(hDrop
, 0xffffffff, (char*)0xdeadbeef, 0xffffffff);
782 ok(num
== 1, "expected 1, got %u\n", num
);
784 len
= strlen(expected_filename
);
785 num
= DragQueryFileA(hDrop
, 0, NULL
, 0);
786 ok(num
== len
, "expected %u, got %u\n", len
, num
);
788 num
= DragQueryFileA(hDrop
, 0, filename
, 0);
789 ok(num
== len
, "expected %u, got %u\n", len
, num
);
790 ok(!strcmp(filename
, "dummy"), "got %s\n", filename
);
792 num
= DragQueryFileA(hDrop
, 0, filename
, sizeof(filename
));
793 ok(num
== len
, "expected %u, got %u\n", len
, num
);
794 ok(!strcmp(filename
, expected_filename
), "expected %s, got %s\n",
795 expected_filename
, filename
);
797 memset(filename
, 0xaa, sizeof(filename
));
798 num
= DragQueryFileA(hDrop
, 0, filename
, 2);
799 ok(num
== 1, "expected 1, got %u\n", num
);
800 ok(filename
[0] == expected_filename
[0], "expected '%c', got '%c'\n",
801 expected_filename
[0], filename
[0]);
802 ok(filename
[1] == '\0', "expected nul, got %#x\n", (BYTE
)filename
[1]);
804 MultiByteToWideChar(CP_ACP
, 0, expected_filename
, -1,
805 expected_filenameW
, ARRAY_SIZE(expected_filenameW
));
807 len
= wcslen(expected_filenameW
);
808 num
= DragQueryFileW(hDrop
, 0, NULL
, 0);
809 ok(num
== len
, "expected %u, got %u\n", len
, num
);
811 num
= DragQueryFileW(hDrop
, 0, filenameW
, 0);
812 ok(num
== len
, "expected %u, got %u\n", len
, num
);
813 ok(!wcscmp(filenameW
, L
"dummy"), "got %s\n", wine_dbgstr_w(filenameW
));
815 num
= DragQueryFileW(hDrop
, 0, filenameW
, ARRAY_SIZE(filename
));
816 ok(num
== len
, "expected %u, got %u\n", len
, num
);
817 ok(!wcscmp(filenameW
, expected_filenameW
), "expected %s, got %s\n",
818 wine_dbgstr_w(expected_filenameW
), wine_dbgstr_w(filenameW
));
820 memset(filenameW
, 0xaa, sizeof(filenameW
));
821 num
= DragQueryFileW(hDrop
, 0, filenameW
, 2);
822 ok(num
== 1, "expected 1, got %u\n", num
);
823 ok(filenameW
[0] == expected_filenameW
[0], "expected '%lc', got '%lc'\n",
824 expected_filenameW
[0], filenameW
[0]);
825 ok(filenameW
[1] == L
'\0', "expected nul, got %#x\n", (WCHAR
)filenameW
[1]);
827 r
= DragQueryPoint(hDrop
, &pt
);
828 ok(r
== !(flags
& DROP_NC_AREA
), "expected %d, got %d\n", !(flags
& DROP_NC_AREA
), r
);
829 ok(pt
.x
== 10, "expected 10, got %ld\n", pt
.x
);
830 ok(pt
.y
== 20, "expected 20, got %ld\n", pt
.y
);
832 winetest_pop_context();
836 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
839 static DWORD WINAPI
drop_window_therad(void *arg
)
841 struct DragParam
*param
= arg
;
847 memset(&cls
, 0, sizeof(cls
));
848 cls
.lpfnWndProc
= drop_window_proc
;
849 cls
.hInstance
= GetModuleHandleA(NULL
);
850 cls
.lpszClassName
= "drop test";
851 RegisterClassA(&cls
);
853 param
->hwnd
= CreateWindowA("drop test", NULL
, 0, 0, 0, 0, 0,
855 ok(param
->hwnd
!= NULL
, "CreateWindow failed: %ld\n", GetLastError());
857 memset(&info
, 0, sizeof(info
));
858 info
.cbSize
= sizeof(info
);
859 r
= GetWindowInfo(param
->hwnd
, &info
);
860 ok(r
, "got %d\n", r
);
861 ok(!(info
.dwExStyle
& WS_EX_ACCEPTFILES
), "got %08lx\n", info
.dwExStyle
);
863 DragAcceptFiles(param
->hwnd
, TRUE
);
865 memset(&info
, 0, sizeof(info
));
866 info
.cbSize
= sizeof(info
);
867 r
= GetWindowInfo(param
->hwnd
, &info
);
868 ok(r
, "got %d\n", r
);
869 ok((info
.dwExStyle
& WS_EX_ACCEPTFILES
), "got %08lx\n", info
.dwExStyle
);
871 SetEvent(param
->ready
);
873 while ((r
= GetMessageA(&msg
, NULL
, 0, 0)) != 0) {
875 ok(0, "unexpected return value, got %d\n", r
);
878 DispatchMessageA(&msg
);
881 DestroyWindow(param
->hwnd
);
882 UnregisterClassA("drop test", GetModuleHandleA(NULL
));
886 static void test_DragQueryFile(BOOL non_client_flag
)
888 struct DragParam param
;
895 static const struct {
897 const char* filename
;
899 { 0, "c:\\wintest.bin" },
900 { 932, "d:\\\x89\xb9\x8a\x79_02.CHY" },
903 param
.ready
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
);
904 ok(param
.ready
!= NULL
, "can't create event\n");
905 hThread
= CreateThread(NULL
, 0, drop_window_therad
, ¶m
, 0, NULL
);
907 rc
= WaitForSingleObject(param
.ready
, 5000);
908 ok(rc
== WAIT_OBJECT_0
, "got %lu\n", rc
);
910 for (i
= 0; i
< ARRAY_SIZE(testcase
); i
++)
912 winetest_push_context("%d", i
);
913 if (testcase
[i
].codepage
&& testcase
[i
].codepage
!= GetACP())
915 skip("need codepage %u for this test\n", testcase
[i
].codepage
);
916 winetest_pop_context();
920 ret
= MultiByteToWideChar(CP_ACP
, 0, testcase
[i
].filename
, -1, NULL
, 0);
921 ok(ret
> 0, "got %d\n", ret
);
922 hDrop
= GlobalAlloc(GHND
, sizeof(DROPFILES
) + (ret
+ 1) * sizeof(WCHAR
));
923 pDrop
= GlobalLock(hDrop
);
926 pDrop
->fNC
= non_client_flag
;
927 pDrop
->pFiles
= sizeof(DROPFILES
);
928 ret
= MultiByteToWideChar(CP_ACP
, 0, testcase
[i
].filename
, -1,
929 (LPWSTR
)(pDrop
+ 1), ret
);
930 ok(ret
> 0, "got %d\n", ret
);
934 r
= PostMessageA(param
.hwnd
, WM_EXPECTED_VALUE
,
935 (WPARAM
)testcase
[i
].filename
, DROP_WIDE_FILENAME
| (non_client_flag
? DROP_NC_AREA
: 0));
936 ok(r
, "got %d\n", r
);
938 r
= PostMessageA(param
.hwnd
, WM_DROPFILES
, (WPARAM
)hDrop
, 0);
939 ok(r
, "got %d\n", r
);
941 hDrop
= GlobalAlloc(GHND
, sizeof(DROPFILES
) + strlen(testcase
[i
].filename
) + 2);
942 pDrop
= GlobalLock(hDrop
);
945 pDrop
->fNC
= non_client_flag
;
946 pDrop
->pFiles
= sizeof(DROPFILES
);
947 strcpy((char *)(pDrop
+ 1), testcase
[i
].filename
);
948 pDrop
->fWide
= FALSE
;
951 r
= PostMessageA(param
.hwnd
, WM_EXPECTED_VALUE
,
952 (WPARAM
)testcase
[i
].filename
, non_client_flag
? DROP_NC_AREA
: 0);
953 ok(r
, "got %d\n", r
);
955 r
= PostMessageA(param
.hwnd
, WM_DROPFILES
, (WPARAM
)hDrop
, 0);
956 ok(r
, "got %d\n", r
);
958 winetest_pop_context();
961 r
= PostMessageA(param
.hwnd
, WM_QUIT
, 0, 0);
962 ok(r
, "got %d\n", r
);
964 rc
= WaitForSingleObject(hThread
, 5000);
965 ok(rc
== WAIT_OBJECT_0
, "got %ld\n", rc
);
967 CloseHandle(param
.ready
);
968 CloseHandle(hThread
);
970 #undef WM_EXPECTED_VALUE
972 #undef DROP_WIDE_FILENAME
974 static void test_SHCreateSessionKey(void)
976 static const WCHAR session_format
[] = {
977 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
978 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
979 'E','x','p','l','o','r','e','r','\\','S','e','s','s','i','o','n','I','n','f','o','\\','%','u',0};
983 WCHAR sessionW
[ARRAY_SIZE(session_format
) + 16];
986 if (!pSHCreateSessionKey
)
988 win_skip("SHCreateSessionKey is not implemented\n");
992 if (0) /* crashes on native */
993 hr
= pSHCreateSessionKey(KEY_READ
, NULL
);
995 hkey
= (HKEY
)0xdeadbeef;
996 hr
= pSHCreateSessionKey(0, &hkey
);
997 ok(hr
== E_ACCESSDENIED
, "got 0x%08lx\n", hr
);
998 ok(hkey
== NULL
, "got %p\n", hkey
);
1000 hr
= pSHCreateSessionKey(KEY_READ
, &hkey
);
1001 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1003 hr
= pSHCreateSessionKey(KEY_READ
, &hkey2
);
1004 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1005 ok(hkey
!= hkey2
, "got %p, %p\n", hkey
, hkey2
);
1010 /* check the registry */
1011 ProcessIdToSessionId( GetCurrentProcessId(), &session
);
1014 wsprintfW(sessionW
, session_format
, session
);
1015 ret
= RegOpenKeyW(HKEY_CURRENT_USER
, sessionW
, &hkey
);
1016 ok(!ret
, "key not found\n");
1021 static void test_dragdrophelper(void)
1023 IDragSourceHelper
*dragsource
;
1024 IDropTargetHelper
*target
;
1027 hr
= CoCreateInstance(&CLSID_DragDropHelper
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDropTargetHelper
, (void **)&target
);
1028 ok(hr
== S_OK
, "Failed to create IDropTargetHelper, %#lx\n", hr
);
1030 hr
= IDropTargetHelper_QueryInterface(target
, &IID_IDragSourceHelper
, (void **)&dragsource
);
1031 ok(hr
== S_OK
, "QI failed, %#lx\n", hr
);
1032 IDragSourceHelper_Release(dragsource
);
1034 IDropTargetHelper_Release(target
);
1037 START_TEST(shellole
)
1043 hr
= CoInitialize(NULL
);
1044 ok(hr
== S_OK
, "CoInitialize failed (0x%08lx)\n", hr
);
1048 test_SHPropStg_functions();
1049 test_SHCreateQueryCancelAutoPlayMoniker();
1050 test_DragQueryFile(TRUE
);
1051 test_DragQueryFile(FALSE
);
1052 test_SHCreateSessionKey();
1053 test_dragdrophelper();