- Code cleanup.
[wine/hacks.git] / dlls / mshtml / tests / htmldoc.c
blob01e4c64adc355af7dd8c7126844709f8880fff74
1 /*
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
19 #define COBJMACROS
21 #include <wine/test.h>
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ole2.h"
27 #include "mshtml.h"
28 #include "docobj.h"
29 #include "mshtmhst.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 IOleDocumentView *view = NULL;
47 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
49 DEFINE_EXPECT(LockContainer);
50 DEFINE_EXPECT(SetActiveObject);
51 DEFINE_EXPECT(GetWindow);
52 DEFINE_EXPECT(CanInPlaceActivate);
53 DEFINE_EXPECT(OnInPlaceActivate);
54 DEFINE_EXPECT(OnUIActivate);
55 DEFINE_EXPECT(GetWindowContext);
56 DEFINE_EXPECT(OnUIDeactivate);
57 DEFINE_EXPECT(OnInPlaceDeactivate);
58 DEFINE_EXPECT(GetContainer);
59 DEFINE_EXPECT(ShowUI);
60 DEFINE_EXPECT(ActivateMe);
61 DEFINE_EXPECT(GetHostInfo);
62 DEFINE_EXPECT(HideUI);
63 DEFINE_EXPECT(GetOptionKeyPath);
64 DEFINE_EXPECT(GetOverrideKeyPath);
66 static BOOL expect_LockContainer_fLock;
67 static BOOL expect_SetActiveObject_active;
69 static HRESULT QueryInterface(REFIID riid, void **ppv);
71 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
73 return QueryInterface(riid, ppv);
76 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
78 return 2;
81 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
83 return 1;
86 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
87 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
89 ok(0, "unexpected call\n");
90 return E_NOTIMPL;
93 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
94 IEnumUnknown **ppenum)
96 ok(0, "unexpected call\n");
97 return E_NOTIMPL;
100 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
102 CHECK_EXPECT(LockContainer);
103 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
104 return S_OK;
107 static const IOleContainerVtbl OleContainerVtbl = {
108 OleContainer_QueryInterface,
109 OleContainer_AddRef,
110 OleContainer_Release,
111 OleContainer_ParseDisplayName,
112 OleContainer_EnumObjects,
113 OleContainer_LockContainer
116 static IOleContainer OleContainer = { &OleContainerVtbl };
118 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
120 return QueryInterface(riid, ppv);
123 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
125 return 2;
128 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
130 return 1;
133 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
135 ok(0, "unexpected call\n");
136 return E_NOTIMPL;
139 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
141 ok(0, "unexpected call\n");
142 return E_NOTIMPL;
145 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
147 ok(0, "unexpected call\n");
148 return E_NOTIMPL;
151 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
152 LPCBORDERWIDTHS pborderwidths)
154 ok(0, "unexpected call\n");
155 return E_NOTIMPL;
158 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
159 LPCBORDERWIDTHS pborderwidths)
161 ok(0, "unexpected call\n");
162 return E_NOTIMPL;
165 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
166 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
168 static const WCHAR wszHTML_Document[] =
169 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
171 ok(expect_SetActiveObject, "unexpected call\n");
172 called_SetActiveObject = TRUE;
174 if(expect_SetActiveObject_active) {
175 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
176 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
177 }else {
178 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
179 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
182 return S_OK;
185 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
186 LPOLEMENUGROUPWIDTHS lpMenuWidths)
188 ok(0, "unexpected call\n");
189 return E_NOTIMPL;
192 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
193 HOLEMENU holemenu, HWND hwndActiveObject)
195 ok(0, "unexpected call\n");
196 return E_NOTIMPL;
199 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
201 ok(0, "unexpected call\n");
202 return E_NOTIMPL;
205 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
207 ok(0, "unexpected call\n");
208 return E_NOTIMPL;
211 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
213 ok(0, "unexpected call\n");
214 return E_NOTIMPL;
217 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
219 ok(0, "unexpected call\n");
220 return E_NOTIMPL;
223 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
224 InPlaceFrame_QueryInterface,
225 InPlaceFrame_AddRef,
226 InPlaceFrame_Release,
227 InPlaceFrame_GetWindow,
228 InPlaceFrame_ContextSensitiveHelp,
229 InPlaceFrame_GetBorder,
230 InPlaceFrame_RequestBorderSpace,
231 InPlaceFrame_SetBorderSpace,
232 InPlaceFrame_SetActiveObject,
233 InPlaceFrame_InsertMenus,
234 InPlaceFrame_SetMenu,
235 InPlaceFrame_RemoveMenus,
236 InPlaceFrame_SetStatusText,
237 InPlaceFrame_EnableModeless,
238 InPlaceFrame_TranslateAccelerator
241 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
243 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
245 return QueryInterface(riid, ppv);
248 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
250 return 2;
253 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
255 return 1;
258 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
260 CHECK_EXPECT(GetWindow);
261 ok(phwnd != NULL, "phwnd = NULL\n");
262 *phwnd = container_hwnd;
263 return S_OK;
266 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
268 ok(0, "unexpected call\n");
269 return E_NOTIMPL;
272 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
274 CHECK_EXPECT(CanInPlaceActivate);
275 return S_OK;
278 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
280 CHECK_EXPECT(OnInPlaceActivate);
281 return S_OK;
284 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
286 CHECK_EXPECT(OnUIActivate);
287 return S_OK;
290 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
291 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
292 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
294 static const RECT rect = {0,0,500,500};
296 CHECK_EXPECT(GetWindowContext);
298 ok(ppFrame != NULL, "ppFrame = NULL\n");
299 if(ppFrame)
300 *ppFrame = &InPlaceFrame;
301 ok(ppDoc != NULL, "ppDoc = NULL\n");
302 if(ppDoc)
303 *ppDoc = NULL;
304 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
305 if(lprcPosRect)
306 memcpy(lprcPosRect, &rect, sizeof(RECT));
307 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
308 if(lprcClipRect)
309 memcpy(lprcClipRect, &rect, sizeof(RECT));
310 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
311 if(lpFrameInfo) {
312 lpFrameInfo->cb = sizeof(*lpFrameInfo);
313 lpFrameInfo->fMDIApp = FALSE;
314 lpFrameInfo->hwndFrame = container_hwnd;
315 lpFrameInfo->haccel = NULL;
316 lpFrameInfo->cAccelEntries = 0;
319 return S_OK;
322 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtant)
324 ok(0, "unexpected call\n");
325 return E_NOTIMPL;
328 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
330 CHECK_EXPECT(OnUIDeactivate);
331 ok(!fUndoable, "fUndoable = TRUE\n");
332 return S_OK;
335 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
337 CHECK_EXPECT(OnInPlaceDeactivate);
338 return S_OK;
341 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
343 ok(0, "unexpected call\n");
344 return E_NOTIMPL;
347 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
349 ok(0, "unexpected call\n");
350 return E_NOTIMPL;
353 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
355 ok(0, "unexpected call\n");
356 return E_NOTIMPL;
359 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl = {
360 InPlaceSite_QueryInterface,
361 InPlaceSite_AddRef,
362 InPlaceSite_Release,
363 InPlaceSite_GetWindow,
364 InPlaceSite_ContextSensitiveHelp,
365 InPlaceSite_CanInPlaceActivate,
366 InPlaceSite_OnInPlaceActivate,
367 InPlaceSite_OnUIActivate,
368 InPlaceSite_GetWindowContext,
369 InPlaceSite_Scroll,
370 InPlaceSite_OnUIDeactivate,
371 InPlaceSite_OnInPlaceDeactivate,
372 InPlaceSite_DiscardUndoState,
373 InPlaceSite_DeactivateAndUndo,
374 InPlaceSite_OnPosRectChange
377 static IOleInPlaceSite InPlaceSite = { &InPlaceSiteVtbl };
379 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
381 return QueryInterface(riid, ppv);
384 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
386 return 2;
389 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
391 return 1;
394 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
396 ok(0, "unexpected call\n");
397 return E_NOTIMPL;
400 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAsign, DWORD dwWhichMoniker,
401 IMoniker **ppmon)
403 ok(0, "unexpected call\n");
404 return E_NOTIMPL;
407 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
409 CHECK_EXPECT(GetContainer);
410 ok(ppContainer != NULL, "ppContainer = NULL\n");
411 *ppContainer = &OleContainer;
412 return S_OK;
415 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
417 ok(0, "unexpected call\n");
418 return E_NOTIMPL;
421 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
423 ok(0, "unexpected call\n");
424 return E_NOTIMPL;
427 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
429 ok(0, "unexpected call\n");
430 return E_NOTIMPL;
433 static const IOleClientSiteVtbl ClientSiteVtbl = {
434 ClientSite_QueryInterface,
435 ClientSite_AddRef,
436 ClientSite_Release,
437 ClientSite_SaveObject,
438 ClientSite_GetMoniker,
439 ClientSite_GetContainer,
440 ClientSite_ShowObject,
441 ClientSite_OnShowWindow,
442 ClientSite_RequestNewObjectLayout
445 static IOleClientSite ClientSite = { &ClientSiteVtbl };
447 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
449 return QueryInterface(riid, ppv);
452 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
454 return 2;
457 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
459 return 1;
462 static BOOL call_UIActivate = TRUE;
463 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
465 IOleDocument *document;
466 HRESULT hres;
468 CHECK_EXPECT(ActivateMe);
469 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
471 hres = IOleDocumentView_QueryInterface(pViewToActivate, &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);
500 if(activeobj) {
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 if(call_UIActivate) {
507 SET_EXPECT(CanInPlaceActivate);
508 SET_EXPECT(GetWindowContext);
509 SET_EXPECT(GetWindow);
510 SET_EXPECT(OnInPlaceActivate);
511 SET_EXPECT(OnUIActivate);
512 SET_EXPECT(SetActiveObject);
513 SET_EXPECT(ShowUI);
514 expect_SetActiveObject_active = TRUE;
516 hres = IOleDocumentView_UIActivate(view, TRUE);
518 if(FAILED(hres)) {
519 trace("UIActivate failed: %08lx\n", hres);
520 return hres;
522 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
524 CHECK_CALLED(CanInPlaceActivate);
525 CHECK_CALLED(GetWindowContext);
526 CHECK_CALLED(GetWindow);
527 CHECK_CALLED(OnInPlaceActivate);
528 CHECK_CALLED(OnUIActivate);
529 CHECK_CALLED(SetActiveObject);
530 CHECK_CALLED(ShowUI);
532 if(activeobj) {
533 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
534 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
535 ok(hwnd != NULL, "hwnd == NULL\n");
536 if(last_hwnd)
537 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
540 hres = IOleDocumentView_UIActivate(view, TRUE);
541 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
543 if(activeobj) {
544 IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
545 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
546 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
550 hres = IOleDocumentView_SetRect(view, &rect);
551 ok(hres == S_OK, "SetRect failed: %08lx\n", hres);
553 if(call_UIActivate) {
554 hres = IOleDocumentView_Show(view, TRUE);
555 ok(hres == S_OK, "Show failed: %08lx\n", hres);
556 }else {
557 SET_EXPECT(CanInPlaceActivate);
558 SET_EXPECT(GetWindowContext);
559 SET_EXPECT(GetWindow);
560 SET_EXPECT(OnInPlaceActivate);
561 hres = IOleDocumentView_Show(view, TRUE);
562 ok(hres == S_OK, "Show failed: %08lx\n", hres);
563 CHECK_CALLED(CanInPlaceActivate);
564 CHECK_CALLED(GetWindowContext);
565 CHECK_CALLED(GetWindow);
566 CHECK_CALLED(OnInPlaceActivate);
568 if(activeobj) {
569 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
570 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
571 ok(hwnd != NULL, "hwnd == NULL\n");
572 if(last_hwnd)
573 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
577 if(activeobj)
578 IOleInPlaceActiveObject_Release(activeobj);
581 IOleDocument_Release(document);
584 return S_OK;
587 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
588 DocumentSite_QueryInterface,
589 DocumentSite_AddRef,
590 DocumentSite_Release,
591 DocumentSite_ActivateMe
594 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
596 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
598 return QueryInterface(riid, ppv);
601 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
603 return 2;
606 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
608 return 1;
611 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
612 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
614 ok(0, "unexpected call\n");
615 return E_NOTIMPL;
618 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
620 CHECK_EXPECT(GetHostInfo);
621 ok(pInfo != NULL, "pInfo=NULL\n");
622 if(pInfo) {
623 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%lu, expected %u\n",
624 pInfo->cbSize, sizeof(DOCHOSTUIINFO));
625 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08lx, expected 0\n", pInfo->dwFlags);
626 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
627 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
628 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
629 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08lx, expected 0\n", pInfo->dwDoubleClick);
630 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
631 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
633 return S_OK;
636 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
637 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
638 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
640 CHECK_EXPECT(ShowUI);
642 ok(dwID == 0, "dwID=%ld, expected 0\n", dwID);
643 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
644 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
645 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
646 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
648 return S_OK;
651 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
653 CHECK_EXPECT(HideUI);
654 return S_OK;
657 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
659 ok(0, "unexpected call\n");
660 return E_NOTIMPL;
663 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
665 ok(0, "unexpected call\n");
666 return E_NOTIMPL;
669 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
671 ok(0, "unexpected call\n");
672 return E_NOTIMPL;
675 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
677 ok(0, "unexpected call\n");
678 return E_NOTIMPL;
681 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
682 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
684 ok(0, "unexpected call\n");
685 return E_NOTIMPL;
688 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
689 const GUID *pguidCmdGroup, DWORD nCmdID)
691 ok(0, "unexpected call\n");
692 return E_NOTIMPL;
695 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
696 LPOLESTR *pchKey, DWORD dw)
698 CHECK_EXPECT(GetOptionKeyPath);
699 ok(pchKey != NULL, "pchKey = NULL\n");
700 ok(!dw, "dw=%ld, expected 0\n", dw);
701 if(pchKey)
702 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
703 return S_OK;
706 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
707 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
709 ok(0, "unexpected call\n");
710 return E_NOTIMPL;
713 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
715 ok(0, "unexpected call\n");
716 return E_NOTIMPL;
719 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
720 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
722 ok(0, "unexpected call\n");
723 return E_NOTIMPL;
726 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
727 IDataObject **ppPORet)
729 ok(0, "unexpected call\n");
730 return E_NOTIMPL;
733 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
734 LPOLESTR *pchKey, DWORD dw)
736 CHECK_EXPECT(GetOverrideKeyPath);
737 ok(pchKey != NULL, "pchKey = NULL\n");
738 if(pchKey)
739 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
740 ok(!dw, "dw=%ld, xepected 0\n", dw);
741 return S_OK;
744 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
745 DocHostUIHandler_QueryInterface,
746 DocHostUIHandler_AddRef,
747 DocHostUIHandler_Release,
748 DocHostUIHandler_ShowContextMenu,
749 DocHostUIHandler_GetHostInfo,
750 DocHostUIHandler_ShowUI,
751 DocHostUIHandler_HideUI,
752 DocHostUIHandler_UpdateUI,
753 DocHostUIHandler_EnableModeless,
754 DocHostUIHandler_OnDocWindowActivate,
755 DocHostUIHandler_OnFrameWindowActivate,
756 DocHostUIHandler_ResizeBorder,
757 DocHostUIHandler_TranslateAccelerator,
758 DocHostUIHandler_GetOptionKeyPath,
759 DocHostUIHandler_GetDropTarget,
760 DocHostUIHandler_GetExternal,
761 DocHostUIHandler_TranslateUrl,
762 DocHostUIHandler_FilterDataObject,
763 DocHostUIHandler_GetOverrideKeyPath
766 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
768 static HRESULT QueryInterface(REFIID riid, void **ppv)
770 *ppv = NULL;
772 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
773 *ppv = &ClientSite;
774 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
775 *ppv = &DocumentSite;
776 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
777 *ppv = &DocHostUIHandler;
779 else if(IsEqualGUID(&IID_IOleContainer, riid))
780 *ppv = &OleContainer;
781 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
782 *ppv = &InPlaceSite;
783 else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid) || IsEqualGUID(&IID_IOleInPlaceFrame, riid))
784 *ppv = &InPlaceFrame;
786 /* TODO:
787 * IDispatch
788 * IServiceProvider
789 * IOleCommandTarget
790 * {D48A6EC6-6A4A-11CF-94A7-444553540000}
791 * {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
792 * {000670BA-0000-0000-C000-000000000046}
795 if(*ppv)
796 return S_OK;
797 return E_NOINTERFACE;
800 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
802 return DefWindowProc(hwnd, msg, wParam, lParam);
805 static void test_Persist(IUnknown *unk)
807 IPersistMoniker *persist_mon;
808 IPersistFile *persist_file;
809 GUID guid;
810 HRESULT hres;
812 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
813 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08lx\n", hres);
814 if(SUCCEEDED(hres)) {
815 hres = IPersist_GetClassID(persist_file, NULL);
816 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
818 hres = IPersist_GetClassID(persist_file, &guid);
819 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
820 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
822 IPersist_Release(persist_file);
825 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
826 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08lx\n", hres);
827 if(SUCCEEDED(hres)) {
828 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
829 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
831 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
832 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
833 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
835 IPersistMoniker_Release(persist_mon);
839 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
841 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
842 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
843 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
844 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
845 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
846 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
847 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
848 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
849 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
850 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
851 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
852 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
853 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
854 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
855 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
856 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
857 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
858 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
859 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
860 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
862 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
863 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
864 0,0,0,0,0,0,
865 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
866 0,0,
867 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
868 0,0,
869 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
870 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
871 0,0,0,0,0,
872 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
873 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
874 0,0,
875 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
876 0,0,0,
877 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
878 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
881 static void test_OleCommandTarget(IUnknown *unk)
883 IOleCommandTarget *cmdtrg;
884 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
885 int i;
886 HRESULT hres;
888 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
889 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08lx\n", hres);
890 if(FAILED(hres))
891 return;
893 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
894 cmds[i].cmdID = i+1;
895 cmds[i].cmdf = 0xf0f0;
898 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
899 ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
901 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
902 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %lx\n", i, cmds[i].cmdID);
903 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%lx, expected %x\n",
904 i+1, cmds[i].cmdf, expect_cmds[i+1]);
907 IOleCommandTarget_Release(cmdtrg);
910 static void test_OleCommandTarget_fail(IUnknown *unk)
912 IOleCommandTarget *cmdtrg;
913 int i;
914 HRESULT hres;
916 OLECMD cmd[2] = {
917 {OLECMDID_OPEN, 0xf0f0},
918 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
921 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
922 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08lx\n", hres);
923 if(FAILED(hres))
924 return;
928 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
929 ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
931 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
932 ok(hres == OLECMDERR_E_NOTSUPPORTED,
933 "QueryStatus failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
934 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
935 "cmd[0].cmdID=%ld, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
936 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%lx, expected 0\n", cmd[0].cmdf);
937 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
938 "cmd[1].cmdf=%lx, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
940 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
941 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
942 "QueryStatus failed: %08lx, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
944 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
945 if(!expect_cmds[i]) {
946 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
947 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
948 ok(hres == OLECMDERR_E_NOTSUPPORTED,
949 "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
953 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
954 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
955 ok(hres == OLECMDERR_E_NOTSUPPORTED,
956 "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
958 IOleCommandTarget_Release(cmdtrg);
961 static HWND create_container_window(void)
963 static const WCHAR wszHTMLDocumentTest[] =
964 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
965 static WNDCLASSEXW wndclass = {
966 sizeof(WNDCLASSEXW),
968 wnd_proc,
969 0, 0, NULL, NULL, NULL, NULL, NULL,
970 wszHTMLDocumentTest,
971 NULL
974 RegisterClassExW(&wndclass);
975 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
976 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
977 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
980 static HRESULT test_DoVerb(IOleObject *oleobj)
982 RECT rect = {0,0,500,500};
983 HRESULT hres;
985 SET_EXPECT(GetContainer);
986 SET_EXPECT(LockContainer);
987 SET_EXPECT(ActivateMe);
988 expect_LockContainer_fLock = TRUE;
989 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
991 if(FAILED(hres))
992 return hres;
994 ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
995 CHECK_CALLED(GetContainer);
996 CHECK_CALLED(LockContainer);
997 CHECK_CALLED(ActivateMe);
999 return hres;
1002 #define CLIENTSITE_EXPECTPATH 0x00000001
1003 #define CLIENTSITE_SETNULL 0x00000002
1004 #define CLIENTSITE_DONTSET 0x00000004
1006 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
1008 IOleClientSite *clientsite;
1009 HRESULT hres;
1011 if(flags & CLIENTSITE_SETNULL) {
1012 hres = IOleObject_GetClientSite(oleobj, &clientsite);
1013 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
1015 hres = IOleObject_SetClientSite(oleobj, NULL);
1016 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
1019 if(flags & CLIENTSITE_DONTSET)
1020 return;
1022 hres = IOleObject_GetClientSite(oleobj, &clientsite);
1023 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
1024 ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
1026 SET_EXPECT(GetHostInfo);
1027 if(flags & CLIENTSITE_EXPECTPATH) {
1028 SET_EXPECT(GetOptionKeyPath);
1029 SET_EXPECT(GetOverrideKeyPath);
1031 SET_EXPECT(GetWindow);
1032 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
1033 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
1034 CHECK_CALLED(GetHostInfo);
1035 if(flags & CLIENTSITE_EXPECTPATH) {
1036 CHECK_CALLED(GetOptionKeyPath);
1037 CHECK_CALLED(GetOverrideKeyPath);
1039 CHECK_CALLED(GetWindow);
1041 hres = IOleObject_GetClientSite(oleobj, &clientsite);
1042 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
1043 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
1046 static void test_Close(IUnknown *unk, BOOL set_client)
1048 IOleObject *oleobj = NULL;
1049 HRESULT hres;
1051 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1052 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
1053 if(FAILED(hres))
1054 return;
1056 SET_EXPECT(GetContainer);
1057 SET_EXPECT(LockContainer);
1058 expect_LockContainer_fLock = FALSE;
1059 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
1060 ok(hres == S_OK, "Close failed: %08lx\n", hres);
1061 CHECK_CALLED(GetContainer);
1062 CHECK_CALLED(LockContainer);
1064 if(set_client)
1065 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
1067 IOleObject_Release(oleobj);
1070 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
1072 IOleInPlaceObjectWindowless *windowlessobj = NULL;
1073 HRESULT hres;
1075 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
1076 (void**)&windowlessobj);
1077 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08lx\n", hres);
1078 if(FAILED(hres))
1079 return;
1081 if(expect_call) SET_EXPECT(OnInPlaceDeactivate);
1082 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
1083 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
1084 if(expect_call) CHECK_CALLED(OnInPlaceDeactivate);
1086 IOleInPlaceObjectWindowless_Release(windowlessobj);
1089 static HRESULT test_Activate(IUnknown *unk, DWORD flags)
1091 IOleObject *oleobj = NULL;
1092 GUID guid;
1093 HRESULT hres;
1095 last_hwnd = hwnd;
1097 if(view)
1098 IOleDocumentView_Release(view);
1099 view = NULL;
1101 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1102 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
1103 if(FAILED(hres))
1104 return hres;
1106 hres = IOleObject_GetUserClassID(oleobj, NULL);
1107 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08lx, expected E_INVALIDARG\n", hres);
1109 hres = IOleObject_GetUserClassID(oleobj, &guid);
1110 ok(hres == S_OK, "GetUserClassID failed: %08lx\n", hres);
1111 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
1113 test_ClientSite(oleobj, flags);
1114 test_InPlaceDeactivate(unk, FALSE);
1116 hres = test_DoVerb(oleobj);
1118 IOleObject_Release(oleobj);
1119 return hres;
1122 static void test_Window(IUnknown *unk, BOOL expect_success)
1124 IOleInPlaceActiveObject *activeobject = NULL;
1125 HWND tmp_hwnd;
1126 HRESULT hres;
1128 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
1129 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
1130 if(FAILED(hres))
1131 return;
1133 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
1135 if(expect_success) {
1136 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
1137 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1138 }else {
1139 ok(hres == E_FAIL, "GetWindow returned %08lx, expected E_FAIL\n", hres);
1140 ok(IsWindow(hwnd), "hwnd is destroyed\n");
1143 IOleInPlaceActiveObject_Release(activeobject);
1146 static void test_CloseView(void)
1148 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
1149 HRESULT hres;
1151 if(!view)
1152 return;
1154 hres = IOleDocumentView_Show(view, FALSE);
1155 ok(hres == S_OK, "Show failed: %08lx\n", hres);
1157 hres = IOleDocumentView_CloseView(view, 0);
1158 ok(hres == S_OK, "CloseView failed: %08lx\n", hres);
1160 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
1161 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
1163 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1164 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
1165 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
1168 static void test_UIDeactivate(void)
1170 HRESULT hres;
1172 if(call_UIActivate) {
1173 SET_EXPECT(SetActiveObject);
1174 SET_EXPECT(HideUI);
1175 SET_EXPECT(OnUIDeactivate);
1178 expect_SetActiveObject_active = FALSE;
1179 hres = IOleDocumentView_UIActivate(view, FALSE);
1180 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
1182 if(call_UIActivate) {
1183 CHECK_CALLED(SetActiveObject);
1184 CHECK_CALLED(HideUI);
1185 CHECK_CALLED(OnUIDeactivate);
1189 static void test_Hide(void)
1191 HRESULT hres;
1193 if(!view)
1194 return;
1196 hres = IOleDocumentView_Show(view, FALSE);
1197 ok(hres == S_OK, "Show failed: %08lx\n", hres);
1200 static void test_HTMLDocument(void)
1202 IUnknown *unk;
1203 HRESULT hres;
1204 ULONG ref;
1206 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1207 &IID_IUnknown, (void**)&unk);
1208 ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
1209 if(FAILED(hres))
1210 return;
1212 test_Persist(unk);
1214 hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
1215 if(FAILED(hres)) {
1216 IUnknown_Release(unk);
1217 return;
1220 test_OleCommandTarget_fail(unk);
1221 test_OleCommandTarget(unk);
1222 test_Window(unk, TRUE);
1223 test_UIDeactivate();
1224 test_OleCommandTarget(unk);
1225 test_Window(unk, TRUE);
1226 test_InPlaceDeactivate(unk, TRUE);
1228 /* Calling test_OleCommandTarget here couses Segmentation Fault with native
1229 * MSHTML. It doesn't with Wine. */
1231 test_Window(unk, FALSE);
1232 test_Hide();
1233 test_InPlaceDeactivate(unk, FALSE);
1234 test_CloseView();
1235 test_Close(unk, FALSE);
1237 /* Activate HTMLDocument again */
1238 test_Activate(unk, CLIENTSITE_SETNULL);
1239 test_Window(unk, TRUE);
1240 test_OleCommandTarget(unk);
1241 test_UIDeactivate();
1242 test_InPlaceDeactivate(unk, TRUE);
1243 test_Close(unk, FALSE);
1245 /* Activate HTMLDocument again, this time without UIActivate */
1246 call_UIActivate = FALSE;
1247 test_Activate(unk, CLIENTSITE_SETNULL);
1248 test_Window(unk, TRUE);
1249 test_UIDeactivate();
1250 test_InPlaceDeactivate(unk, TRUE);
1251 test_CloseView();
1252 test_CloseView();
1253 test_Close(unk, TRUE);
1255 if(view)
1256 IOleDocumentView_Release(view);
1257 view = NULL;
1259 ok(IsWindow(hwnd), "hwnd is destroyed\n");
1261 ref = IUnknown_Release(unk);
1262 ok(ref == 0, "ref=%ld, expected 0\n", ref);
1264 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
1268 START_TEST(htmldoc)
1270 CoInitialize(NULL);
1271 container_hwnd = create_container_window();
1273 test_HTMLDocument();
1275 DestroyWindow(container_hwnd);
1276 CoUninitialize();