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, "expected " #func "\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, last_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");
529 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
532 hres = IOleDocumentView_UIActivate(view, TRUE);
533 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
536 IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
537 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
538 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
541 hres = IOleDocumentView_SetRect(view, &rect);
542 ok(hres == S_OK, "SetRect failed: %08lx\n", hres);
544 hres = IOleDocumentView_Show(view, TRUE);
545 ok(hres == S_OK, "Show failed: %08lx\n", hres);
548 IOleInPlaceActiveObject_Release(activeobj);
551 IOleDocument_Release(document);
557 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
558 DocumentSite_QueryInterface,
560 DocumentSite_Release,
561 DocumentSite_ActivateMe
564 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
566 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
568 return QueryInterface(riid, ppv);
571 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
576 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
581 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
582 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
584 ok(0, "unexpected call\n");
588 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
590 CHECK_EXPECT(GetHostInfo);
591 ok(pInfo != NULL, "pInfo=NULL\n");
593 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%lu, expected %u\n",
594 pInfo->cbSize, sizeof(DOCHOSTUIINFO));
595 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08lx, expected 0\n", pInfo->dwFlags);
596 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
597 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
598 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
599 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08lx, expected 0\n", pInfo->dwDoubleClick);
600 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
601 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
606 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
607 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
608 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
610 CHECK_EXPECT(ShowUI);
612 ok(dwID == 0, "dwID=%ld, expected 0\n", dwID);
613 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
614 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
615 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
616 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
621 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
623 CHECK_EXPECT(HideUI);
627 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
629 ok(0, "unexpected call\n");
633 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
635 ok(0, "unexpected call\n");
639 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
641 ok(0, "unexpected call\n");
645 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
647 ok(0, "unexpected call\n");
651 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
652 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
654 ok(0, "unexpected call\n");
658 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
659 const GUID *pguidCmdGroup, DWORD nCmdID)
661 ok(0, "unexpected call\n");
665 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
666 LPOLESTR *pchKey, DWORD dw)
668 CHECK_EXPECT(GetOptionKeyPath);
669 ok(pchKey != NULL, "pchKey = NULL\n");
670 ok(!dw, "dw=%ld, expected 0\n", dw);
672 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
676 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
677 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
679 ok(0, "unexpected call\n");
683 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
685 ok(0, "unexpected call\n");
689 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
690 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
692 ok(0, "unexpected call\n");
696 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
697 IDataObject **ppPORet)
699 ok(0, "unexpected call\n");
703 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
704 LPOLESTR *pchKey, DWORD dw)
706 CHECK_EXPECT(GetOverrideKeyPath);
707 ok(pchKey != NULL, "pchKey = NULL\n");
709 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
710 ok(!dw, "dw=%ld, xepected 0\n", dw);
714 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
715 DocHostUIHandler_QueryInterface,
716 DocHostUIHandler_AddRef,
717 DocHostUIHandler_Release,
718 DocHostUIHandler_ShowContextMenu,
719 DocHostUIHandler_GetHostInfo,
720 DocHostUIHandler_ShowUI,
721 DocHostUIHandler_HideUI,
722 DocHostUIHandler_UpdateUI,
723 DocHostUIHandler_EnableModeless,
724 DocHostUIHandler_OnDocWindowActivate,
725 DocHostUIHandler_OnFrameWindowActivate,
726 DocHostUIHandler_ResizeBorder,
727 DocHostUIHandler_TranslateAccelerator,
728 DocHostUIHandler_GetOptionKeyPath,
729 DocHostUIHandler_GetDropTarget,
730 DocHostUIHandler_GetExternal,
731 DocHostUIHandler_TranslateUrl,
732 DocHostUIHandler_FilterDataObject,
733 DocHostUIHandler_GetOverrideKeyPath
736 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
738 static HRESULT QueryInterface(REFIID riid, void **ppv)
742 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
744 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
745 *ppv = &DocumentSite;
746 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
747 *ppv = &DocHostUIHandler;
749 else if(IsEqualGUID(&IID_IOleContainer, riid))
750 *ppv = &OleContainer;
751 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
753 else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid) || IsEqualGUID(&IID_IOleInPlaceFrame, riid))
754 *ppv = &InPlaceFrame;
760 * {D48A6EC6-6A4A-11CF-94A7-444553540000}
761 * {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
762 * {000670BA-0000-0000-C000-000000000046}
767 return E_NOINTERFACE;
770 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
772 return DefWindowProc(hwnd, msg, wParam, lParam);
775 static void test_Persist()
777 IPersistMoniker *persist_mon;
778 IPersistFile *persist_file;
782 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IPersistFile, (void**)&persist_file);
783 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08lx\n", hres);
784 if(SUCCEEDED(hres)) {
785 hres = IPersist_GetClassID(persist_file, NULL);
786 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
788 hres = IPersist_GetClassID(persist_file, &guid);
789 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
790 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
792 IPersist_Release(persist_file);
795 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IPersistMoniker, (void**)&persist_mon);
796 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08lx\n", hres);
797 if(SUCCEEDED(hres)) {
798 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
799 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
801 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
802 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
803 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
805 IPersistMoniker_Release(persist_mon);
809 static void test_HTMLDocument(void)
811 IOleObject *oleobj = NULL;
812 IOleClientSite *clientsite = (LPVOID)0xdeadbeef;
813 IOleInPlaceObjectWindowless *windowlessobj = NULL;
814 IOleInPlaceActiveObject *activeobject = NULL;
816 RECT rect = {0,0,500,500};
820 static const WCHAR wszHTMLDocumentTest[] =
821 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
822 static const WNDCLASSEXW wndclass = {
826 0, 0, NULL, NULL, NULL, NULL, NULL,
831 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
832 &IID_IUnknown, (void**)&htmldoc_unk);
833 ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
837 RegisterClassExW(&wndclass);
838 container_hwnd = CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
839 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
840 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
844 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleInPlaceObjectWindowless,
845 (void**)&windowlessobj);
846 ok(hres == S_OK, "Could not get IOleInPlaceObjectWindowless interface: %08lx\n", hres);
848 hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleObject, (void**)&oleobj);
849 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
851 hres = IOleObject_GetUserClassID(oleobj, NULL);
852 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08lx, expected E_INVALIDARG\n", hres);
854 hres = IOleObject_GetUserClassID(oleobj, &guid);
855 ok(hres == S_OK, "GetUserClassID failed: %08lx\n", hres);
856 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
858 hres = IOleObject_GetClientSite(oleobj, &clientsite);
859 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
860 ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
862 SET_EXPECT(GetHostInfo);
863 SET_EXPECT(GetOptionKeyPath);
864 SET_EXPECT(GetOverrideKeyPath);
865 SET_EXPECT(GetWindow);
866 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
867 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
868 CHECK_CALLED(GetHostInfo);
869 CHECK_CALLED(GetOptionKeyPath);
870 CHECK_CALLED(GetOverrideKeyPath);
871 CHECK_CALLED(GetWindow);
873 hres = IOleObject_GetClientSite(oleobj, &clientsite);
874 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
875 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
878 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
879 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
882 SET_EXPECT(GetContainer);
883 SET_EXPECT(LockContainer);
884 SET_EXPECT(ActivateMe);
885 expect_LockContainer_fLock = TRUE;
886 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
887 ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
888 CHECK_CALLED(GetContainer);
889 CHECK_CALLED(LockContainer);
890 CHECK_CALLED(ActivateMe);
893 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
894 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
898 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
899 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
900 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
904 SET_EXPECT(SetActiveObject);
906 SET_EXPECT(OnUIDeactivate);
907 expect_SetActiveObject_active = FALSE;
908 hres = IOleDocumentView_UIActivate(view, FALSE);
909 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
910 CHECK_CALLED(SetActiveObject);
911 CHECK_CALLED(HideUI);
912 CHECK_CALLED(OnUIDeactivate);
917 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
918 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
919 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
923 SET_EXPECT(OnInPlaceDeactivate);
924 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
925 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
926 CHECK_CALLED(OnInPlaceDeactivate);
931 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
932 ok(hres == E_FAIL, "GetWindow returned %08lx, expected E_FAIL\n", hres);
933 ok(IsWindow(hwnd), "hwnd is destroyed\n");
937 hres = IOleDocumentView_Show(view, FALSE);
938 ok(hres == S_OK, "Show failed: %08lx\n", hres);
942 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
943 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
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);
973 IOleDocumentView_Release(view);
975 /* Activate HTMLDocument again */
978 hres = IOleObject_GetClientSite(oleobj, &clientsite);
979 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
981 hres = IOleObject_SetClientSite(oleobj, NULL);
982 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
984 hres = IOleObject_GetClientSite(oleobj, &clientsite);
985 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
986 ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
988 SET_EXPECT(GetHostInfo);
989 SET_EXPECT(GetWindow);
990 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
991 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
992 CHECK_CALLED(GetHostInfo);
993 CHECK_CALLED(GetWindow);
996 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
997 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
1000 SET_EXPECT(GetContainer);
1001 SET_EXPECT(LockContainer);
1002 SET_EXPECT(ActivateMe);
1003 expect_LockContainer_fLock = TRUE;
1004 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
1005 ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
1006 CHECK_CALLED(GetContainer);
1007 CHECK_CALLED(LockContainer);
1008 CHECK_CALLED(ActivateMe);
1013 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
1014 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
1015 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1019 SET_EXPECT(SetActiveObject);
1021 SET_EXPECT(OnUIDeactivate);
1022 expect_SetActiveObject_active = FALSE;
1023 hres = IOleDocumentView_UIActivate(view, FALSE);
1024 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
1025 CHECK_CALLED(SetActiveObject);
1026 CHECK_CALLED(HideUI);
1027 CHECK_CALLED(OnUIDeactivate);
1031 SET_EXPECT(OnInPlaceDeactivate);
1032 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
1033 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
1034 CHECK_CALLED(OnInPlaceDeactivate);
1038 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
1040 hres = IOleDocumentView_Show(view, FALSE);
1041 ok(hres == S_OK, "Show failed: %08lx\n", hres);
1043 hres = IOleDocumentView_CloseView(view, 0);
1044 ok(hres == S_OK, "CloseVire failed: %08lx\n", hres);
1046 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
1047 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
1049 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1050 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
1051 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
1055 SET_EXPECT(GetContainer);
1056 SET_EXPECT(LockContainer);
1057 expect_LockContainer_fLock = FALSE;
1058 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
1059 ok(hres == S_OK, "Close failed: %08lx\n", hres);
1060 CHECK_CALLED(GetContainer);
1061 CHECK_CALLED(LockContainer);
1063 hres = IOleObject_GetClientSite(oleobj, &clientsite);
1064 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
1066 hres = IOleObject_SetClientSite(oleobj, NULL);
1067 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
1071 IOleInPlaceObjectWindowless_Release(windowlessobj);
1073 IOleObject_Release(oleobj);
1075 IOleDocumentView_Release(view);
1077 IOleInPlaceActiveObject_Release(activeobject);
1079 ok(IsWindow(hwnd), "hwnd is destroyed\n");
1081 ref = IUnknown_Release(htmldoc_unk);
1082 ok(ref == 0, "ref=%ld, expected 0\n", ref);
1084 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
1086 DestroyWindow(container_hwnd);
1093 test_HTMLDocument();