shell32/tests: Add DBCS file name tests for DragQueryFile.
[wine.git] / dlls / shell32 / tests / shellole.c
blob1129b6032019ff56388abaa11eaf792b32c94d02
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 struct DragParam {
750 HWND hwnd;
751 HANDLE ready;
754 static LRESULT WINAPI drop_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
756 static BOOL expected;
757 static char expected_filename[MAX_PATH];
759 switch (msg) {
760 case WM_EXPECTED_VALUE:
762 lstrcpynA(expected_filename, (const char*)wparam, sizeof(expected_filename));
763 expected = lparam;
764 break;
766 case WM_DROPFILES:
768 HDROP hDrop = (HDROP)wparam;
769 char filename[MAX_PATH] = "dummy";
770 POINT pt;
771 BOOL r;
772 UINT num, len;
773 winetest_push_context("%s", wine_dbgstr_a(expected_filename));
775 num = DragQueryFileA(hDrop, 0xffffffff, NULL, 0);
776 ok(num == 1, "expected 1, got %u\n", num);
778 num = DragQueryFileA(hDrop, 0xffffffff, (char*)0xdeadbeef, 0xffffffff);
779 ok(num == 1, "expected 1, got %u\n", num);
781 len = strlen(expected_filename);
782 num = DragQueryFileA(hDrop, 0, NULL, 0);
783 todo_wine_if(expected_filename[0] == 'd')
784 ok(num == len, "expected %u, got %u\n", len, num);
786 num = DragQueryFileA(hDrop, 0, filename, 0);
787 todo_wine_if(expected_filename[0] == 'd')
788 ok(num == len, "expected %u, got %u\n", len, num);
789 ok(!strcmp(filename, "dummy"), "got %s\n", filename);
791 num = DragQueryFileA(hDrop, 0, filename, sizeof(filename));
792 todo_wine_if(expected_filename[0] == 'd')
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 todo_wine 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 r = DragQueryPoint(hDrop, &pt);
805 ok(r == expected, "expected %d, got %d\n", expected, r);
806 ok(pt.x == 10, "expected 10, got %ld\n", pt.x);
807 ok(pt.y == 20, "expected 20, got %ld\n", pt.y);
808 DragFinish(hDrop);
809 winetest_pop_context();
810 return 0;
813 return DefWindowProcA(hwnd, msg, wparam, lparam);
816 static DWORD WINAPI drop_window_therad(void *arg)
818 struct DragParam *param = arg;
819 WNDCLASSA cls;
820 WINDOWINFO info;
821 BOOL r;
822 MSG msg;
824 memset(&cls, 0, sizeof(cls));
825 cls.lpfnWndProc = drop_window_proc;
826 cls.hInstance = GetModuleHandleA(NULL);
827 cls.lpszClassName = "drop test";
828 RegisterClassA(&cls);
830 param->hwnd = CreateWindowA("drop test", NULL, 0, 0, 0, 0, 0,
831 NULL, 0, NULL, 0);
832 ok(param->hwnd != NULL, "CreateWindow failed: %ld\n", GetLastError());
834 memset(&info, 0, sizeof(info));
835 info.cbSize = sizeof(info);
836 r = GetWindowInfo(param->hwnd, &info);
837 ok(r, "got %d\n", r);
838 ok(!(info.dwExStyle & WS_EX_ACCEPTFILES), "got %08lx\n", info.dwExStyle);
840 DragAcceptFiles(param->hwnd, TRUE);
842 memset(&info, 0, sizeof(info));
843 info.cbSize = sizeof(info);
844 r = GetWindowInfo(param->hwnd, &info);
845 ok(r, "got %d\n", r);
846 ok((info.dwExStyle & WS_EX_ACCEPTFILES), "got %08lx\n", info.dwExStyle);
848 SetEvent(param->ready);
850 while ((r = GetMessageA(&msg, NULL, 0, 0)) != 0) {
851 if (r == (BOOL)-1) {
852 ok(0, "unexpected return value, got %d\n", r);
853 break;
855 DispatchMessageA(&msg);
858 DestroyWindow(param->hwnd);
859 UnregisterClassA("drop test", GetModuleHandleA(NULL));
860 return 0;
863 static void test_DragQueryFile(BOOL non_client_flag)
865 struct DragParam param;
866 HANDLE hThread;
867 DWORD rc;
868 HGLOBAL hDrop;
869 DROPFILES *pDrop;
870 int ret, i;
871 BOOL r;
872 static const struct {
873 UINT codepage;
874 const char* filename;
875 } testcase[] = {
876 { 0, "c:\\wintest.bin" },
877 { 932, "d:\\\x89\xb9\x8a\x79_02.CHY" },
880 param.ready = CreateEventA(NULL, FALSE, FALSE, NULL);
881 ok(param.ready != NULL, "can't create event\n");
882 hThread = CreateThread(NULL, 0, drop_window_therad, &param, 0, NULL);
884 rc = WaitForSingleObject(param.ready, 5000);
885 ok(rc == WAIT_OBJECT_0, "got %lu\n", rc);
887 for (i = 0; i < ARRAY_SIZE(testcase); i++)
889 winetest_push_context("%d", i);
890 if (testcase[i].codepage && testcase[i].codepage != GetACP())
892 skip("need codepage %u for this test\n", testcase[i].codepage);
893 winetest_pop_context();
894 continue;
897 ret = MultiByteToWideChar(CP_ACP, 0, testcase[i].filename, -1, NULL, 0);
898 ok(ret > 0, "got %d\n", ret);
899 hDrop = GlobalAlloc(GHND, sizeof(DROPFILES) + (ret + 1) * sizeof(WCHAR));
900 pDrop = GlobalLock(hDrop);
901 pDrop->pt.x = 10;
902 pDrop->pt.y = 20;
903 pDrop->fNC = non_client_flag;
904 pDrop->pFiles = sizeof(DROPFILES);
905 ret = MultiByteToWideChar(CP_ACP, 0, testcase[i].filename, -1,
906 (LPWSTR)(pDrop + 1), ret);
907 ok(ret > 0, "got %d\n", ret);
908 pDrop->fWide = TRUE;
909 GlobalUnlock(hDrop);
911 r = PostMessageA(param.hwnd, WM_EXPECTED_VALUE,
912 (WPARAM)testcase[i].filename, !non_client_flag);
913 ok(r, "got %d\n", r);
915 r = PostMessageA(param.hwnd, WM_DROPFILES, (WPARAM)hDrop, 0);
916 ok(r, "got %d\n", r);
918 winetest_pop_context();
921 r = PostMessageA(param.hwnd, WM_QUIT, 0, 0);
922 ok(r, "got %d\n", r);
924 rc = WaitForSingleObject(hThread, 5000);
925 ok(rc == WAIT_OBJECT_0, "got %ld\n", rc);
927 CloseHandle(param.ready);
928 CloseHandle(hThread);
930 #undef WM_EXPECTED_VALUE
932 static void test_SHCreateSessionKey(void)
934 static const WCHAR session_format[] = {
935 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
936 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
937 'E','x','p','l','o','r','e','r','\\','S','e','s','s','i','o','n','I','n','f','o','\\','%','u',0};
938 HKEY hkey, hkey2;
939 HRESULT hr;
940 DWORD session;
941 WCHAR sessionW[ARRAY_SIZE(session_format) + 16];
942 LONG ret;
944 if (!pSHCreateSessionKey)
946 win_skip("SHCreateSessionKey is not implemented\n");
947 return;
950 if (0) /* crashes on native */
951 hr = pSHCreateSessionKey(KEY_READ, NULL);
953 hkey = (HKEY)0xdeadbeef;
954 hr = pSHCreateSessionKey(0, &hkey);
955 ok(hr == E_ACCESSDENIED, "got 0x%08lx\n", hr);
956 ok(hkey == NULL, "got %p\n", hkey);
958 hr = pSHCreateSessionKey(KEY_READ, &hkey);
959 ok(hr == S_OK, "got 0x%08lx\n", hr);
961 hr = pSHCreateSessionKey(KEY_READ, &hkey2);
962 ok(hr == S_OK, "got 0x%08lx\n", hr);
963 ok(hkey != hkey2, "got %p, %p\n", hkey, hkey2);
965 RegCloseKey(hkey);
966 RegCloseKey(hkey2);
968 /* check the registry */
969 ProcessIdToSessionId( GetCurrentProcessId(), &session);
970 if (session)
972 wsprintfW(sessionW, session_format, session);
973 ret = RegOpenKeyW(HKEY_CURRENT_USER, sessionW, &hkey);
974 ok(!ret, "key not found\n");
975 RegCloseKey(hkey);
979 static void test_dragdrophelper(void)
981 IDragSourceHelper *dragsource;
982 IDropTargetHelper *target;
983 HRESULT hr;
985 hr = CoCreateInstance(&CLSID_DragDropHelper, NULL, CLSCTX_INPROC_SERVER, &IID_IDropTargetHelper, (void **)&target);
986 ok(hr == S_OK, "Failed to create IDropTargetHelper, %#lx\n", hr);
988 hr = IDropTargetHelper_QueryInterface(target, &IID_IDragSourceHelper, (void **)&dragsource);
989 ok(hr == S_OK, "QI failed, %#lx\n", hr);
990 IDragSourceHelper_Release(dragsource);
992 IDropTargetHelper_Release(target);
995 START_TEST(shellole)
997 HRESULT hr;
999 init();
1001 hr = CoInitialize(NULL);
1002 ok(hr == S_OK, "CoInitialize failed (0x%08lx)\n", hr);
1003 if (hr != S_OK)
1004 return;
1006 test_SHPropStg_functions();
1007 test_SHCreateQueryCancelAutoPlayMoniker();
1008 test_DragQueryFile(TRUE);
1009 test_DragQueryFile(FALSE);
1010 test_SHCreateSessionKey();
1011 test_dragdrophelper();
1013 CoUninitialize();