1c2c66affSColin Finck /*
2c2c66affSColin Finck * Copyright 2010 Piotr Caban for CodeWeavers
3c2c66affSColin Finck *
4c2c66affSColin Finck * This library is free software; you can redistribute it and/or
5c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
6c2c66affSColin Finck * License as published by the Free Software Foundation; either
7c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
8c2c66affSColin Finck *
9c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
10c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
11c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12c2c66affSColin Finck * Lesser General Public License for more details.
13c2c66affSColin Finck *
14c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
15c2c66affSColin Finck * License along with this library; if not, write to the Free Software
16c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17c2c66affSColin Finck */
18c2c66affSColin Finck
190be033feSAmine Khaldi #define COBJMACROS
200be033feSAmine Khaldi #define CONST_VTABLE
210be033feSAmine Khaldi #ifndef __REACTOS__
220be033feSAmine Khaldi #define NONAMELESSUNION
230be033feSAmine Khaldi #endif
24c2c66affSColin Finck
250be033feSAmine Khaldi #include <stdio.h>
260be033feSAmine Khaldi #include <wine/test.h>
270be033feSAmine Khaldi
280be033feSAmine Khaldi #include "winbase.h"
290be033feSAmine Khaldi #include "shlobj.h"
300be033feSAmine Khaldi #include "shellapi.h"
310be033feSAmine Khaldi #include "initguid.h"
32c2c66affSColin Finck
33c2c66affSColin Finck DEFINE_GUID(FMTID_Test,0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12);
34c2c66affSColin Finck DEFINE_GUID(FMTID_NotExisting, 0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x13);
35c2c66affSColin Finck DEFINE_GUID(CLSID_ClassMoniker, 0x0000031a,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
36c2c66affSColin Finck
37c2c66affSColin Finck #define DEFINE_EXPECT(func) \
38c2c66affSColin Finck static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
39c2c66affSColin Finck
40c2c66affSColin Finck #define SET_EXPECT(func) \
41c2c66affSColin Finck expect_ ## func = TRUE
42c2c66affSColin Finck
43c2c66affSColin Finck #define CHECK_EXPECT2(func) \
44c2c66affSColin Finck do { \
45c2c66affSColin Finck ok(expect_ ##func, "unexpected call " #func "\n"); \
46c2c66affSColin Finck called_ ## func = TRUE; \
47c2c66affSColin Finck }while(0)
48c2c66affSColin Finck
49c2c66affSColin Finck #define CHECK_EXPECT(func) \
50c2c66affSColin Finck do { \
51c2c66affSColin Finck CHECK_EXPECT2(func); \
52c2c66affSColin Finck expect_ ## func = FALSE; \
53c2c66affSColin Finck }while(0)
54c2c66affSColin Finck
55c2c66affSColin Finck #define CHECK_CALLED(func) \
56c2c66affSColin Finck do { \
57c2c66affSColin Finck ok(called_ ## func, "expected " #func "\n"); \
58c2c66affSColin Finck expect_ ## func = called_ ## func = FALSE; \
59c2c66affSColin Finck }while(0)
60c2c66affSColin Finck
61c2c66affSColin Finck DEFINE_EXPECT(Create);
62c2c66affSColin Finck DEFINE_EXPECT(Delete);
63c2c66affSColin Finck DEFINE_EXPECT(Open);
64c2c66affSColin Finck DEFINE_EXPECT(ReadMultiple);
65c2c66affSColin Finck DEFINE_EXPECT(ReadMultipleCodePage);
66c2c66affSColin Finck DEFINE_EXPECT(Release);
67c2c66affSColin Finck DEFINE_EXPECT(Stat);
68c2c66affSColin Finck DEFINE_EXPECT(WriteMultiple);
69c2c66affSColin Finck
70c2c66affSColin Finck DEFINE_EXPECT(autoplay_BindToObject);
71c2c66affSColin Finck DEFINE_EXPECT(autoplay_GetClassObject);
72c2c66affSColin Finck
73c2c66affSColin Finck static HRESULT (WINAPI *pSHPropStgCreate)(IPropertySetStorage*, REFFMTID, const CLSID*,
74c2c66affSColin Finck DWORD, DWORD, DWORD, IPropertyStorage**, UINT*);
75c2c66affSColin Finck static HRESULT (WINAPI *pSHPropStgReadMultiple)(IPropertyStorage*, UINT,
76c2c66affSColin Finck ULONG, const PROPSPEC*, PROPVARIANT*);
77c2c66affSColin Finck static HRESULT (WINAPI *pSHPropStgWriteMultiple)(IPropertyStorage*, UINT*,
78c2c66affSColin Finck ULONG, const PROPSPEC*, PROPVARIANT*, PROPID);
79c2c66affSColin Finck static HRESULT (WINAPI *pSHCreateQueryCancelAutoPlayMoniker)(IMoniker**);
80c2c66affSColin Finck static HRESULT (WINAPI *pSHCreateSessionKey)(REGSAM, HKEY*);
81c2c66affSColin Finck
init(void)82c2c66affSColin Finck static void init(void)
83c2c66affSColin Finck {
84c2c66affSColin Finck HMODULE hmod = GetModuleHandleA("shell32.dll");
85c2c66affSColin Finck
86c2c66affSColin Finck pSHPropStgCreate = (void*)GetProcAddress(hmod, "SHPropStgCreate");
87c2c66affSColin Finck pSHPropStgReadMultiple = (void*)GetProcAddress(hmod, "SHPropStgReadMultiple");
88c2c66affSColin Finck pSHPropStgWriteMultiple = (void*)GetProcAddress(hmod, "SHPropStgWriteMultiple");
89c2c66affSColin Finck pSHCreateQueryCancelAutoPlayMoniker = (void*)GetProcAddress(hmod, "SHCreateQueryCancelAutoPlayMoniker");
90c2c66affSColin Finck pSHCreateSessionKey = (void*)GetProcAddress(hmod, (char*)723);
91c2c66affSColin Finck }
92c2c66affSColin Finck
PropertyStorage_QueryInterface(IPropertyStorage * This,REFIID riid,void ** ppvObject)93c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_QueryInterface(IPropertyStorage *This,
94c2c66affSColin Finck REFIID riid, void **ppvObject)
95c2c66affSColin Finck {
96c2c66affSColin Finck ok(0, "unexpected call\n");
97c2c66affSColin Finck return E_NOTIMPL;
98c2c66affSColin Finck }
99c2c66affSColin Finck
PropertyStorage_AddRef(IPropertyStorage * This)100c2c66affSColin Finck static ULONG WINAPI PropertyStorage_AddRef(IPropertyStorage *This)
101c2c66affSColin Finck {
102c2c66affSColin Finck ok(0, "unexpected call\n");
103c2c66affSColin Finck return 2;
104c2c66affSColin Finck }
105c2c66affSColin Finck
PropertyStorage_Release(IPropertyStorage * This)106c2c66affSColin Finck static ULONG WINAPI PropertyStorage_Release(IPropertyStorage *This)
107c2c66affSColin Finck {
108c2c66affSColin Finck CHECK_EXPECT(Release);
109c2c66affSColin Finck return 1;
110c2c66affSColin Finck }
111c2c66affSColin Finck
PropertyStorage_ReadMultiple(IPropertyStorage * This,ULONG cpspec,const PROPSPEC * rgpspec,PROPVARIANT * rgpropvar)112c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_ReadMultiple(IPropertyStorage *This, ULONG cpspec,
113c2c66affSColin Finck const PROPSPEC *rgpspec, PROPVARIANT *rgpropvar)
114c2c66affSColin Finck {
115c2c66affSColin Finck if(cpspec == 1) {
116c2c66affSColin Finck CHECK_EXPECT(ReadMultipleCodePage);
117c2c66affSColin Finck
118c2c66affSColin Finck ok(rgpspec != NULL, "rgpspec = NULL\n");
119c2c66affSColin Finck ok(rgpropvar != NULL, "rgpropvar = NULL\n");
120c2c66affSColin Finck
121c2c66affSColin Finck ok(rgpspec[0].ulKind == PRSPEC_PROPID, "rgpspec[0].ulKind = %d\n", rgpspec[0].ulKind);
122e32018baSAmine Khaldi ok(rgpspec[0].propid == PID_CODEPAGE, "rgpspec[0].propid = %d\n", rgpspec[0].propid);
123c2c66affSColin Finck
124c2c66affSColin Finck rgpropvar[0].vt = VT_I2;
125e32018baSAmine Khaldi rgpropvar[0].iVal = 1234;
126c2c66affSColin Finck } else {
127c2c66affSColin Finck CHECK_EXPECT(ReadMultiple);
128c2c66affSColin Finck
129c2c66affSColin Finck ok(cpspec == 10, "cpspec = %u\n", cpspec);
130c2c66affSColin Finck ok(rgpspec == (void*)0xdeadbeef, "rgpspec = %p\n", rgpspec);
131c2c66affSColin Finck ok(rgpropvar != NULL, "rgpropvar = NULL\n");
132c2c66affSColin Finck
133c2c66affSColin Finck ok(rgpropvar[0].vt==0 || broken(rgpropvar[0].vt==VT_BSTR), "rgpropvar[0].vt = %d\n", rgpropvar[0].vt);
134c2c66affSColin Finck
135c2c66affSColin Finck rgpropvar[0].vt = VT_BSTR;
136e32018baSAmine Khaldi rgpropvar[0].bstrVal = (void*)0xdeadbeef;
137c2c66affSColin Finck rgpropvar[1].vt = VT_LPSTR;
138e32018baSAmine Khaldi rgpropvar[1].pszVal = (void*)0xdeadbeef;
139c2c66affSColin Finck rgpropvar[2].vt = VT_BYREF|VT_I1;
140e32018baSAmine Khaldi rgpropvar[2].pcVal = (void*)0xdeadbeef;
141c2c66affSColin Finck rgpropvar[3].vt = VT_BYREF|VT_VARIANT;
142e32018baSAmine Khaldi rgpropvar[3].pvarVal = (void*)0xdeadbeef;
143c2c66affSColin Finck }
144c2c66affSColin Finck
145c2c66affSColin Finck return S_OK;
146c2c66affSColin Finck }
147c2c66affSColin Finck
PropertyStorage_WriteMultiple(IPropertyStorage * This,ULONG cpspec,const PROPSPEC * rgpspec,const PROPVARIANT * rgpropvar,PROPID propidNameFirst)148c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_WriteMultiple(IPropertyStorage *This, ULONG cpspec,
149c2c66affSColin Finck const PROPSPEC *rgpspec, const PROPVARIANT *rgpropvar,
150c2c66affSColin Finck PROPID propidNameFirst)
151c2c66affSColin Finck {
152c2c66affSColin Finck CHECK_EXPECT(WriteMultiple);
153c2c66affSColin Finck
154c2c66affSColin Finck ok(cpspec == 20, "cpspec = %d\n", cpspec);
155c2c66affSColin Finck ok(rgpspec == (void*)0xdeadbeef, "rgpspec = %p\n", rgpspec);
156c2c66affSColin Finck ok(rgpropvar == (void*)0xdeadbeef, "rgpropvar = %p\n", rgpspec);
157c2c66affSColin Finck ok(propidNameFirst == PID_FIRST_USABLE, "propidNameFirst = %d\n", propidNameFirst);
158c2c66affSColin Finck return S_OK;
159c2c66affSColin Finck }
160c2c66affSColin Finck
PropertyStorage_DeleteMultiple(IPropertyStorage * This,ULONG cpspec,const PROPSPEC * rgpspec)161c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_DeleteMultiple(IPropertyStorage *This, ULONG cpspec,
162c2c66affSColin Finck const PROPSPEC *rgpspec)
163c2c66affSColin Finck {
164c2c66affSColin Finck ok(0, "unexpected call\n");
165c2c66affSColin Finck return E_NOTIMPL;
166c2c66affSColin Finck }
167c2c66affSColin Finck
PropertyStorage_ReadPropertyNames(IPropertyStorage * This,ULONG cpropid,const PROPID * rgpropid,LPOLESTR * rglpwstrName)168c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_ReadPropertyNames(IPropertyStorage *This, ULONG cpropid,
169c2c66affSColin Finck const PROPID *rgpropid, LPOLESTR *rglpwstrName)
170c2c66affSColin Finck {
171c2c66affSColin Finck ok(0, "unexpected call\n");
172c2c66affSColin Finck return E_NOTIMPL;
173c2c66affSColin Finck }
174c2c66affSColin Finck
PropertyStorage_WritePropertyNames(IPropertyStorage * This,ULONG cpropid,const PROPID * rgpropid,const LPOLESTR * rglpwstrName)175c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_WritePropertyNames(IPropertyStorage *This, ULONG cpropid,
176c2c66affSColin Finck const PROPID *rgpropid, const LPOLESTR *rglpwstrName)
177c2c66affSColin Finck {
178c2c66affSColin Finck ok(0, "unexpected call\n");
179c2c66affSColin Finck return E_NOTIMPL;
180c2c66affSColin Finck }
181c2c66affSColin Finck
PropertyStorage_DeletePropertyNames(IPropertyStorage * This,ULONG cpropid,const PROPID * rgpropid)182c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_DeletePropertyNames(IPropertyStorage *This, ULONG cpropid,
183c2c66affSColin Finck const PROPID *rgpropid)
184c2c66affSColin Finck {
185c2c66affSColin Finck ok(0, "unexpected call\n");
186c2c66affSColin Finck return E_NOTIMPL;
187c2c66affSColin Finck }
188c2c66affSColin Finck
PropertyStorage_Commit(IPropertyStorage * This,DWORD grfCommitFlags)189c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_Commit(IPropertyStorage *This, DWORD grfCommitFlags)
190c2c66affSColin Finck {
191c2c66affSColin Finck ok(0, "unexpected call\n");
192c2c66affSColin Finck return E_NOTIMPL;
193c2c66affSColin Finck }
194c2c66affSColin Finck
PropertyStorage_Revert(IPropertyStorage * This)195c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_Revert(IPropertyStorage *This)
196c2c66affSColin Finck {
197c2c66affSColin Finck ok(0, "unexpected call\n");
198c2c66affSColin Finck return E_NOTIMPL;
199c2c66affSColin Finck }
200c2c66affSColin Finck
PropertyStorage_Enum(IPropertyStorage * This,IEnumSTATPROPSTG ** ppenum)201c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_Enum(IPropertyStorage *This, IEnumSTATPROPSTG **ppenum)
202c2c66affSColin Finck {
203c2c66affSColin Finck ok(0, "unexpected call\n");
204c2c66affSColin Finck return E_NOTIMPL;
205c2c66affSColin Finck }
206c2c66affSColin Finck
PropertyStorage_SetTimes(IPropertyStorage * This,const FILETIME * pctime,const FILETIME * patime,const FILETIME * pmtime)207c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_SetTimes(IPropertyStorage *This, const FILETIME *pctime,
208c2c66affSColin Finck const FILETIME *patime, const FILETIME *pmtime)
209c2c66affSColin Finck {
210c2c66affSColin Finck ok(0, "unexpected call\n");
211c2c66affSColin Finck return E_NOTIMPL;
212c2c66affSColin Finck }
213c2c66affSColin Finck
PropertyStorage_SetClass(IPropertyStorage * This,REFCLSID clsid)214c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_SetClass(IPropertyStorage *This, REFCLSID clsid)
215c2c66affSColin Finck {
216c2c66affSColin Finck ok(0, "unexpected call\n");
217c2c66affSColin Finck return E_NOTIMPL;
218c2c66affSColin Finck }
219c2c66affSColin Finck
PropertyStorage_Stat(IPropertyStorage * This,STATPROPSETSTG * statpsstg)220c2c66affSColin Finck static HRESULT WINAPI PropertyStorage_Stat(IPropertyStorage *This, STATPROPSETSTG *statpsstg)
221c2c66affSColin Finck {
222c2c66affSColin Finck CHECK_EXPECT(Stat);
223c2c66affSColin Finck
224c2c66affSColin Finck memset(statpsstg, 0, sizeof(STATPROPSETSTG));
225c2c66affSColin Finck memcpy(&statpsstg->fmtid, &FMTID_Test, sizeof(FMTID));
226c2c66affSColin Finck statpsstg->grfFlags = PROPSETFLAG_ANSI;
227c2c66affSColin Finck return S_OK;
228c2c66affSColin Finck }
229c2c66affSColin Finck
230c2c66affSColin Finck static IPropertyStorageVtbl PropertyStorageVtbl = {
231c2c66affSColin Finck PropertyStorage_QueryInterface,
232c2c66affSColin Finck PropertyStorage_AddRef,
233c2c66affSColin Finck PropertyStorage_Release,
234c2c66affSColin Finck PropertyStorage_ReadMultiple,
235c2c66affSColin Finck PropertyStorage_WriteMultiple,
236c2c66affSColin Finck PropertyStorage_DeleteMultiple,
237c2c66affSColin Finck PropertyStorage_ReadPropertyNames,
238c2c66affSColin Finck PropertyStorage_WritePropertyNames,
239c2c66affSColin Finck PropertyStorage_DeletePropertyNames,
240c2c66affSColin Finck PropertyStorage_Commit,
241c2c66affSColin Finck PropertyStorage_Revert,
242c2c66affSColin Finck PropertyStorage_Enum,
243c2c66affSColin Finck PropertyStorage_SetTimes,
244c2c66affSColin Finck PropertyStorage_SetClass,
245c2c66affSColin Finck PropertyStorage_Stat
246c2c66affSColin Finck };
247c2c66affSColin Finck
248c2c66affSColin Finck static IPropertyStorage PropertyStorage = { &PropertyStorageVtbl };
249c2c66affSColin Finck
PropertySetStorage_QueryInterface(IPropertySetStorage * This,REFIID riid,void ** ppvObject)250c2c66affSColin Finck static HRESULT WINAPI PropertySetStorage_QueryInterface(IPropertySetStorage *This,
251c2c66affSColin Finck REFIID riid, void **ppvObject)
252c2c66affSColin Finck {
253c2c66affSColin Finck ok(0, "unexpected call\n");
254c2c66affSColin Finck return E_NOTIMPL;
255c2c66affSColin Finck }
256c2c66affSColin Finck
PropertySetStorage_AddRef(IPropertySetStorage * This)257c2c66affSColin Finck static ULONG WINAPI PropertySetStorage_AddRef(IPropertySetStorage *This)
258c2c66affSColin Finck {
259c2c66affSColin Finck ok(0, "unexpected call\n");
260c2c66affSColin Finck return 2;
261c2c66affSColin Finck }
262c2c66affSColin Finck
PropertySetStorage_Release(IPropertySetStorage * This)263c2c66affSColin Finck static ULONG WINAPI PropertySetStorage_Release(IPropertySetStorage *This)
264c2c66affSColin Finck {
265c2c66affSColin Finck ok(0, "unexpected call\n");
266c2c66affSColin Finck return 1;
267c2c66affSColin Finck }
268c2c66affSColin Finck
PropertySetStorage_Create(IPropertySetStorage * This,REFFMTID rfmtid,const CLSID * pclsid,DWORD grfFlags,DWORD grfMode,IPropertyStorage ** ppprstg)269c2c66affSColin Finck static HRESULT WINAPI PropertySetStorage_Create(IPropertySetStorage *This,
270c2c66affSColin Finck REFFMTID rfmtid, const CLSID *pclsid, DWORD grfFlags,
271c2c66affSColin Finck DWORD grfMode, IPropertyStorage **ppprstg)
272c2c66affSColin Finck {
273c2c66affSColin Finck CHECK_EXPECT(Create);
274c2c66affSColin Finck ok(IsEqualGUID(rfmtid, &FMTID_Test) || IsEqualGUID(rfmtid, &FMTID_NotExisting),
275c2c66affSColin Finck "Incorrect rfmtid value\n");
276c2c66affSColin Finck ok(pclsid == NULL, "pclsid != NULL\n");
277c2c66affSColin Finck ok(grfFlags == PROPSETFLAG_ANSI, "grfFlags = %x\n", grfFlags);
278c2c66affSColin Finck ok(grfMode == STGM_READ, "grfMode = %x\n", grfMode);
279c2c66affSColin Finck
280c2c66affSColin Finck *ppprstg = &PropertyStorage;
281c2c66affSColin Finck return S_OK;
282c2c66affSColin Finck }
283c2c66affSColin Finck
PropertySetStorage_Open(IPropertySetStorage * This,REFFMTID rfmtid,DWORD grfMode,IPropertyStorage ** ppprstg)284c2c66affSColin Finck static HRESULT WINAPI PropertySetStorage_Open(IPropertySetStorage *This,
285c2c66affSColin Finck REFFMTID rfmtid, DWORD grfMode, IPropertyStorage **ppprstg)
286c2c66affSColin Finck {
287c2c66affSColin Finck CHECK_EXPECT(Open);
288c2c66affSColin Finck
289c2c66affSColin Finck if(IsEqualGUID(rfmtid, &FMTID_Test)) {
290c2c66affSColin Finck ok(grfMode == STGM_READ, "grfMode = %x\n", grfMode);
291c2c66affSColin Finck
292c2c66affSColin Finck *ppprstg = &PropertyStorage;
293c2c66affSColin Finck return S_OK;
294c2c66affSColin Finck }
295c2c66affSColin Finck
296c2c66affSColin Finck return STG_E_FILENOTFOUND;
297c2c66affSColin Finck }
298c2c66affSColin Finck
PropertySetStorage_Delete(IPropertySetStorage * This,REFFMTID rfmtid)299c2c66affSColin Finck static HRESULT WINAPI PropertySetStorage_Delete(IPropertySetStorage *This,
300c2c66affSColin Finck REFFMTID rfmtid)
301c2c66affSColin Finck {
302c2c66affSColin Finck CHECK_EXPECT(Delete);
303c2c66affSColin Finck ok(IsEqualGUID(rfmtid, &FMTID_Test), "wrong rfmtid value\n");
304c2c66affSColin Finck return S_OK;
305c2c66affSColin Finck }
306c2c66affSColin Finck
PropertySetStorage_Enum(IPropertySetStorage * This,IEnumSTATPROPSETSTG ** ppenum)307c2c66affSColin Finck static HRESULT WINAPI PropertySetStorage_Enum(IPropertySetStorage *This,
308c2c66affSColin Finck IEnumSTATPROPSETSTG **ppenum)
309c2c66affSColin Finck {
310c2c66affSColin Finck ok(0, "unexpected call\n");
311c2c66affSColin Finck return E_NOTIMPL;
312c2c66affSColin Finck }
313c2c66affSColin Finck
314c2c66affSColin Finck static IPropertySetStorageVtbl PropertySetStorageVtbl = {
315c2c66affSColin Finck PropertySetStorage_QueryInterface,
316c2c66affSColin Finck PropertySetStorage_AddRef,
317c2c66affSColin Finck PropertySetStorage_Release,
318c2c66affSColin Finck PropertySetStorage_Create,
319c2c66affSColin Finck PropertySetStorage_Open,
320c2c66affSColin Finck PropertySetStorage_Delete,
321c2c66affSColin Finck PropertySetStorage_Enum
322c2c66affSColin Finck };
323c2c66affSColin Finck
324c2c66affSColin Finck static IPropertySetStorage PropertySetStorage = { &PropertySetStorageVtbl };
325c2c66affSColin Finck
test_SHPropStg_functions(void)326c2c66affSColin Finck static void test_SHPropStg_functions(void)
327c2c66affSColin Finck {
328c2c66affSColin Finck IPropertyStorage *property_storage;
329c2c66affSColin Finck UINT codepage;
330c2c66affSColin Finck PROPVARIANT read[10];
331c2c66affSColin Finck HRESULT hres;
332c2c66affSColin Finck
333c2c66affSColin Finck if(!pSHPropStgCreate || !pSHPropStgReadMultiple || !pSHPropStgWriteMultiple) {
334c2c66affSColin Finck win_skip("SHPropStg* functions are missing\n");
335c2c66affSColin Finck return;
336c2c66affSColin Finck }
337c2c66affSColin Finck
338c2c66affSColin Finck if(0) {
339c2c66affSColin Finck /* Crashes on Windows */
340c2c66affSColin Finck pSHPropStgCreate(NULL, &FMTID_Test, NULL, PROPSETFLAG_DEFAULT,
341c2c66affSColin Finck STGM_READ, OPEN_EXISTING, &property_storage, &codepage);
342c2c66affSColin Finck pSHPropStgCreate(&PropertySetStorage, NULL, NULL, PROPSETFLAG_DEFAULT,
343c2c66affSColin Finck STGM_READ, OPEN_EXISTING, &property_storage, &codepage);
344c2c66affSColin Finck pSHPropStgCreate(&PropertySetStorage, &FMTID_Test, NULL, PROPSETFLAG_DEFAULT,
345c2c66affSColin Finck STGM_READ, OPEN_EXISTING, NULL, &codepage);
346c2c66affSColin Finck }
347c2c66affSColin Finck
348c2c66affSColin Finck SET_EXPECT(Open);
349c2c66affSColin Finck SET_EXPECT(ReadMultipleCodePage);
350c2c66affSColin Finck hres = pSHPropStgCreate(&PropertySetStorage, &FMTID_Test, NULL, PROPSETFLAG_DEFAULT,
351c2c66affSColin Finck STGM_READ, OPEN_EXISTING, &property_storage, &codepage);
352c2c66affSColin Finck ok(codepage == 1234, "codepage = %d\n", codepage);
353c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
354c2c66affSColin Finck CHECK_CALLED(Open);
355c2c66affSColin Finck CHECK_CALLED(ReadMultipleCodePage);
356c2c66affSColin Finck
357c2c66affSColin Finck SET_EXPECT(Open);
358c2c66affSColin Finck hres = pSHPropStgCreate(&PropertySetStorage, &FMTID_NotExisting, NULL,
359c2c66affSColin Finck PROPSETFLAG_DEFAULT, STGM_READ, OPEN_EXISTING, &property_storage, &codepage);
360c2c66affSColin Finck ok(hres == STG_E_FILENOTFOUND, "hres = %x\n", hres);
361c2c66affSColin Finck CHECK_CALLED(Open);
362c2c66affSColin Finck
363c2c66affSColin Finck SET_EXPECT(Open);
364c2c66affSColin Finck SET_EXPECT(Release);
365c2c66affSColin Finck SET_EXPECT(Delete);
366c2c66affSColin Finck SET_EXPECT(Create);
367c2c66affSColin Finck SET_EXPECT(ReadMultipleCodePage);
368c2c66affSColin Finck hres = pSHPropStgCreate(&PropertySetStorage, &FMTID_Test, NULL, PROPSETFLAG_ANSI,
369c2c66affSColin Finck STGM_READ, CREATE_ALWAYS, &property_storage, &codepage);
370c2c66affSColin Finck ok(codepage == 1234, "codepage = %d\n", codepage);
371c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
372c2c66affSColin Finck CHECK_CALLED(Open);
373c2c66affSColin Finck CHECK_CALLED(Release);
374c2c66affSColin Finck CHECK_CALLED(Delete);
375c2c66affSColin Finck CHECK_CALLED(Create);
376c2c66affSColin Finck CHECK_CALLED(ReadMultipleCodePage);
377c2c66affSColin Finck
378c2c66affSColin Finck SET_EXPECT(Open);
379c2c66affSColin Finck SET_EXPECT(Create);
380c2c66affSColin Finck SET_EXPECT(ReadMultipleCodePage);
381c2c66affSColin Finck hres = pSHPropStgCreate(&PropertySetStorage, &FMTID_NotExisting, NULL, PROPSETFLAG_ANSI,
382c2c66affSColin Finck STGM_READ, CREATE_ALWAYS, &property_storage, &codepage);
383c2c66affSColin Finck ok(codepage == 1234, "codepage = %d\n", codepage);
384c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
385c2c66affSColin Finck CHECK_CALLED(Open);
386c2c66affSColin Finck CHECK_CALLED(Create);
387c2c66affSColin Finck CHECK_CALLED(ReadMultipleCodePage);
388c2c66affSColin Finck
389c2c66affSColin Finck SET_EXPECT(Open);
390c2c66affSColin Finck hres = pSHPropStgCreate(&PropertySetStorage, &FMTID_Test, &FMTID_NotExisting,
391c2c66affSColin Finck PROPSETFLAG_DEFAULT, STGM_READ, OPEN_EXISTING, &property_storage, NULL);
392c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
393c2c66affSColin Finck CHECK_CALLED(Open);
394c2c66affSColin Finck
395c2c66affSColin Finck SET_EXPECT(Stat);
396c2c66affSColin Finck SET_EXPECT(ReadMultipleCodePage);
397c2c66affSColin Finck SET_EXPECT(WriteMultiple);
398c2c66affSColin Finck codepage = 0;
399c2c66affSColin Finck hres = pSHPropStgWriteMultiple(property_storage, &codepage, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE);
400c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
401c2c66affSColin Finck ok(codepage == 1234, "codepage = %d\n", codepage);
402c2c66affSColin Finck CHECK_CALLED(Stat);
403c2c66affSColin Finck CHECK_CALLED(ReadMultipleCodePage);
404c2c66affSColin Finck CHECK_CALLED(WriteMultiple);
405c2c66affSColin Finck
406c2c66affSColin Finck SET_EXPECT(Stat);
407c2c66affSColin Finck SET_EXPECT(ReadMultipleCodePage);
408c2c66affSColin Finck SET_EXPECT(WriteMultiple);
409c2c66affSColin Finck hres = pSHPropStgWriteMultiple(property_storage, NULL, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE);
410c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
411c2c66affSColin Finck CHECK_CALLED(Stat);
412c2c66affSColin Finck CHECK_CALLED(ReadMultipleCodePage);
413c2c66affSColin Finck CHECK_CALLED(WriteMultiple);
414c2c66affSColin Finck
415c2c66affSColin Finck SET_EXPECT(Stat);
416c2c66affSColin Finck SET_EXPECT(WriteMultiple);
417c2c66affSColin Finck codepage = 1000;
418c2c66affSColin Finck hres = pSHPropStgWriteMultiple(property_storage, &codepage, 20, (void*)0xdeadbeef, (void*)0xdeadbeef, PID_FIRST_USABLE);
419c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
420c2c66affSColin Finck ok(codepage == 1000, "codepage = %d\n", codepage);
421c2c66affSColin Finck CHECK_CALLED(Stat);
422c2c66affSColin Finck CHECK_CALLED(WriteMultiple);
423c2c66affSColin Finck
424c2c66affSColin Finck read[0].vt = VT_BSTR;
425e32018baSAmine Khaldi read[0].bstrVal = (void*)0xdeadbeef;
426c2c66affSColin Finck SET_EXPECT(ReadMultiple);
427c2c66affSColin Finck SET_EXPECT(ReadMultipleCodePage);
428c2c66affSColin Finck SET_EXPECT(Stat);
429c2c66affSColin Finck hres = pSHPropStgReadMultiple(property_storage, 0, 10, (void*)0xdeadbeef, read);
430c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
431c2c66affSColin Finck CHECK_CALLED(ReadMultiple);
432c2c66affSColin Finck CHECK_CALLED(ReadMultipleCodePage);
433c2c66affSColin Finck CHECK_CALLED(Stat);
434c2c66affSColin Finck
435c2c66affSColin Finck SET_EXPECT(ReadMultiple);
436c2c66affSColin Finck SET_EXPECT(Stat);
437c2c66affSColin Finck hres = pSHPropStgReadMultiple(property_storage, 1251, 10, (void*)0xdeadbeef, read);
438c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
439c2c66affSColin Finck CHECK_CALLED(ReadMultiple);
440c2c66affSColin Finck CHECK_CALLED(Stat);
441c2c66affSColin Finck }
442c2c66affSColin Finck
test_activator_QI(IClassActivator * iface,REFIID riid,void ** ppv)443c2c66affSColin Finck static HRESULT WINAPI test_activator_QI(IClassActivator *iface, REFIID riid, void **ppv)
444c2c66affSColin Finck {
445c2c66affSColin Finck *ppv = NULL;
446c2c66affSColin Finck
447c2c66affSColin Finck if (IsEqualIID(riid, &IID_IUnknown) ||
448c2c66affSColin Finck IsEqualIID(riid, &IID_IClassActivator))
449c2c66affSColin Finck {
450c2c66affSColin Finck *ppv = iface;
451c2c66affSColin Finck }
452c2c66affSColin Finck
453c2c66affSColin Finck if (!*ppv) return E_NOINTERFACE;
454c2c66affSColin Finck
455c2c66affSColin Finck IClassActivator_AddRef(iface);
456c2c66affSColin Finck
457c2c66affSColin Finck return S_OK;
458c2c66affSColin Finck }
459c2c66affSColin Finck
test_activator_AddRef(IClassActivator * iface)460c2c66affSColin Finck static ULONG WINAPI test_activator_AddRef(IClassActivator *iface)
461c2c66affSColin Finck {
462c2c66affSColin Finck return 2;
463c2c66affSColin Finck }
464c2c66affSColin Finck
test_activator_Release(IClassActivator * iface)465c2c66affSColin Finck static ULONG WINAPI test_activator_Release(IClassActivator *iface)
466c2c66affSColin Finck {
467c2c66affSColin Finck return 1;
468c2c66affSColin Finck }
469c2c66affSColin Finck
test_activator_GetClassObject(IClassActivator * iface,REFCLSID clsid,DWORD context,LCID locale,REFIID riid,void ** ppv)470c2c66affSColin Finck static HRESULT WINAPI test_activator_GetClassObject(IClassActivator *iface, REFCLSID clsid,
471c2c66affSColin Finck DWORD context, LCID locale, REFIID riid, void **ppv)
472c2c66affSColin Finck {
473c2c66affSColin Finck CHECK_EXPECT(autoplay_GetClassObject);
474c2c66affSColin Finck ok(IsEqualGUID(clsid, &CLSID_QueryCancelAutoPlay), "clsid %s\n", wine_dbgstr_guid(clsid));
475c2c66affSColin Finck ok(IsEqualIID(riid, &IID_IQueryCancelAutoPlay), "riid %s\n", wine_dbgstr_guid(riid));
476c2c66affSColin Finck return E_NOTIMPL;
477c2c66affSColin Finck }
478c2c66affSColin Finck
479c2c66affSColin Finck static const IClassActivatorVtbl test_activator_vtbl = {
480c2c66affSColin Finck test_activator_QI,
481c2c66affSColin Finck test_activator_AddRef,
482c2c66affSColin Finck test_activator_Release,
483c2c66affSColin Finck test_activator_GetClassObject
484c2c66affSColin Finck };
485c2c66affSColin Finck
486c2c66affSColin Finck static IClassActivator test_activator = { &test_activator_vtbl };
487c2c66affSColin Finck
test_moniker_QueryInterface(IMoniker * iface,REFIID riid,void ** ppvObject)488c2c66affSColin Finck static HRESULT WINAPI test_moniker_QueryInterface(IMoniker* iface, REFIID riid, void **ppvObject)
489c2c66affSColin Finck {
490c2c66affSColin Finck *ppvObject = 0;
491c2c66affSColin Finck
492c2c66affSColin Finck if (IsEqualIID(&IID_IUnknown, riid) ||
493c2c66affSColin Finck IsEqualIID(&IID_IPersist, riid) ||
494c2c66affSColin Finck IsEqualIID(&IID_IPersistStream, riid) ||
495c2c66affSColin Finck IsEqualIID(&IID_IMoniker, riid))
496c2c66affSColin Finck {
497c2c66affSColin Finck *ppvObject = iface;
498c2c66affSColin Finck }
499c2c66affSColin Finck
500c2c66affSColin Finck if (!*ppvObject)
501c2c66affSColin Finck return E_NOINTERFACE;
502c2c66affSColin Finck
503c2c66affSColin Finck return S_OK;
504c2c66affSColin Finck }
505c2c66affSColin Finck
test_moniker_AddRef(IMoniker * iface)506c2c66affSColin Finck static ULONG WINAPI test_moniker_AddRef(IMoniker* iface)
507c2c66affSColin Finck {
508c2c66affSColin Finck return 2;
509c2c66affSColin Finck }
510c2c66affSColin Finck
test_moniker_Release(IMoniker * iface)511c2c66affSColin Finck static ULONG WINAPI test_moniker_Release(IMoniker* iface)
512c2c66affSColin Finck {
513c2c66affSColin Finck return 1;
514c2c66affSColin Finck }
515c2c66affSColin Finck
test_moniker_GetClassID(IMoniker * iface,CLSID * pClassID)516c2c66affSColin Finck static HRESULT WINAPI test_moniker_GetClassID(IMoniker* iface, CLSID *pClassID)
517c2c66affSColin Finck {
518c2c66affSColin Finck ok(0, "unexpected call\n");
519c2c66affSColin Finck return E_NOTIMPL;
520c2c66affSColin Finck }
521c2c66affSColin Finck
test_moniker_IsDirty(IMoniker * iface)522c2c66affSColin Finck static HRESULT WINAPI test_moniker_IsDirty(IMoniker* iface)
523c2c66affSColin Finck {
524c2c66affSColin Finck ok(0, "unexpected call\n");
525c2c66affSColin Finck return E_NOTIMPL;
526c2c66affSColin Finck }
527c2c66affSColin Finck
test_moniker_Load(IMoniker * iface,IStream * pStm)528c2c66affSColin Finck static HRESULT WINAPI test_moniker_Load(IMoniker* iface, IStream* pStm)
529c2c66affSColin Finck {
530c2c66affSColin Finck ok(0, "unexpected call\n");
531c2c66affSColin Finck return E_NOTIMPL;
532c2c66affSColin Finck }
533c2c66affSColin Finck
test_moniker_Save(IMoniker * iface,IStream * pStm,BOOL fClearDirty)534c2c66affSColin Finck static HRESULT WINAPI test_moniker_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
535c2c66affSColin Finck {
536c2c66affSColin Finck ok(0, "unexpected call\n");
537c2c66affSColin Finck return E_NOTIMPL;
538c2c66affSColin Finck }
539c2c66affSColin Finck
test_moniker_GetSizeMax(IMoniker * iface,ULARGE_INTEGER * pcbSize)540c2c66affSColin Finck static HRESULT WINAPI test_moniker_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
541c2c66affSColin Finck {
542c2c66affSColin Finck ok(0, "unexpected call\n");
543c2c66affSColin Finck return E_NOTIMPL;
544c2c66affSColin Finck }
545c2c66affSColin Finck
test_moniker_BindToObject(IMoniker * iface,IBindCtx * pbc,IMoniker * moniker_to_left,REFIID riid,void ** ppv)546c2c66affSColin Finck static HRESULT WINAPI test_moniker_BindToObject(IMoniker* iface,
547c2c66affSColin Finck IBindCtx* pbc,
548c2c66affSColin Finck IMoniker* moniker_to_left,
549c2c66affSColin Finck REFIID riid,
550c2c66affSColin Finck void** ppv)
551c2c66affSColin Finck {
552c2c66affSColin Finck CHECK_EXPECT(autoplay_BindToObject);
553c2c66affSColin Finck ok(pbc != NULL, "got %p\n", pbc);
554c2c66affSColin Finck ok(moniker_to_left == NULL, "got %p\n", moniker_to_left);
555c2c66affSColin Finck ok(IsEqualIID(riid, &IID_IClassActivator), "got riid %s\n", wine_dbgstr_guid(riid));
556c2c66affSColin Finck
557c2c66affSColin Finck if (IsEqualIID(riid, &IID_IClassActivator))
558c2c66affSColin Finck {
559c2c66affSColin Finck *ppv = &test_activator;
560c2c66affSColin Finck return S_OK;
561c2c66affSColin Finck }
562c2c66affSColin Finck
563c2c66affSColin Finck return E_NOTIMPL;
564c2c66affSColin Finck }
565c2c66affSColin Finck
test_moniker_BindToStorage(IMoniker * iface,IBindCtx * pbc,IMoniker * pmkToLeft,REFIID riid,VOID ** ppvResult)566c2c66affSColin Finck static HRESULT WINAPI test_moniker_BindToStorage(IMoniker* iface,
567c2c66affSColin Finck IBindCtx* pbc,
568c2c66affSColin Finck IMoniker* pmkToLeft,
569c2c66affSColin Finck REFIID riid,
570c2c66affSColin Finck VOID** ppvResult)
571c2c66affSColin Finck {
572c2c66affSColin Finck ok(0, "unexpected call\n");
573c2c66affSColin Finck return E_NOTIMPL;
574c2c66affSColin Finck }
575c2c66affSColin Finck
test_moniker_Reduce(IMoniker * iface,IBindCtx * pbc,DWORD dwReduceHowFar,IMoniker ** ppmkToLeft,IMoniker ** ppmkReduced)576c2c66affSColin Finck static HRESULT WINAPI test_moniker_Reduce(IMoniker* iface,
577c2c66affSColin Finck IBindCtx* pbc,
578c2c66affSColin Finck DWORD dwReduceHowFar,
579c2c66affSColin Finck IMoniker** ppmkToLeft,
580c2c66affSColin Finck IMoniker** ppmkReduced)
581c2c66affSColin Finck {
582c2c66affSColin Finck ok(0, "unexpected call\n");
583c2c66affSColin Finck return E_NOTIMPL;
584c2c66affSColin Finck }
585c2c66affSColin Finck
test_moniker_ComposeWith(IMoniker * iface,IMoniker * pmkRight,BOOL fOnlyIfNotGeneric,IMoniker ** ppmkComposite)586c2c66affSColin Finck static HRESULT WINAPI test_moniker_ComposeWith(IMoniker* iface,
587c2c66affSColin Finck IMoniker* pmkRight,
588c2c66affSColin Finck BOOL fOnlyIfNotGeneric,
589c2c66affSColin Finck IMoniker** ppmkComposite)
590c2c66affSColin Finck {
591c2c66affSColin Finck ok(0, "unexpected call\n");
592c2c66affSColin Finck return E_NOTIMPL;
593c2c66affSColin Finck }
594c2c66affSColin Finck
test_moniker_Enum(IMoniker * iface,BOOL fForward,IEnumMoniker ** ppenumMoniker)595c2c66affSColin Finck static HRESULT WINAPI test_moniker_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
596c2c66affSColin Finck {
597c2c66affSColin Finck ok(0, "unexpected call\n");
598c2c66affSColin Finck return E_NOTIMPL;
599c2c66affSColin Finck }
600c2c66affSColin Finck
test_moniker_IsEqual(IMoniker * iface,IMoniker * pmkOtherMoniker)601c2c66affSColin Finck static HRESULT WINAPI test_moniker_IsEqual(IMoniker* iface, IMoniker* pmkOtherMoniker)
602c2c66affSColin Finck {
603c2c66affSColin Finck ok(0, "unexpected call\n");
604c2c66affSColin Finck return E_NOTIMPL;
605c2c66affSColin Finck }
606c2c66affSColin Finck
test_moniker_Hash(IMoniker * iface,DWORD * pdwHash)607c2c66affSColin Finck static HRESULT WINAPI test_moniker_Hash(IMoniker* iface, DWORD* pdwHash)
608c2c66affSColin Finck {
609c2c66affSColin Finck ok(0, "unexpected call\n");
610c2c66affSColin Finck return E_NOTIMPL;
611c2c66affSColin Finck }
612c2c66affSColin Finck
test_moniker_IsRunning(IMoniker * iface,IBindCtx * pbc,IMoniker * pmkToLeft,IMoniker * pmkNewlyRunning)613c2c66affSColin Finck static HRESULT WINAPI test_moniker_IsRunning(IMoniker* iface,
614c2c66affSColin Finck IBindCtx* pbc,
615c2c66affSColin Finck IMoniker* pmkToLeft,
616c2c66affSColin Finck IMoniker* pmkNewlyRunning)
617c2c66affSColin Finck {
618c2c66affSColin Finck ok(0, "unexpected call\n");
619c2c66affSColin Finck return E_NOTIMPL;
620c2c66affSColin Finck }
621c2c66affSColin Finck
test_moniker_GetTimeOfLastChange(IMoniker * iface,IBindCtx * pbc,IMoniker * pmkToLeft,FILETIME * pItemTime)622c2c66affSColin Finck static HRESULT WINAPI test_moniker_GetTimeOfLastChange(IMoniker* iface,
623c2c66affSColin Finck IBindCtx* pbc,
624c2c66affSColin Finck IMoniker* pmkToLeft,
625c2c66affSColin Finck FILETIME* pItemTime)
626c2c66affSColin Finck {
627c2c66affSColin Finck ok(0, "unexpected call\n");
628c2c66affSColin Finck return E_NOTIMPL;
629c2c66affSColin Finck }
630c2c66affSColin Finck
test_moniker_Inverse(IMoniker * iface,IMoniker ** ppmk)631c2c66affSColin Finck static HRESULT WINAPI test_moniker_Inverse(IMoniker* iface, IMoniker** ppmk)
632c2c66affSColin Finck {
633c2c66affSColin Finck ok(0, "unexpected call\n");
634c2c66affSColin Finck return E_NOTIMPL;
635c2c66affSColin Finck }
636c2c66affSColin Finck
test_moniker_CommonPrefixWith(IMoniker * iface,IMoniker * pmkOther,IMoniker ** ppmkPrefix)637c2c66affSColin Finck static HRESULT WINAPI test_moniker_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
638c2c66affSColin Finck {
639c2c66affSColin Finck ok(0, "unexpected call\n");
640c2c66affSColin Finck return E_NOTIMPL;
641c2c66affSColin Finck }
642c2c66affSColin Finck
test_moniker_RelativePathTo(IMoniker * iface,IMoniker * pmOther,IMoniker ** ppmkRelPath)643c2c66affSColin Finck static HRESULT WINAPI test_moniker_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
644c2c66affSColin Finck {
645c2c66affSColin Finck ok(0, "unexpected call\n");
646c2c66affSColin Finck return E_NOTIMPL;
647c2c66affSColin Finck }
648c2c66affSColin Finck
test_moniker_GetDisplayName(IMoniker * iface,IBindCtx * pbc,IMoniker * pmkToLeft,LPOLESTR * ppszDisplayName)649c2c66affSColin Finck static HRESULT WINAPI test_moniker_GetDisplayName(IMoniker* iface,
650c2c66affSColin Finck IBindCtx* pbc,
651c2c66affSColin Finck IMoniker* pmkToLeft,
652c2c66affSColin Finck LPOLESTR *ppszDisplayName)
653c2c66affSColin Finck {
654c2c66affSColin Finck ok(0, "unexpected call\n");
655c2c66affSColin Finck return E_NOTIMPL;
656c2c66affSColin Finck }
657c2c66affSColin Finck
test_moniker_ParseDisplayName(IMoniker * iface,IBindCtx * pbc,IMoniker * pmkToLeft,LPOLESTR pszDisplayName,ULONG * pchEaten,IMoniker ** ppmkOut)658c2c66affSColin Finck static HRESULT WINAPI test_moniker_ParseDisplayName(IMoniker* iface,
659c2c66affSColin Finck IBindCtx* pbc,
660c2c66affSColin Finck IMoniker* pmkToLeft,
661c2c66affSColin Finck LPOLESTR pszDisplayName,
662c2c66affSColin Finck ULONG* pchEaten,
663c2c66affSColin Finck IMoniker** ppmkOut)
664c2c66affSColin Finck {
665c2c66affSColin Finck ok(0, "unexpected call\n");
666c2c66affSColin Finck return E_NOTIMPL;
667c2c66affSColin Finck }
668c2c66affSColin Finck
test_moniker_IsSystemMoniker(IMoniker * iface,DWORD * pwdMksys)669c2c66affSColin Finck static HRESULT WINAPI test_moniker_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
670c2c66affSColin Finck {
671c2c66affSColin Finck ok(0, "unexpected call\n");
672c2c66affSColin Finck return E_NOTIMPL;
673c2c66affSColin Finck }
674c2c66affSColin Finck
675c2c66affSColin Finck static const IMonikerVtbl test_moniker_vtbl =
676c2c66affSColin Finck {
677c2c66affSColin Finck test_moniker_QueryInterface,
678c2c66affSColin Finck test_moniker_AddRef,
679c2c66affSColin Finck test_moniker_Release,
680c2c66affSColin Finck test_moniker_GetClassID,
681c2c66affSColin Finck test_moniker_IsDirty,
682c2c66affSColin Finck test_moniker_Load,
683c2c66affSColin Finck test_moniker_Save,
684c2c66affSColin Finck test_moniker_GetSizeMax,
685c2c66affSColin Finck test_moniker_BindToObject,
686c2c66affSColin Finck test_moniker_BindToStorage,
687c2c66affSColin Finck test_moniker_Reduce,
688c2c66affSColin Finck test_moniker_ComposeWith,
689c2c66affSColin Finck test_moniker_Enum,
690c2c66affSColin Finck test_moniker_IsEqual,
691c2c66affSColin Finck test_moniker_Hash,
692c2c66affSColin Finck test_moniker_IsRunning,
693c2c66affSColin Finck test_moniker_GetTimeOfLastChange,
694c2c66affSColin Finck test_moniker_Inverse,
695c2c66affSColin Finck test_moniker_CommonPrefixWith,
696c2c66affSColin Finck test_moniker_RelativePathTo,
697c2c66affSColin Finck test_moniker_GetDisplayName,
698c2c66affSColin Finck test_moniker_ParseDisplayName,
699c2c66affSColin Finck test_moniker_IsSystemMoniker
700c2c66affSColin Finck };
701c2c66affSColin Finck
702c2c66affSColin Finck static IMoniker test_moniker = { &test_moniker_vtbl };
703c2c66affSColin Finck
test_SHCreateQueryCancelAutoPlayMoniker(void)704c2c66affSColin Finck static void test_SHCreateQueryCancelAutoPlayMoniker(void)
705c2c66affSColin Finck {
706c2c66affSColin Finck IBindCtx *ctxt;
707c2c66affSColin Finck IMoniker *mon;
708c2c66affSColin Finck IUnknown *unk;
709c2c66affSColin Finck CLSID clsid;
710c2c66affSColin Finck HRESULT hr;
711c2c66affSColin Finck DWORD sys;
712c2c66affSColin Finck
713c2c66affSColin Finck if (!pSHCreateQueryCancelAutoPlayMoniker)
714c2c66affSColin Finck {
715c2c66affSColin Finck win_skip("SHCreateQueryCancelAutoPlayMoniker is not available, skipping tests.\n");
716c2c66affSColin Finck return;
717c2c66affSColin Finck }
718c2c66affSColin Finck
719c2c66affSColin Finck hr = pSHCreateQueryCancelAutoPlayMoniker(NULL);
720c2c66affSColin Finck ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
721c2c66affSColin Finck
722c2c66affSColin Finck hr = pSHCreateQueryCancelAutoPlayMoniker(&mon);
723c2c66affSColin Finck ok(hr == S_OK, "got 0x%08x\n", hr);
724c2c66affSColin Finck
725c2c66affSColin Finck sys = -1;
726c2c66affSColin Finck hr = IMoniker_IsSystemMoniker(mon, &sys);
727c2c66affSColin Finck ok(hr == S_OK, "got 0x%08x\n", hr);
728c2c66affSColin Finck ok(sys == MKSYS_CLASSMONIKER, "got %d\n", sys);
729c2c66affSColin Finck
730c2c66affSColin Finck memset(&clsid, 0, sizeof(clsid));
731c2c66affSColin Finck hr = IMoniker_GetClassID(mon, &clsid);
732c2c66affSColin Finck ok(hr == S_OK, "got 0x%08x\n", hr);
733c2c66affSColin Finck ok(IsEqualGUID(&clsid, &CLSID_ClassMoniker), "got %s\n", wine_dbgstr_guid(&clsid));
734c2c66affSColin Finck
735c2c66affSColin Finck /* extract used CLSID that implements this hook */
736c2c66affSColin Finck SET_EXPECT(autoplay_BindToObject);
737c2c66affSColin Finck SET_EXPECT(autoplay_GetClassObject);
738c2c66affSColin Finck
739c2c66affSColin Finck CreateBindCtx(0, &ctxt);
740c2c66affSColin Finck hr = IMoniker_BindToObject(mon, ctxt, &test_moniker, &IID_IQueryCancelAutoPlay, (void**)&unk);
741c2c66affSColin Finck ok(hr == E_NOTIMPL, "got 0x%08x\n", hr);
742c2c66affSColin Finck IBindCtx_Release(ctxt);
743c2c66affSColin Finck
744c2c66affSColin Finck CHECK_CALLED(autoplay_BindToObject);
745c2c66affSColin Finck CHECK_CALLED(autoplay_GetClassObject);
746c2c66affSColin Finck
747c2c66affSColin Finck IMoniker_Release(mon);
748c2c66affSColin Finck }
749c2c66affSColin Finck
750*b8dc669cSAmine Khaldi #define WM_EXPECTED_VALUE WM_APP
751c2c66affSColin Finck #define DROPTEST_FILENAME "c:\\wintest.bin"
752c2c66affSColin Finck struct DragParam {
753c2c66affSColin Finck HWND hwnd;
754c2c66affSColin Finck HANDLE ready;
755c2c66affSColin Finck };
756c2c66affSColin Finck
drop_window_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)757c2c66affSColin Finck static LRESULT WINAPI drop_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
758c2c66affSColin Finck {
759*b8dc669cSAmine Khaldi static BOOL expected;
760*b8dc669cSAmine Khaldi
761c2c66affSColin Finck switch (msg) {
762*b8dc669cSAmine Khaldi case WM_EXPECTED_VALUE:
763*b8dc669cSAmine Khaldi {
764*b8dc669cSAmine Khaldi expected = lparam;
765*b8dc669cSAmine Khaldi break;
766*b8dc669cSAmine Khaldi }
767c2c66affSColin Finck case WM_DROPFILES:
768c2c66affSColin Finck {
769c2c66affSColin Finck HDROP hDrop = (HDROP)wparam;
770c2c66affSColin Finck char filename[MAX_PATH] = "dummy";
771*b8dc669cSAmine Khaldi POINT pt;
772*b8dc669cSAmine Khaldi BOOL r;
773c2c66affSColin Finck UINT num;
774c2c66affSColin Finck num = DragQueryFileA(hDrop, 0xffffffff, NULL, 0);
775c2c66affSColin Finck ok(num == 1, "expected 1, got %u\n", num);
776c2c66affSColin Finck num = DragQueryFileA(hDrop, 0xffffffff, (char*)0xdeadbeef, 0xffffffff);
777c2c66affSColin Finck ok(num == 1, "expected 1, got %u\n", num);
778c2c66affSColin Finck num = DragQueryFileA(hDrop, 0, filename, sizeof(filename));
779c2c66affSColin Finck ok(num == strlen(DROPTEST_FILENAME), "got %u\n", num);
780c2c66affSColin Finck ok(!strcmp(filename, DROPTEST_FILENAME), "got %s\n", filename);
781*b8dc669cSAmine Khaldi r = DragQueryPoint(hDrop, &pt);
782*b8dc669cSAmine Khaldi ok(r == expected, "expected %d, got %d\n", expected, r);
783*b8dc669cSAmine Khaldi ok(pt.x == 10, "expected 10, got %d\n", pt.x);
784*b8dc669cSAmine Khaldi ok(pt.y == 20, "expected 20, got %d\n", pt.y);
785c2c66affSColin Finck DragFinish(hDrop);
786c2c66affSColin Finck return 0;
787c2c66affSColin Finck }
788c2c66affSColin Finck }
789c2c66affSColin Finck return DefWindowProcA(hwnd, msg, wparam, lparam);
790c2c66affSColin Finck }
791c2c66affSColin Finck
drop_window_therad(void * arg)792c2c66affSColin Finck static DWORD WINAPI drop_window_therad(void *arg)
793c2c66affSColin Finck {
794c2c66affSColin Finck struct DragParam *param = arg;
795c2c66affSColin Finck WNDCLASSA cls;
796c2c66affSColin Finck WINDOWINFO info;
797c2c66affSColin Finck BOOL r;
798c2c66affSColin Finck MSG msg;
799c2c66affSColin Finck
800c2c66affSColin Finck memset(&cls, 0, sizeof(cls));
801c2c66affSColin Finck cls.lpfnWndProc = drop_window_proc;
802c2c66affSColin Finck cls.hInstance = GetModuleHandleA(NULL);
803c2c66affSColin Finck cls.lpszClassName = "drop test";
804c2c66affSColin Finck RegisterClassA(&cls);
805c2c66affSColin Finck
806c2c66affSColin Finck param->hwnd = CreateWindowA("drop test", NULL, 0, 0, 0, 0, 0,
807c2c66affSColin Finck NULL, 0, NULL, 0);
808c2c66affSColin Finck ok(param->hwnd != NULL, "CreateWindow failed: %d\n", GetLastError());
809c2c66affSColin Finck
810c2c66affSColin Finck memset(&info, 0, sizeof(info));
811c2c66affSColin Finck info.cbSize = sizeof(info);
812c2c66affSColin Finck r = GetWindowInfo(param->hwnd, &info);
813c2c66affSColin Finck ok(r, "got %d\n", r);
814c2c66affSColin Finck ok(!(info.dwExStyle & WS_EX_ACCEPTFILES), "got %08x\n", info.dwExStyle);
815c2c66affSColin Finck
816c2c66affSColin Finck DragAcceptFiles(param->hwnd, TRUE);
817c2c66affSColin Finck
818c2c66affSColin Finck memset(&info, 0, sizeof(info));
819c2c66affSColin Finck info.cbSize = sizeof(info);
820c2c66affSColin Finck r = GetWindowInfo(param->hwnd, &info);
821c2c66affSColin Finck ok(r, "got %d\n", r);
822c2c66affSColin Finck ok((info.dwExStyle & WS_EX_ACCEPTFILES), "got %08x\n", info.dwExStyle);
823c2c66affSColin Finck
824c2c66affSColin Finck SetEvent(param->ready);
825c2c66affSColin Finck
826c2c66affSColin Finck while ((r = GetMessageA(&msg, NULL, 0, 0)) != 0) {
827c2c66affSColin Finck if (r == (BOOL)-1) {
828c2c66affSColin Finck ok(0, "unexpected return value, got %d\n", r);
829c2c66affSColin Finck break;
830c2c66affSColin Finck }
831c2c66affSColin Finck DispatchMessageA(&msg);
832c2c66affSColin Finck }
833c2c66affSColin Finck
834c2c66affSColin Finck DestroyWindow(param->hwnd);
835c2c66affSColin Finck UnregisterClassA("drop test", GetModuleHandleA(NULL));
836c2c66affSColin Finck return 0;
837c2c66affSColin Finck }
838c2c66affSColin Finck
test_DragQueryFile(BOOL non_client_flag)839*b8dc669cSAmine Khaldi static void test_DragQueryFile(BOOL non_client_flag)
840c2c66affSColin Finck {
841c2c66affSColin Finck struct DragParam param;
842c2c66affSColin Finck HANDLE hThread;
843c2c66affSColin Finck DWORD rc;
844c2c66affSColin Finck HGLOBAL hDrop;
845c2c66affSColin Finck DROPFILES *pDrop;
846c2c66affSColin Finck int ret;
847c2c66affSColin Finck BOOL r;
848c2c66affSColin Finck
849c2c66affSColin Finck param.ready = CreateEventA(NULL, FALSE, FALSE, NULL);
850c2c66affSColin Finck ok(param.ready != NULL, "can't create event\n");
851c2c66affSColin Finck hThread = CreateThread(NULL, 0, drop_window_therad, ¶m, 0, NULL);
852c2c66affSColin Finck
853c2c66affSColin Finck rc = WaitForSingleObject(param.ready, 5000);
854c2c66affSColin Finck ok(rc == WAIT_OBJECT_0, "got %u\n", rc);
855c2c66affSColin Finck
856c2c66affSColin Finck hDrop = GlobalAlloc(GHND, sizeof(DROPFILES) + (strlen(DROPTEST_FILENAME) + 2) * sizeof(WCHAR));
857c2c66affSColin Finck pDrop = GlobalLock(hDrop);
858*b8dc669cSAmine Khaldi pDrop->pt.x = 10;
859*b8dc669cSAmine Khaldi pDrop->pt.y = 20;
860*b8dc669cSAmine Khaldi pDrop->fNC = non_client_flag;
861c2c66affSColin Finck pDrop->pFiles = sizeof(DROPFILES);
862c2c66affSColin Finck ret = MultiByteToWideChar(CP_ACP, 0, DROPTEST_FILENAME, -1,
863c2c66affSColin Finck (LPWSTR)(pDrop + 1), strlen(DROPTEST_FILENAME) + 1);
864c2c66affSColin Finck ok(ret > 0, "got %d\n", ret);
865c2c66affSColin Finck pDrop->fWide = TRUE;
866c2c66affSColin Finck GlobalUnlock(hDrop);
867c2c66affSColin Finck
868*b8dc669cSAmine Khaldi r = PostMessageA(param.hwnd, WM_EXPECTED_VALUE, 0, !non_client_flag);
869*b8dc669cSAmine Khaldi ok(r, "got %d\n", r);
870*b8dc669cSAmine Khaldi
871c2c66affSColin Finck r = PostMessageA(param.hwnd, WM_DROPFILES, (WPARAM)hDrop, 0);
872c2c66affSColin Finck ok(r, "got %d\n", r);
873c2c66affSColin Finck
874c2c66affSColin Finck r = PostMessageA(param.hwnd, WM_QUIT, 0, 0);
875c2c66affSColin Finck ok(r, "got %d\n", r);
876c2c66affSColin Finck
877c2c66affSColin Finck rc = WaitForSingleObject(hThread, 5000);
878c2c66affSColin Finck ok(rc == WAIT_OBJECT_0, "got %d\n", rc);
879c2c66affSColin Finck
880c2c66affSColin Finck CloseHandle(param.ready);
881c2c66affSColin Finck CloseHandle(hThread);
882c2c66affSColin Finck }
883*b8dc669cSAmine Khaldi #undef WM_EXPECTED_VALUE
884c2c66affSColin Finck #undef DROPTEST_FILENAME
885c2c66affSColin Finck
test_SHCreateSessionKey(void)886c2c66affSColin Finck static void test_SHCreateSessionKey(void)
887c2c66affSColin Finck {
8884d8c4b14SAmine Khaldi static const WCHAR session_format[] = {
8894d8c4b14SAmine Khaldi 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
8904d8c4b14SAmine Khaldi 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
8914d8c4b14SAmine Khaldi 'E','x','p','l','o','r','e','r','\\','S','e','s','s','i','o','n','I','n','f','o','\\','%','u',0};
892c2c66affSColin Finck HKEY hkey, hkey2;
893c2c66affSColin Finck HRESULT hr;
8944d8c4b14SAmine Khaldi DWORD session;
8954d8c4b14SAmine Khaldi WCHAR sessionW[ARRAY_SIZE(session_format) + 16];
8964d8c4b14SAmine Khaldi LONG ret;
897c2c66affSColin Finck
898c2c66affSColin Finck if (!pSHCreateSessionKey)
899c2c66affSColin Finck {
900c2c66affSColin Finck win_skip("SHCreateSessionKey is not implemented\n");
901c2c66affSColin Finck return;
902c2c66affSColin Finck }
903c2c66affSColin Finck
904c2c66affSColin Finck if (0) /* crashes on native */
905c2c66affSColin Finck hr = pSHCreateSessionKey(KEY_READ, NULL);
906c2c66affSColin Finck
907c2c66affSColin Finck hkey = (HKEY)0xdeadbeef;
908c2c66affSColin Finck hr = pSHCreateSessionKey(0, &hkey);
9094d8c4b14SAmine Khaldi ok(hr == E_ACCESSDENIED, "got 0x%08x\n", hr);
9104d8c4b14SAmine Khaldi ok(hkey == NULL, "got %p\n", hkey);
911c2c66affSColin Finck
912c2c66affSColin Finck hr = pSHCreateSessionKey(KEY_READ, &hkey);
913c2c66affSColin Finck ok(hr == S_OK, "got 0x%08x\n", hr);
914c2c66affSColin Finck
915c2c66affSColin Finck hr = pSHCreateSessionKey(KEY_READ, &hkey2);
916c2c66affSColin Finck ok(hr == S_OK, "got 0x%08x\n", hr);
917c2c66affSColin Finck ok(hkey != hkey2, "got %p, %p\n", hkey, hkey2);
918c2c66affSColin Finck
919c2c66affSColin Finck RegCloseKey(hkey);
920c2c66affSColin Finck RegCloseKey(hkey2);
9214d8c4b14SAmine Khaldi
9224d8c4b14SAmine Khaldi /* check the registry */
9234d8c4b14SAmine Khaldi ProcessIdToSessionId( GetCurrentProcessId(), &session);
9244d8c4b14SAmine Khaldi if (session)
9254d8c4b14SAmine Khaldi {
9264d8c4b14SAmine Khaldi wsprintfW(sessionW, session_format, session);
9274d8c4b14SAmine Khaldi ret = RegOpenKeyW(HKEY_CURRENT_USER, sessionW, &hkey);
9284d8c4b14SAmine Khaldi ok(!ret, "key not found\n");
9294d8c4b14SAmine Khaldi RegCloseKey(hkey);
9304d8c4b14SAmine Khaldi }
931c2c66affSColin Finck }
932c2c66affSColin Finck
test_dragdrophelper(void)933c2c66affSColin Finck static void test_dragdrophelper(void)
934c2c66affSColin Finck {
935c2c66affSColin Finck IDragSourceHelper *dragsource;
936c2c66affSColin Finck IDropTargetHelper *target;
937c2c66affSColin Finck HRESULT hr;
938c2c66affSColin Finck
939c2c66affSColin Finck hr = CoCreateInstance(&CLSID_DragDropHelper, NULL, CLSCTX_INPROC_SERVER, &IID_IDropTargetHelper, (void **)&target);
940c2c66affSColin Finck ok(hr == S_OK, "Failed to create IDropTargetHelper, %#x\n", hr);
941c2c66affSColin Finck
942c2c66affSColin Finck hr = IDropTargetHelper_QueryInterface(target, &IID_IDragSourceHelper, (void **)&dragsource);
943c2c66affSColin Finck ok(hr == S_OK, "QI failed, %#x\n", hr);
944c2c66affSColin Finck IDragSourceHelper_Release(dragsource);
945c2c66affSColin Finck
946c2c66affSColin Finck IDropTargetHelper_Release(target);
947c2c66affSColin Finck }
948c2c66affSColin Finck
START_TEST(shellole)949c2c66affSColin Finck START_TEST(shellole)
950c2c66affSColin Finck {
951c2c66affSColin Finck HRESULT hr;
952c2c66affSColin Finck
953c2c66affSColin Finck init();
954c2c66affSColin Finck
955c2c66affSColin Finck hr = CoInitialize(NULL);
956c2c66affSColin Finck ok(hr == S_OK, "CoInitialize failed (0x%08x)\n", hr);
957c2c66affSColin Finck if (hr != S_OK)
958c2c66affSColin Finck return;
959c2c66affSColin Finck
960c2c66affSColin Finck test_SHPropStg_functions();
961c2c66affSColin Finck test_SHCreateQueryCancelAutoPlayMoniker();
962*b8dc669cSAmine Khaldi test_DragQueryFile(TRUE);
963*b8dc669cSAmine Khaldi test_DragQueryFile(FALSE);
964c2c66affSColin Finck test_SHCreateSessionKey();
965c2c66affSColin Finck test_dragdrophelper();
966c2c66affSColin Finck
967c2c66affSColin Finck CoUninitialize();
968c2c66affSColin Finck }
969