dinput: Clear DIA_APPNOMAP BuildActionMap flag with specific device semantic.
[wine.git] / dlls / shell32 / tests / shellole.c
blob4864d35ea9a700716a2a25d412f731e0fc44cc5e
1 /*
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
19 #define COBJMACROS
20 #define CONST_VTABLE
21 #define NONAMELESSUNION
23 #include <stdio.h>
24 #include <wine/test.h>
26 #include "winbase.h"
27 #include "shlobj.h"
28 #include "shellapi.h"
29 #include "initguid.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) \
42 do { \
43 ok(expect_ ##func, "unexpected call " #func "\n"); \
44 called_ ## func = TRUE; \
45 }while(0)
47 #define CHECK_EXPECT(func) \
48 do { \
49 CHECK_EXPECT2(func); \
50 expect_ ## func = FALSE; \
51 }while(0)
53 #define CHECK_CALLED(func) \
54 do { \
55 ok(called_ ## func, "expected " #func "\n"); \
56 expect_ ## func = called_ ## func = FALSE; \
57 }while(0)
59 DEFINE_EXPECT(Create);
60 DEFINE_EXPECT(Delete);
61 DEFINE_EXPECT(Open);
62 DEFINE_EXPECT(ReadMultiple);
63 DEFINE_EXPECT(ReadMultipleCodePage);
64 DEFINE_EXPECT(Release);
65 DEFINE_EXPECT(Stat);
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");
95 return E_NOTIMPL;
98 static ULONG WINAPI PropertyStorage_AddRef(IPropertyStorage *This)
100 ok(0, "unexpected call\n");
101 return 2;
104 static ULONG WINAPI PropertyStorage_Release(IPropertyStorage *This)
106 CHECK_EXPECT(Release);
107 return 1;
110 static HRESULT WINAPI PropertyStorage_ReadMultiple(IPropertyStorage *This, ULONG cpspec,
111 const PROPSPEC *rgpspec, PROPVARIANT *rgpropvar)
113 if(cpspec == 1) {
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;
124 } else {
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;
143 return S_OK;
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);
156 return S_OK;
159 static HRESULT WINAPI PropertyStorage_DeleteMultiple(IPropertyStorage *This, ULONG cpspec,
160 const PROPSPEC *rgpspec)
162 ok(0, "unexpected call\n");
163 return E_NOTIMPL;
166 static HRESULT WINAPI PropertyStorage_ReadPropertyNames(IPropertyStorage *This, ULONG cpropid,
167 const PROPID *rgpropid, LPOLESTR *rglpwstrName)
169 ok(0, "unexpected call\n");
170 return E_NOTIMPL;
173 static HRESULT WINAPI PropertyStorage_WritePropertyNames(IPropertyStorage *This, ULONG cpropid,
174 const PROPID *rgpropid, const LPOLESTR *rglpwstrName)
176 ok(0, "unexpected call\n");
177 return E_NOTIMPL;
180 static HRESULT WINAPI PropertyStorage_DeletePropertyNames(IPropertyStorage *This, ULONG cpropid,
181 const PROPID *rgpropid)
183 ok(0, "unexpected call\n");
184 return E_NOTIMPL;
187 static HRESULT WINAPI PropertyStorage_Commit(IPropertyStorage *This, DWORD grfCommitFlags)
189 ok(0, "unexpected call\n");
190 return E_NOTIMPL;
193 static HRESULT WINAPI PropertyStorage_Revert(IPropertyStorage *This)
195 ok(0, "unexpected call\n");
196 return E_NOTIMPL;
199 static HRESULT WINAPI PropertyStorage_Enum(IPropertyStorage *This, IEnumSTATPROPSTG **ppenum)
201 ok(0, "unexpected call\n");
202 return E_NOTIMPL;
205 static HRESULT WINAPI PropertyStorage_SetTimes(IPropertyStorage *This, const FILETIME *pctime,
206 const FILETIME *patime, const FILETIME *pmtime)
208 ok(0, "unexpected call\n");
209 return E_NOTIMPL;
212 static HRESULT WINAPI PropertyStorage_SetClass(IPropertyStorage *This, REFCLSID clsid)
214 ok(0, "unexpected call\n");
215 return E_NOTIMPL;
218 static HRESULT WINAPI PropertyStorage_Stat(IPropertyStorage *This, STATPROPSETSTG *statpsstg)
220 CHECK_EXPECT(Stat);
222 memset(statpsstg, 0, sizeof(STATPROPSETSTG));
223 memcpy(&statpsstg->fmtid, &FMTID_Test, sizeof(FMTID));
224 statpsstg->grfFlags = PROPSETFLAG_ANSI;
225 return S_OK;
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,
243 PropertyStorage_Stat
246 static IPropertyStorage PropertyStorage = { &PropertyStorageVtbl };
248 static HRESULT WINAPI PropertySetStorage_QueryInterface(IPropertySetStorage *This,
249 REFIID riid, void **ppvObject)
251 ok(0, "unexpected call\n");
252 return E_NOTIMPL;
255 static ULONG WINAPI PropertySetStorage_AddRef(IPropertySetStorage *This)
257 ok(0, "unexpected call\n");
258 return 2;
261 static ULONG WINAPI PropertySetStorage_Release(IPropertySetStorage *This)
263 ok(0, "unexpected call\n");
264 return 1;
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;
279 return S_OK;
282 static HRESULT WINAPI PropertySetStorage_Open(IPropertySetStorage *This,
283 REFFMTID rfmtid, DWORD grfMode, IPropertyStorage **ppprstg)
285 CHECK_EXPECT(Open);
287 if(IsEqualGUID(rfmtid, &FMTID_Test)) {
288 ok(grfMode == STGM_READ, "grfMode = %lx\n", grfMode);
290 *ppprstg = &PropertyStorage;
291 return S_OK;
294 return STG_E_FILENOTFOUND;
297 static HRESULT WINAPI PropertySetStorage_Delete(IPropertySetStorage *This,
298 REFFMTID rfmtid)
300 CHECK_EXPECT(Delete);
301 ok(IsEqualGUID(rfmtid, &FMTID_Test), "wrong rfmtid value\n");
302 return S_OK;
305 static HRESULT WINAPI PropertySetStorage_Enum(IPropertySetStorage *This,
306 IEnumSTATPROPSETSTG **ppenum)
308 ok(0, "unexpected call\n");
309 return E_NOTIMPL;
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;
327 UINT codepage;
328 PROPVARIANT read[10];
329 HRESULT hres;
331 if(!pSHPropStgCreate || !pSHPropStgReadMultiple || !pSHPropStgWriteMultiple) {
332 win_skip("SHPropStg* functions are missing\n");
333 return;
336 if(0) {
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);
346 SET_EXPECT(Open);
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);
352 CHECK_CALLED(Open);
353 CHECK_CALLED(ReadMultipleCodePage);
355 SET_EXPECT(Open);
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);
359 CHECK_CALLED(Open);
361 SET_EXPECT(Open);
362 SET_EXPECT(Release);
363 SET_EXPECT(Delete);
364 SET_EXPECT(Create);
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);
370 CHECK_CALLED(Open);
371 CHECK_CALLED(Release);
372 CHECK_CALLED(Delete);
373 CHECK_CALLED(Create);
374 CHECK_CALLED(ReadMultipleCodePage);
376 SET_EXPECT(Open);
377 SET_EXPECT(Create);
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);
383 CHECK_CALLED(Open);
384 CHECK_CALLED(Create);
385 CHECK_CALLED(ReadMultipleCodePage);
387 SET_EXPECT(Open);
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);
391 CHECK_CALLED(Open);
393 SET_EXPECT(Stat);
394 SET_EXPECT(ReadMultipleCodePage);
395 SET_EXPECT(WriteMultiple);
396 codepage = 0;
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);
400 CHECK_CALLED(Stat);
401 CHECK_CALLED(ReadMultipleCodePage);
402 CHECK_CALLED(WriteMultiple);
404 SET_EXPECT(Stat);
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);
409 CHECK_CALLED(Stat);
410 CHECK_CALLED(ReadMultipleCodePage);
411 CHECK_CALLED(WriteMultiple);
413 SET_EXPECT(Stat);
414 SET_EXPECT(WriteMultiple);
415 codepage = 1000;
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);
419 CHECK_CALLED(Stat);
420 CHECK_CALLED(WriteMultiple);
422 read[0].vt = VT_BSTR;
423 read[0].bstrVal = (void*)0xdeadbeef;
424 SET_EXPECT(ReadMultiple);
425 SET_EXPECT(ReadMultipleCodePage);
426 SET_EXPECT(Stat);
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);
431 CHECK_CALLED(Stat);
433 SET_EXPECT(ReadMultiple);
434 SET_EXPECT(Stat);
435 hres = pSHPropStgReadMultiple(property_storage, 1251, 10, (void*)0xdeadbeef, read);
436 ok(hres == S_OK, "hres = %lx\n", hres);
437 CHECK_CALLED(ReadMultiple);
438 CHECK_CALLED(Stat);
441 static HRESULT WINAPI test_activator_QI(IClassActivator *iface, REFIID riid, void **ppv)
443 *ppv = NULL;
445 if (IsEqualIID(riid, &IID_IUnknown) ||
446 IsEqualIID(riid, &IID_IClassActivator))
448 *ppv = iface;
451 if (!*ppv) return E_NOINTERFACE;
453 IClassActivator_AddRef(iface);
455 return S_OK;
458 static ULONG WINAPI test_activator_AddRef(IClassActivator *iface)
460 return 2;
463 static ULONG WINAPI test_activator_Release(IClassActivator *iface)
465 return 1;
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));
474 return E_NOTIMPL;
477 static const IClassActivatorVtbl test_activator_vtbl = {
478 test_activator_QI,
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)
488 *ppvObject = 0;
490 if (IsEqualIID(&IID_IUnknown, riid) ||
491 IsEqualIID(&IID_IPersist, riid) ||
492 IsEqualIID(&IID_IPersistStream, riid) ||
493 IsEqualIID(&IID_IMoniker, riid))
495 *ppvObject = iface;
498 if (!*ppvObject)
499 return E_NOINTERFACE;
501 return S_OK;
504 static ULONG WINAPI test_moniker_AddRef(IMoniker* iface)
506 return 2;
509 static ULONG WINAPI test_moniker_Release(IMoniker* iface)
511 return 1;
514 static HRESULT WINAPI test_moniker_GetClassID(IMoniker* iface, CLSID *pClassID)
516 ok(0, "unexpected call\n");
517 return E_NOTIMPL;
520 static HRESULT WINAPI test_moniker_IsDirty(IMoniker* iface)
522 ok(0, "unexpected call\n");
523 return E_NOTIMPL;
526 static HRESULT WINAPI test_moniker_Load(IMoniker* iface, IStream* pStm)
528 ok(0, "unexpected call\n");
529 return E_NOTIMPL;
532 static HRESULT WINAPI test_moniker_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
534 ok(0, "unexpected call\n");
535 return E_NOTIMPL;
538 static HRESULT WINAPI test_moniker_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
540 ok(0, "unexpected call\n");
541 return E_NOTIMPL;
544 static HRESULT WINAPI test_moniker_BindToObject(IMoniker* iface,
545 IBindCtx* pbc,
546 IMoniker* moniker_to_left,
547 REFIID riid,
548 void** ppv)
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;
558 return S_OK;
561 return E_NOTIMPL;
564 static HRESULT WINAPI test_moniker_BindToStorage(IMoniker* iface,
565 IBindCtx* pbc,
566 IMoniker* pmkToLeft,
567 REFIID riid,
568 VOID** ppvResult)
570 ok(0, "unexpected call\n");
571 return E_NOTIMPL;
574 static HRESULT WINAPI test_moniker_Reduce(IMoniker* iface,
575 IBindCtx* pbc,
576 DWORD dwReduceHowFar,
577 IMoniker** ppmkToLeft,
578 IMoniker** ppmkReduced)
580 ok(0, "unexpected call\n");
581 return E_NOTIMPL;
584 static HRESULT WINAPI test_moniker_ComposeWith(IMoniker* iface,
585 IMoniker* pmkRight,
586 BOOL fOnlyIfNotGeneric,
587 IMoniker** ppmkComposite)
589 ok(0, "unexpected call\n");
590 return E_NOTIMPL;
593 static HRESULT WINAPI test_moniker_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
595 ok(0, "unexpected call\n");
596 return E_NOTIMPL;
599 static HRESULT WINAPI test_moniker_IsEqual(IMoniker* iface, IMoniker* pmkOtherMoniker)
601 ok(0, "unexpected call\n");
602 return E_NOTIMPL;
605 static HRESULT WINAPI test_moniker_Hash(IMoniker* iface, DWORD* pdwHash)
607 ok(0, "unexpected call\n");
608 return E_NOTIMPL;
611 static HRESULT WINAPI test_moniker_IsRunning(IMoniker* iface,
612 IBindCtx* pbc,
613 IMoniker* pmkToLeft,
614 IMoniker* pmkNewlyRunning)
616 ok(0, "unexpected call\n");
617 return E_NOTIMPL;
620 static HRESULT WINAPI test_moniker_GetTimeOfLastChange(IMoniker* iface,
621 IBindCtx* pbc,
622 IMoniker* pmkToLeft,
623 FILETIME* pItemTime)
625 ok(0, "unexpected call\n");
626 return E_NOTIMPL;
629 static HRESULT WINAPI test_moniker_Inverse(IMoniker* iface, IMoniker** ppmk)
631 ok(0, "unexpected call\n");
632 return E_NOTIMPL;
635 static HRESULT WINAPI test_moniker_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
637 ok(0, "unexpected call\n");
638 return E_NOTIMPL;
641 static HRESULT WINAPI test_moniker_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
643 ok(0, "unexpected call\n");
644 return E_NOTIMPL;
647 static HRESULT WINAPI test_moniker_GetDisplayName(IMoniker* iface,
648 IBindCtx* pbc,
649 IMoniker* pmkToLeft,
650 LPOLESTR *ppszDisplayName)
652 ok(0, "unexpected call\n");
653 return E_NOTIMPL;
656 static HRESULT WINAPI test_moniker_ParseDisplayName(IMoniker* iface,
657 IBindCtx* pbc,
658 IMoniker* pmkToLeft,
659 LPOLESTR pszDisplayName,
660 ULONG* pchEaten,
661 IMoniker** ppmkOut)
663 ok(0, "unexpected call\n");
664 return E_NOTIMPL;
667 static HRESULT WINAPI test_moniker_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
669 ok(0, "unexpected call\n");
670 return E_NOTIMPL;
673 static const IMonikerVtbl test_moniker_vtbl =
675 test_moniker_QueryInterface,
676 test_moniker_AddRef,
677 test_moniker_Release,
678 test_moniker_GetClassID,
679 test_moniker_IsDirty,
680 test_moniker_Load,
681 test_moniker_Save,
682 test_moniker_GetSizeMax,
683 test_moniker_BindToObject,
684 test_moniker_BindToStorage,
685 test_moniker_Reduce,
686 test_moniker_ComposeWith,
687 test_moniker_Enum,
688 test_moniker_IsEqual,
689 test_moniker_Hash,
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)
704 IBindCtx *ctxt;
705 IMoniker *mon;
706 IUnknown *unk;
707 CLSID clsid;
708 HRESULT hr;
709 DWORD sys;
711 if (!pSHCreateQueryCancelAutoPlayMoniker)
713 win_skip("SHCreateQueryCancelAutoPlayMoniker is not available, skipping tests.\n");
714 return;
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);
723 sys = -1;
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
751 struct DragParam {
752 HWND hwnd;
753 HANDLE ready;
756 static LRESULT WINAPI drop_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
758 static DWORD flags;
759 static char expected_filename[MAX_PATH];
761 switch (msg) {
762 case WM_EXPECTED_VALUE:
764 lstrcpynA(expected_filename, (const char*)wparam, sizeof(expected_filename));
765 flags = lparam;
766 break;
768 case WM_DROPFILES:
770 HDROP hDrop = (HDROP)wparam;
771 char filename[MAX_PATH] = "dummy";
772 WCHAR filenameW[MAX_PATH] = L"dummy", expected_filenameW[MAX_PATH];
773 POINT pt;
774 BOOL r;
775 UINT num, len;
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);
831 DragFinish(hDrop);
832 winetest_pop_context();
833 return 0;
836 return DefWindowProcA(hwnd, msg, wparam, lparam);
839 static DWORD WINAPI drop_window_therad(void *arg)
841 struct DragParam *param = arg;
842 WNDCLASSA cls;
843 WINDOWINFO info;
844 BOOL r;
845 MSG msg;
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,
854 NULL, 0, NULL, 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) {
874 if (r == (BOOL)-1) {
875 ok(0, "unexpected return value, got %d\n", r);
876 break;
878 DispatchMessageA(&msg);
881 DestroyWindow(param->hwnd);
882 UnregisterClassA("drop test", GetModuleHandleA(NULL));
883 return 0;
886 static void test_DragQueryFile(BOOL non_client_flag)
888 struct DragParam param;
889 HANDLE hThread;
890 DWORD rc;
891 HGLOBAL hDrop;
892 DROPFILES *pDrop;
893 int ret, i;
894 BOOL r;
895 static const struct {
896 UINT codepage;
897 const char* filename;
898 } testcase[] = {
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, &param, 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();
917 continue;
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);
924 pDrop->pt.x = 10;
925 pDrop->pt.y = 20;
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);
931 pDrop->fWide = TRUE;
932 GlobalUnlock(hDrop);
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);
943 pDrop->pt.x = 10;
944 pDrop->pt.y = 20;
945 pDrop->fNC = non_client_flag;
946 pDrop->pFiles = sizeof(DROPFILES);
947 strcpy((char *)(pDrop + 1), testcase[i].filename);
948 pDrop->fWide = FALSE;
949 GlobalUnlock(hDrop);
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
971 #undef DROP_NC_AREA
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};
980 HKEY hkey, hkey2;
981 HRESULT hr;
982 DWORD session;
983 WCHAR sessionW[ARRAY_SIZE(session_format) + 16];
984 LONG ret;
986 if (!pSHCreateSessionKey)
988 win_skip("SHCreateSessionKey is not implemented\n");
989 return;
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);
1007 RegCloseKey(hkey);
1008 RegCloseKey(hkey2);
1010 /* check the registry */
1011 ProcessIdToSessionId( GetCurrentProcessId(), &session);
1012 if (session)
1014 wsprintfW(sessionW, session_format, session);
1015 ret = RegOpenKeyW(HKEY_CURRENT_USER, sessionW, &hkey);
1016 ok(!ret, "key not found\n");
1017 RegCloseKey(hkey);
1021 static void test_dragdrophelper(void)
1023 IDragSourceHelper *dragsource;
1024 IDropTargetHelper *target;
1025 HRESULT hr;
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)
1039 HRESULT hr;
1041 init();
1043 hr = CoInitialize(NULL);
1044 ok(hr == S_OK, "CoInitialize failed (0x%08lx)\n", hr);
1045 if (hr != S_OK)
1046 return;
1048 test_SHPropStg_functions();
1049 test_SHCreateQueryCancelAutoPlayMoniker();
1050 test_DragQueryFile(TRUE);
1051 test_DragQueryFile(FALSE);
1052 test_SHCreateSessionKey();
1053 test_dragdrophelper();
1055 CoUninitialize();