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 = %d\n", rgpspec
[0].ulKind
);
120 ok(rgpspec
[0].u
.propid
== PID_CODEPAGE
, "rgpspec[0].propid = %d\n", rgpspec
[0].u
.propid
);
122 rgpropvar
[0].vt
= VT_I2
;
123 rgpropvar
[0].u
.iVal
= 1234;
125 CHECK_EXPECT(ReadMultiple
);
127 ok(cpspec
== 10, "cpspec = %u\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].u
.bstrVal
= (void*)0xdeadbeef;
135 rgpropvar
[1].vt
= VT_LPSTR
;
136 rgpropvar
[1].u
.pszVal
= (void*)0xdeadbeef;
137 rgpropvar
[2].vt
= VT_BYREF
|VT_I1
;
138 rgpropvar
[2].u
.pcVal
= (void*)0xdeadbeef;
139 rgpropvar
[3].vt
= VT_BYREF
|VT_VARIANT
;
140 rgpropvar
[3].u
.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 = %d\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 = %d\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 = %x\n", grfFlags
);
276 ok(grfMode
== STGM_READ
, "grfMode = %x\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 = %x\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 = %x\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 = %x\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 = %x\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 = %x\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 = %x\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 = %x\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 = %x\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 = %x\n", hres
);
418 ok(codepage
== 1000, "codepage = %d\n", codepage
);
420 CHECK_CALLED(WriteMultiple
);
422 read
[0].vt
= VT_BSTR
;
423 read
[0].u
.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 = %x\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 = %x\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%08x\n", hr
);
720 hr
= pSHCreateQueryCancelAutoPlayMoniker(&mon
);
721 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
724 hr
= IMoniker_IsSystemMoniker(mon
, &sys
);
725 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
726 ok(sys
== MKSYS_CLASSMONIKER
, "got %d\n", sys
);
728 memset(&clsid
, 0, sizeof(clsid
));
729 hr
= IMoniker_GetClassID(mon
, &clsid
);
730 ok(hr
== S_OK
, "got 0x%08x\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%08x\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 DROPTEST_FILENAME "c:\\wintest.bin"
755 static LRESULT WINAPI
drop_window_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
757 static BOOL expected
;
760 case WM_EXPECTED_VALUE
:
767 HDROP hDrop
= (HDROP
)wparam
;
768 char filename
[MAX_PATH
] = "dummy";
772 num
= DragQueryFileA(hDrop
, 0xffffffff, NULL
, 0);
773 ok(num
== 1, "expected 1, got %u\n", num
);
774 num
= DragQueryFileA(hDrop
, 0xffffffff, (char*)0xdeadbeef, 0xffffffff);
775 ok(num
== 1, "expected 1, got %u\n", num
);
776 num
= DragQueryFileA(hDrop
, 0, filename
, sizeof(filename
));
777 ok(num
== strlen(DROPTEST_FILENAME
), "got %u\n", num
);
778 ok(!strcmp(filename
, DROPTEST_FILENAME
), "got %s\n", filename
);
779 r
= DragQueryPoint(hDrop
, &pt
);
780 ok(r
== expected
, "expected %d, got %d\n", expected
, r
);
781 ok(pt
.x
== 10, "expected 10, got %d\n", pt
.x
);
782 ok(pt
.y
== 20, "expected 20, got %d\n", pt
.y
);
787 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
790 static DWORD WINAPI
drop_window_therad(void *arg
)
792 struct DragParam
*param
= arg
;
798 memset(&cls
, 0, sizeof(cls
));
799 cls
.lpfnWndProc
= drop_window_proc
;
800 cls
.hInstance
= GetModuleHandleA(NULL
);
801 cls
.lpszClassName
= "drop test";
802 RegisterClassA(&cls
);
804 param
->hwnd
= CreateWindowA("drop test", NULL
, 0, 0, 0, 0, 0,
806 ok(param
->hwnd
!= NULL
, "CreateWindow failed: %d\n", GetLastError());
808 memset(&info
, 0, sizeof(info
));
809 info
.cbSize
= sizeof(info
);
810 r
= GetWindowInfo(param
->hwnd
, &info
);
811 ok(r
, "got %d\n", r
);
812 ok(!(info
.dwExStyle
& WS_EX_ACCEPTFILES
), "got %08x\n", info
.dwExStyle
);
814 DragAcceptFiles(param
->hwnd
, TRUE
);
816 memset(&info
, 0, sizeof(info
));
817 info
.cbSize
= sizeof(info
);
818 r
= GetWindowInfo(param
->hwnd
, &info
);
819 ok(r
, "got %d\n", r
);
820 ok((info
.dwExStyle
& WS_EX_ACCEPTFILES
), "got %08x\n", info
.dwExStyle
);
822 SetEvent(param
->ready
);
824 while ((r
= GetMessageA(&msg
, NULL
, 0, 0)) != 0) {
826 ok(0, "unexpected return value, got %d\n", r
);
829 DispatchMessageA(&msg
);
832 DestroyWindow(param
->hwnd
);
833 UnregisterClassA("drop test", GetModuleHandleA(NULL
));
837 static void test_DragQueryFile(BOOL non_client_flag
)
839 struct DragParam param
;
847 param
.ready
= CreateEventA(NULL
, FALSE
, FALSE
, NULL
);
848 ok(param
.ready
!= NULL
, "can't create event\n");
849 hThread
= CreateThread(NULL
, 0, drop_window_therad
, ¶m
, 0, NULL
);
851 rc
= WaitForSingleObject(param
.ready
, 5000);
852 ok(rc
== WAIT_OBJECT_0
, "got %u\n", rc
);
854 hDrop
= GlobalAlloc(GHND
, sizeof(DROPFILES
) + (strlen(DROPTEST_FILENAME
) + 2) * sizeof(WCHAR
));
855 pDrop
= GlobalLock(hDrop
);
858 pDrop
->fNC
= non_client_flag
;
859 pDrop
->pFiles
= sizeof(DROPFILES
);
860 ret
= MultiByteToWideChar(CP_ACP
, 0, DROPTEST_FILENAME
, -1,
861 (LPWSTR
)(pDrop
+ 1), strlen(DROPTEST_FILENAME
) + 1);
862 ok(ret
> 0, "got %d\n", ret
);
866 r
= PostMessageA(param
.hwnd
, WM_EXPECTED_VALUE
, 0, !non_client_flag
);
867 ok(r
, "got %d\n", r
);
869 r
= PostMessageA(param
.hwnd
, WM_DROPFILES
, (WPARAM
)hDrop
, 0);
870 ok(r
, "got %d\n", r
);
872 r
= PostMessageA(param
.hwnd
, WM_QUIT
, 0, 0);
873 ok(r
, "got %d\n", r
);
875 rc
= WaitForSingleObject(hThread
, 5000);
876 ok(rc
== WAIT_OBJECT_0
, "got %d\n", rc
);
878 CloseHandle(param
.ready
);
879 CloseHandle(hThread
);
881 #undef WM_EXPECTED_VALUE
882 #undef DROPTEST_FILENAME
884 static void test_SHCreateSessionKey(void)
886 static const WCHAR session_format
[] = {
887 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
888 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
889 'E','x','p','l','o','r','e','r','\\','S','e','s','s','i','o','n','I','n','f','o','\\','%','u',0};
893 WCHAR sessionW
[ARRAY_SIZE(session_format
) + 16];
896 if (!pSHCreateSessionKey
)
898 win_skip("SHCreateSessionKey is not implemented\n");
902 if (0) /* crashes on native */
903 hr
= pSHCreateSessionKey(KEY_READ
, NULL
);
905 hkey
= (HKEY
)0xdeadbeef;
906 hr
= pSHCreateSessionKey(0, &hkey
);
907 ok(hr
== E_ACCESSDENIED
, "got 0x%08x\n", hr
);
908 ok(hkey
== NULL
, "got %p\n", hkey
);
910 hr
= pSHCreateSessionKey(KEY_READ
, &hkey
);
911 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
913 hr
= pSHCreateSessionKey(KEY_READ
, &hkey2
);
914 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
915 ok(hkey
!= hkey2
, "got %p, %p\n", hkey
, hkey2
);
920 /* check the registry */
921 ProcessIdToSessionId( GetCurrentProcessId(), &session
);
924 wsprintfW(sessionW
, session_format
, session
);
925 ret
= RegOpenKeyW(HKEY_CURRENT_USER
, sessionW
, &hkey
);
926 ok(!ret
, "key not found\n");
931 static void test_dragdrophelper(void)
933 IDragSourceHelper
*dragsource
;
934 IDropTargetHelper
*target
;
937 hr
= CoCreateInstance(&CLSID_DragDropHelper
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDropTargetHelper
, (void **)&target
);
938 ok(hr
== S_OK
, "Failed to create IDropTargetHelper, %#x\n", hr
);
940 hr
= IDropTargetHelper_QueryInterface(target
, &IID_IDragSourceHelper
, (void **)&dragsource
);
941 ok(hr
== S_OK
, "QI failed, %#x\n", hr
);
942 IDragSourceHelper_Release(dragsource
);
944 IDropTargetHelper_Release(target
);
953 hr
= CoInitialize(NULL
);
954 ok(hr
== S_OK
, "CoInitialize failed (0x%08x)\n", hr
);
958 test_SHPropStg_functions();
959 test_SHCreateQueryCancelAutoPlayMoniker();
960 test_DragQueryFile(TRUE
);
961 test_DragQueryFile(FALSE
);
962 test_SHCreateSessionKey();
963 test_dragdrophelper();