2 * Copyright 2006 Jacek 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
22 #include <wine/test.h>
32 #define DEFINE_EXPECT(func) \
33 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
35 #define SET_EXPECT(func) \
36 expect_ ## func = TRUE
38 #define CHECK_EXPECT(func) \
40 ok(expect_ ##func, "unexpected call " #func "\n"); \
41 expect_ ## func = FALSE; \
42 called_ ## func = TRUE; \
45 #define CHECK_EXPECT2(func) \
47 ok(expect_ ##func, "unexpected call " #func "\n"); \
48 called_ ## func = TRUE; \
51 #define CHECK_CALLED(func) \
53 ok(called_ ## func, "expected " #func "\n"); \
54 expect_ ## func = called_ ## func = FALSE; \
57 DEFINE_EXPECT(GetContainer);
58 DEFINE_EXPECT(Site_GetWindow);
59 DEFINE_EXPECT(ShowObject);
60 DEFINE_EXPECT(CanInPlaceActivate);
61 DEFINE_EXPECT(OnInPlaceActivate);
62 DEFINE_EXPECT(OnUIActivate);
63 DEFINE_EXPECT(GetWindowContext);
64 DEFINE_EXPECT(Frame_GetWindow);
65 DEFINE_EXPECT(Frame_SetActiveObject);
66 DEFINE_EXPECT(UIWindow_SetActiveObject);
67 DEFINE_EXPECT(SetMenu);
69 static const WCHAR wszItem[] = {'i','t','e','m',0};
71 static HWND container_hwnd, shell_embedding_hwnd;
73 static HRESULT QueryInterface(REFIID,void**);
75 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
77 if(IsEqualGUID(&IID_ITargetContainer, riid))
78 return E_NOINTERFACE; /* TODO */
79 if(IsEqualGUID(&IID_IOleCommandTarget, riid))
80 return E_NOINTERFACE; /* TODO */
82 ok(0, "unexpected call\n");
86 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
91 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
96 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
97 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
99 ok(0, "unexpected call\n");
103 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
104 IEnumUnknown **ppenum)
106 ok(0, "unexpected call\n");
110 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
112 ok(0, "unexpected call\n");
116 static const IOleContainerVtbl OleContainerVtbl = {
117 OleContainer_QueryInterface,
119 OleContainer_Release,
120 OleContainer_ParseDisplayName,
121 OleContainer_EnumObjects,
122 OleContainer_LockContainer
125 static IOleContainer OleContainer = { &OleContainerVtbl };
127 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
129 return QueryInterface(riid, ppv);
132 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
137 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
142 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
144 ok(0, "unexpected call\n");
148 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAsign, DWORD dwWhichMoniker,
151 ok(0, "unexpected call\n");
155 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
157 CHECK_EXPECT(GetContainer);
159 ok(ppContainer != NULL, "ppContainer == NULL\n");
161 *ppContainer = &OleContainer;
166 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
168 CHECK_EXPECT(ShowObject);
172 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
174 ok(0, "unexpected call\n");
178 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
180 ok(0, "unexpected call\n");
184 static const IOleClientSiteVtbl ClientSiteVtbl = {
185 ClientSite_QueryInterface,
188 ClientSite_SaveObject,
189 ClientSite_GetMoniker,
190 ClientSite_GetContainer,
191 ClientSite_ShowObject,
192 ClientSite_OnShowWindow,
193 ClientSite_RequestNewObjectLayout
196 static IOleClientSite ClientSite = { &ClientSiteVtbl };
198 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
199 REFIID riid, void **ppv)
201 ok(0, "unexpected call\n");
202 return E_NOINTERFACE;
205 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
210 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
215 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
217 ok(0, "unexpected call\n");
221 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
223 CHECK_EXPECT(Frame_GetWindow);
224 ok(phwnd != NULL, "phwnd == NULL\n");
226 *phwnd = container_hwnd;
230 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
232 ok(0, "unexpected call\n");
236 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
238 ok(0, "unexpected call\n");
242 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
243 LPCBORDERWIDTHS pborderwidths)
245 ok(0, "unexpected call\n");
249 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
250 LPCBORDERWIDTHS pborderwidths)
252 ok(0, "unexpected call\n");
256 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
257 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
259 CHECK_EXPECT(UIWindow_SetActiveObject);
260 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
261 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
265 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
266 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
268 CHECK_EXPECT(Frame_SetActiveObject);
269 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
270 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
274 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
275 LPOLEMENUGROUPWIDTHS lpMenuWidths)
277 ok(0, "unexpected call\n");
281 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
282 HOLEMENU holemenu, HWND hwndActiveObject)
284 CHECK_EXPECT(SetMenu);
285 ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
286 ok(holemenu == NULL, "holemenu=%p\n", holemenu);
287 ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
288 hwndActiveObject, shell_embedding_hwnd);
292 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
294 ok(0, "unexpected call\n");
298 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
300 ok(0, "unexpected call\n");
304 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
306 ok(0, "unexpected call\n");
310 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
312 ok(0, "unexpected call\n");
316 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
317 InPlaceUIWindow_QueryInterface,
318 InPlaceUIWindow_AddRef,
319 InPlaceUIWindow_Release,
320 InPlaceUIWindow_GetWindow,
321 InPlaceUIWindow_ContextSensitiveHelp,
322 InPlaceUIWindow_GetBorder,
323 InPlaceUIWindow_RequestBorderSpace,
324 InPlaceUIWindow_SetBorderSpace,
325 InPlaceUIWindow_SetActiveObject,
328 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
330 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
331 InPlaceUIWindow_QueryInterface,
332 InPlaceUIWindow_AddRef,
333 InPlaceUIWindow_Release,
334 InPlaceFrame_GetWindow,
335 InPlaceUIWindow_ContextSensitiveHelp,
336 InPlaceUIWindow_GetBorder,
337 InPlaceUIWindow_RequestBorderSpace,
338 InPlaceUIWindow_SetBorderSpace,
339 InPlaceFrame_SetActiveObject,
340 InPlaceFrame_InsertMenus,
341 InPlaceFrame_SetMenu,
342 InPlaceFrame_RemoveMenus,
343 InPlaceFrame_SetStatusText,
344 InPlaceFrame_EnableModeless,
345 InPlaceFrame_TranslateAccelerator
348 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
350 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
352 return QueryInterface(riid, ppv);
355 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
360 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
365 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
367 CHECK_EXPECT(Site_GetWindow);
368 ok(phwnd != NULL, "phwnd == NULL\n");
370 *phwnd = container_hwnd;
374 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
376 ok(0, "unexpected call\n");
380 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
382 CHECK_EXPECT(CanInPlaceActivate);
386 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
388 CHECK_EXPECT(OnInPlaceActivate);
392 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
394 CHECK_EXPECT(OnUIActivate);
398 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
399 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
400 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
402 static const RECT pos_rect = {2,1,1002,901};
403 static const RECT clip_rect = {10,10,990,890};
405 CHECK_EXPECT(GetWindowContext);
407 ok(ppFrame != NULL, "ppFrame = NULL\n");
409 *ppFrame = &InPlaceFrame;
411 ok(ppDoc != NULL, "ppDoc = NULL\n");
413 *ppDoc = &InPlaceUIWindow;
415 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
417 memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
419 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
421 memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
423 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
425 lpFrameInfo->cb = sizeof(*lpFrameInfo);
426 lpFrameInfo->fMDIApp = FALSE;
427 lpFrameInfo->hwndFrame = container_hwnd;
428 lpFrameInfo->haccel = NULL;
429 lpFrameInfo->cAccelEntries = 0;
435 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
437 ok(0, "unexpected call\n");
441 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
443 ok(0, "unexpected call\n");
447 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
449 ok(0, "unexpected call\n");
453 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
455 ok(0, "unexpected call\n");
459 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
461 ok(0, "unexpected call\n");
465 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
467 ok(0, "unexpected call\n");
471 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
472 BOOL *pNoRedraw, DWORD dwFlags)
474 ok(0, "unexpected call\n");
478 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
481 ok(0, "unexpected call\n");
485 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
487 ok(0, "unexpected call\n");
491 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
492 InPlaceSite_QueryInterface,
495 InPlaceSite_GetWindow,
496 InPlaceSite_ContextSensitiveHelp,
497 InPlaceSite_CanInPlaceActivate,
498 InPlaceSite_OnInPlaceActivate,
499 InPlaceSite_OnUIActivate,
500 InPlaceSite_GetWindowContext,
502 InPlaceSite_OnUIDeactivate,
503 InPlaceSite_OnInPlaceDeactivate,
504 InPlaceSite_DiscardUndoState,
505 InPlaceSite_DeactivateAndUndo,
506 InPlaceSite_OnPosRectChange,
507 InPlaceSite_OnInPlaceActivateEx,
508 InPlaceSite_OnInPlaceDeactivateEx,
509 InPlaceSite_RequestUIActivate
512 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
514 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
516 return QueryInterface(riid, ppv);
519 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
524 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
529 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
530 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
532 ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
536 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
538 ok(0, "unexpected call\n");
542 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
543 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
544 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
546 ok(0, "unexpected call\n");
550 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
552 ok(0, "unexpected call\n");
556 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
558 ok(0, "unexpected call\n");
562 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
564 ok(0, "unexpected call\n");
568 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
570 ok(0, "unexpected call\n");
574 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
576 ok(0, "unexpected call\n");
580 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
581 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
583 ok(0, "unexpected call\n");
587 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
588 const GUID *pguidCmdGroup, DWORD nCmdID)
590 ok(0, "unexpected call\n");
594 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
595 LPOLESTR *pchKey, DWORD dw)
597 ok(0, "unexpected call\n");
601 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
602 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
604 ok(0, "unexpected call\n");
608 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
610 ok(0, "unexpected call\n");
614 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
615 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
617 ok(0, "unexpected call\n");
621 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
622 IDataObject **ppPORet)
624 ok(0, "unexpected call\n");
628 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
629 LPOLESTR *pchKey, DWORD dw)
631 ok(0, "unexpected call\n");
635 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
636 DocHostUIHandler_QueryInterface,
637 DocHostUIHandler_AddRef,
638 DocHostUIHandler_Release,
639 DocHostUIHandler_ShowContextMenu,
640 DocHostUIHandler_GetHostInfo,
641 DocHostUIHandler_ShowUI,
642 DocHostUIHandler_HideUI,
643 DocHostUIHandler_UpdateUI,
644 DocHostUIHandler_EnableModeless,
645 DocHostUIHandler_OnDocWindowActivate,
646 DocHostUIHandler_OnFrameWindowActivate,
647 DocHostUIHandler_ResizeBorder,
648 DocHostUIHandler_TranslateAccelerator,
649 DocHostUIHandler_GetOptionKeyPath,
650 DocHostUIHandler_GetDropTarget,
651 DocHostUIHandler_GetExternal,
652 DocHostUIHandler_TranslateUrl,
653 DocHostUIHandler_FilterDataObject,
654 DocHostUIHandler_GetOverrideKeyPath
657 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
659 static HRESULT QueryInterface(REFIID riid, void **ppv)
663 if(IsEqualGUID(&IID_IUnknown, riid)
664 || IsEqualGUID(&IID_IOleClientSite, riid))
666 else if(IsEqualGUID(&IID_IOleWindow, riid)
667 || IsEqualGUID(&IID_IOleInPlaceSite, riid)
668 || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
670 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
671 || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
672 *ppv = &DocHostUIHandler;
677 return E_NOINTERFACE;
680 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
682 return DefWindowProcW(hwnd, msg, wParam, lParam);
685 static HWND create_container_window(void)
687 static const WCHAR wszWebBrowserContainer[] =
688 {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
689 static WNDCLASSEXW wndclass = {
693 0, 0, NULL, NULL, NULL, NULL, NULL,
694 wszWebBrowserContainer,
698 RegisterClassExW(&wndclass);
699 return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
700 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
701 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
704 static void test_DoVerb(IUnknown *unk)
707 RECT rect = {0,0,1000,1000};
710 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
711 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
715 SET_EXPECT(CanInPlaceActivate);
716 SET_EXPECT(Site_GetWindow);
717 SET_EXPECT(OnInPlaceActivate);
718 SET_EXPECT(GetWindowContext);
719 SET_EXPECT(ShowObject);
720 SET_EXPECT(GetContainer);
721 SET_EXPECT(Frame_GetWindow);
722 SET_EXPECT(OnUIActivate);
723 SET_EXPECT(Frame_SetActiveObject);
724 SET_EXPECT(UIWindow_SetActiveObject);
727 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
728 0, (HWND)0xdeadbeef, &rect);
729 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
731 CHECK_CALLED(CanInPlaceActivate);
732 CHECK_CALLED(Site_GetWindow);
733 CHECK_CALLED(OnInPlaceActivate);
734 CHECK_CALLED(GetWindowContext);
735 CHECK_CALLED(ShowObject);
736 CHECK_CALLED(GetContainer);
737 CHECK_CALLED(Frame_GetWindow);
738 CHECK_CALLED(OnUIActivate);
739 CHECK_CALLED(Frame_SetActiveObject);
740 CHECK_CALLED(UIWindow_SetActiveObject);
741 CHECK_CALLED(SetMenu);
743 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
744 0, (HWND)0xdeadbeef, &rect);
745 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
747 IOleObject_Release(oleobj);
750 static void test_GetMiscStatus(IOleObject *oleobj)
755 for(i=0; i<10; i++) {
757 hres = IOleObject_GetMiscStatus(oleobj, i, &st);
758 ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
759 ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
760 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
761 "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
762 "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
766 static void test_ClientSite(IUnknown *unk, IOleClientSite *client)
769 IOleInPlaceObject *inplace;
773 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
774 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
778 test_GetMiscStatus(oleobj);
780 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
781 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
783 IOleObject_Release(oleobj);
787 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
788 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
789 ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
792 SET_EXPECT(GetContainer);
793 SET_EXPECT(Site_GetWindow);
796 hres = IOleObject_SetClientSite(oleobj, client);
797 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
800 CHECK_CALLED(GetContainer);
801 CHECK_CALLED(Site_GetWindow);
804 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
805 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
806 ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
808 shell_embedding_hwnd = hwnd;
810 IOleInPlaceObject_Release(inplace);
811 IOleObject_Release(oleobj);
814 static void test_ClassInfo(IUnknown *unk)
816 IProvideClassInfo2 *class_info;
820 hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
821 ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo) failed: %08x\n", hres);
825 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
826 ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
827 ok(IsEqualGUID(&DIID_DWebBrowserEvents2, &guid), "wrong guid\n");
829 hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
830 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
831 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
833 hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
834 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
835 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
837 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
838 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
840 hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
841 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
843 IProvideClassInfo2_Release(class_info);
846 static void test_ie_funcs(IUnknown *unk)
854 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
855 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
862 hres = IWebBrowser2_get_HWND(wb, &hwnd);
863 ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
864 ok(hwnd == 0, "unexpected hwnd %lx\n", hwnd);
868 hres = IWebBrowser2_get_MenuBar(wb, &b);
869 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
870 ok(b == VARIANT_TRUE, "b=%x\n", b);
872 hres = IWebBrowser2_put_MenuBar(wb, VARIANT_FALSE);
873 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
875 hres = IWebBrowser2_get_MenuBar(wb, &b);
876 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
877 ok(b == VARIANT_FALSE, "b=%x\n", b);
879 hres = IWebBrowser2_put_MenuBar(wb, 100);
880 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
882 hres = IWebBrowser2_get_MenuBar(wb, &b);
883 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
884 ok(b == VARIANT_TRUE, "b=%x\n", b);
888 hres = IWebBrowser2_get_AddressBar(wb, &b);
889 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
890 ok(b == VARIANT_TRUE, "b=%x\n", b);
892 hres = IWebBrowser2_put_AddressBar(wb, VARIANT_FALSE);
893 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
895 hres = IWebBrowser2_get_AddressBar(wb, &b);
896 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
897 ok(b == VARIANT_FALSE, "b=%x\n", b);
899 hres = IWebBrowser2_put_AddressBar(wb, 100);
900 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
902 hres = IWebBrowser2_get_AddressBar(wb, &b);
903 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
904 ok(b == VARIANT_TRUE, "b=%x\n", b);
906 hres = IWebBrowser2_put_AddressBar(wb, VARIANT_TRUE);
907 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
911 hres = IWebBrowser2_get_StatusBar(wb, &b);
912 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
913 ok(b == VARIANT_TRUE, "b=%x\n", b);
915 hres = IWebBrowser2_put_StatusBar(wb, VARIANT_TRUE);
916 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
918 hres = IWebBrowser2_get_StatusBar(wb, &b);
919 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
920 ok(b == VARIANT_TRUE, "b=%x\n", b);
922 hres = IWebBrowser2_put_StatusBar(wb, VARIANT_FALSE);
923 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
925 hres = IWebBrowser2_get_StatusBar(wb, &b);
926 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
927 ok(b == VARIANT_FALSE, "b=%x\n", b);
929 hres = IWebBrowser2_put_StatusBar(wb, 100);
930 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
932 hres = IWebBrowser2_get_StatusBar(wb, &b);
933 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
934 ok(b == VARIANT_TRUE, "b=%x\n", b);
938 hres = IWebBrowser2_get_ToolBar(wb, &i);
939 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
940 ok(i == VARIANT_TRUE, "i=%x\n", i);
942 hres = IWebBrowser2_put_ToolBar(wb, VARIANT_FALSE);
943 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
945 hres = IWebBrowser2_get_ToolBar(wb, &i);
946 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
947 ok(i == VARIANT_FALSE, "b=%x\n", i);
949 hres = IWebBrowser2_put_ToolBar(wb, 100);
950 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
952 hres = IWebBrowser2_get_ToolBar(wb, &i);
953 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
954 ok(i == VARIANT_TRUE, "i=%x\n", i);
956 hres = IWebBrowser2_put_ToolBar(wb, VARIANT_TRUE);
957 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
959 IWebBrowser2_Release(wb);
962 static void test_Silent(IUnknown *unk)
968 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
969 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
974 hres = IWebBrowser2_get_Silent(wb, &b);
975 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
976 ok(b == VARIANT_FALSE, "b=%x\n", b);
978 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
979 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
982 hres = IWebBrowser2_get_Silent(wb, &b);
983 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
984 ok(b == VARIANT_TRUE, "b=%x\n", b);
986 hres = IWebBrowser2_put_Silent(wb, 100);
987 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
990 hres = IWebBrowser2_get_Silent(wb, &b);
991 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
992 ok(b == VARIANT_TRUE, "b=%x\n", b);
994 hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
995 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
998 hres = IWebBrowser2_get_Silent(wb, &b);
999 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1000 ok(b == VARIANT_FALSE, "b=%x\n", b);
1002 IWebBrowser_Release(wb);
1005 static void test_GetControlInfo(IUnknown *unk)
1007 IOleControl *control;
1011 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
1012 ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
1016 hres = IOleControl_GetControlInfo(control, &info);
1017 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, exxpected E_NOTIMPL\n", hres);
1018 hres = IOleControl_GetControlInfo(control, NULL);
1019 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, exxpected E_NOTIMPL\n", hres);
1021 IOleControl_Release(control);
1024 static void test_Extent(IUnknown *unk)
1030 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1031 ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
1035 size.cx = size.cy = 0xdeadbeef;
1036 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
1037 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1038 ok(size.cx == 1323 && size.cy == 529, "size = {%d %d}\n", size.cx, size.cy);
1042 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
1043 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
1045 size.cx = size.cy = 0xdeadbeef;
1046 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
1047 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1048 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
1050 size.cx = size.cy = 0xdeadbeef;
1051 hres = IOleObject_GetExtent(oleobj, 0, &size);
1052 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1053 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
1057 hres = IOleObject_SetExtent(oleobj, 0, &size);
1058 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
1060 size.cx = size.cy = 0xdeadbeef;
1061 hres = IOleObject_GetExtent(oleobj, 0, &size);
1062 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1063 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
1065 size.cx = size.cy = 0xdeadbeef;
1066 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
1067 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1068 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
1072 hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
1073 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
1075 size.cx = size.cy = 0xdeadbeef;
1076 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
1077 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1078 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
1080 size.cx = size.cy = 0xdeadbeef;
1081 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
1082 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1083 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
1085 IOleObject_Release(oleobj);
1088 static void test_QueryInterface(IUnknown *unk)
1090 IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
1091 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
1094 hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
1095 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
1096 ok(qa == NULL, "qa=%p, ezpected NULL\n", qa);
1098 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
1099 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
1100 ok(runnable == NULL, "runnable=%p, ezpected NULL\n", runnable);
1103 static void test_WebBrowser(void)
1105 IUnknown *unk = NULL;
1109 hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1110 &IID_IUnknown, (void**)&unk);
1111 ok(hres == S_OK, "CoCreateInterface failed: %08x\n", hres);
1115 test_QueryInterface(unk);
1116 test_ClassInfo(unk);
1117 test_ClientSite(unk, &ClientSite);
1120 test_ClientSite(unk, NULL);
1122 test_GetControlInfo(unk);
1125 ref = IUnknown_Release(unk);
1126 ok(ref == 0, "ref=%d, expected 0\n", ref);
1129 START_TEST(webbrowser)
1131 container_hwnd = create_container_window();
1133 OleInitialize(NULL);