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>
35 DEFINE_SHLGUID(CGID_Undocumented, 0x000214D4L, 0, 0);
37 #define DEFINE_EXPECT(func) \
38 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
40 #define SET_EXPECT(func) \
41 expect_ ## func = TRUE
43 #define CHECK_EXPECT(func) \
44 ok(expect_ ##func, "unexpected call\n"); \
45 expect_ ## func = FALSE; \
46 called_ ## func = TRUE
48 #define CHECK_EXPECT2(func) \
49 ok(expect_ ##func, "unexpected call\n"); \
50 called_ ## func = TRUE
52 #define CHECK_CALLED(func) \
53 ok(called_ ## func, "expected " #func "\n"); \
54 expect_ ## func = called_ ## func = FALSE
56 static IOleDocumentView *view = NULL;
57 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
59 DEFINE_EXPECT(LockContainer);
60 DEFINE_EXPECT(SetActiveObject);
61 DEFINE_EXPECT(GetWindow);
62 DEFINE_EXPECT(CanInPlaceActivate);
63 DEFINE_EXPECT(OnInPlaceActivate);
64 DEFINE_EXPECT(OnUIActivate);
65 DEFINE_EXPECT(GetWindowContext);
66 DEFINE_EXPECT(OnUIDeactivate);
67 DEFINE_EXPECT(OnInPlaceDeactivate);
68 DEFINE_EXPECT(GetContainer);
69 DEFINE_EXPECT(ShowUI);
70 DEFINE_EXPECT(ActivateMe);
71 DEFINE_EXPECT(GetHostInfo);
72 DEFINE_EXPECT(HideUI);
73 DEFINE_EXPECT(GetOptionKeyPath);
74 DEFINE_EXPECT(GetOverrideKeyPath);
75 DEFINE_EXPECT(SetStatusText);
76 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
77 DEFINE_EXPECT(QueryStatus_OPEN);
78 DEFINE_EXPECT(QueryStatus_NEW);
79 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
80 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
81 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
82 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
83 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
84 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
85 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
86 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
88 static BOOL expect_LockContainer_fLock;
89 static BOOL expect_SetActiveObject_active;
91 static HRESULT QueryInterface(REFIID riid, void **ppv);
93 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
95 return QueryInterface(riid, ppv);
98 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
103 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
108 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
109 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
111 ok(0, "unexpected call\n");
115 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
116 IEnumUnknown **ppenum)
118 ok(0, "unexpected call\n");
122 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
124 CHECK_EXPECT(LockContainer);
125 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
129 static const IOleContainerVtbl OleContainerVtbl = {
130 OleContainer_QueryInterface,
132 OleContainer_Release,
133 OleContainer_ParseDisplayName,
134 OleContainer_EnumObjects,
135 OleContainer_LockContainer
138 static IOleContainer OleContainer = { &OleContainerVtbl };
140 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
142 return QueryInterface(riid, ppv);
145 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
150 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
155 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
157 ok(0, "unexpected call\n");
161 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
163 ok(0, "unexpected call\n");
167 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
169 ok(0, "unexpected call\n");
173 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
174 LPCBORDERWIDTHS pborderwidths)
176 ok(0, "unexpected call\n");
180 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
181 LPCBORDERWIDTHS pborderwidths)
183 ok(0, "unexpected call\n");
187 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
188 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
190 static const WCHAR wszHTML_Document[] =
191 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
193 ok(expect_SetActiveObject, "unexpected call\n");
194 called_SetActiveObject = TRUE;
196 if(expect_SetActiveObject_active) {
197 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
198 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
200 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
201 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
207 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
208 LPOLEMENUGROUPWIDTHS lpMenuWidths)
210 ok(0, "unexpected call\n");
214 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
215 HOLEMENU holemenu, HWND hwndActiveObject)
217 ok(0, "unexpected call\n");
221 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
223 ok(0, "unexpected call\n");
227 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
229 CHECK_EXPECT(SetStatusText);
230 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
234 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
236 ok(0, "unexpected call\n");
240 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
242 ok(0, "unexpected call\n");
246 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
247 InPlaceFrame_QueryInterface,
249 InPlaceFrame_Release,
250 InPlaceFrame_GetWindow,
251 InPlaceFrame_ContextSensitiveHelp,
252 InPlaceFrame_GetBorder,
253 InPlaceFrame_RequestBorderSpace,
254 InPlaceFrame_SetBorderSpace,
255 InPlaceFrame_SetActiveObject,
256 InPlaceFrame_InsertMenus,
257 InPlaceFrame_SetMenu,
258 InPlaceFrame_RemoveMenus,
259 InPlaceFrame_SetStatusText,
260 InPlaceFrame_EnableModeless,
261 InPlaceFrame_TranslateAccelerator
264 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
266 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
268 return QueryInterface(riid, ppv);
271 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
276 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
281 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
283 CHECK_EXPECT(GetWindow);
284 ok(phwnd != NULL, "phwnd = NULL\n");
285 *phwnd = container_hwnd;
289 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
291 ok(0, "unexpected call\n");
295 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
297 CHECK_EXPECT(CanInPlaceActivate);
301 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
303 CHECK_EXPECT(OnInPlaceActivate);
307 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
309 CHECK_EXPECT(OnUIActivate);
313 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
314 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
315 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
317 static const RECT rect = {0,0,500,500};
319 CHECK_EXPECT(GetWindowContext);
321 ok(ppFrame != NULL, "ppFrame = NULL\n");
323 *ppFrame = &InPlaceFrame;
324 ok(ppDoc != NULL, "ppDoc = NULL\n");
327 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
329 memcpy(lprcPosRect, &rect, sizeof(RECT));
330 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
332 memcpy(lprcClipRect, &rect, sizeof(RECT));
333 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
335 lpFrameInfo->cb = sizeof(*lpFrameInfo);
336 lpFrameInfo->fMDIApp = FALSE;
337 lpFrameInfo->hwndFrame = container_hwnd;
338 lpFrameInfo->haccel = NULL;
339 lpFrameInfo->cAccelEntries = 0;
345 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtant)
347 ok(0, "unexpected call\n");
351 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
353 CHECK_EXPECT(OnUIDeactivate);
354 ok(!fUndoable, "fUndoable = TRUE\n");
358 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
360 CHECK_EXPECT(OnInPlaceDeactivate);
364 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
366 ok(0, "unexpected call\n");
370 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
372 ok(0, "unexpected call\n");
376 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
378 ok(0, "unexpected call\n");
382 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl = {
383 InPlaceSite_QueryInterface,
386 InPlaceSite_GetWindow,
387 InPlaceSite_ContextSensitiveHelp,
388 InPlaceSite_CanInPlaceActivate,
389 InPlaceSite_OnInPlaceActivate,
390 InPlaceSite_OnUIActivate,
391 InPlaceSite_GetWindowContext,
393 InPlaceSite_OnUIDeactivate,
394 InPlaceSite_OnInPlaceDeactivate,
395 InPlaceSite_DiscardUndoState,
396 InPlaceSite_DeactivateAndUndo,
397 InPlaceSite_OnPosRectChange
400 static IOleInPlaceSite InPlaceSite = { &InPlaceSiteVtbl };
402 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
404 return QueryInterface(riid, ppv);
407 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
412 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
417 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
419 ok(0, "unexpected call\n");
423 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAsign, DWORD dwWhichMoniker,
426 ok(0, "unexpected call\n");
430 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
432 CHECK_EXPECT(GetContainer);
433 ok(ppContainer != NULL, "ppContainer = NULL\n");
434 *ppContainer = &OleContainer;
438 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
440 ok(0, "unexpected call\n");
444 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
446 ok(0, "unexpected call\n");
450 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
452 ok(0, "unexpected call\n");
456 static const IOleClientSiteVtbl ClientSiteVtbl = {
457 ClientSite_QueryInterface,
460 ClientSite_SaveObject,
461 ClientSite_GetMoniker,
462 ClientSite_GetContainer,
463 ClientSite_ShowObject,
464 ClientSite_OnShowWindow,
465 ClientSite_RequestNewObjectLayout
468 static IOleClientSite ClientSite = { &ClientSiteVtbl };
470 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
472 return QueryInterface(riid, ppv);
475 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
480 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
485 static BOOL call_UIActivate = TRUE;
486 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
488 IOleDocument *document;
491 CHECK_EXPECT(ActivateMe);
492 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
494 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
495 ok(hres == S_OK, "could not get IOleDocument: %08lx\n", hres);
497 if(SUCCEEDED(hres)) {
498 hres = IOleDocument_CreateView(document, &InPlaceSite, NULL, 0, &view);
499 ok(hres == S_OK, "CreateView failed: %08lx\n", hres);
501 if(SUCCEEDED(hres)) {
502 IOleInPlaceActiveObject *activeobj = NULL;
503 IOleInPlaceSite *inplacesite = NULL;
504 HWND tmp_hwnd = NULL;
505 static RECT rect = {0,0,400,500};
507 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
508 ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
509 ok(inplacesite == &InPlaceSite, "inplacesite=%p, expected %p\n",
510 inplacesite, &InPlaceSite);
512 hres = IOleDocumentView_SetInPlaceSite(view, &InPlaceSite);
513 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
515 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
516 ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
517 ok(inplacesite == &InPlaceSite, "inplacesite=%p, expected %p\n",
518 inplacesite, &InPlaceSite);
520 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
521 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08lx\n", hres);
524 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
525 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
526 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
529 if(call_UIActivate) {
530 SET_EXPECT(CanInPlaceActivate);
531 SET_EXPECT(GetWindowContext);
532 SET_EXPECT(GetWindow);
533 SET_EXPECT(OnInPlaceActivate);
534 SET_EXPECT(SetStatusText);
535 SET_EXPECT(Exec_SETPROGRESSMAX);
536 SET_EXPECT(Exec_SETPROGRESSPOS);
537 SET_EXPECT(OnUIActivate);
538 SET_EXPECT(SetActiveObject);
540 expect_SetActiveObject_active = TRUE;
542 hres = IOleDocumentView_UIActivate(view, TRUE);
545 trace("UIActivate failed: %08lx\n", hres);
548 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
550 CHECK_CALLED(CanInPlaceActivate);
551 CHECK_CALLED(GetWindowContext);
552 CHECK_CALLED(GetWindow);
553 CHECK_CALLED(OnInPlaceActivate);
554 CHECK_CALLED(SetStatusText);
555 CHECK_CALLED(Exec_SETPROGRESSMAX);
556 CHECK_CALLED(Exec_SETPROGRESSPOS);
557 CHECK_CALLED(OnUIActivate);
558 CHECK_CALLED(SetActiveObject);
559 CHECK_CALLED(ShowUI);
562 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
563 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
564 ok(hwnd != NULL, "hwnd == NULL\n");
566 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
569 hres = IOleDocumentView_UIActivate(view, TRUE);
570 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
573 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
574 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
575 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
579 hres = IOleDocumentView_SetRect(view, &rect);
580 ok(hres == S_OK, "SetRect failed: %08lx\n", hres);
582 if(call_UIActivate) {
583 hres = IOleDocumentView_Show(view, TRUE);
584 ok(hres == S_OK, "Show failed: %08lx\n", hres);
586 SET_EXPECT(CanInPlaceActivate);
587 SET_EXPECT(GetWindowContext);
588 SET_EXPECT(GetWindow);
589 SET_EXPECT(OnInPlaceActivate);
590 SET_EXPECT(SetStatusText);
591 SET_EXPECT(Exec_SETPROGRESSMAX);
592 SET_EXPECT(Exec_SETPROGRESSPOS);
593 SET_EXPECT(OnUIActivate);
594 hres = IOleDocumentView_Show(view, TRUE);
595 ok(hres == S_OK, "Show failed: %08lx\n", hres);
596 CHECK_CALLED(CanInPlaceActivate);
597 CHECK_CALLED(GetWindowContext);
598 CHECK_CALLED(GetWindow);
599 CHECK_CALLED(OnInPlaceActivate);
600 CHECK_CALLED(SetStatusText);
601 CHECK_CALLED(Exec_SETPROGRESSMAX);
602 CHECK_CALLED(Exec_SETPROGRESSPOS);
605 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
606 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
607 ok(hwnd != NULL, "hwnd == NULL\n");
609 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
614 IOleInPlaceActiveObject_Release(activeobj);
617 IOleDocument_Release(document);
623 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
624 DocumentSite_QueryInterface,
626 DocumentSite_Release,
627 DocumentSite_ActivateMe
630 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
632 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
634 return QueryInterface(riid, ppv);
637 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
642 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
647 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
648 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
650 ok(0, "unexpected call\n");
654 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
656 CHECK_EXPECT(GetHostInfo);
657 ok(pInfo != NULL, "pInfo=NULL\n");
659 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%lu, expected %u\n",
660 pInfo->cbSize, sizeof(DOCHOSTUIINFO));
661 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08lx, expected 0\n", pInfo->dwFlags);
662 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
663 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
664 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
665 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08lx, expected 0\n", pInfo->dwDoubleClick);
666 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
667 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
672 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
673 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
674 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
676 CHECK_EXPECT(ShowUI);
678 ok(dwID == 0, "dwID=%ld, expected 0\n", dwID);
679 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
680 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
681 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
682 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
687 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
689 CHECK_EXPECT(HideUI);
693 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
695 ok(0, "unexpected call\n");
699 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
701 ok(0, "unexpected call\n");
705 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
707 ok(0, "unexpected call\n");
711 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
713 ok(0, "unexpected call\n");
717 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
718 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
720 ok(0, "unexpected call\n");
724 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
725 const GUID *pguidCmdGroup, DWORD nCmdID)
727 ok(0, "unexpected call\n");
731 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
732 LPOLESTR *pchKey, DWORD dw)
734 CHECK_EXPECT(GetOptionKeyPath);
735 ok(pchKey != NULL, "pchKey = NULL\n");
736 ok(!dw, "dw=%ld, expected 0\n", dw);
738 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
742 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
743 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
745 ok(0, "unexpected call\n");
749 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
751 ok(0, "unexpected call\n");
755 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
756 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
758 ok(0, "unexpected call\n");
762 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
763 IDataObject **ppPORet)
765 ok(0, "unexpected call\n");
769 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
770 LPOLESTR *pchKey, DWORD dw)
772 CHECK_EXPECT(GetOverrideKeyPath);
773 ok(pchKey != NULL, "pchKey = NULL\n");
775 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
776 ok(!dw, "dw=%ld, xepected 0\n", dw);
780 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
781 DocHostUIHandler_QueryInterface,
782 DocHostUIHandler_AddRef,
783 DocHostUIHandler_Release,
784 DocHostUIHandler_ShowContextMenu,
785 DocHostUIHandler_GetHostInfo,
786 DocHostUIHandler_ShowUI,
787 DocHostUIHandler_HideUI,
788 DocHostUIHandler_UpdateUI,
789 DocHostUIHandler_EnableModeless,
790 DocHostUIHandler_OnDocWindowActivate,
791 DocHostUIHandler_OnFrameWindowActivate,
792 DocHostUIHandler_ResizeBorder,
793 DocHostUIHandler_TranslateAccelerator,
794 DocHostUIHandler_GetOptionKeyPath,
795 DocHostUIHandler_GetDropTarget,
796 DocHostUIHandler_GetExternal,
797 DocHostUIHandler_TranslateUrl,
798 DocHostUIHandler_FilterDataObject,
799 DocHostUIHandler_GetOverrideKeyPath
802 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
804 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
805 REFIID riid, void **ppv)
807 return QueryInterface(riid, ppv);
810 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
815 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
820 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
821 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
823 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
824 ok(cCmds == 1, "cCmds=%ld, expected 1\n", cCmds);
825 ok(!pCmdText, "pCmdText != NULL\n");
827 switch(prgCmds[0].cmdID) {
828 case OLECMDID_SETPROGRESSTEXT:
829 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
830 prgCmds[0].cmdf = OLECMDF_ENABLED;
833 CHECK_EXPECT(QueryStatus_OPEN);
837 CHECK_EXPECT(QueryStatus_NEW);
841 ok(0, "unexpected command %ld\n", prgCmds[0].cmdID);
847 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
848 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
852 case OLECMDID_SETPROGRESSMAX:
853 CHECK_EXPECT(Exec_SETPROGRESSMAX);
854 ok(pvaIn != NULL, "pvaIn == NULL\n");
856 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
857 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%ld, expected 0\n", V_I4(pvaIn));
859 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
861 case OLECMDID_SETPROGRESSPOS:
862 CHECK_EXPECT(Exec_SETPROGRESSPOS);
863 ok(pvaIn != NULL, "pvaIn == NULL\n");
865 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
866 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%ld, expected 0\n", V_I4(pvaIn));
868 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
871 ok(0, "unexpected command %ld\n", nCmdID);
876 if(IsEqualGUID(&CGID_Undocumented, pguidCmdGroup))
877 return E_FAIL; /* TODO */
879 ok(0, "unexpected call");
884 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
885 OleCommandTarget_QueryInterface,
886 OleCommandTarget_AddRef,
887 OleCommandTarget_Release,
888 OleCommandTarget_QueryStatus,
889 OleCommandTarget_Exec
892 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
894 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
896 return QueryInterface(riid, ppv);
899 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
904 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
909 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
911 ok(0, "unexpected call\n");
915 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
918 ok(0, "unexpected call\n");
922 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
923 UINT cNames, LCID lcid, DISPID *rgDispId)
925 ok(0, "unexpected call\n");
929 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
930 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
931 EXCEPINFO *pExcepInfo, UINT *puArgErr)
933 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
934 ok(pDispParams != NULL, "pDispParams == NULL\n");
935 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
936 ok(puArgErr != NULL, "puArgErr == NULL\n");
937 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
938 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
940 switch(dispIdMember) {
941 case DISPID_AMBIENT_USERMODE:
942 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
943 V_VT(pVarResult) = VT_BOOL;
944 V_BOOL(pVarResult) = VARIANT_TRUE;
946 case DISPID_AMBIENT_DLCONTROL:
947 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
949 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
950 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
952 case DISPID_AMBIENT_SILENT:
953 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
954 V_VT(pVarResult) = VT_BOOL;
955 V_BOOL(pVarResult) = VARIANT_FALSE;
957 case DISPID_AMBIENT_USERAGENT:
958 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
960 case DISPID_AMBIENT_PALETTE:
961 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
965 ok(0, "unexpected dispid %ld\n", dispIdMember);
969 static IDispatchVtbl DispatchVtbl = {
970 Dispatch_QueryInterface,
973 Dispatch_GetTypeInfoCount,
974 Dispatch_GetTypeInfo,
975 Dispatch_GetIDsOfNames,
979 static IDispatch Dispatch = { &DispatchVtbl };
981 static HRESULT QueryInterface(REFIID riid, void **ppv)
985 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
987 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
988 *ppv = &DocumentSite;
989 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
990 *ppv = &DocHostUIHandler;
991 else if(IsEqualGUID(&IID_IOleContainer, riid))
992 *ppv = &OleContainer;
993 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
995 else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid) || IsEqualGUID(&IID_IOleInPlaceFrame, riid))
996 *ppv = &InPlaceFrame;
997 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
998 *ppv = &OleCommandTarget;
999 else if(IsEqualGUID(&IID_IDispatch, riid))
1004 * {D48A6EC6-6A4A-11CF-94A7-444553540000}
1005 * {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
1006 * {000670BA-0000-0000-C000-000000000046}
1011 return E_NOINTERFACE;
1014 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1016 return DefWindowProc(hwnd, msg, wParam, lParam);
1019 static void test_Persist(IUnknown *unk)
1021 IPersistMoniker *persist_mon;
1022 IPersistFile *persist_file;
1026 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
1027 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08lx\n", hres);
1028 if(SUCCEEDED(hres)) {
1029 hres = IPersist_GetClassID(persist_file, NULL);
1030 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
1032 hres = IPersist_GetClassID(persist_file, &guid);
1033 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
1034 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
1036 IPersist_Release(persist_file);
1039 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
1040 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08lx\n", hres);
1041 if(SUCCEEDED(hres)) {
1042 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
1043 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
1045 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
1046 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
1047 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
1049 IPersistMoniker_Release(persist_mon);
1053 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
1055 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
1056 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
1057 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
1058 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
1059 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
1060 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
1061 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
1062 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
1063 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
1064 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
1065 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
1066 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
1067 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
1068 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
1069 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
1070 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
1071 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
1072 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
1073 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
1074 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
1076 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
1077 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
1079 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
1081 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
1083 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
1084 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
1086 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
1087 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
1089 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
1091 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
1092 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
1095 static void test_OleCommandTarget(IUnknown *unk)
1097 IOleCommandTarget *cmdtrg;
1098 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
1102 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
1103 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08lx\n", hres);
1107 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
1108 cmds[i].cmdID = i+1;
1109 cmds[i].cmdf = 0xf0f0;
1112 SET_EXPECT(QueryStatus_OPEN);
1113 SET_EXPECT(QueryStatus_NEW);
1114 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
1115 ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
1116 CHECK_CALLED(QueryStatus_OPEN);
1117 CHECK_CALLED(QueryStatus_NEW);
1119 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
1120 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %lx\n", i, cmds[i].cmdID);
1121 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%lx, expected %x\n",
1122 i+1, cmds[i].cmdf, expect_cmds[i+1]);
1125 IOleCommandTarget_Release(cmdtrg);
1128 static void test_OleCommandTarget_fail(IUnknown *unk)
1130 IOleCommandTarget *cmdtrg;
1135 {OLECMDID_OPEN, 0xf0f0},
1136 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
1139 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
1140 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08lx\n", hres);
1144 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
1145 ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
1147 SET_EXPECT(QueryStatus_OPEN);
1148 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
1149 CHECK_CALLED(QueryStatus_OPEN);
1151 ok(hres == OLECMDERR_E_NOTSUPPORTED,
1152 "QueryStatus failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
1153 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
1154 "cmd[0].cmdID=%ld, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
1155 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%lx, expected 0\n", cmd[0].cmdf);
1156 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
1157 "cmd[1].cmdf=%lx, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
1159 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
1160 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
1161 "QueryStatus failed: %08lx, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
1163 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
1164 if(!expect_cmds[i]) {
1165 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
1166 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
1167 ok(hres == OLECMDERR_E_NOTSUPPORTED,
1168 "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
1172 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
1173 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
1174 ok(hres == OLECMDERR_E_NOTSUPPORTED,
1175 "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
1177 IOleCommandTarget_Release(cmdtrg);
1180 static HWND create_container_window(void)
1182 static const WCHAR wszHTMLDocumentTest[] =
1183 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
1184 static WNDCLASSEXW wndclass = {
1185 sizeof(WNDCLASSEXW),
1188 0, 0, NULL, NULL, NULL, NULL, NULL,
1189 wszHTMLDocumentTest,
1193 RegisterClassExW(&wndclass);
1194 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
1195 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1196 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
1199 static HRESULT test_DoVerb(IOleObject *oleobj)
1201 RECT rect = {0,0,500,500};
1204 SET_EXPECT(GetContainer);
1205 SET_EXPECT(LockContainer);
1206 SET_EXPECT(ActivateMe);
1207 expect_LockContainer_fLock = TRUE;
1209 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
1213 ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
1214 CHECK_CALLED(GetContainer);
1215 CHECK_CALLED(LockContainer);
1216 CHECK_CALLED(ActivateMe);
1221 #define CLIENTSITE_EXPECTPATH 0x00000001
1222 #define CLIENTSITE_SETNULL 0x00000002
1223 #define CLIENTSITE_DONTSET 0x00000004
1225 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
1227 IOleClientSite *clientsite;
1230 if(flags & CLIENTSITE_SETNULL) {
1231 hres = IOleObject_GetClientSite(oleobj, &clientsite);
1232 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
1234 hres = IOleObject_SetClientSite(oleobj, NULL);
1235 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
1238 if(flags & CLIENTSITE_DONTSET)
1241 hres = IOleObject_GetClientSite(oleobj, &clientsite);
1242 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
1243 ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
1245 SET_EXPECT(GetHostInfo);
1246 if(flags & CLIENTSITE_EXPECTPATH) {
1247 SET_EXPECT(GetOptionKeyPath);
1248 SET_EXPECT(GetOverrideKeyPath);
1250 SET_EXPECT(GetWindow);
1251 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
1252 SET_EXPECT(Exec_SETPROGRESSMAX);
1253 SET_EXPECT(Exec_SETPROGRESSPOS);
1254 SET_EXPECT(Invoke_AMBIENT_USERMODE);
1255 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
1256 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1257 SET_EXPECT(Invoke_AMBIENT_SILENT);
1258 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
1259 SET_EXPECT(Invoke_AMBIENT_PALETTE);
1260 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
1261 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
1262 CHECK_CALLED(GetHostInfo);
1263 if(flags & CLIENTSITE_EXPECTPATH) {
1264 CHECK_CALLED(GetOptionKeyPath);
1265 CHECK_CALLED(GetOverrideKeyPath);
1267 CHECK_CALLED(GetWindow);
1268 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
1269 CHECK_CALLED(Exec_SETPROGRESSMAX);
1270 CHECK_CALLED(Exec_SETPROGRESSPOS);
1271 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
1272 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
1273 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1274 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1275 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
1276 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
1278 hres = IOleObject_GetClientSite(oleobj, &clientsite);
1279 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
1280 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
1283 static void test_OnAmbientPropertyChange(IUnknown *unk)
1285 IOleControl *control = NULL;
1288 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
1289 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08lx\n", hres);
1293 SET_EXPECT(Invoke_AMBIENT_USERMODE);
1294 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
1295 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
1296 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
1298 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
1299 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
1300 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
1301 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
1303 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
1304 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1305 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
1306 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
1307 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
1308 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1310 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
1311 SET_EXPECT(Invoke_AMBIENT_SILENT);
1312 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
1313 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
1314 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
1315 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1317 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
1318 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
1319 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
1320 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
1322 SET_EXPECT(Invoke_AMBIENT_PALETTE);
1323 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
1324 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
1325 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
1327 IOleControl_Release(control);
1332 static void test_OnAmbientPropertyChange2(IUnknown *unk)
1334 IOleControl *control = NULL;
1337 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
1338 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08lx\n", hres);
1342 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
1343 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08lx\n", hres);
1345 IOleControl_Release(control);
1348 static void test_Close(IUnknown *unk, BOOL set_client)
1350 IOleObject *oleobj = NULL;
1353 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1354 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
1358 SET_EXPECT(GetContainer);
1359 SET_EXPECT(LockContainer);
1360 expect_LockContainer_fLock = FALSE;
1361 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
1362 ok(hres == S_OK, "Close failed: %08lx\n", hres);
1363 CHECK_CALLED(GetContainer);
1364 CHECK_CALLED(LockContainer);
1367 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
1369 IOleObject_Release(oleobj);
1372 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
1374 IOleInPlaceObjectWindowless *windowlessobj = NULL;
1377 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
1378 (void**)&windowlessobj);
1379 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08lx\n", hres);
1383 if(expect_call) SET_EXPECT(OnInPlaceDeactivate);
1384 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
1385 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
1386 if(expect_call) CHECK_CALLED(OnInPlaceDeactivate);
1388 IOleInPlaceObjectWindowless_Release(windowlessobj);
1391 static HRESULT test_Activate(IUnknown *unk, DWORD flags)
1393 IOleObject *oleobj = NULL;
1400 IOleDocumentView_Release(view);
1403 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1404 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
1408 hres = IOleObject_GetUserClassID(oleobj, NULL);
1409 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08lx, expected E_INVALIDARG\n", hres);
1411 hres = IOleObject_GetUserClassID(oleobj, &guid);
1412 ok(hres == S_OK, "GetUserClassID failed: %08lx\n", hres);
1413 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
1415 test_ClientSite(oleobj, flags);
1416 test_InPlaceDeactivate(unk, FALSE);
1418 hres = test_DoVerb(oleobj);
1420 IOleObject_Release(oleobj);
1424 static void test_Window(IUnknown *unk, BOOL expect_success)
1426 IOleInPlaceActiveObject *activeobject = NULL;
1430 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
1431 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
1435 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
1437 if(expect_success) {
1438 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
1439 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1441 ok(hres == E_FAIL, "GetWindow returned %08lx, expected E_FAIL\n", hres);
1442 ok(IsWindow(hwnd), "hwnd is destroyed\n");
1445 IOleInPlaceActiveObject_Release(activeobject);
1448 static void test_CloseView(void)
1450 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
1456 hres = IOleDocumentView_Show(view, FALSE);
1457 ok(hres == S_OK, "Show failed: %08lx\n", hres);
1459 hres = IOleDocumentView_CloseView(view, 0);
1460 ok(hres == S_OK, "CloseView failed: %08lx\n", hres);
1462 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
1463 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
1465 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1466 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
1467 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
1470 static void test_UIDeactivate(void)
1474 if(call_UIActivate) {
1475 SET_EXPECT(SetActiveObject);
1477 SET_EXPECT(OnUIDeactivate);
1480 expect_SetActiveObject_active = FALSE;
1481 hres = IOleDocumentView_UIActivate(view, FALSE);
1482 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
1484 if(call_UIActivate) {
1485 CHECK_CALLED(SetActiveObject);
1486 CHECK_CALLED(HideUI);
1487 CHECK_CALLED(OnUIDeactivate);
1491 static void test_Hide(void)
1498 hres = IOleDocumentView_Show(view, FALSE);
1499 ok(hres == S_OK, "Show failed: %08lx\n", hres);
1502 static void test_HTMLDocument(void)
1508 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1509 &IID_IUnknown, (void**)&unk);
1510 ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
1516 test_OnAmbientPropertyChange2(unk);
1517 hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
1519 IUnknown_Release(unk);
1523 test_OleCommandTarget_fail(unk);
1524 test_OleCommandTarget(unk);
1525 test_OnAmbientPropertyChange(unk);
1526 test_Window(unk, TRUE);
1527 test_UIDeactivate();
1528 test_OleCommandTarget(unk);
1529 test_Window(unk, TRUE);
1530 test_InPlaceDeactivate(unk, TRUE);
1532 /* Calling test_OleCommandTarget here couses Segmentation Fault with native
1533 * MSHTML. It doesn't with Wine. */
1535 test_Window(unk, FALSE);
1537 test_InPlaceDeactivate(unk, FALSE);
1539 test_Close(unk, FALSE);
1541 /* Activate HTMLDocument again */
1542 test_Activate(unk, CLIENTSITE_SETNULL);
1543 test_Window(unk, TRUE);
1544 test_OleCommandTarget(unk);
1545 test_UIDeactivate();
1546 test_InPlaceDeactivate(unk, TRUE);
1547 test_Close(unk, FALSE);
1549 /* Activate HTMLDocument again, this time without UIActivate */
1550 call_UIActivate = FALSE;
1551 test_Activate(unk, CLIENTSITE_SETNULL);
1552 test_Window(unk, TRUE);
1553 test_UIDeactivate();
1554 test_InPlaceDeactivate(unk, TRUE);
1557 test_Close(unk, TRUE);
1558 test_OnAmbientPropertyChange2(unk);
1561 IOleDocumentView_Release(view);
1564 ok(IsWindow(hwnd), "hwnd is destroyed\n");
1566 ref = IUnknown_Release(unk);
1567 ok(ref == 0, "ref=%ld, expected 0\n", ref);
1569 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
1576 container_hwnd = create_container_window();
1578 test_HTMLDocument();
1580 DestroyWindow(container_hwnd);