1c2c66affSColin Finck /*
2c2c66affSColin Finck  * oledlg tests
3c2c66affSColin Finck  *
4c2c66affSColin Finck  * Copyright 2015 Nikolay Sivov for CodeWeavers
5c2c66affSColin Finck  *
6c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
7c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
8c2c66affSColin Finck  * License as published by the Free Software Foundation; either
9c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
10c2c66affSColin Finck  *
11c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
12c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14c2c66affSColin Finck  * Lesser General Public License for more details.
15c2c66affSColin Finck  *
16c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
17c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
18c2c66affSColin Finck  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19c2c66affSColin Finck  */
20c2c66affSColin Finck 
21c2c66affSColin Finck #define COBJMACROS
22c2c66affSColin Finck 
23000789f4SAmine Khaldi #include "wine/test.h"
24c2c66affSColin Finck #include <stdio.h>
25c2c66affSColin Finck 
26000789f4SAmine Khaldi #include "initguid.h"
27000789f4SAmine Khaldi #include "oledlg.h"
28c2c66affSColin Finck 
strstrW(const WCHAR * str,const WCHAR * sub)29c2c66affSColin Finck static const WCHAR *strstrW( const WCHAR *str, const WCHAR *sub )
30c2c66affSColin Finck {
31c2c66affSColin Finck     while (*str)
32c2c66affSColin Finck     {
33c2c66affSColin Finck         const WCHAR *p1 = str, *p2 = sub;
34c2c66affSColin Finck         while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
35c2c66affSColin Finck         if (!*p2) return str;
36c2c66affSColin Finck         str++;
37c2c66affSColin Finck     }
38c2c66affSColin Finck     return NULL;
39c2c66affSColin Finck }
40c2c66affSColin Finck 
enumverbs_QueryInterface(IEnumOLEVERB * iface,REFIID riid,void ** ppv)41c2c66affSColin Finck static HRESULT WINAPI enumverbs_QueryInterface(IEnumOLEVERB *iface, REFIID riid, void **ppv)
42c2c66affSColin Finck {
43c2c66affSColin Finck     if (IsEqualIID(riid, &IID_IEnumOLEVERB) || IsEqualIID(riid, &IID_IUnknown)) {
44c2c66affSColin Finck         *ppv = iface;
45c2c66affSColin Finck         IEnumOLEVERB_AddRef(iface);
46c2c66affSColin Finck         return S_OK;
47c2c66affSColin Finck     }
48c2c66affSColin Finck 
49c2c66affSColin Finck     *ppv = NULL;
50c2c66affSColin Finck     return E_NOINTERFACE;
51c2c66affSColin Finck }
52c2c66affSColin Finck 
enumverbs_AddRef(IEnumOLEVERB * iface)53c2c66affSColin Finck static ULONG WINAPI enumverbs_AddRef(IEnumOLEVERB *iface)
54c2c66affSColin Finck {
55c2c66affSColin Finck     return 2;
56c2c66affSColin Finck }
57c2c66affSColin Finck 
enumverbs_Release(IEnumOLEVERB * iface)58c2c66affSColin Finck static ULONG WINAPI enumverbs_Release(IEnumOLEVERB *iface)
59c2c66affSColin Finck {
60c2c66affSColin Finck     return 1;
61c2c66affSColin Finck }
62c2c66affSColin Finck 
63c2c66affSColin Finck static int g_enumpos;
64c2c66affSColin Finck static const WCHAR verbW[] = {'v','e','r','b',0};
enumverbs_Next(IEnumOLEVERB * iface,ULONG count,OLEVERB * verbs,ULONG * fetched)65c2c66affSColin Finck static HRESULT WINAPI enumverbs_Next(IEnumOLEVERB *iface, ULONG count, OLEVERB *verbs, ULONG *fetched)
66c2c66affSColin Finck {
67c2c66affSColin Finck     ok(count == 1, "got %u\n", count);
68c2c66affSColin Finck     ok(fetched == NULL, "got %p\n", fetched);
69c2c66affSColin Finck     ok(g_enumpos == 0 || g_enumpos == 1, "got pos %d\n", g_enumpos);
70c2c66affSColin Finck 
71c2c66affSColin Finck     if (g_enumpos++ == 0) {
72c2c66affSColin Finck         verbs->lVerb = 123;
73c2c66affSColin Finck         verbs->lpszVerbName = CoTaskMemAlloc(sizeof(verbW));
74c2c66affSColin Finck         lstrcpyW(verbs->lpszVerbName, verbW);
75c2c66affSColin Finck         verbs->fuFlags = MF_ENABLED;
76c2c66affSColin Finck         verbs->grfAttribs = OLEVERBATTRIB_ONCONTAINERMENU;
77c2c66affSColin Finck         if (fetched) *fetched = 1;
78c2c66affSColin Finck         return S_OK;
79c2c66affSColin Finck     }
80c2c66affSColin Finck 
81c2c66affSColin Finck     return S_FALSE;
82c2c66affSColin Finck }
83c2c66affSColin Finck 
enumverbs_Skip(IEnumOLEVERB * iface,ULONG count)84c2c66affSColin Finck static HRESULT WINAPI enumverbs_Skip(IEnumOLEVERB *iface, ULONG count)
85c2c66affSColin Finck {
86c2c66affSColin Finck     ok(0, "unexpected call\n");
87c2c66affSColin Finck     return E_NOTIMPL;
88c2c66affSColin Finck }
89c2c66affSColin Finck 
enumverbs_Reset(IEnumOLEVERB * iface)90c2c66affSColin Finck static HRESULT WINAPI enumverbs_Reset(IEnumOLEVERB *iface)
91c2c66affSColin Finck {
92c2c66affSColin Finck     ok(0, "unexpected call\n");
93c2c66affSColin Finck     return E_NOTIMPL;
94c2c66affSColin Finck }
95c2c66affSColin Finck 
enumverbs_Clone(IEnumOLEVERB * iface,IEnumOLEVERB ** ppenum)96c2c66affSColin Finck static HRESULT WINAPI enumverbs_Clone(IEnumOLEVERB *iface, IEnumOLEVERB **ppenum)
97c2c66affSColin Finck {
98c2c66affSColin Finck     ok(0, "unexpected call\n");
99c2c66affSColin Finck     return E_NOTIMPL;
100c2c66affSColin Finck }
101c2c66affSColin Finck 
102c2c66affSColin Finck static IEnumOLEVERBVtbl enumverbsvtbl = {
103c2c66affSColin Finck     enumverbs_QueryInterface,
104c2c66affSColin Finck     enumverbs_AddRef,
105c2c66affSColin Finck     enumverbs_Release,
106c2c66affSColin Finck     enumverbs_Next,
107c2c66affSColin Finck     enumverbs_Skip,
108c2c66affSColin Finck     enumverbs_Reset,
109c2c66affSColin Finck     enumverbs_Clone
110c2c66affSColin Finck };
111c2c66affSColin Finck 
112c2c66affSColin Finck static IEnumOLEVERB enumverbs = { &enumverbsvtbl };
113c2c66affSColin Finck 
oleobject_QueryInterface(IOleObject * iface,REFIID riid,void ** ppv)114c2c66affSColin Finck static HRESULT WINAPI oleobject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
115c2c66affSColin Finck {
116c2c66affSColin Finck     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IOleObject)) {
117c2c66affSColin Finck         *ppv = iface;
118c2c66affSColin Finck         IOleObject_AddRef(iface);
119c2c66affSColin Finck         return S_OK;
120c2c66affSColin Finck     }
121c2c66affSColin Finck 
122c2c66affSColin Finck     *ppv = NULL;
123c2c66affSColin Finck     return E_NOINTERFACE;
124c2c66affSColin Finck }
125c2c66affSColin Finck 
oleobject_AddRef(IOleObject * iface)126c2c66affSColin Finck static ULONG WINAPI oleobject_AddRef(IOleObject *iface)
127c2c66affSColin Finck {
128c2c66affSColin Finck     return 2;
129c2c66affSColin Finck }
130c2c66affSColin Finck 
oleobject_Release(IOleObject * iface)131c2c66affSColin Finck static ULONG WINAPI oleobject_Release(IOleObject *iface)
132c2c66affSColin Finck {
133c2c66affSColin Finck     return 1;
134c2c66affSColin Finck }
135c2c66affSColin Finck 
oleobject_SetClientSite(IOleObject * iface,IOleClientSite * site)136c2c66affSColin Finck static HRESULT WINAPI oleobject_SetClientSite(IOleObject *iface, IOleClientSite *site)
137c2c66affSColin Finck {
138c2c66affSColin Finck     ok(0, "unexpected call\n");
139c2c66affSColin Finck     return E_NOTIMPL;
140c2c66affSColin Finck }
141c2c66affSColin Finck 
oleobject_GetClientSite(IOleObject * iface,IOleClientSite ** site)142c2c66affSColin Finck static HRESULT WINAPI oleobject_GetClientSite(IOleObject *iface, IOleClientSite **site)
143c2c66affSColin Finck {
144c2c66affSColin Finck     ok(0, "unexpected call\n");
145c2c66affSColin Finck     return E_NOTIMPL;
146c2c66affSColin Finck }
147c2c66affSColin Finck 
oleobject_SetHostNames(IOleObject * iface,LPCOLESTR containerapp,LPCOLESTR containerObj)148c2c66affSColin Finck static HRESULT WINAPI oleobject_SetHostNames(IOleObject *iface, LPCOLESTR containerapp,
149c2c66affSColin Finck     LPCOLESTR containerObj)
150c2c66affSColin Finck {
151c2c66affSColin Finck     ok(0, "unexpected call\n");
152c2c66affSColin Finck     return E_NOTIMPL;
153c2c66affSColin Finck }
154c2c66affSColin Finck 
oleobject_Close(IOleObject * iface,DWORD saveopt)155c2c66affSColin Finck static HRESULT WINAPI oleobject_Close(IOleObject *iface, DWORD saveopt)
156c2c66affSColin Finck {
157c2c66affSColin Finck     ok(0, "unexpected call\n");
158c2c66affSColin Finck     return E_NOTIMPL;
159c2c66affSColin Finck }
160c2c66affSColin Finck 
oleobject_SetMoniker(IOleObject * iface,DWORD whichmoniker,IMoniker * mk)161c2c66affSColin Finck static HRESULT WINAPI oleobject_SetMoniker(IOleObject *iface, DWORD whichmoniker, IMoniker *mk)
162c2c66affSColin Finck {
163c2c66affSColin Finck     ok(0, "unexpected call\n");
164c2c66affSColin Finck     return E_NOTIMPL;
165c2c66affSColin Finck }
166c2c66affSColin Finck 
oleobject_GetMoniker(IOleObject * iface,DWORD assign,DWORD whichmoniker,IMoniker ** mk)167c2c66affSColin Finck static HRESULT WINAPI oleobject_GetMoniker(IOleObject *iface, DWORD assign, DWORD whichmoniker,
168c2c66affSColin Finck     IMoniker **mk)
169c2c66affSColin Finck {
170c2c66affSColin Finck     ok(0, "unexpected call\n");
171c2c66affSColin Finck     return E_NOTIMPL;
172c2c66affSColin Finck }
173c2c66affSColin Finck 
oleobject_InitFromData(IOleObject * iface,IDataObject * dataobject,BOOL creation,DWORD reserved)174c2c66affSColin Finck static HRESULT WINAPI oleobject_InitFromData(IOleObject *iface, IDataObject *dataobject,
175c2c66affSColin Finck     BOOL creation, DWORD reserved)
176c2c66affSColin Finck {
177c2c66affSColin Finck     ok(0, "unexpected call\n");
178c2c66affSColin Finck     return E_NOTIMPL;
179c2c66affSColin Finck }
180c2c66affSColin Finck 
oleobject_GetClipboardData(IOleObject * iface,DWORD reserved,IDataObject ** dataobject)181c2c66affSColin Finck static HRESULT WINAPI oleobject_GetClipboardData(IOleObject *iface, DWORD reserved, IDataObject **dataobject)
182c2c66affSColin Finck {
183c2c66affSColin Finck     ok(0, "unexpected call\n");
184c2c66affSColin Finck     return E_NOTIMPL;
185c2c66affSColin Finck }
186c2c66affSColin Finck 
oleobject_DoVerb(IOleObject * iface,LONG verb,MSG * msg,IOleClientSite * activesite,LONG index,HWND hwndParent,LPCRECT rect)187c2c66affSColin Finck static HRESULT WINAPI oleobject_DoVerb(IOleObject *iface, LONG verb, MSG *msg, IOleClientSite *activesite,
188c2c66affSColin Finck     LONG index, HWND hwndParent, LPCRECT rect)
189c2c66affSColin Finck {
190c2c66affSColin Finck     ok(0, "unexpected call\n");
191c2c66affSColin Finck     return E_NOTIMPL;
192c2c66affSColin Finck }
193c2c66affSColin Finck 
194c2c66affSColin Finck static BOOL g_enumverbsfail;
oleobject_EnumVerbs(IOleObject * iface,IEnumOLEVERB ** enumverb)195c2c66affSColin Finck static HRESULT WINAPI oleobject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **enumverb)
196c2c66affSColin Finck {
197c2c66affSColin Finck     if (g_enumverbsfail) {
198c2c66affSColin Finck         *enumverb = NULL;
199c2c66affSColin Finck         return E_FAIL;
200c2c66affSColin Finck     }
201c2c66affSColin Finck     *enumverb = &enumverbs;
202c2c66affSColin Finck     return S_OK;
203c2c66affSColin Finck }
204c2c66affSColin Finck 
oleobject_Update(IOleObject * iface)205c2c66affSColin Finck static HRESULT WINAPI oleobject_Update(IOleObject *iface)
206c2c66affSColin Finck {
207c2c66affSColin Finck     ok(0, "unexpected call\n");
208c2c66affSColin Finck     return E_NOTIMPL;
209c2c66affSColin Finck }
210c2c66affSColin Finck 
oleobject_IsUpToDate(IOleObject * iface)211c2c66affSColin Finck static HRESULT WINAPI oleobject_IsUpToDate(IOleObject *iface)
212c2c66affSColin Finck {
213c2c66affSColin Finck     ok(0, "unexpected call\n");
214c2c66affSColin Finck     return E_NOTIMPL;
215c2c66affSColin Finck }
216c2c66affSColin Finck 
oleobject_GetUserClassID(IOleObject * iface,CLSID * clsid)217c2c66affSColin Finck static HRESULT WINAPI oleobject_GetUserClassID(IOleObject *iface, CLSID *clsid)
218c2c66affSColin Finck {
219c2c66affSColin Finck     ok(0, "unexpected call\n");
220c2c66affSColin Finck     return E_NOTIMPL;
221c2c66affSColin Finck }
222c2c66affSColin Finck 
223c2c66affSColin Finck static const WCHAR testW[] = {'t','e','s','t',0};
oleobject_GetUserType(IOleObject * iface,DWORD formoftype,LPOLESTR * usertype)224c2c66affSColin Finck static HRESULT WINAPI oleobject_GetUserType(IOleObject *iface, DWORD formoftype,
225c2c66affSColin Finck     LPOLESTR *usertype)
226c2c66affSColin Finck {
227c2c66affSColin Finck     ok(formoftype == USERCLASSTYPE_SHORT, "got %d\n", formoftype);
228c2c66affSColin Finck     *usertype = CoTaskMemAlloc(sizeof(testW));
229c2c66affSColin Finck     lstrcpyW(*usertype, testW);
230c2c66affSColin Finck     return S_OK;
231c2c66affSColin Finck }
232c2c66affSColin Finck 
oleobject_SetExtent(IOleObject * iface,DWORD aspect,SIZEL * size)233c2c66affSColin Finck static HRESULT WINAPI oleobject_SetExtent(IOleObject *iface, DWORD aspect, SIZEL *size)
234c2c66affSColin Finck {
235c2c66affSColin Finck     ok(0, "unexpected call\n");
236c2c66affSColin Finck     return E_NOTIMPL;
237c2c66affSColin Finck }
238c2c66affSColin Finck 
oleobject_GetExtent(IOleObject * iface,DWORD aspect,SIZEL * size)239c2c66affSColin Finck static HRESULT WINAPI oleobject_GetExtent(IOleObject *iface, DWORD aspect, SIZEL *size)
240c2c66affSColin Finck {
241c2c66affSColin Finck     ok(0, "unexpected call\n");
242c2c66affSColin Finck     return E_NOTIMPL;
243c2c66affSColin Finck }
244c2c66affSColin Finck 
oleobject_Advise(IOleObject * iface,IAdviseSink * sink,DWORD * connection)245c2c66affSColin Finck static HRESULT WINAPI oleobject_Advise(IOleObject *iface, IAdviseSink *sink, DWORD *connection)
246c2c66affSColin Finck {
247c2c66affSColin Finck     ok(0, "unexpected call\n");
248c2c66affSColin Finck     return E_NOTIMPL;
249c2c66affSColin Finck }
250c2c66affSColin Finck 
oleobject_Unadvise(IOleObject * iface,DWORD connection)251c2c66affSColin Finck static HRESULT WINAPI oleobject_Unadvise(IOleObject *iface, DWORD connection)
252c2c66affSColin Finck {
253c2c66affSColin Finck     ok(0, "unexpected call\n");
254c2c66affSColin Finck     return E_NOTIMPL;
255c2c66affSColin Finck }
256c2c66affSColin Finck 
oleobject_EnumAdvise(IOleObject * iface,IEnumSTATDATA ** enumadvise)257c2c66affSColin Finck static HRESULT WINAPI oleobject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **enumadvise)
258c2c66affSColin Finck {
259c2c66affSColin Finck     ok(0, "unexpected call\n");
260c2c66affSColin Finck     return E_NOTIMPL;
261c2c66affSColin Finck }
262c2c66affSColin Finck 
oleobject_GetMiscStatus(IOleObject * iface,DWORD aspect,DWORD * status)263c2c66affSColin Finck static HRESULT WINAPI oleobject_GetMiscStatus(IOleObject *iface, DWORD aspect, DWORD *status)
264c2c66affSColin Finck {
265c2c66affSColin Finck     ok(0, "unexpected call\n");
266c2c66affSColin Finck     return E_NOTIMPL;
267c2c66affSColin Finck }
268c2c66affSColin Finck 
oleobject_SetColorScheme(IOleObject * iface,LOGPALETTE * pal)269c2c66affSColin Finck static HRESULT WINAPI oleobject_SetColorScheme(IOleObject *iface, LOGPALETTE *pal)
270c2c66affSColin Finck {
271c2c66affSColin Finck     ok(0, "unexpected call\n");
272c2c66affSColin Finck     return E_NOTIMPL;
273c2c66affSColin Finck }
274c2c66affSColin Finck 
275c2c66affSColin Finck static IOleObjectVtbl oleobjectvtbl = {
276c2c66affSColin Finck     oleobject_QueryInterface,
277c2c66affSColin Finck     oleobject_AddRef,
278c2c66affSColin Finck     oleobject_Release,
279c2c66affSColin Finck     oleobject_SetClientSite,
280c2c66affSColin Finck     oleobject_GetClientSite,
281c2c66affSColin Finck     oleobject_SetHostNames,
282c2c66affSColin Finck     oleobject_Close,
283c2c66affSColin Finck     oleobject_SetMoniker,
284c2c66affSColin Finck     oleobject_GetMoniker,
285c2c66affSColin Finck     oleobject_InitFromData,
286c2c66affSColin Finck     oleobject_GetClipboardData,
287c2c66affSColin Finck     oleobject_DoVerb,
288c2c66affSColin Finck     oleobject_EnumVerbs,
289c2c66affSColin Finck     oleobject_Update,
290c2c66affSColin Finck     oleobject_IsUpToDate,
291c2c66affSColin Finck     oleobject_GetUserClassID,
292c2c66affSColin Finck     oleobject_GetUserType,
293c2c66affSColin Finck     oleobject_SetExtent,
294c2c66affSColin Finck     oleobject_GetExtent,
295c2c66affSColin Finck     oleobject_Advise,
296c2c66affSColin Finck     oleobject_Unadvise,
297c2c66affSColin Finck     oleobject_EnumAdvise,
298c2c66affSColin Finck     oleobject_GetMiscStatus,
299c2c66affSColin Finck     oleobject_SetColorScheme
300c2c66affSColin Finck };
301c2c66affSColin Finck 
302c2c66affSColin Finck static IOleObject oleobject = { &oleobjectvtbl };
303c2c66affSColin Finck 
test_OleUIAddVerbMenu(void)304c2c66affSColin Finck static void test_OleUIAddVerbMenu(void)
305c2c66affSColin Finck {
306c2c66affSColin Finck     static const WCHAR cadabraW[] = {'c','a','d','a','b','r','a',0};
307c2c66affSColin Finck     HMENU hMenu, verbmenu;
308c2c66affSColin Finck     MENUITEMINFOW info;
309c2c66affSColin Finck     WCHAR buffW[50];
310c2c66affSColin Finck     int count;
311c2c66affSColin Finck     BOOL ret;
312c2c66affSColin Finck 
313c2c66affSColin Finck     ret = OleUIAddVerbMenuW(NULL, NULL, NULL, 0, 0, 0, FALSE, 0, NULL);
314c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
315c2c66affSColin Finck 
316c2c66affSColin Finck     verbmenu = (HMENU)0xdeadbeef;
317c2c66affSColin Finck     ret = OleUIAddVerbMenuW(NULL, NULL, NULL, 0, 0, 0, FALSE, 0, &verbmenu);
318c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
319c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
320c2c66affSColin Finck 
321c2c66affSColin Finck     g_enumpos = 0;
322c2c66affSColin Finck     ret = OleUIAddVerbMenuW(&oleobject, NULL, NULL, 0, 0, 0, FALSE, 0, NULL);
323c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
324c2c66affSColin Finck 
325c2c66affSColin Finck     hMenu = CreatePopupMenu();
326c2c66affSColin Finck 
327c2c66affSColin Finck     memset(&info, 0, sizeof(info));
328c2c66affSColin Finck     info.cbSize = sizeof(info);
329c2c66affSColin Finck     ret = InsertMenuItemW(hMenu, 0, TRUE, &info);
330c2c66affSColin Finck     ok(ret, "got %d\n", ret);
331c2c66affSColin Finck 
332c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
333c2c66affSColin Finck     ok(count == 1, "got %d\n", count);
334c2c66affSColin Finck 
335c2c66affSColin Finck     g_enumpos = 0;
336c2c66affSColin Finck     ret = OleUIAddVerbMenuW(&oleobject, NULL, hMenu, 0, 0, 0, FALSE, 0, NULL);
337c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
338c2c66affSColin Finck 
339c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
340c2c66affSColin Finck     ok(count == 1, "got %d\n", count);
341c2c66affSColin Finck 
342c2c66affSColin Finck     ret = InsertMenuItemW(hMenu, 0, TRUE, &info);
343c2c66affSColin Finck     ok(ret, "got %d\n", ret);
344c2c66affSColin Finck 
345c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
346c2c66affSColin Finck     ok(count == 2, "got %d\n", count);
347c2c66affSColin Finck 
348c2c66affSColin Finck     verbmenu = (HMENU)0xdeadbeef;
349c2c66affSColin Finck     g_enumpos = 0;
350c2c66affSColin Finck     ret = OleUIAddVerbMenuW(&oleobject, NULL, hMenu, 1, 0, 0, FALSE, 0, &verbmenu);
351c2c66affSColin Finck     ok(ret, "got %d\n", ret);
352c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
353c2c66affSColin Finck 
354c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
355c2c66affSColin Finck     ok(count == 2, "got %d\n", count);
356c2c66affSColin Finck 
357c2c66affSColin Finck     /* object doesn't support EnumVerbs() */
358c2c66affSColin Finck     g_enumverbsfail = TRUE;
359c2c66affSColin Finck     g_enumpos = 0;
360c2c66affSColin Finck     verbmenu = (HMENU)0xdeadbeef;
361c2c66affSColin Finck     ret = OleUIAddVerbMenuW(&oleobject, NULL, hMenu, 2, 0, 0, FALSE, 0, &verbmenu);
362c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
363c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
364c2c66affSColin Finck     g_enumverbsfail = FALSE;
365c2c66affSColin Finck 
366c2c66affSColin Finck     /* added disabled item */
367c2c66affSColin Finck     memset(&info, 0, sizeof(info));
368c2c66affSColin Finck     info.cbSize = sizeof(info);
369c2c66affSColin Finck     info.fMask = MIIM_STATE|MIIM_SUBMENU;
370c2c66affSColin Finck     ret = GetMenuItemInfoW(hMenu, 2, TRUE, &info);
371c2c66affSColin Finck     ok(ret, "got %d\n", ret);
372c2c66affSColin Finck     ok(info.fState & MFS_DISABLED, "got state 0x%08x\n", info.fState);
373c2c66affSColin Finck     ok(info.hSubMenu == NULL, "got submenu %p\n", info.hSubMenu);
374c2c66affSColin Finck 
375c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
376c2c66affSColin Finck     ok(count == 3, "got %d\n", count);
377c2c66affSColin Finck 
378c2c66affSColin Finck     /* now without object */
379c2c66affSColin Finck     verbmenu = (HMENU)0xdeadbeef;
380c2c66affSColin Finck     ret = OleUIAddVerbMenuW(NULL, testW, hMenu, 3, 42, 0, FALSE, 0, &verbmenu);
381c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
382c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
383c2c66affSColin Finck 
384c2c66affSColin Finck     memset(&info, 0, sizeof(info));
385c2c66affSColin Finck     info.cbSize = sizeof(info);
386c2c66affSColin Finck     info.fMask = MIIM_STATE|MIIM_ID|MIIM_STRING|MIIM_SUBMENU;
387c2c66affSColin Finck     info.dwTypeData = buffW;
388*b9e30580SAmine Khaldi     info.cch = ARRAY_SIZE(buffW);
389c2c66affSColin Finck     ret = GetMenuItemInfoW(hMenu, 3, TRUE, &info);
390c2c66affSColin Finck     ok(ret, "got %d\n", ret);
391c2c66affSColin Finck     ok(info.fState == MF_GRAYED, "got state 0x%08x\n", info.fState);
392c2c66affSColin Finck     ok(info.wID == 42, "got id %d\n", info.wID);
393c2c66affSColin Finck     ok(info.hSubMenu == NULL, "got submenu %p\n", info.hSubMenu);
394c2c66affSColin Finck 
395c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
396c2c66affSColin Finck     ok(count == 4, "got %d\n", count);
397c2c66affSColin Finck 
398c2c66affSColin Finck     verbmenu = (HMENU)0xdeadbeef;
399c2c66affSColin Finck     g_enumpos = 0;
400c2c66affSColin Finck     ret = OleUIAddVerbMenuW(&oleobject, NULL, hMenu, 4, 0, 0, FALSE, 0, &verbmenu);
401c2c66affSColin Finck     ok(ret, "got %d\n", ret);
402c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
403c2c66affSColin Finck 
404c2c66affSColin Finck     /* check newly added item */
405c2c66affSColin Finck     memset(&info, 0, sizeof(info));
406c2c66affSColin Finck     info.cbSize = sizeof(info);
407c2c66affSColin Finck     info.fMask = MIIM_STRING|MIIM_STATE|MIIM_SUBMENU;
408c2c66affSColin Finck     info.dwTypeData = buffW;
409*b9e30580SAmine Khaldi     info.cch = ARRAY_SIZE(buffW);
410c2c66affSColin Finck     ret = GetMenuItemInfoW(hMenu, 4, TRUE, &info);
411c2c66affSColin Finck     ok(ret, "got %d\n", ret);
412c2c66affSColin Finck     /* Item string contains verb, usertype and localized string for 'Object' word,
413c2c66affSColin Finck        exact format depends on localization. */
414c2c66affSColin Finck     ok(strstrW(buffW, verbW) != NULL, "str %s\n", wine_dbgstr_w(buffW));
415c2c66affSColin Finck     ok(info.fState == 0, "got state 0x%08x\n", info.fState);
416c2c66affSColin Finck     ok(info.hSubMenu == NULL, "got submenu %p\n", info.hSubMenu);
417c2c66affSColin Finck 
418c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
419c2c66affSColin Finck     ok(count == 5, "got %d\n", count);
420c2c66affSColin Finck 
421c2c66affSColin Finck     DestroyMenu(hMenu);
422c2c66affSColin Finck 
423c2c66affSColin Finck     /* try to add verb menu repeatedly, with same id */
424c2c66affSColin Finck     hMenu = CreatePopupMenu();
425c2c66affSColin Finck 
426c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
427c2c66affSColin Finck     ok(count == 0, "got %d\n", count);
428c2c66affSColin Finck 
429c2c66affSColin Finck     verbmenu = NULL;
430c2c66affSColin Finck     ret = OleUIAddVerbMenuW(NULL, NULL, hMenu, 0, 5, 10, TRUE, 3, &verbmenu);
431c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
432c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
433c2c66affSColin Finck 
434c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
435c2c66affSColin Finck     ok(count == 1, "got %d\n", count);
436c2c66affSColin Finck 
437c2c66affSColin Finck     verbmenu = NULL;
438c2c66affSColin Finck     ret = OleUIAddVerbMenuW(NULL, NULL, hMenu, 0, 5, 10, TRUE, 3, &verbmenu);
439c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
440c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
441c2c66affSColin Finck 
442c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
443c2c66affSColin Finck     ok(count == 1, "got %d\n", count);
444c2c66affSColin Finck 
445c2c66affSColin Finck     /* same position, different id */
446c2c66affSColin Finck     verbmenu = NULL;
447c2c66affSColin Finck     ret = OleUIAddVerbMenuW(NULL, NULL, hMenu, 0, 6, 10, TRUE, 3, &verbmenu);
448c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
449c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
450c2c66affSColin Finck 
451c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
452c2c66affSColin Finck     ok(count == 1, "got %d\n", count);
453c2c66affSColin Finck 
454c2c66affSColin Finck     /* change added item string and state */
455c2c66affSColin Finck     memset(&info, 0, sizeof(info));
456c2c66affSColin Finck     info.cbSize = sizeof(info);
457c2c66affSColin Finck     info.fMask = MIIM_STRING|MIIM_STATE;
458c2c66affSColin Finck     info.fState = MFS_ENABLED;
459c2c66affSColin Finck     info.dwTypeData = buffW;
460c2c66affSColin Finck     lstrcpyW(buffW, cadabraW);
461c2c66affSColin Finck     ret = SetMenuItemInfoW(hMenu, 0, TRUE, &info);
462c2c66affSColin Finck     ok(ret, "got %d\n", ret);
463c2c66affSColin Finck 
464c2c66affSColin Finck     buffW[0] = 0;
465*b9e30580SAmine Khaldi     GetMenuStringW(hMenu, 0, buffW, ARRAY_SIZE(buffW), MF_BYPOSITION);
466c2c66affSColin Finck     ok(!lstrcmpW(buffW, cadabraW), "got %s\n", wine_dbgstr_w(buffW));
467c2c66affSColin Finck 
468c2c66affSColin Finck     verbmenu = NULL;
469c2c66affSColin Finck     ret = OleUIAddVerbMenuW(NULL, NULL, hMenu, 0, 5, 10, TRUE, 3, &verbmenu);
470c2c66affSColin Finck     ok(!ret, "got %d\n", ret);
471c2c66affSColin Finck     ok(verbmenu == NULL, "got %p\n", verbmenu);
472c2c66affSColin Finck 
473c2c66affSColin Finck     memset(&info, 0, sizeof(info));
474c2c66affSColin Finck     info.cbSize = sizeof(info);
475c2c66affSColin Finck     info.fMask = MIIM_STRING|MIIM_STATE;
476c2c66affSColin Finck     buffW[0] = 0;
477c2c66affSColin Finck     info.dwTypeData = buffW;
478*b9e30580SAmine Khaldi     info.cch = ARRAY_SIZE(buffW);
479c2c66affSColin Finck     ret = GetMenuItemInfoW(hMenu, 0, TRUE, &info);
480c2c66affSColin Finck     ok(ret, "got %d\n", ret);
481c2c66affSColin Finck     ok(lstrcmpW(buffW, cadabraW), "got %s\n", wine_dbgstr_w(buffW));
482c2c66affSColin Finck     ok(info.fState == MF_GRAYED, "got state 0x%08x\n", info.fState);
483c2c66affSColin Finck 
484c2c66affSColin Finck     count = GetMenuItemCount(hMenu);
485c2c66affSColin Finck     ok(count == 1, "got %d\n", count);
486c2c66affSColin Finck 
487c2c66affSColin Finck     DestroyMenu(hMenu);
488c2c66affSColin Finck }
489c2c66affSColin Finck 
START_TEST(main)490c2c66affSColin Finck START_TEST(main)
491c2c66affSColin Finck {
492c2c66affSColin Finck     test_OleUIAddVerbMenu();
493c2c66affSColin Finck }
494