2 * Copyright 2005 Jacek Caban
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <wine/test.h>
31 #define DEFINE_EXPECT(func) \
32 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
34 #define SET_EXPECT(func) \
35 expect_ ## func = TRUE
37 #define CHECK_EXPECT(func) \
38 ok(expect_ ##func, "unexpected call\n"); \
39 expect_ ## func = FALSE; \
40 called_ ## func = TRUE
42 #define CHECK_CALLED(func) \
43 ok(called_ ## func, "unexpected call\n"); \
44 expect_ ## func = called_ ## func = FALSE
46 static IUnknown *htmldoc_unk = NULL;
47 static IOleDocumentView *view = NULL;
48 static HWND container_hwnd = NULL, hwnd = NULL;
50 DEFINE_EXPECT(LockContainer);
51 DEFINE_EXPECT(SetActiveObject);
52 DEFINE_EXPECT(GetWindow);
53 DEFINE_EXPECT(CanInPlaceActivate);
54 DEFINE_EXPECT(OnInPlaceActivate);
55 DEFINE_EXPECT(OnUIActivate);
56 DEFINE_EXPECT(GetWindowContext);
57 DEFINE_EXPECT(OnUIDeactivate);
58 DEFINE_EXPECT(OnInPlaceDeactivate);
59 DEFINE_EXPECT(GetContainer);
60 DEFINE_EXPECT(ShowUI);
61 DEFINE_EXPECT(ActivateMe);
62 DEFINE_EXPECT(GetHostInfo);
63 DEFINE_EXPECT(HideUI);
64 DEFINE_EXPECT(GetOptionKeyPath);
65 DEFINE_EXPECT(GetOverrideKeyPath);
67 static BOOL expect_LockContainer_fLock;
68 static BOOL expect_SetActiveObject_active;
70 static HRESULT QueryInterface(REFIID riid, void **ppv);
72 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
74 return QueryInterface(riid, ppv);
77 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
82 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
87 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
88 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
90 ok(0, "unexpected call\n");
94 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
95 IEnumUnknown **ppenum)
97 ok(0, "unexpected call\n");
101 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
103 CHECK_EXPECT(LockContainer);
104 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
108 static const IOleContainerVtbl OleContainerVtbl = {
109 OleContainer_QueryInterface,
111 OleContainer_Release,
112 OleContainer_ParseDisplayName,
113 OleContainer_EnumObjects,
114 OleContainer_LockContainer
117 static IOleContainer OleContainer = { &OleContainerVtbl };
119 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
121 return QueryInterface(riid, ppv);
124 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
129 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
134 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
136 ok(0, "unexpected call\n");
140 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
142 ok(0, "unexpected call\n");
146 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
148 ok(0, "unexpected call\n");
152 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
153 LPCBORDERWIDTHS pborderwidths)
155 ok(0, "unexpected call\n");
159 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
160 LPCBORDERWIDTHS pborderwidths)
162 ok(0, "unexpected call\n");
166 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
167 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
169 static const WCHAR wszHTML_Document[] =
170 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
172 ok(expect_SetActiveObject, "unexpected call\n");
173 called_SetActiveObject = TRUE;
175 if(expect_SetActiveObject_active) {
176 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
177 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
179 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
180 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
186 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
187 LPOLEMENUGROUPWIDTHS lpMenuWidths)
189 ok(0, "unexpected call\n");
193 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
194 HOLEMENU holemenu, HWND hwndActiveObject)
196 ok(0, "unexpected call\n");
200 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
202 ok(0, "unexpected call\n");
206 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
208 ok(0, "unexpected call\n");
212 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
214 ok(0, "unexpected call\n");
218 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
220 ok(0, "unexpected call\n");
224 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
225 InPlaceFrame_QueryInterface,
227 InPlaceFrame_Release,
228 InPlaceFrame_GetWindow,
229 InPlaceFrame_ContextSensitiveHelp,
230 InPlaceFrame_GetBorder,
231 InPlaceFrame_RequestBorderSpace,
232 InPlaceFrame_SetBorderSpace,
233 InPlaceFrame_SetActiveObject,
234 InPlaceFrame_InsertMenus,
235 InPlaceFrame_SetMenu,
236 InPlaceFrame_RemoveMenus,
237 InPlaceFrame_SetStatusText,
238 InPlaceFrame_EnableModeless,
239 InPlaceFrame_TranslateAccelerator
242 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
244 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
246 return QueryInterface(riid, ppv);
249 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
254 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
259 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
261 CHECK_EXPECT(GetWindow);
262 ok(phwnd != NULL, "phwnd = NULL\n");
263 *phwnd = container_hwnd;
267 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
269 ok(0, "unexpected call\n");
273 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
275 CHECK_EXPECT(CanInPlaceActivate);
279 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
281 CHECK_EXPECT(OnInPlaceActivate);
285 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
287 CHECK_EXPECT(OnUIActivate);
291 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
292 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
293 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
295 static const RECT rect = {0,0,500,500};
297 CHECK_EXPECT(GetWindowContext);
299 ok(ppFrame != NULL, "ppFrame = NULL\n");
301 *ppFrame = &InPlaceFrame;
302 ok(ppDoc != NULL, "ppDoc = NULL\n");
305 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
307 memcpy(lprcPosRect, &rect, sizeof(RECT));
308 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
310 memcpy(lprcClipRect, &rect, sizeof(RECT));
311 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
313 lpFrameInfo->cb = sizeof(*lpFrameInfo);
314 lpFrameInfo->fMDIApp = FALSE;
315 lpFrameInfo->hwndFrame = container_hwnd;
316 lpFrameInfo->haccel = NULL;
317 lpFrameInfo->cAccelEntries = 0;
323 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtant)
325 ok(0, "unexpected call\n");
329 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
331 CHECK_EXPECT(OnUIDeactivate);
332 ok(!fUndoable, "fUndoable = TRUE\n");
336 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
338 CHECK_EXPECT(OnInPlaceDeactivate);
342 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
344 ok(0, "unexpected call\n");
348 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
350 ok(0, "unexpected call\n");
354 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
356 ok(0, "unexpected call\n");
360 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl = {
361 InPlaceSite_QueryInterface,
364 InPlaceSite_GetWindow,
365 InPlaceSite_ContextSensitiveHelp,
366 InPlaceSite_CanInPlaceActivate,
367 InPlaceSite_OnInPlaceActivate,
368 InPlaceSite_OnUIActivate,
369 InPlaceSite_GetWindowContext,
371 InPlaceSite_OnUIDeactivate,
372 InPlaceSite_OnInPlaceDeactivate,
373 InPlaceSite_DiscardUndoState,
374 InPlaceSite_DeactivateAndUndo,
375 InPlaceSite_OnPosRectChange
378 static IOleInPlaceSite InPlaceSite = { &InPlaceSiteVtbl };
380 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
382 return QueryInterface(riid, ppv);
385 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
390 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
395 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
397 ok(0, "unexpected call\n");
401 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAsign, DWORD dwWhichMoniker,
404 ok(0, "unexpected call\n");
408 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
410 CHECK_EXPECT(GetContainer);
411 ok(ppContainer != NULL, "ppContainer = NULL\n");
412 *ppContainer = &OleContainer;
416 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
418 ok(0, "unexpected call\n");
422 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
424 ok(0, "unexpected call\n");
428 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
430 ok(0, "unexpected call\n");
434 static const IOleClientSiteVtbl ClientSiteVtbl = {
435 ClientSite_QueryInterface,
438 ClientSite_SaveObject,
439 ClientSite_GetMoniker,
440 ClientSite_GetContainer,
441 ClientSite_ShowObject,
442 ClientSite_OnShowWindow,
443 ClientSite_RequestNewObjectLayout
446 static IOleClientSite ClientSite = { &ClientSiteVtbl };
448 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
450 return QueryInterface(riid, ppv);
453 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
458 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
463 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
465 IOleDocument *document;
468 CHECK_EXPECT(ActivateMe);
469 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
471 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleDocument, (void**)&document);
472 ok(hres == S_OK, "could not get IOleDocument: %08lx\n", hres);
474 if(SUCCEEDED(hres)) {
475 hres = IOleDocument_CreateView(document, &InPlaceSite, NULL, 0, &view);
476 ok(hres == S_OK, "CreateView failed: %08lx\n", hres);
478 if(SUCCEEDED(hres)) {
479 IOleInPlaceActiveObject *activeobj = NULL;
480 IOleInPlaceSite *inplacesite = NULL;
481 HWND tmp_hwnd = NULL;
482 static RECT rect = {0,0,400,500};
484 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
485 ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
486 ok(inplacesite == &InPlaceSite, "inplacesite=%p, expected %p\n",
487 inplacesite, &InPlaceSite);
489 hres = IOleDocumentView_SetInPlaceSite(view, &InPlaceSite);
490 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
492 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
493 ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
494 ok(inplacesite == &InPlaceSite, "inplacesite=%p, expected %p\n",
495 inplacesite, &InPlaceSite);
497 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
498 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08lx\n", hres);
501 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
502 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
503 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
506 SET_EXPECT(CanInPlaceActivate);
507 SET_EXPECT(GetWindowContext);
508 SET_EXPECT(GetWindow);
509 SET_EXPECT(OnInPlaceActivate);
510 SET_EXPECT(OnUIActivate);
511 SET_EXPECT(SetActiveObject);
513 expect_SetActiveObject_active = TRUE;
514 hres = IOleDocumentView_UIActivate(view, TRUE);
515 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
516 CHECK_CALLED(CanInPlaceActivate);
517 CHECK_CALLED(GetWindowContext);
518 CHECK_CALLED(GetWindow);
519 CHECK_CALLED(OnInPlaceActivate);
520 CHECK_CALLED(OnUIActivate);
521 CHECK_CALLED(SetActiveObject);
522 CHECK_CALLED(ShowUI);
525 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
526 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
527 ok(hwnd != NULL, "hwnd == NULL\n");
530 hres = IOleDocumentView_UIActivate(view, TRUE);
531 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
534 IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
535 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
536 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
539 hres = IOleDocumentView_SetRect(view, &rect);
540 ok(hres == S_OK, "SetRect failed: %08lx\n", hres);
542 hres = IOleDocumentView_Show(view, TRUE);
543 ok(hres == S_OK, "Show failed: %08lx\n", hres);
546 IOleInPlaceActiveObject_Release(activeobj);
549 IOleDocument_Release(document);
555 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
556 DocumentSite_QueryInterface,
558 DocumentSite_Release,
559 DocumentSite_ActivateMe
562 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
564 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
566 return QueryInterface(riid, ppv);
569 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
574 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
579 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
580 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
582 ok(0, "unexpected call\n");
586 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
588 CHECK_EXPECT(GetHostInfo);
589 ok(pInfo != NULL, "pInfo=NULL\n");
591 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%lu, expected %u\n",
592 pInfo->cbSize, sizeof(DOCHOSTUIINFO));
593 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08lx, expected 0\n", pInfo->dwFlags);
594 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
595 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
596 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
597 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08lx, expected 0\n", pInfo->dwDoubleClick);
598 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
599 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
604 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
605 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
606 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
608 CHECK_EXPECT(ShowUI);
610 ok(dwID == 0, "dwID=%ld, expected 0\n", dwID);
611 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
612 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
613 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
614 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
619 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
621 CHECK_EXPECT(HideUI);
625 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
627 ok(0, "unexpected call\n");
631 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
633 ok(0, "unexpected call\n");
637 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
639 ok(0, "unexpected call\n");
643 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
645 ok(0, "unexpected call\n");
649 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
650 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
652 ok(0, "unexpected call\n");
656 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
657 const GUID *pguidCmdGroup, DWORD nCmdID)
659 ok(0, "unexpected call\n");
663 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
664 LPOLESTR *pchKey, DWORD dw)
666 CHECK_EXPECT(GetOptionKeyPath);
667 ok(pchKey != NULL, "pchKey = NULL\n");
668 ok(!dw, "dw=%ld, expected 0\n", dw);
670 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
674 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
675 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
677 ok(0, "unexpected call\n");
681 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
683 ok(0, "unexpected call\n");
687 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
688 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
690 ok(0, "unexpected call\n");
694 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
695 IDataObject **ppPORet)
697 ok(0, "unexpected call\n");
701 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
702 LPOLESTR *pchKey, DWORD dw)
704 CHECK_EXPECT(GetOverrideKeyPath);
705 ok(pchKey != NULL, "pchKey = NULL\n");
707 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
708 ok(!dw, "dw=%ld, xepected 0\n", dw);
712 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
713 DocHostUIHandler_QueryInterface,
714 DocHostUIHandler_AddRef,
715 DocHostUIHandler_Release,
716 DocHostUIHandler_ShowContextMenu,
717 DocHostUIHandler_GetHostInfo,
718 DocHostUIHandler_ShowUI,
719 DocHostUIHandler_HideUI,
720 DocHostUIHandler_UpdateUI,
721 DocHostUIHandler_EnableModeless,
722 DocHostUIHandler_OnDocWindowActivate,
723 DocHostUIHandler_OnFrameWindowActivate,
724 DocHostUIHandler_ResizeBorder,
725 DocHostUIHandler_TranslateAccelerator,
726 DocHostUIHandler_GetOptionKeyPath,
727 DocHostUIHandler_GetDropTarget,
728 DocHostUIHandler_GetExternal,
729 DocHostUIHandler_TranslateUrl,
730 DocHostUIHandler_FilterDataObject,
731 DocHostUIHandler_GetOverrideKeyPath
734 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
736 static HRESULT QueryInterface(REFIID riid, void **ppv)
740 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
742 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
743 *ppv = &DocumentSite;
744 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
745 *ppv = &DocHostUIHandler;
747 else if(IsEqualGUID(&IID_IOleContainer, riid))
748 *ppv = &OleContainer;
749 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
751 else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid) || IsEqualGUID(&IID_IOleInPlaceFrame, riid))
752 *ppv = &InPlaceFrame;
758 * {D48A6EC6-6A4A-11CF-94A7-444553540000}
759 * {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
760 * {000670BA-0000-0000-C000-000000000046}
765 return E_NOINTERFACE;
768 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
770 return DefWindowProc(hwnd, msg, wParam, lParam);
773 static void test_Persist()
775 IPersistMoniker *persist_mon;
776 IPersistFile *persist_file;
780 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IPersistFile, (void**)&persist_file);
781 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08lx\n", hres);
782 if(SUCCEEDED(hres)) {
783 hres = IPersist_GetClassID(persist_file, NULL);
784 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
786 hres = IPersist_GetClassID(persist_file, &guid);
787 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
788 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
790 IPersist_Release(persist_file);
793 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IPersistMoniker, (void**)&persist_mon);
794 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08lx\n", hres);
795 if(SUCCEEDED(hres)) {
796 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
797 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
799 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
800 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
801 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
803 IPersistMoniker_Release(persist_mon);
807 static void test_HTMLDocument(void)
809 IOleObject *oleobj = NULL;
810 IOleClientSite *clientsite = (LPVOID)0xdeadbeef;
811 IOleInPlaceObjectWindowless *windowlessobj = NULL;
812 IOleInPlaceActiveObject *activeobject = NULL;
814 RECT rect = {0,0,500,500};
818 static const WCHAR wszHTMLDocumentTest[] =
819 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
820 static const WNDCLASSEXW wndclass = {
824 0, 0, NULL, NULL, NULL, NULL, NULL,
829 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
830 &IID_IUnknown, (void**)&htmldoc_unk);
831 ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
835 RegisterClassExW(&wndclass);
836 container_hwnd = CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
837 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
838 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
842 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleInPlaceObjectWindowless,
843 (void**)&windowlessobj);
844 ok(hres == S_OK, "Could not get IOleInPlaceObjectWindowless interface: %08lx\n", hres);
846 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleObject, (void**)&oleobj);
847 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
849 hres = IOleObject_GetUserClassID(oleobj, NULL);
850 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08lx, expected E_INVALIDARG\n", hres);
852 hres = IOleObject_GetUserClassID(oleobj, &guid);
853 ok(hres == S_OK, "GetUserClassID failed: %08lx\n", hres);
854 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
856 hres = IOleObject_GetClientSite(oleobj, &clientsite);
857 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
858 ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
860 SET_EXPECT(GetHostInfo);
861 SET_EXPECT(GetOptionKeyPath);
862 SET_EXPECT(GetOverrideKeyPath);
863 SET_EXPECT(GetWindow);
864 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
865 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
866 CHECK_CALLED(GetHostInfo);
867 CHECK_CALLED(GetOptionKeyPath);
868 CHECK_CALLED(GetOverrideKeyPath);
869 CHECK_CALLED(GetWindow);
871 hres = IOleObject_GetClientSite(oleobj, &clientsite);
872 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
873 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
876 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
877 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
880 SET_EXPECT(GetContainer);
881 SET_EXPECT(LockContainer);
882 SET_EXPECT(ActivateMe);
883 expect_LockContainer_fLock = TRUE;
884 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
885 ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
886 CHECK_CALLED(GetContainer);
887 CHECK_CALLED(LockContainer);
888 CHECK_CALLED(ActivateMe);
891 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
892 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
896 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
897 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
898 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
902 SET_EXPECT(SetActiveObject);
904 SET_EXPECT(OnUIDeactivate);
905 expect_SetActiveObject_active = FALSE;
906 hres = IOleDocumentView_UIActivate(view, FALSE);
907 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
908 CHECK_CALLED(SetActiveObject);
909 CHECK_CALLED(HideUI);
910 CHECK_CALLED(OnUIDeactivate);
915 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
916 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
917 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
921 SET_EXPECT(OnInPlaceDeactivate);
922 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
923 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
924 CHECK_CALLED(OnInPlaceDeactivate);
929 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
930 ok(hres == E_FAIL, "GetWindow failed: %08lx\n", hres);
931 ok(IsWindow(hwnd), "hwnd is destroyed\n");
935 hres = IOleDocumentView_Show(view, FALSE);
936 ok(hres == S_OK, "Show failed: %08lx\n", hres);
940 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
941 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
943 IOleInPlaceObjectWindowless_Release(windowlessobj);
947 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
949 hres = IOleDocumentView_Show(view, FALSE);
950 ok(hres == S_OK, "Show failed: %08lx\n", hres);
952 hres = IOleDocumentView_CloseView(view, 0);
953 ok(hres == S_OK, "CloseVire failed: %08lx\n", hres);
955 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
956 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
958 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
959 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
960 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
964 SET_EXPECT(GetContainer);
965 SET_EXPECT(LockContainer);
966 expect_LockContainer_fLock = FALSE;
967 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
968 ok(hres == S_OK, "Close failed: %08lx\n", hres);
969 CHECK_CALLED(GetContainer);
970 CHECK_CALLED(LockContainer);
972 hres = IOleObject_GetClientSite(oleobj, &clientsite);
973 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
975 hres = IOleObject_SetClientSite(oleobj, NULL);
976 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
980 IOleObject_Release(oleobj);
982 IOleDocumentView_Release(view);
984 IOleInPlaceActiveObject_Release(activeobject);
986 ok(IsWindow(hwnd), "hwnd is destroyed\n");
988 ref = IUnknown_Release(htmldoc_unk);
989 ok(ref == 0, "ref=%ld, expected 0\n", ref);
991 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
993 DestroyWindow(container_hwnd);
1000 test_HTMLDocument();