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
23 DEFINE_GUID(FMTID_Test
,0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12);
24 DEFINE_GUID(FMTID_NotExisting
, 0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x13);
25 DEFINE_GUID(CLSID_ClassMoniker
, 0x0000031a,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
27 #define DEFINE_EXPECT(func) \
28 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
30 #define SET_EXPECT(func) \
31 expect_ ## func = TRUE
33 #define CHECK_EXPECT2(func) \
35 ok(expect_ ##func, "unexpected call " #func "\n"); \
36 called_ ## func = TRUE; \
39 #define CHECK_EXPECT(func) \
41 CHECK_EXPECT2(func); \
42 expect_ ## func = FALSE; \
45 #define CHECK_CALLED(func) \
47 ok(called_ ## func, "expected " #func "\n"); \
48 expect_ ## func = called_ ## func = FALSE; \
51 DEFINE_EXPECT(Create
);
52 DEFINE_EXPECT(Delete
);
54 DEFINE_EXPECT(ReadMultiple
);
55 DEFINE_EXPECT(ReadMultipleCodePage
);
56 DEFINE_EXPECT(Release
);
58 DEFINE_EXPECT(WriteMultiple
);
60 DEFINE_EXPECT(autoplay_BindToObject
);
61 DEFINE_EXPECT(autoplay_GetClassObject
);
63 static HRESULT (WINAPI
*pSHPropStgCreate
)(IPropertySetStorage
*, REFFMTID
, const CLSID
*,
64 DWORD
, DWORD
, DWORD
, IPropertyStorage
**, UINT
*);
65 static HRESULT (WINAPI
*pSHPropStgReadMultiple
)(IPropertyStorage
*, UINT
,
66 ULONG
, const PROPSPEC
*, PROPVARIANT
*);
67 static HRESULT (WINAPI
*pSHPropStgWriteMultiple
)(IPropertyStorage
*, UINT
*,
68 ULONG
, const PROPSPEC
*, PROPVARIANT
*, PROPID
);
69 static HRESULT (WINAPI
*pSHCreateQueryCancelAutoPlayMoniker
)(IMoniker
**);
70 static HRESULT (WINAPI
*pSHCreateSessionKey
)(REGSAM
, HKEY
*);
72 static void init(void)
74 HMODULE hmod
= GetModuleHandleA("shell32.dll");
76 pSHPropStgCreate
= (void*)GetProcAddress(hmod
, "SHPropStgCreate");
77 pSHPropStgReadMultiple
= (void*)GetProcAddress(hmod
, "SHPropStgReadMultiple");
78 pSHPropStgWriteMultiple
= (void*)GetProcAddress(hmod
, "SHPropStgWriteMultiple");
79 pSHCreateQueryCancelAutoPlayMoniker
= (void*)GetProcAddress(hmod
, "SHCreateQueryCancelAutoPlayMoniker");
80 pSHCreateSessionKey
= (void*)GetProcAddress(hmod
, (char*)723);
83 static HRESULT WINAPI
PropertyStorage_QueryInterface(IPropertyStorage
*This
,
84 REFIID riid
, void **ppvObject
)
86 ok(0, "unexpected call\n");
90 static ULONG WINAPI
PropertyStorage_AddRef(IPropertyStorage
*This
)
92 ok(0, "unexpected call\n");
96 static ULONG WINAPI
PropertyStorage_Release(IPropertyStorage
*This
)
98 CHECK_EXPECT(Release
);
102 static HRESULT WINAPI
PropertyStorage_ReadMultiple(IPropertyStorage
*This
, ULONG cpspec
,
103 const PROPSPEC
*rgpspec
, PROPVARIANT
*rgpropvar
)
106 CHECK_EXPECT(ReadMultipleCodePage
);
108 ok(rgpspec
!= NULL
, "rgpspec = NULL\n");
109 ok(rgpropvar
!= NULL
, "rgpropvar = NULL\n");
111 ok(rgpspec
[0].ulKind
== PRSPEC_PROPID
, "rgpspec[0].ulKind = %d\n", rgpspec
[0].ulKind
);
112 ok(rgpspec
[0].propid
== PID_CODEPAGE
, "rgpspec[0].propid = %d\n", rgpspec
[0].propid
);
114 rgpropvar
[0].vt
= VT_I2
;
115 rgpropvar
[0].iVal
= 1234;
117 CHECK_EXPECT(ReadMultiple
);
119 ok(cpspec
== 10, "cpspec = %u\n", cpspec
);
120 ok(rgpspec
== (void*)0xdeadbeef, "rgpspec = %p\n", rgpspec
);
121 ok(rgpropvar
!= NULL
, "rgpropvar = NULL\n");
123 ok(rgpropvar
[0].vt
==0 || broken(rgpropvar
[0].vt
==VT_BSTR
), "rgpropvar[0].vt = %d\n", rgpropvar
[0].vt
);
125 rgpropvar
[0].vt
= VT_BSTR
;
126 rgpropvar
[0].bstrVal
= (void*)0xdeadbeef;
127 rgpropvar
[1].vt
= VT_LPSTR
;
128 rgpropvar
[1].pszVal
= (void*)0xdeadbeef;
129 rgpropvar
[2].vt
= VT_BYREF
|VT_I1
;
130 rgpropvar
[2].pcVal
= (void*)0xdeadbeef;
131 rgpropvar
[3].vt
= VT_BYREF
|VT_VARIANT
;
132 rgpropvar
[3].pvarVal
= (void*)0xdeadbeef;
138 static HRESULT WINAPI
PropertyStorage_WriteMultiple(IPropertyStorage
*This
, ULONG cpspec
,
139 const PROPSPEC
*rgpspec
, const PROPVARIANT
*rgpropvar
,
140 PROPID propidNameFirst
)
142 CHECK_EXPECT(WriteMultiple
);
144 ok(cpspec
== 20, "cpspec = %d\n", cpspec
);
145 ok(rgpspec
== (void*)0xdeadbeef, "rgpspec = %p\n", rgpspec
);
146 ok(rgpropvar
== (void*)0xdeadbeef, "rgpropvar = %p\n", rgpspec
);
147 ok(propidNameFirst
== PID_FIRST_USABLE
, "propidNameFirst = %d\n", propidNameFirst
);
151 static HRESULT WINAPI
PropertyStorage_DeleteMultiple(IPropertyStorage
*This
, ULONG cpspec
,
152 const PROPSPEC
*rgpspec
)
154 ok(0, "unexpected call\n");
158 static HRESULT WINAPI
PropertyStorage_ReadPropertyNames(IPropertyStorage
*This
, ULONG cpropid
,
159 const PROPID
*rgpropid
, LPOLESTR
*rglpwstrName
)
161 ok(0, "unexpected call\n");
165 static HRESULT WINAPI
PropertyStorage_WritePropertyNames(IPropertyStorage
*This
, ULONG cpropid
,
166 const PROPID
*rgpropid
, const LPOLESTR
*rglpwstrName
)
168 ok(0, "unexpected call\n");
172 static HRESULT WINAPI
PropertyStorage_DeletePropertyNames(IPropertyStorage
*This
, ULONG cpropid
,
173 const PROPID
*rgpropid
)
175 ok(0, "unexpected call\n");
179 static HRESULT WINAPI
PropertyStorage_Commit(IPropertyStorage
*This
, DWORD grfCommitFlags
)
181 ok(0, "unexpected call\n");
185 static HRESULT WINAPI
PropertyStorage_Revert(IPropertyStorage
*This
)
187 ok(0, "unexpected call\n");
191 static HRESULT WINAPI
PropertyStorage_Enum(IPropertyStorage
*This
, IEnumSTATPROPSTG
**ppenum
)
193 ok(0, "unexpected call\n");
197 static HRESULT WINAPI
PropertyStorage_SetTimes(IPropertyStorage
*This
, const FILETIME
*pctime
,
198 const FILETIME
*patime
, const FILETIME
*pmtime
)
200 ok(0, "unexpected call\n");
204 static HRESULT WINAPI
PropertyStorage_SetClass(IPropertyStorage
*This
, REFCLSID clsid
)
206 ok(0, "unexpected call\n");
210 static HRESULT WINAPI
PropertyStorage_Stat(IPropertyStorage
*This
, STATPROPSETSTG
*statpsstg
)
214 memset(statpsstg
, 0, sizeof(STATPROPSETSTG
));
215 memcpy(&statpsstg
->fmtid
, &FMTID_Test
, sizeof(FMTID
));
216 statpsstg
->grfFlags
= PROPSETFLAG_ANSI
;
220 static IPropertyStorageVtbl PropertyStorageVtbl
= {
221 PropertyStorage_QueryInterface
,
222 PropertyStorage_AddRef
,
223 PropertyStorage_Release
,
224 PropertyStorage_ReadMultiple
,
225 PropertyStorage_WriteMultiple
,
226 PropertyStorage_DeleteMultiple
,
227 PropertyStorage_ReadPropertyNames
,
228 PropertyStorage_WritePropertyNames
,
229 PropertyStorage_DeletePropertyNames
,
230 PropertyStorage_Commit
,
231 PropertyStorage_Revert
,
232 PropertyStorage_Enum
,
233 PropertyStorage_SetTimes
,
234 PropertyStorage_SetClass
,
238 static IPropertyStorage PropertyStorage
= { &PropertyStorageVtbl
};
240 static HRESULT WINAPI
PropertySetStorage_QueryInterface(IPropertySetStorage
*This
,
241 REFIID riid
, void **ppvObject
)
243 ok(0, "unexpected call\n");
247 static ULONG WINAPI
PropertySetStorage_AddRef(IPropertySetStorage
*This
)
249 ok(0, "unexpected call\n");
253 static ULONG WINAPI
PropertySetStorage_Release(IPropertySetStorage
*This
)
255 ok(0, "unexpected call\n");
259 static HRESULT WINAPI
PropertySetStorage_Create(IPropertySetStorage
*This
,
260 REFFMTID rfmtid
, const CLSID
*pclsid
, DWORD grfFlags
,
261 DWORD grfMode
, IPropertyStorage
**ppprstg
)
263 CHECK_EXPECT(Create
);
264 ok(IsEqualGUID(rfmtid
, &FMTID_Test
) || IsEqualGUID(rfmtid
, &FMTID_NotExisting
),
265 "Incorrect rfmtid value\n");
266 ok(pclsid
== NULL
, "pclsid != NULL\n");
267 ok(grfFlags
== PROPSETFLAG_ANSI
, "grfFlags = %x\n", grfFlags
);
268 ok(grfMode
== STGM_READ
, "grfMode = %x\n", grfMode
);
270 *ppprstg
= &PropertyStorage
;
274 static HRESULT WINAPI
PropertySetStorage_Open(IPropertySetStorage
*This
,
275 REFFMTID rfmtid
, DWORD grfMode
, IPropertyStorage
**ppprstg
)
279 if(IsEqualGUID(rfmtid
, &FMTID_Test
)) {
280 ok(grfMode
== STGM_READ
, "grfMode = %x\n", grfMode
);
282 *ppprstg
= &PropertyStorage
;
286 return STG_E_FILENOTFOUND
;
289 static HRESULT WINAPI
PropertySetStorage_Delete(IPropertySetStorage
*This
,
292 CHECK_EXPECT(Delete
);
293 ok(IsEqualGUID(rfmtid
, &FMTID_Test
), "wrong rfmtid value\n");
297 static HRESULT WINAPI
PropertySetStorage_Enum(IPropertySetStorage
*This
,
298 IEnumSTATPROPSETSTG
**ppenum
)
300 ok(0, "unexpected call\n");
304 static IPropertySetStorageVtbl PropertySetStorageVtbl
= {
305 PropertySetStorage_QueryInterface
,
306 PropertySetStorage_AddRef
,
307 PropertySetStorage_Release
,
308 PropertySetStorage_Create
,
309 PropertySetStorage_Open
,
310 PropertySetStorage_Delete
,
311 PropertySetStorage_Enum
314 static IPropertySetStorage PropertySetStorage
= { &PropertySetStorageVtbl
};
316 static void test_SHPropStg_functions(void)
318 IPropertyStorage
*property_storage
;
320 PROPVARIANT read
[10];
323 if(!pSHPropStgCreate
|| !pSHPropStgReadMultiple
|| !pSHPropStgWriteMultiple
) {
324 win_skip("SHPropStg* functions are missing\n");
329 /* Crashes on Windows */
330 pSHPropStgCreate(NULL
, &FMTID_Test
, NULL
, PROPSETFLAG_DEFAULT
,
331 STGM_READ
, OPEN_EXISTING
, &property_storage
, &codepage
);
332 pSHPropStgCreate(&PropertySetStorage
, NULL
, NULL
, PROPSETFLAG_DEFAULT
,
333 STGM_READ
, OPEN_EXISTING
, &property_storage
, &codepage
);
334 pSHPropStgCreate(&PropertySetStorage
, &FMTID_Test
, NULL
, PROPSETFLAG_DEFAULT
,
335 STGM_READ
, OPEN_EXISTING
, NULL
, &codepage
);
339 SET_EXPECT(ReadMultipleCodePage
);
340 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_Test
, NULL
, PROPSETFLAG_DEFAULT
,
341 STGM_READ
, OPEN_EXISTING
, &property_storage
, &codepage
);
342 ok(codepage
== 1234, "codepage = %d\n", codepage
);
343 ok(hres
== S_OK
, "hres = %x\n", hres
);
345 CHECK_CALLED(ReadMultipleCodePage
);
348 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_NotExisting
, NULL
,
349 PROPSETFLAG_DEFAULT
, STGM_READ
, OPEN_EXISTING
, &property_storage
, &codepage
);
350 ok(hres
== STG_E_FILENOTFOUND
, "hres = %x\n", hres
);
357 SET_EXPECT(ReadMultipleCodePage
);
358 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_Test
, NULL
, PROPSETFLAG_ANSI
,
359 STGM_READ
, CREATE_ALWAYS
, &property_storage
, &codepage
);
360 ok(codepage
== 1234, "codepage = %d\n", codepage
);
361 ok(hres
== S_OK
, "hres = %x\n", hres
);
363 CHECK_CALLED(Release
);
364 CHECK_CALLED(Delete
);
365 CHECK_CALLED(Create
);
366 CHECK_CALLED(ReadMultipleCodePage
);
370 SET_EXPECT(ReadMultipleCodePage
);
371 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_NotExisting
, NULL
, PROPSETFLAG_ANSI
,
372 STGM_READ
, CREATE_ALWAYS
, &property_storage
, &codepage
);
373 ok(codepage
== 1234, "codepage = %d\n", codepage
);
374 ok(hres
== S_OK
, "hres = %x\n", hres
);
376 CHECK_CALLED(Create
);
377 CHECK_CALLED(ReadMultipleCodePage
);
380 hres
= pSHPropStgCreate(&PropertySetStorage
, &FMTID_Test
, &FMTID_NotExisting
,
381 PROPSETFLAG_DEFAULT
, STGM_READ
, OPEN_EXISTING
, &property_storage
, NULL
);
382 ok(hres
== S_OK
, "hres = %x\n", hres
);
386 SET_EXPECT(ReadMultipleCodePage
);
387 SET_EXPECT(WriteMultiple
);
389 hres
= pSHPropStgWriteMultiple(property_storage
, &codepage
, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE
);
390 ok(hres
== S_OK
, "hres = %x\n", hres
);
391 ok(codepage
== 1234, "codepage = %d\n", codepage
);
393 CHECK_CALLED(ReadMultipleCodePage
);
394 CHECK_CALLED(WriteMultiple
);
397 SET_EXPECT(ReadMultipleCodePage
);
398 SET_EXPECT(WriteMultiple
);
399 hres
= pSHPropStgWriteMultiple(property_storage
, NULL
, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE
);
400 ok(hres
== S_OK
, "hres = %x\n", hres
);
402 CHECK_CALLED(ReadMultipleCodePage
);
403 CHECK_CALLED(WriteMultiple
);
406 SET_EXPECT(WriteMultiple
);
408 hres
= pSHPropStgWriteMultiple(property_storage
, &codepage
, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE
);
409 ok(hres
== S_OK
, "hres = %x\n", hres
);
410 ok(codepage
== 1000, "codepage = %d\n", codepage
);
412 CHECK_CALLED(WriteMultiple
);
414 read
[0].vt
= VT_BSTR
;
415 read
[0].bstrVal
= (void*)0xdeadbeef;
416 SET_EXPECT(ReadMultiple
);
417 SET_EXPECT(ReadMultipleCodePage
);
419 hres
= pSHPropStgReadMultiple(property_storage
, 0, 10, (void*)0xdeadbeef, read
);
420 ok(hres
== S_OK
, "hres = %x\n", hres
);
421 CHECK_CALLED(ReadMultiple
);
422 CHECK_CALLED(ReadMultipleCodePage
);
425 SET_EXPECT(ReadMultiple
);
427 hres
= pSHPropStgReadMultiple(property_storage
, 1251, 10, (void*)0xdeadbeef, read
);
428 ok(hres
== S_OK
, "hres = %x\n", hres
);
429 CHECK_CALLED(ReadMultiple
);
433 static HRESULT WINAPI
test_activator_QI(IClassActivator
*iface
, REFIID riid
, void **ppv
)
437 if (IsEqualIID(riid
, &IID_IUnknown
) ||
438 IsEqualIID(riid
, &IID_IClassActivator
))
443 if (!*ppv
) return E_NOINTERFACE
;
445 IClassActivator_AddRef(iface
);
450 static ULONG WINAPI
test_activator_AddRef(IClassActivator
*iface
)
455 static ULONG WINAPI
test_activator_Release(IClassActivator
*iface
)
460 static HRESULT WINAPI
test_activator_GetClassObject(IClassActivator
*iface
, REFCLSID clsid
,
461 DWORD context
, LCID locale
, REFIID riid
, void **ppv
)
463 CHECK_EXPECT(autoplay_GetClassObject
);
464 ok(IsEqualGUID(clsid
, &CLSID_QueryCancelAutoPlay
), "clsid %s\n", wine_dbgstr_guid(clsid
));
465 ok(IsEqualIID(riid
, &IID_IQueryCancelAutoPlay
), "riid %s\n", wine_dbgstr_guid(riid
));
469 static const IClassActivatorVtbl test_activator_vtbl
= {
471 test_activator_AddRef
,
472 test_activator_Release
,
473 test_activator_GetClassObject
476 static IClassActivator test_activator
= { &test_activator_vtbl
};
478 static HRESULT WINAPI
test_moniker_QueryInterface(IMoniker
* iface
, REFIID riid
, void **ppvObject
)
482 if (IsEqualIID(&IID_IUnknown
, riid
) ||
483 IsEqualIID(&IID_IPersist
, riid
) ||
484 IsEqualIID(&IID_IPersistStream
, riid
) ||
485 IsEqualIID(&IID_IMoniker
, riid
))
491 return E_NOINTERFACE
;
496 static ULONG WINAPI
test_moniker_AddRef(IMoniker
* iface
)
501 static ULONG WINAPI
test_moniker_Release(IMoniker
* iface
)
506 static HRESULT WINAPI
test_moniker_GetClassID(IMoniker
* iface
, CLSID
*pClassID
)
508 ok(0, "unexpected call\n");
512 static HRESULT WINAPI
test_moniker_IsDirty(IMoniker
* iface
)
514 ok(0, "unexpected call\n");
518 static HRESULT WINAPI
test_moniker_Load(IMoniker
* iface
, IStream
* pStm
)
520 ok(0, "unexpected call\n");
524 static HRESULT WINAPI
test_moniker_Save(IMoniker
* iface
, IStream
* pStm
, BOOL fClearDirty
)
526 ok(0, "unexpected call\n");
530 static HRESULT WINAPI
test_moniker_GetSizeMax(IMoniker
* iface
, ULARGE_INTEGER
* pcbSize
)
532 ok(0, "unexpected call\n");
536 static HRESULT WINAPI
test_moniker_BindToObject(IMoniker
* iface
,
538 IMoniker
* moniker_to_left
,
542 CHECK_EXPECT(autoplay_BindToObject
);
543 ok(pbc
!= NULL
, "got %p\n", pbc
);
544 ok(moniker_to_left
== NULL
, "got %p\n", moniker_to_left
);
545 ok(IsEqualIID(riid
, &IID_IClassActivator
), "got riid %s\n", wine_dbgstr_guid(riid
));
547 if (IsEqualIID(riid
, &IID_IClassActivator
))
549 *ppv
= &test_activator
;
556 static HRESULT WINAPI
test_moniker_BindToStorage(IMoniker
* iface
,
562 ok(0, "unexpected call\n");
566 static HRESULT WINAPI
test_moniker_Reduce(IMoniker
* iface
,
568 DWORD dwReduceHowFar
,
569 IMoniker
** ppmkToLeft
,
570 IMoniker
** ppmkReduced
)
572 ok(0, "unexpected call\n");
576 static HRESULT WINAPI
test_moniker_ComposeWith(IMoniker
* iface
,
578 BOOL fOnlyIfNotGeneric
,
579 IMoniker
** ppmkComposite
)
581 ok(0, "unexpected call\n");
585 static HRESULT WINAPI
test_moniker_Enum(IMoniker
* iface
,BOOL fForward
, IEnumMoniker
** ppenumMoniker
)
587 ok(0, "unexpected call\n");
591 static HRESULT WINAPI
test_moniker_IsEqual(IMoniker
* iface
, IMoniker
* pmkOtherMoniker
)
593 ok(0, "unexpected call\n");
597 static HRESULT WINAPI
test_moniker_Hash(IMoniker
* iface
, DWORD
* pdwHash
)
599 ok(0, "unexpected call\n");
603 static HRESULT WINAPI
test_moniker_IsRunning(IMoniker
* iface
,
606 IMoniker
* pmkNewlyRunning
)
608 ok(0, "unexpected call\n");
612 static HRESULT WINAPI
test_moniker_GetTimeOfLastChange(IMoniker
* iface
,
617 ok(0, "unexpected call\n");
621 static HRESULT WINAPI
test_moniker_Inverse(IMoniker
* iface
, IMoniker
** ppmk
)
623 ok(0, "unexpected call\n");
627 static HRESULT WINAPI
test_moniker_CommonPrefixWith(IMoniker
* iface
,IMoniker
* pmkOther
,IMoniker
** ppmkPrefix
)
629 ok(0, "unexpected call\n");
633 static HRESULT WINAPI
test_moniker_RelativePathTo(IMoniker
* iface
,IMoniker
* pmOther
, IMoniker
** ppmkRelPath
)
635 ok(0, "unexpected call\n");
639 static HRESULT WINAPI
test_moniker_GetDisplayName(IMoniker
* iface
,
642 LPOLESTR
*ppszDisplayName
)
644 ok(0, "unexpected call\n");
648 static HRESULT WINAPI
test_moniker_ParseDisplayName(IMoniker
* iface
,
651 LPOLESTR pszDisplayName
,
655 ok(0, "unexpected call\n");
659 static HRESULT WINAPI
test_moniker_IsSystemMoniker(IMoniker
* iface
,DWORD
* pwdMksys
)
661 ok(0, "unexpected call\n");
665 static const IMonikerVtbl test_moniker_vtbl
=
667 test_moniker_QueryInterface
,
669 test_moniker_Release
,
670 test_moniker_GetClassID
,
671 test_moniker_IsDirty
,
674 test_moniker_GetSizeMax
,
675 test_moniker_BindToObject
,
676 test_moniker_BindToStorage
,
678 test_moniker_ComposeWith
,
680 test_moniker_IsEqual
,
682 test_moniker_IsRunning
,
683 test_moniker_GetTimeOfLastChange
,
684 test_moniker_Inverse
,
685 test_moniker_CommonPrefixWith
,
686 test_moniker_RelativePathTo
,
687 test_moniker_GetDisplayName
,
688 test_moniker_ParseDisplayName
,
689 test_moniker_IsSystemMoniker
692 static IMoniker test_moniker
= { &test_moniker_vtbl
};
694 static void test_SHCreateQueryCancelAutoPlayMoniker(void)
703 if (!pSHCreateQueryCancelAutoPlayMoniker
)
705 win_skip("SHCreateQueryCancelAutoPlayMoniker is not available, skipping tests.\n");
709 hr
= pSHCreateQueryCancelAutoPlayMoniker(NULL
);
710 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
712 hr
= pSHCreateQueryCancelAutoPlayMoniker(&mon
);
713 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
716 hr
= IMoniker_IsSystemMoniker(mon
, &sys
);
717 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
718 ok(sys
== MKSYS_CLASSMONIKER
, "got %d\n", sys
);
720 memset(&clsid
, 0, sizeof(clsid
));
721 hr
= IMoniker_GetClassID(mon
, &clsid
);
722 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
723 ok(IsEqualGUID(&clsid
, &CLSID_ClassMoniker
), "got %s\n", wine_dbgstr_guid(&clsid
));
725 /* extract used CLSID that implements this hook */
726 SET_EXPECT(autoplay_BindToObject
);
727 SET_EXPECT(autoplay_GetClassObject
);
729 CreateBindCtx(0, &ctxt
);
730 hr
= IMoniker_BindToObject(mon
, ctxt
, &test_moniker
, &IID_IQueryCancelAutoPlay
, (void**)&unk
);
731 ok(hr
== E_NOTIMPL
, "got 0x%08x\n", hr
);
732 IBindCtx_Release(ctxt
);
734 CHECK_CALLED(autoplay_BindToObject
);
735 CHECK_CALLED(autoplay_GetClassObject
);
737 IMoniker_Release(mon
);
740 #define DROPTEST_FILENAME "c:\\wintest.bin"
746 static LRESULT WINAPI
drop_window_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
751 HDROP hDrop
= (HDROP
)wparam
;
752 char filename
[MAX_PATH
] = "dummy";
754 num
= DragQueryFileA(hDrop
, 0xffffffff, NULL
, 0);
755 ok(num
== 1, "expected 1, got %u\n", num
);
756 num
= DragQueryFileA(hDrop
, 0xffffffff, (char*)0xdeadbeef, 0xffffffff);
757 ok(num
== 1, "expected 1, got %u\n", num
);
758 num
= DragQueryFileA(hDrop
, 0, filename
, sizeof(filename
));
759 ok(num
== strlen(DROPTEST_FILENAME
), "got %u\n", num
);
760 ok(!strcmp(filename
, DROPTEST_FILENAME
), "got %s\n", filename
);
765 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
768 static DWORD WINAPI
drop_window_therad(void *arg
)
770 struct DragParam
*param
= arg
;
776 memset(&cls
, 0, sizeof(cls
));
777 cls
.lpfnWndProc
= drop_window_proc
;
778 cls
.hInstance
= GetModuleHandleA(NULL
);
779 cls
.lpszClassName
= "drop test";
780 RegisterClassA(&cls
);
782 param
->hwnd
= CreateWindowA("drop test", NULL
, 0, 0, 0, 0, 0,
784 ok(param
->hwnd
!= NULL
, "CreateWindow failed: %d\n", GetLastError());
786 memset(&info
, 0, sizeof(info
));
787 info
.cbSize
= sizeof(info
);
788 r
= GetWindowInfo(param
->hwnd
, &info
);
789 ok(r
, "got %d\n", r
);
790 ok(!(info
.dwExStyle
& WS_EX_ACCEPTFILES
), "got %08x\n", info
.dwExStyle
);
792 DragAcceptFiles(param
->hwnd
, TRUE
);
794 memset(&info
, 0, sizeof(info
));
795 info
.cbSize
= sizeof(info
);
796 r
= GetWindowInfo(param
->hwnd
, &info
);
797 ok(r
, "got %d\n", r
);
798 ok((info
.dwExStyle
& WS_EX_ACCEPTFILES
), "got %08x\n", info
.dwExStyle
);
800 SetEvent(param
->ready
);
802 while ((r
= GetMessageA(&msg
, NULL
, 0, 0)) != 0) {
804 ok(0, "unexpected return value, got %d\n", r
);
807 DispatchMessageA(&msg
);
810 DestroyWindow(param
->hwnd
);
811 UnregisterClassA("drop test", GetModuleHandleA(NULL
));
815 static void test_DragQueryFile(void)
817 struct DragParam param
;
825 param
.ready
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
);
826 ok(param
.ready
!= NULL
, "can't create event\n");
827 hThread
= CreateThread(NULL
, 0, drop_window_therad
, ¶m
, 0, NULL
);
829 rc
= WaitForSingleObject(param
.ready
, 5000);
830 ok(rc
== WAIT_OBJECT_0
, "got %u\n", rc
);
832 hDrop
= GlobalAlloc(GHND
, sizeof(DROPFILES
) + (strlen(DROPTEST_FILENAME
) + 2) * sizeof(WCHAR
));
833 pDrop
= GlobalLock(hDrop
);
834 pDrop
->pFiles
= sizeof(DROPFILES
);
835 ret
= MultiByteToWideChar(CP_ACP
, 0, DROPTEST_FILENAME
, -1,
836 (LPWSTR
)(pDrop
+ 1), strlen(DROPTEST_FILENAME
) + 1);
837 ok(ret
> 0, "got %d\n", ret
);
841 r
= PostMessageA(param
.hwnd
, WM_DROPFILES
, (WPARAM
)hDrop
, 0);
842 ok(r
, "got %d\n", r
);
844 r
= PostMessageA(param
.hwnd
, WM_QUIT
, 0, 0);
845 ok(r
, "got %d\n", r
);
847 rc
= WaitForSingleObject(hThread
, 5000);
848 ok(rc
== WAIT_OBJECT_0
, "got %d\n", rc
);
850 CloseHandle(param
.ready
);
851 CloseHandle(hThread
);
853 #undef DROPTEST_FILENAME
855 static void test_SHCreateSessionKey(void)
860 if (!pSHCreateSessionKey
)
862 win_skip("SHCreateSessionKey is not implemented\n");
866 if (0) /* crashes on native */
867 hr
= pSHCreateSessionKey(KEY_READ
, NULL
);
869 hkey
= (HKEY
)0xdeadbeef;
870 hr
= pSHCreateSessionKey(0, &hkey
);
871 todo_wine
ok(hr
== E_ACCESSDENIED
, "got 0x%08x\n", hr
);
872 todo_wine
ok(hkey
== NULL
, "got %p\n", hkey
);
874 hr
= pSHCreateSessionKey(KEY_READ
, &hkey
);
875 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
877 hr
= pSHCreateSessionKey(KEY_READ
, &hkey2
);
878 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
879 ok(hkey
!= hkey2
, "got %p, %p\n", hkey
, hkey2
);
885 static void test_dragdrophelper(void)
887 IDragSourceHelper
*dragsource
;
888 IDropTargetHelper
*target
;
891 hr
= CoCreateInstance(&CLSID_DragDropHelper
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDropTargetHelper
, (void **)&target
);
892 ok(hr
== S_OK
, "Failed to create IDropTargetHelper, %#x\n", hr
);
894 hr
= IDropTargetHelper_QueryInterface(target
, &IID_IDragSourceHelper
, (void **)&dragsource
);
895 ok(hr
== S_OK
, "QI failed, %#x\n", hr
);
896 IDragSourceHelper_Release(dragsource
);
898 IDropTargetHelper_Release(target
);
907 hr
= CoInitialize(NULL
);
908 ok(hr
== S_OK
, "CoInitialize failed (0x%08x)\n", hr
);
912 test_SHPropStg_functions();
913 test_SHCreateQueryCancelAutoPlayMoniker();
914 test_DragQueryFile();
915 test_SHCreateSessionKey();
916 test_dragdrophelper();