2 * Copyright 2005-2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
38 DEFINE_SHLGUID(CGID_DocHostCmdPriv
, 0x000214D4L
, 0, 0);
40 #define DEFINE_EXPECT(func) \
41 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
43 #define SET_EXPECT(func) \
44 expect_ ## func = TRUE
46 #define SET_CALLED(func) \
47 called_ ## func = TRUE
49 #define CHECK_EXPECT2(func) \
51 ok(expect_ ##func, "unexpected call " #func "\n"); \
52 called_ ## func = TRUE; \
55 #define CHECK_EXPECT(func) \
57 CHECK_EXPECT2(func); \
58 expect_ ## func = FALSE; \
61 #define CHECK_CALLED(func) \
63 ok(called_ ## func, "expected " #func "\n"); \
64 expect_ ## func = called_ ## func = FALSE; \
67 static IOleDocumentView
*view
= NULL
;
68 static HWND container_hwnd
= NULL
, hwnd
= NULL
, last_hwnd
= NULL
;
70 DEFINE_EXPECT(LockContainer
);
71 DEFINE_EXPECT(SetActiveObject
);
72 DEFINE_EXPECT(GetWindow
);
73 DEFINE_EXPECT(CanInPlaceActivate
);
74 DEFINE_EXPECT(OnInPlaceActivate
);
75 DEFINE_EXPECT(OnUIActivate
);
76 DEFINE_EXPECT(GetWindowContext
);
77 DEFINE_EXPECT(OnUIDeactivate
);
78 DEFINE_EXPECT(OnInPlaceDeactivate
);
79 DEFINE_EXPECT(GetContainer
);
80 DEFINE_EXPECT(ShowUI
);
81 DEFINE_EXPECT(ActivateMe
);
82 DEFINE_EXPECT(GetHostInfo
);
83 DEFINE_EXPECT(HideUI
);
84 DEFINE_EXPECT(GetOptionKeyPath
);
85 DEFINE_EXPECT(GetOverrideKeyPath
);
86 DEFINE_EXPECT(SetStatusText
);
87 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT
);
88 DEFINE_EXPECT(QueryStatus_OPEN
);
89 DEFINE_EXPECT(QueryStatus_NEW
);
90 DEFINE_EXPECT(Exec_SETPROGRESSMAX
);
91 DEFINE_EXPECT(Exec_SETPROGRESSPOS
);
92 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE
);
93 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0
);
94 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1
);
95 DEFINE_EXPECT(Exec_ShellDocView_37
);
96 DEFINE_EXPECT(Exec_UPDATECOMMANDS
);
97 DEFINE_EXPECT(Exec_SETTITLE
);
98 DEFINE_EXPECT(Exec_HTTPEQUIV
);
99 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE
);
100 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE
);
101 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL
);
102 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
103 DEFINE_EXPECT(Invoke_AMBIENT_SILENT
);
104 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT
);
105 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE
);
106 DEFINE_EXPECT(GetDropTarget
);
107 DEFINE_EXPECT(UpdateUI
);
108 DEFINE_EXPECT(Navigate
);
109 DEFINE_EXPECT(OnFrameWindowActivate
);
110 DEFINE_EXPECT(OnChanged_READYSTATE
);
111 DEFINE_EXPECT(OnChanged_1005
);
112 DEFINE_EXPECT(GetDisplayName
);
113 DEFINE_EXPECT(BindToStorage
);
114 DEFINE_EXPECT(Abort
);
116 DEFINE_EXPECT(CreateInstance
);
117 DEFINE_EXPECT(Start
);
118 DEFINE_EXPECT(Terminate
);
119 DEFINE_EXPECT(Protocol_Read
);
120 DEFINE_EXPECT(LockRequest
);
121 DEFINE_EXPECT(UnlockRequest
);
123 static IUnknown
*doc_unk
;
124 static BOOL expect_LockContainer_fLock
;
125 static BOOL expect_SetActiveObject_active
;
126 static BOOL set_clientsite
= FALSE
, container_locked
= FALSE
;
127 static BOOL readystate_set_loading
= FALSE
, load_from_stream
;
128 static BOOL editmode
= FALSE
;
129 static int stream_read
, protocol_read
;
130 static enum load_state_t
{
138 static LPCOLESTR expect_status_text
= NULL
;
140 static const char html_page
[] =
142 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
146 static const char css_data
[] = "body {color: red}";
148 static const WCHAR doc_url
[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
150 static HRESULT
QueryInterface(REFIID riid
, void **ppv
);
151 static void test_readyState(IUnknown
*);
152 static void test_MSHTML_QueryStatus(IUnknown
*,DWORD
);
154 static HRESULT WINAPI
Protocol_QueryInterface(IInternetProtocol
*iface
, REFIID riid
, void **ppv
)
156 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
162 return E_NOINTERFACE
;
165 static ULONG WINAPI
Protocol_AddRef(IInternetProtocol
*iface
)
170 static ULONG WINAPI
Protocol_Release(IInternetProtocol
*iface
)
175 static HRESULT WINAPI
Protocol_Start(IInternetProtocol
*iface
, LPCWSTR szUrl
,
176 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
177 DWORD grfPI
, DWORD dwReserved
)
183 static const WCHAR wszTextCss
[] = {'t','e','x','t','/','c','s','s',0};
184 static const WCHAR empty_str
= {0};
188 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
189 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
190 ok(!grfPI
, "grfPI = %x\n", grfPI
);
191 ok(!dwReserved
, "dwReserved = %d\n", dwReserved
);
193 memset(&bindinfo
, 0, sizeof(bindinfo
));
194 bindinfo
.cbSize
= sizeof(bindinfo
);
195 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &bindf
, &bindinfo
);
196 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
197 ok(bindf
== (BINDF_FROMURLMON
|BINDF_PULLDATA
|BINDF_NEEDFILE
|BINDF_ASYNCSTORAGE
|BINDF_ASYNCHRONOUS
),
198 "bindf = %x\n", bindf
);
200 ok(bindinfo
.cbSize
== sizeof(bindinfo
), "bindinfo.cbSize=%d\n", bindinfo
.cbSize
);
201 ok(bindinfo
.szExtraInfo
== NULL
, "bindinfo.szExtraInfo=%p\n", bindinfo
.szExtraInfo
);
202 /* TODO: test stgmedData */
203 ok(bindinfo
.grfBindInfoF
== 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo
.grfBindInfoF
);
204 ok(bindinfo
.dwBindVerb
== 0, "bindinfo.dwBindVerb=%d\n", bindinfo
.dwBindVerb
);
205 ok(bindinfo
.szCustomVerb
== 0, "bindinfo.szCustomVerb=%p\n", bindinfo
.szCustomVerb
);
206 ok(bindinfo
.cbstgmedData
== 0, "bindinfo.cbstgmedData=%d\n", bindinfo
.cbstgmedData
);
207 ok(bindinfo
.dwOptions
== 0x80000, "bindinfo.dwOptions=%x\n", bindinfo
.dwOptions
);
208 ok(bindinfo
.dwOptionsFlags
== 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo
.dwOptionsFlags
);
209 /* TODO: test dwCodePage */
210 /* TODO: test securityAttributes */
211 ok(IsEqualGUID(&IID_NULL
, &bindinfo
.iid
), "unexpected bindinfo.iid\n");
212 ok(bindinfo
.pUnk
== NULL
, "bindinfo.pUnk=%p\n", bindinfo
.pUnk
);
213 ok(bindinfo
.dwReserved
== 0, "bindinfo.dwReserved=%d\n", bindinfo
.dwReserved
);
215 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
216 BINDSTATUS_CACHEFILENAMEAVAILABLE
, &empty_str
);
217 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
219 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
220 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
, wszTextCss
);
222 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres
);
224 hres
= IInternetProtocolSink_ReportData(pOIProtSink
,
225 BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
, 13, 13);
226 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
228 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, S_OK
, 0, NULL
);
229 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
234 static HRESULT WINAPI
Protocol_Continue(IInternetProtocol
*iface
,
235 PROTOCOLDATA
*pProtocolData
)
237 ok(0, "unexpected call\n");
241 static HRESULT WINAPI
Protocol_Abort(IInternetProtocol
*iface
, HRESULT hrReason
,
244 ok(0, "unexpected call\n");
248 static HRESULT WINAPI
Protocol_Terminate(IInternetProtocol
*iface
, DWORD dwOptions
)
250 CHECK_EXPECT(Terminate
);
254 static HRESULT WINAPI
Protocol_Suspend(IInternetProtocol
*iface
)
256 ok(0, "unexpected call\n");
260 static HRESULT WINAPI
Protocol_Resume(IInternetProtocol
*iface
)
262 ok(0, "unexpected call\n");
266 static HRESULT WINAPI
Protocol_Read(IInternetProtocol
*iface
, void *pv
,
267 ULONG cb
, ULONG
*pcbRead
)
269 CHECK_EXPECT2(Protocol_Read
);
271 ok(pv
!= NULL
, "pv == NULL\n");
272 ok(cb
> sizeof(css_data
), "cb < sizeof(css_data)\n");
273 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
274 ok(!*pcbRead
, "*pcbRead=%d\n", *pcbRead
);
279 protocol_read
+= *pcbRead
= sizeof(css_data
)-1;
280 memcpy(pv
, css_data
, sizeof(css_data
)-1);
284 static HRESULT WINAPI
Protocol_Seek(IInternetProtocol
*iface
,
285 LARGE_INTEGER dlibMove
, DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
287 ok(0, "unexpected call\n");
291 static HRESULT WINAPI
Protocol_LockRequest(IInternetProtocol
*iface
, DWORD dwOptions
)
293 CHECK_EXPECT(LockRequest
);
297 static HRESULT WINAPI
Protocol_UnlockRequest(IInternetProtocol
*iface
)
299 CHECK_EXPECT(UnlockRequest
);
303 static const IInternetProtocolVtbl ProtocolVtbl
= {
304 Protocol_QueryInterface
,
315 Protocol_LockRequest
,
316 Protocol_UnlockRequest
319 static IInternetProtocol Protocol
= { &ProtocolVtbl
};
321 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
323 if(!IsEqualGUID(&IID_IInternetProtocolInfo
, riid
))
324 ok(0, "unexpected call\n");
325 return E_NOINTERFACE
;
328 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
333 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
338 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
339 REFIID riid
, void **ppv
)
341 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
))
342 return E_NOINTERFACE
;
344 CHECK_EXPECT(CreateInstance
);
345 ok(ppv
!= NULL
, "ppv == NULL\n");
351 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
353 ok(0, "unexpected call\n");
357 static const IClassFactoryVtbl ClassFactoryVtbl
= {
358 ClassFactory_QueryInterface
,
360 ClassFactory_Release
,
361 ClassFactory_CreateInstance
,
362 ClassFactory_LockServer
365 static IClassFactory ClassFactory
= { &ClassFactoryVtbl
};
367 static HRESULT WINAPI
HlinkFrame_QueryInterface(IHlinkFrame
*iface
, REFIID riid
, void **ppv
)
369 ok(0, "unexpected call\n");
373 static ULONG WINAPI
HlinkFrame_AddRef(IHlinkFrame
*iface
)
378 static ULONG WINAPI
HlinkFrame_Release(IHlinkFrame
*iface
)
383 static HRESULT WINAPI
HlinkFrame_SetBrowseContext(IHlinkFrame
*iface
,
384 IHlinkBrowseContext
*pihlbc
)
386 ok(0, "unexpected call\n");
390 static HRESULT WINAPI
HlinkFrame_GetBrowseContext(IHlinkFrame
*iface
,
391 IHlinkBrowseContext
**ppihlbc
)
393 ok(0, "unexpected call\n");
397 static HRESULT WINAPI
HlinkFrame_Navigate(IHlinkFrame
*iface
, DWORD grfHLNF
, LPBC pbc
,
398 IBindStatusCallback
*pibsc
, IHlink
*pihlNavigate
)
402 CHECK_EXPECT(Navigate
);
404 ok(grfHLNF
== 0, "grfHLNF=%d, expected 0\n", grfHLNF
);
405 ok(pbc
!= NULL
, "pbc == NULL\n");
406 ok(pibsc
!= NULL
, "pubsc == NULL\n");
407 ok(pihlNavigate
!= NULL
, "puhlNavigate == NULL\n");
410 LPWSTR frame_name
= (LPWSTR
)0xdeadbeef;
411 LPWSTR location
= (LPWSTR
)0xdeadbeef;
413 IMoniker
*mon
= NULL
;
414 DWORD site_data
= 0xdeadbeef;
416 hres
= IHlink_GetTargetFrameName(pihlNavigate
, &frame_name
);
417 ok(hres
== S_FALSE
, "GetTargetFrameName failed: %08x\n", hres
);
418 ok(frame_name
== NULL
, "frame_name = %p\n", frame_name
);
420 hres
= IHlink_GetMonikerReference(pihlNavigate
, 1, &mon
, &location
);
421 ok(hres
== S_OK
, "GetMonikerReference failed: %08x\n", hres
);
422 ok(location
== NULL
, "location = %p\n", location
);
423 ok(mon
!= NULL
, "mon == NULL\n");
425 hres
= IHlink_GetHlinkSite(pihlNavigate
, &site
, &site_data
);
426 ok(hres
== S_OK
, "GetHlinkSite failed: %08x\n", hres
);
427 ok(site
== NULL
, "site = %p\n, expected NULL\n", site
);
428 ok(site_data
== 0xdeadbeef, "site_data = %x\n", site_data
);
434 static HRESULT WINAPI
HlinkFrame_OnNavigate(IHlinkFrame
*iface
, DWORD grfHLNF
,
435 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
, DWORD dwreserved
)
437 ok(0, "unexpected call\n");
441 static HRESULT WINAPI
HlinkFrame_UpdateHlink(IHlinkFrame
*iface
, ULONG uHLID
,
442 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
)
444 ok(0, "unexpected call\n");
448 static const IHlinkFrameVtbl HlinkFrameVtbl
= {
449 HlinkFrame_QueryInterface
,
452 HlinkFrame_SetBrowseContext
,
453 HlinkFrame_GetBrowseContext
,
455 HlinkFrame_OnNavigate
,
456 HlinkFrame_UpdateHlink
459 static IHlinkFrame HlinkFrame
= { &HlinkFrameVtbl
};
461 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
462 REFIID riid
, void**ppv
)
464 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
469 ok(0, "unexpected call\n");
470 return E_NOINTERFACE
;
473 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
478 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
483 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
486 case DISPID_READYSTATE
:
487 CHECK_EXPECT2(OnChanged_READYSTATE
);
488 test_MSHTML_QueryStatus(NULL
, OLECMDF_SUPPORTED
489 | (editmode
&& (load_state
== LD_INTERACTIVE
|| load_state
== LD_COMPLETE
)
490 ? OLECMDF_ENABLED
: 0));
492 if(readystate_set_loading
) {
493 readystate_set_loading
= FALSE
;
494 load_state
= LD_LOADING
;
496 test_readyState(NULL
);
499 CHECK_EXPECT(OnChanged_1005
);
500 test_readyState(NULL
);
501 load_state
= LD_INTERACTIVE
;
505 ok(0, "unexpected id %d\n", dispID
);
509 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
511 ok(0, "unexpected call\n");
515 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
516 PropertyNotifySink_QueryInterface
,
517 PropertyNotifySink_AddRef
,
518 PropertyNotifySink_Release
,
519 PropertyNotifySink_OnChanged
,
520 PropertyNotifySink_OnRequestEdit
523 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
525 static HRESULT WINAPI
Stream_QueryInterface(IStream
*iface
, REFIID riid
, void **ppv
)
527 ok(0, "unexpected call\n");
528 return E_NOINTERFACE
;
531 static ULONG WINAPI
Stream_AddRef(IStream
*iface
)
536 static ULONG WINAPI
Stream_Release(IStream
*iface
)
541 static HRESULT WINAPI
Stream_Read(IStream
*iface
, void *pv
,
542 ULONG cb
, ULONG
*pcbRead
)
545 ok(pv
!= NULL
, "pv == NULL\n");
546 ok(cb
> sizeof(html_page
), "cb = %d\n", cb
);
547 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
548 ok(!*pcbRead
, "*pcbRead = %d\n", *pcbRead
);
553 memcpy(pv
, html_page
, sizeof(html_page
)-1);
554 stream_read
+= *pcbRead
= sizeof(html_page
)-1;
558 static HRESULT WINAPI
Stream_Write(IStream
*iface
, const void *pv
,
559 ULONG cb
, ULONG
*pcbWritten
)
561 ok(0, "unexpected call\n");
565 static HRESULT WINAPI
Stream_Seek(IStream
*iface
, LARGE_INTEGER dlibMove
,
566 DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
568 ok(0, "unexpected call\n");
572 static HRESULT WINAPI
Stream_SetSize(IStream
*iface
, ULARGE_INTEGER libNewSize
)
574 ok(0, "unexpected call\n");
578 static HRESULT WINAPI
Stream_CopyTo(IStream
*iface
, IStream
*pstm
,
579 ULARGE_INTEGER cb
, ULARGE_INTEGER
*pcbRead
, ULARGE_INTEGER
*pcbWritten
)
581 ok(0, "unexpected call\n");
585 static HRESULT WINAPI
Stream_Commit(IStream
*iface
, DWORD grfCommitFlags
)
587 ok(0, "unexpected call\n");
591 static HRESULT WINAPI
Stream_Revert(IStream
*iface
)
593 ok(0, "unexpected call\n");
597 static HRESULT WINAPI
Stream_LockRegion(IStream
*iface
, ULARGE_INTEGER libOffset
,
598 ULARGE_INTEGER cb
, DWORD dwLockType
)
600 ok(0, "unexpected call\n");
604 static HRESULT WINAPI
Stream_UnlockRegion(IStream
*iface
,
605 ULARGE_INTEGER libOffset
, ULARGE_INTEGER cb
, DWORD dwLockType
)
607 ok(0, "unexpected call\n");
611 static HRESULT WINAPI
Stream_Stat(IStream
*iface
, STATSTG
*pstatstg
,
614 ok(0, "unexpected call\n");
618 static HRESULT WINAPI
Stream_Clone(IStream
*iface
, IStream
**ppstm
)
620 ok(0, "unexpected call\n");
624 static const IStreamVtbl StreamVtbl
= {
625 Stream_QueryInterface
,
641 static IStream Stream
= { &StreamVtbl
};
643 static HRESULT WINAPI
Binding_QueryInterface(IBinding
*iface
, REFIID riid
, void **ppv
)
645 if(IsEqualGUID(&IID_IWinInetHttpInfo
, riid
))
646 return E_NOINTERFACE
; /* TODO */
648 if(IsEqualGUID(&IID_IWinInetInfo
, riid
))
649 return E_NOINTERFACE
; /* TODO */
651 ok(0, "unexpected call\n");
652 return E_NOINTERFACE
;
655 static ULONG WINAPI
Binding_AddRef(IBinding
*iface
)
660 static ULONG WINAPI
Binding_Release(IBinding
*iface
)
665 static HRESULT WINAPI
Binding_Abort(IBinding
*iface
)
671 static HRESULT WINAPI
Binding_Suspend(IBinding
*iface
)
673 ok(0, "unexpected call\n");
677 static HRESULT WINAPI
Binding_Resume(IBinding
*iface
)
679 ok(0, "unexpected call\n");
683 static HRESULT WINAPI
Binding_SetPriority(IBinding
*iface
, LONG nPriority
)
685 ok(0, "unexpected call\n");
689 static HRESULT WINAPI
Binding_GetPriority(IBinding
*iface
, LONG
*pnPriority
)
691 ok(0, "unexpected call\n");
695 static HRESULT WINAPI
Binding_GetBindResult(IBinding
*iface
, CLSID
*pclsidProtocol
,
696 DWORD
*pdwResult
, LPOLESTR
*pszResult
, DWORD
*pdwReserved
)
698 ok(0, "unexpected call\n");
702 static const IBindingVtbl BindingVtbl
= {
703 Binding_QueryInterface
,
711 Binding_GetBindResult
714 static IBinding Binding
= { &BindingVtbl
};
716 static HRESULT WINAPI
Moniker_QueryInterface(IMoniker
*iface
, REFIID riid
, void **ppv
)
718 ok(0, "unexpected call\n");
719 return E_NOINTERFACE
;
722 static ULONG WINAPI
Moniker_AddRef(IMoniker
*iface
)
727 static ULONG WINAPI
Moniker_Release(IMoniker
*iface
)
732 static HRESULT WINAPI
Moniker_GetClassID(IMoniker
*iface
, CLSID
*pClassID
)
734 ok(0, "unexpected call\n");
738 static HRESULT WINAPI
Moniker_IsDirty(IMoniker
*iface
)
740 ok(0, "unexpected call\n");
744 static HRESULT WINAPI
Moniker_Load(IMoniker
*iface
, IStream
*pStm
)
746 ok(0, "unexpected call\n");
750 static HRESULT WINAPI
Moniker_Save(IMoniker
*iface
, IStream
*pStm
, BOOL fClearDirty
)
752 ok(0, "unexpected call\n");
756 static HRESULT WINAPI
Moniker_GetSizeMax(IMoniker
*iface
, ULARGE_INTEGER
*pcbSize
)
758 ok(0, "unexpected call\n");
762 static HRESULT WINAPI
Moniker_BindToObject(IMoniker
*iface
, IBindCtx
*pcb
, IMoniker
*pmkToLeft
,
763 REFIID riidResult
, void **ppvResult
)
765 ok(0, "unexpected call\n");
769 static HRESULT WINAPI
Moniker_BindToStorage(IMoniker
*iface
, IBindCtx
*pbc
, IMoniker
*pmkToLeft
,
770 REFIID riid
, void **ppv
)
772 IBindStatusCallback
*callback
= NULL
;
773 FORMATETC formatetc
= {0xc02d, NULL
, 1, -1, TYMED_ISTREAM
};
779 static OLECHAR BSCBHolder
[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
780 static const WCHAR wszTextHtml
[] = {'t','e','x','t','/','h','t','m','l',0};
782 CHECK_EXPECT(BindToStorage
);
784 ok(pbc
!= NULL
, "pbc == NULL\n");
785 ok(pmkToLeft
== NULL
, "pmkToLeft=%p\n", pmkToLeft
);
786 ok(IsEqualGUID(&IID_IStream
, riid
), "unexpected riid\n");
787 ok(ppv
!= NULL
, "ppv == NULL\n");
788 ok(*ppv
== NULL
, "*ppv=%p\n", *ppv
);
790 hres
= IBindCtx_GetObjectParam(pbc
, BSCBHolder
, (IUnknown
**)&callback
);
791 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
792 ok(callback
!= NULL
, "callback == NULL\n");
794 memset(&bindinfo
, 0xf0, sizeof(bindinfo
));
795 bindinfo
.cbSize
= sizeof(bindinfo
);
797 hres
= IBindStatusCallback_GetBindInfo(callback
, &bindf
, &bindinfo
);
798 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
799 ok(bindf
== (BINDF_PULLDATA
|BINDF_ASYNCSTORAGE
|BINDF_ASYNCHRONOUS
), "bindf = %08x\n", bindf
);
800 ok(bindinfo
.cbSize
== sizeof(bindinfo
), "bindinfo.cbSize=%d\n", bindinfo
.cbSize
);
801 ok(bindinfo
.szExtraInfo
== NULL
, "bindinfo.szExtraInfo=%p\n", bindinfo
.szExtraInfo
);
802 /* TODO: test stgmedData */
803 ok(bindinfo
.grfBindInfoF
== 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo
.grfBindInfoF
);
804 ok(bindinfo
.dwBindVerb
== 0, "bindinfo.dwBindVerb=%d\n", bindinfo
.dwBindVerb
);
805 ok(bindinfo
.szCustomVerb
== 0, "bindinfo.szCustomVerb=%p\n", bindinfo
.szCustomVerb
);
806 ok(bindinfo
.cbstgmedData
== 0, "bindinfo.cbstgmedData=%d\n", bindinfo
.cbstgmedData
);
807 ok(bindinfo
.dwOptions
== 0x80000 || bindinfo
.dwOptions
== 0x4080000,
808 "bindinfo.dwOptions=%x\n", bindinfo
.dwOptions
);
809 ok(bindinfo
.dwOptionsFlags
== 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo
.dwOptionsFlags
);
810 /* TODO: test dwCodePage */
811 /* TODO: test securityAttributes */
812 ok(IsEqualGUID(&IID_NULL
, &bindinfo
.iid
), "unexpected bindinfo.iid\n");
813 ok(bindinfo
.pUnk
== NULL
, "bindinfo.pUnk=%p\n", bindinfo
.pUnk
);
814 ok(bindinfo
.dwReserved
== 0, "bindinfo.dwReserved=%d\n", bindinfo
.dwReserved
);
816 hres
= IBindStatusCallback_OnStartBinding(callback
, 0, &Binding
);
817 ok(hres
== S_OK
, "OnStartBinding failed: %08x\n", hres
);
819 hres
= IBindStatusCallback_OnProgress(callback
, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE
,
821 ok(hres
== S_OK
, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
823 hres
= IBindStatusCallback_OnProgress(callback
, sizeof(html_page
)-1, sizeof(html_page
)-1,
824 BINDSTATUS_BEGINDOWNLOADDATA
, doc_url
);
825 ok(hres
== S_OK
, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres
);
828 stgmedium
.tymed
= TYMED_ISTREAM
;
829 U(stgmedium
).pstm
= &Stream
;
830 stgmedium
.pUnkForRelease
= (IUnknown
*)iface
;
831 hres
= IBindStatusCallback_OnDataAvailable(callback
,
832 BSCF_FIRSTDATANOTIFICATION
|BSCF_LASTDATANOTIFICATION
,
833 sizeof(html_page
)-1, &formatetc
, &stgmedium
);
834 ok(hres
== S_OK
, "OnDataAvailable failed: %08x\n", hres
);
837 hres
= IBindStatusCallback_OnProgress(callback
, sizeof(html_page
)-1, sizeof(html_page
)-1,
838 BINDSTATUS_ENDDOWNLOADDATA
, NULL
);
839 ok(hres
== S_OK
, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres
);
841 hres
= IBindStatusCallback_OnStopBinding(callback
, S_OK
, NULL
);
842 ok(hres
== S_OK
, "OnStopBinding failed: %08x\n", hres
);
844 IBindStatusCallback_Release(callback
);
849 static HRESULT WINAPI
Moniker_Reduce(IMoniker
*iface
, IBindCtx
*pbc
, DWORD dwReduceHowFar
,
850 IMoniker
**ppmkToLeft
, IMoniker
**ppmkReduced
)
852 ok(0, "unexpected call\n");
856 static HRESULT WINAPI
Moniker_ComposeWith(IMoniker
*iface
, IMoniker
*pmkRight
,
857 BOOL fOnlyIfNotGeneric
, IMoniker
**ppnkComposite
)
859 ok(0, "unexpected call\n");
863 static HRESULT WINAPI
Moniker_Enum(IMoniker
*iface
, BOOL fForwrd
, IEnumMoniker
**ppenumMoniker
)
865 ok(0, "unexpected call\n");
869 static HRESULT WINAPI
Moniker_IsEqual(IMoniker
*iface
, IMoniker
*pmkOtherMoniker
)
871 ok(0, "unexpected call\n");
875 static HRESULT WINAPI
Moniker_Hash(IMoniker
*iface
, DWORD
*pdwHash
)
877 ok(0, "unexpected call\n");
881 static HRESULT WINAPI
Moniker_IsRunning(IMoniker
*iface
, IBindCtx
*pbc
, IMoniker
*pmkToLeft
,
882 IMoniker
*pmkNewlyRunning
)
884 ok(0, "unexpected call\n");
888 static HRESULT WINAPI
Moniker_GetTimeOfLastChange(IMoniker
*iface
, IBindCtx
*pbc
,
889 IMoniker
*pmkToLeft
, FILETIME
*pFileTime
)
891 ok(0, "unexpected call\n");
895 static HRESULT WINAPI
Moniker_Inverse(IMoniker
*iface
, IMoniker
**ppmk
)
897 ok(0, "unexpected call\n");
901 static HRESULT WINAPI
Moniker_CommonPrefixWith(IMoniker
*iface
, IMoniker
*pmkOther
,
902 IMoniker
**ppmkPrefix
)
904 ok(0, "unexpected call\n");
908 static HRESULT WINAPI
Moniker_RelativePathTo(IMoniker
*iface
, IMoniker
*pmkOther
,
909 IMoniker
**pmkRelPath
)
911 ok(0, "unexpected call\n");
915 static HRESULT WINAPI
Moniker_GetDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
916 IMoniker
*pmkToLeft
, LPOLESTR
*ppszDisplayName
)
918 CHECK_EXPECT2(GetDisplayName
);
920 /* ok(pbc != NULL, "pbc == NULL\n"); */
921 ok(pmkToLeft
== NULL
, "pmkToLeft=%p\n", pmkToLeft
);
922 ok(ppszDisplayName
!= NULL
, "ppszDisplayName == NULL\n");
924 *ppszDisplayName
= CoTaskMemAlloc(sizeof(doc_url
));
925 memcpy(*ppszDisplayName
, doc_url
, sizeof(doc_url
));
930 static HRESULT WINAPI
Moniker_ParseDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
931 IMoniker
*pmkToLeft
, LPOLESTR pszDisplayName
, ULONG
*pchEaten
, IMoniker
**ppmkOut
)
933 ok(0, "unexpected call\n");
937 static HRESULT WINAPI
Moniker_IsSystemMoniker(IMoniker
*iface
, DWORD
*pdwMksys
)
939 ok(0, "unexpected call\n");
943 static const IMonikerVtbl MonikerVtbl
= {
944 Moniker_QueryInterface
,
952 Moniker_BindToObject
,
953 Moniker_BindToStorage
,
960 Moniker_GetTimeOfLastChange
,
962 Moniker_CommonPrefixWith
,
963 Moniker_RelativePathTo
,
964 Moniker_GetDisplayName
,
965 Moniker_ParseDisplayName
,
966 Moniker_IsSystemMoniker
969 static IMoniker Moniker
= { &MonikerVtbl
};
971 static HRESULT WINAPI
OleContainer_QueryInterface(IOleContainer
*iface
, REFIID riid
, void **ppv
)
973 return QueryInterface(riid
, ppv
);
976 static ULONG WINAPI
OleContainer_AddRef(IOleContainer
*iface
)
981 static ULONG WINAPI
OleContainer_Release(IOleContainer
*iface
)
986 static HRESULT WINAPI
OleContainer_ParseDisplayName(IOleContainer
*iface
, IBindCtx
*pbc
,
987 LPOLESTR pszDiaplayName
, ULONG
*pchEaten
, IMoniker
**ppmkOut
)
989 ok(0, "unexpected call\n");
993 static HRESULT WINAPI
OleContainer_EnumObjects(IOleContainer
*iface
, DWORD grfFlags
,
994 IEnumUnknown
**ppenum
)
996 ok(0, "unexpected call\n");
1000 static HRESULT WINAPI
OleContainer_LockContainer(IOleContainer
*iface
, BOOL fLock
)
1002 CHECK_EXPECT(LockContainer
);
1003 ok(expect_LockContainer_fLock
== fLock
, "fLock=%x, expected %x\n", fLock
, expect_LockContainer_fLock
);
1007 static const IOleContainerVtbl OleContainerVtbl
= {
1008 OleContainer_QueryInterface
,
1009 OleContainer_AddRef
,
1010 OleContainer_Release
,
1011 OleContainer_ParseDisplayName
,
1012 OleContainer_EnumObjects
,
1013 OleContainer_LockContainer
1016 static IOleContainer OleContainer
= { &OleContainerVtbl
};
1018 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
1020 return QueryInterface(riid
, ppv
);
1023 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
1028 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
1033 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
1035 ok(0, "unexpected call\n");
1039 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
1041 ok(0, "unexpected call\n");
1045 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
1047 ok(0, "unexpected call\n");
1051 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
1052 LPCBORDERWIDTHS pborderwidths
)
1054 ok(0, "unexpected call\n");
1058 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
1059 LPCBORDERWIDTHS pborderwidths
)
1061 ok(0, "unexpected call\n");
1065 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
1066 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
1068 static const WCHAR wszHTML_Document
[] =
1069 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1071 CHECK_EXPECT2(SetActiveObject
);
1073 if(expect_SetActiveObject_active
) {
1074 ok(pActiveObject
!= NULL
, "pActiveObject = NULL\n");
1075 if(pActiveObject
&& PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH
)
1076 ok(!lstrcmpW(wszHTML_Document
, pszObjName
), "pszObjName != \"HTML Document\"\n");
1078 ok(pActiveObject
== NULL
, "pActiveObject=%p, expected NULL\n", pActiveObject
);
1079 ok(pszObjName
== NULL
, "pszObjName=%p, expected NULL\n", pszObjName
);
1085 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
1086 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
1088 ok(0, "unexpected call\n");
1092 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
1093 HOLEMENU holemenu
, HWND hwndActiveObject
)
1095 ok(0, "unexpected call\n");
1099 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
1101 ok(0, "unexpected call\n");
1105 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
1107 CHECK_EXPECT2(SetStatusText
);
1108 if(!expect_status_text
)
1109 ok(pszStatusText
== NULL
, "pszStatusText=%p, expected NULL\n", pszStatusText
);
1113 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
1115 ok(0, "unexpected call\n");
1119 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
1121 ok(0, "unexpected call\n");
1125 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
1126 InPlaceFrame_QueryInterface
,
1127 InPlaceFrame_AddRef
,
1128 InPlaceFrame_Release
,
1129 InPlaceFrame_GetWindow
,
1130 InPlaceFrame_ContextSensitiveHelp
,
1131 InPlaceFrame_GetBorder
,
1132 InPlaceFrame_RequestBorderSpace
,
1133 InPlaceFrame_SetBorderSpace
,
1134 InPlaceFrame_SetActiveObject
,
1135 InPlaceFrame_InsertMenus
,
1136 InPlaceFrame_SetMenu
,
1137 InPlaceFrame_RemoveMenus
,
1138 InPlaceFrame_SetStatusText
,
1139 InPlaceFrame_EnableModeless
,
1140 InPlaceFrame_TranslateAccelerator
1143 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
1145 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
1147 return QueryInterface(riid
, ppv
);
1150 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
1155 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
1160 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
1162 CHECK_EXPECT(GetWindow
);
1163 ok(phwnd
!= NULL
, "phwnd = NULL\n");
1164 *phwnd
= container_hwnd
;
1168 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
1170 ok(0, "unexpected call\n");
1174 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
1176 CHECK_EXPECT(CanInPlaceActivate
);
1180 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
1182 CHECK_EXPECT(OnInPlaceActivate
);
1186 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
1188 CHECK_EXPECT(OnUIActivate
);
1192 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
1193 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
1194 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
1196 static const RECT rect
= {0,0,500,500};
1198 CHECK_EXPECT(GetWindowContext
);
1200 ok(ppFrame
!= NULL
, "ppFrame = NULL\n");
1202 *ppFrame
= &InPlaceFrame
;
1203 ok(ppDoc
!= NULL
, "ppDoc = NULL\n");
1206 ok(lprcPosRect
!= NULL
, "lprcPosRect = NULL\n");
1208 memcpy(lprcPosRect
, &rect
, sizeof(RECT
));
1209 ok(lprcClipRect
!= NULL
, "lprcClipRect = NULL\n");
1211 memcpy(lprcClipRect
, &rect
, sizeof(RECT
));
1212 ok(lpFrameInfo
!= NULL
, "lpFrameInfo = NULL\n");
1214 lpFrameInfo
->cb
= sizeof(*lpFrameInfo
);
1215 lpFrameInfo
->fMDIApp
= FALSE
;
1216 lpFrameInfo
->hwndFrame
= container_hwnd
;
1217 lpFrameInfo
->haccel
= NULL
;
1218 lpFrameInfo
->cAccelEntries
= 0;
1224 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
1226 ok(0, "unexpected call\n");
1230 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
1232 CHECK_EXPECT(OnUIDeactivate
);
1233 ok(!fUndoable
, "fUndoable = TRUE\n");
1237 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
1239 CHECK_EXPECT(OnInPlaceDeactivate
);
1243 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
1245 ok(0, "unexpected call\n");
1249 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
1251 ok(0, "unexpected call\n");
1255 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
1257 ok(0, "unexpected call\n");
1261 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
1262 InPlaceSite_QueryInterface
,
1264 InPlaceSite_Release
,
1265 InPlaceSite_GetWindow
,
1266 InPlaceSite_ContextSensitiveHelp
,
1267 InPlaceSite_CanInPlaceActivate
,
1268 InPlaceSite_OnInPlaceActivate
,
1269 InPlaceSite_OnUIActivate
,
1270 InPlaceSite_GetWindowContext
,
1272 InPlaceSite_OnUIDeactivate
,
1273 InPlaceSite_OnInPlaceDeactivate
,
1274 InPlaceSite_DiscardUndoState
,
1275 InPlaceSite_DeactivateAndUndo
,
1276 InPlaceSite_OnPosRectChange
1279 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
1281 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
1283 return QueryInterface(riid
, ppv
);
1286 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
1291 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
1296 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
1298 ok(0, "unexpected call\n");
1302 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAsign
, DWORD dwWhichMoniker
,
1305 ok(0, "unexpected call\n");
1309 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
1311 CHECK_EXPECT(GetContainer
);
1312 ok(ppContainer
!= NULL
, "ppContainer = NULL\n");
1313 *ppContainer
= &OleContainer
;
1317 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
1319 ok(0, "unexpected call\n");
1323 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
1325 ok(0, "unexpected call\n");
1329 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
1331 ok(0, "unexpected call\n");
1335 static const IOleClientSiteVtbl ClientSiteVtbl
= {
1336 ClientSite_QueryInterface
,
1339 ClientSite_SaveObject
,
1340 ClientSite_GetMoniker
,
1341 ClientSite_GetContainer
,
1342 ClientSite_ShowObject
,
1343 ClientSite_OnShowWindow
,
1344 ClientSite_RequestNewObjectLayout
1347 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
1349 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
1351 return QueryInterface(riid
, ppv
);
1354 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
1359 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
1364 static BOOL call_UIActivate
= TRUE
;
1365 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
1367 IOleDocument
*document
;
1370 CHECK_EXPECT(ActivateMe
);
1371 ok(pViewToActivate
!= NULL
, "pViewToActivate = NULL\n");
1373 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
1374 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
1376 if(SUCCEEDED(hres
)) {
1377 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
1378 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
1380 if(SUCCEEDED(hres
)) {
1381 IOleInPlaceActiveObject
*activeobj
= NULL
;
1382 IOleInPlaceSite
*inplacesite
= NULL
;
1383 HWND tmp_hwnd
= NULL
;
1384 static RECT rect
= {0,0,400,500};
1386 hres
= IOleDocumentView_GetInPlaceSite(view
, &inplacesite
);
1387 ok(hres
== S_OK
, "GetInPlaceSite failed: %08x\n", hres
);
1388 ok(inplacesite
== &InPlaceSite
, "inplacesite=%p, expected %p\n",
1389 inplacesite
, &InPlaceSite
);
1391 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
1392 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
1394 hres
= IOleDocumentView_GetInPlaceSite(view
, &inplacesite
);
1395 ok(hres
== S_OK
, "GetInPlaceSite failed: %08x\n", hres
);
1396 ok(inplacesite
== &InPlaceSite
, "inplacesite=%p, expected %p\n",
1397 inplacesite
, &InPlaceSite
);
1399 hres
= IOleDocumentView_QueryInterface(view
, &IID_IOleInPlaceActiveObject
, (void**)&activeobj
);
1400 ok(hres
== S_OK
, "Could not get IOleInPlaceActiveObject: %08x\n", hres
);
1403 IOleInPlaceActiveObject_GetWindow(activeobj
, &hwnd
);
1404 ok(hres
== S_OK
, "GetWindow failed: %08x\n", hres
);
1405 ok(hwnd
== NULL
, "hwnd=%p, expeted NULL\n", hwnd
);
1408 if(call_UIActivate
) {
1409 SET_EXPECT(CanInPlaceActivate
);
1410 SET_EXPECT(GetWindowContext
);
1411 SET_EXPECT(GetWindow
);
1412 SET_EXPECT(OnInPlaceActivate
);
1413 SET_EXPECT(SetStatusText
);
1414 SET_EXPECT(Exec_SETPROGRESSMAX
);
1415 SET_EXPECT(Exec_SETPROGRESSPOS
);
1416 SET_EXPECT(OnUIActivate
);
1417 SET_EXPECT(SetActiveObject
);
1419 expect_SetActiveObject_active
= TRUE
;
1420 expect_status_text
= NULL
;
1422 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
1425 trace("UIActivate failed: %08x\n", hres
);
1428 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
1430 CHECK_CALLED(CanInPlaceActivate
);
1431 CHECK_CALLED(GetWindowContext
);
1432 CHECK_CALLED(GetWindow
);
1433 CHECK_CALLED(OnInPlaceActivate
);
1434 CHECK_CALLED(SetStatusText
);
1435 CHECK_CALLED(Exec_SETPROGRESSMAX
);
1436 CHECK_CALLED(Exec_SETPROGRESSPOS
);
1437 CHECK_CALLED(OnUIActivate
);
1438 CHECK_CALLED(SetActiveObject
);
1439 CHECK_CALLED(ShowUI
);
1442 hres
= IOleInPlaceActiveObject_GetWindow(activeobj
, &hwnd
);
1443 ok(hres
== S_OK
, "GetWindow failed: %08x\n", hres
);
1444 ok(hwnd
!= NULL
, "hwnd == NULL\n");
1446 ok(hwnd
== last_hwnd
, "hwnd != last_hwnd\n");
1449 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
1450 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
1453 hres
= IOleInPlaceActiveObject_GetWindow(activeobj
, &tmp_hwnd
);
1454 ok(hres
== S_OK
, "GetWindow failed: %08x\n", hres
);
1455 ok(tmp_hwnd
== hwnd
, "tmp_hwnd=%p, expected %p\n", tmp_hwnd
, hwnd
);
1459 hres
= IOleDocumentView_SetRect(view
, &rect
);
1460 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
1462 if(call_UIActivate
) {
1463 hres
= IOleDocumentView_Show(view
, TRUE
);
1464 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
1466 SET_EXPECT(CanInPlaceActivate
);
1467 SET_EXPECT(GetWindowContext
);
1468 SET_EXPECT(GetWindow
);
1469 SET_EXPECT(OnInPlaceActivate
);
1470 SET_EXPECT(SetStatusText
);
1471 SET_EXPECT(Exec_SETPROGRESSMAX
);
1472 SET_EXPECT(Exec_SETPROGRESSPOS
);
1473 SET_EXPECT(OnUIActivate
);
1474 expect_status_text
= (load_state
== LD_COMPLETE
? (LPCOLESTR
)0xdeadbeef : NULL
);
1476 hres
= IOleDocumentView_Show(view
, TRUE
);
1477 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
1479 CHECK_CALLED(CanInPlaceActivate
);
1480 CHECK_CALLED(GetWindowContext
);
1481 CHECK_CALLED(GetWindow
);
1482 CHECK_CALLED(OnInPlaceActivate
);
1483 CHECK_CALLED(SetStatusText
);
1484 CHECK_CALLED(Exec_SETPROGRESSMAX
);
1485 CHECK_CALLED(Exec_SETPROGRESSPOS
);
1488 hres
= IOleInPlaceActiveObject_GetWindow(activeobj
, &hwnd
);
1489 ok(hres
== S_OK
, "GetWindow failed: %08x\n", hres
);
1490 ok(hwnd
!= NULL
, "hwnd == NULL\n");
1492 ok(hwnd
== last_hwnd
, "hwnd != last_hwnd\n");
1497 IOleInPlaceActiveObject_Release(activeobj
);
1500 IOleDocument_Release(document
);
1506 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
1507 DocumentSite_QueryInterface
,
1508 DocumentSite_AddRef
,
1509 DocumentSite_Release
,
1510 DocumentSite_ActivateMe
1513 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
1515 static HRESULT WINAPI
DocHostUIHandler_QueryInterface(IDocHostUIHandler2
*iface
, REFIID riid
, void **ppv
)
1517 return QueryInterface(riid
, ppv
);
1520 static ULONG WINAPI
DocHostUIHandler_AddRef(IDocHostUIHandler2
*iface
)
1525 static ULONG WINAPI
DocHostUIHandler_Release(IDocHostUIHandler2
*iface
)
1530 static HRESULT WINAPI
DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2
*iface
, DWORD dwID
, POINT
*ppt
,
1531 IUnknown
*pcmdtReserved
, IDispatch
*pdicpReserved
)
1533 ok(0, "unexpected call\n");
1537 static HRESULT WINAPI
DocHostUIHandler_GetHostInfo(IDocHostUIHandler2
*iface
, DOCHOSTUIINFO
*pInfo
)
1539 CHECK_EXPECT(GetHostInfo
);
1540 ok(pInfo
!= NULL
, "pInfo=NULL\n");
1542 ok(pInfo
->cbSize
== sizeof(DOCHOSTUIINFO
), "pInfo->cbSize=%u\n", pInfo
->cbSize
);
1543 ok(!pInfo
->dwFlags
, "pInfo->dwFlags=%08x, expected 0\n", pInfo
->dwFlags
);
1544 pInfo
->dwFlags
= DOCHOSTUIFLAG_DISABLE_HELP_MENU
| DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1545 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY
| DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1546 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION
;
1547 ok(!pInfo
->dwDoubleClick
, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo
->dwDoubleClick
);
1548 ok(!pInfo
->pchHostCss
, "pInfo->pchHostCss=%p, expected NULL\n", pInfo
->pchHostCss
);
1549 ok(!pInfo
->pchHostNS
, "pInfo->pchhostNS=%p, expected NULL\n", pInfo
->pchHostNS
);
1554 static HRESULT WINAPI
DocHostUIHandler_ShowUI(IDocHostUIHandler2
*iface
, DWORD dwID
,
1555 IOleInPlaceActiveObject
*pActiveObject
, IOleCommandTarget
*pCommandTarget
,
1556 IOleInPlaceFrame
*pFrame
, IOleInPlaceUIWindow
*pDoc
)
1558 CHECK_EXPECT(ShowUI
);
1560 ok(dwID
== DOCHOSTUITYPE_BROWSE
, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID
);
1561 ok(pActiveObject
!= NULL
, "pActiveObject = NULL\n");
1562 ok(pCommandTarget
!= NULL
, "pCommandTarget = NULL\n");
1563 ok(pFrame
== &InPlaceFrame
, "pFrame=%p, expected %p\n", pFrame
, &InPlaceFrame
);
1564 ok(pDoc
== NULL
, "pDoc=%p, expected NULL\n", pDoc
);
1569 static HRESULT WINAPI
DocHostUIHandler_HideUI(IDocHostUIHandler2
*iface
)
1571 CHECK_EXPECT(HideUI
);
1575 static HRESULT WINAPI
DocHostUIHandler_UpdateUI(IDocHostUIHandler2
*iface
)
1577 CHECK_EXPECT(UpdateUI
);
1581 static HRESULT WINAPI
DocHostUIHandler_EnableModeless(IDocHostUIHandler2
*iface
, BOOL fEnable
)
1583 ok(0, "unexpected call\n");
1587 static HRESULT WINAPI
DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2
*iface
, BOOL fActivate
)
1589 ok(0, "unexpected call\n");
1593 static BOOL expect_OnFrameWindowActivate_fActivate
;
1594 static HRESULT WINAPI
DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2
*iface
, BOOL fActivate
)
1596 CHECK_EXPECT2(OnFrameWindowActivate
);
1597 ok(fActivate
== expect_OnFrameWindowActivate_fActivate
, "fActivate=%x\n", fActivate
);
1601 static HRESULT WINAPI
DocHostUIHandler_ResizeBorder(IDocHostUIHandler2
*iface
, LPCRECT prcBorder
,
1602 IOleInPlaceUIWindow
*pUIWindow
, BOOL fRameWindow
)
1604 ok(0, "unexpected call\n");
1608 static HRESULT WINAPI
DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2
*iface
, LPMSG lpMsg
,
1609 const GUID
*pguidCmdGroup
, DWORD nCmdID
)
1611 ok(0, "unexpected call\n");
1615 static HRESULT WINAPI
DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2
*iface
,
1616 LPOLESTR
*pchKey
, DWORD dw
)
1618 CHECK_EXPECT(GetOptionKeyPath
);
1619 ok(pchKey
!= NULL
, "pchKey = NULL\n");
1620 ok(!dw
, "dw=%d, expected 0\n", dw
);
1622 ok(!*pchKey
, "*pchKey=%p, expected NULL\n", *pchKey
);
1626 static HRESULT WINAPI
DocHostUIHandler_GetDropTarget(IDocHostUIHandler2
*iface
,
1627 IDropTarget
*pDropTarget
, IDropTarget
**ppDropTarget
)
1629 CHECK_EXPECT(GetDropTarget
);
1634 static HRESULT WINAPI
DocHostUIHandler_GetExternal(IDocHostUIHandler2
*iface
, IDispatch
**ppDispatch
)
1636 ok(0, "unexpected call\n");
1640 static HRESULT WINAPI
DocHostUIHandler_TranslateUrl(IDocHostUIHandler2
*iface
, DWORD dwTranslate
,
1641 OLECHAR
*pchURLIn
, OLECHAR
**ppchURLOut
)
1643 ok(0, "unexpected call\n");
1647 static HRESULT WINAPI
DocHostUIHandler_FilterDataObject(IDocHostUIHandler2
*iface
, IDataObject
*pDO
,
1648 IDataObject
**ppPORet
)
1650 ok(0, "unexpected call\n");
1654 static HRESULT WINAPI
DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2
*iface
,
1655 LPOLESTR
*pchKey
, DWORD dw
)
1657 CHECK_EXPECT(GetOverrideKeyPath
);
1658 ok(pchKey
!= NULL
, "pchKey = NULL\n");
1660 ok(!*pchKey
, "*pchKey=%p, expected NULL\n", *pchKey
);
1661 ok(!dw
, "dw=%d, xepected 0\n", dw
);
1665 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl
= {
1666 DocHostUIHandler_QueryInterface
,
1667 DocHostUIHandler_AddRef
,
1668 DocHostUIHandler_Release
,
1669 DocHostUIHandler_ShowContextMenu
,
1670 DocHostUIHandler_GetHostInfo
,
1671 DocHostUIHandler_ShowUI
,
1672 DocHostUIHandler_HideUI
,
1673 DocHostUIHandler_UpdateUI
,
1674 DocHostUIHandler_EnableModeless
,
1675 DocHostUIHandler_OnDocWindowActivate
,
1676 DocHostUIHandler_OnFrameWindowActivate
,
1677 DocHostUIHandler_ResizeBorder
,
1678 DocHostUIHandler_TranslateAccelerator
,
1679 DocHostUIHandler_GetOptionKeyPath
,
1680 DocHostUIHandler_GetDropTarget
,
1681 DocHostUIHandler_GetExternal
,
1682 DocHostUIHandler_TranslateUrl
,
1683 DocHostUIHandler_FilterDataObject
,
1684 DocHostUIHandler_GetOverrideKeyPath
1687 static IDocHostUIHandler2 DocHostUIHandler
= { &DocHostUIHandlerVtbl
};
1689 static HRESULT WINAPI
OleCommandTarget_QueryInterface(IOleCommandTarget
*iface
,
1690 REFIID riid
, void **ppv
)
1692 return QueryInterface(riid
, ppv
);
1695 static ULONG WINAPI
OleCommandTarget_AddRef(IOleCommandTarget
*iface
)
1700 static ULONG WINAPI
OleCommandTarget_Release(IOleCommandTarget
*iface
)
1705 static HRESULT WINAPI
OleCommandTarget_QueryStatus(IOleCommandTarget
*iface
, const GUID
*pguidCmdGroup
,
1706 ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
1708 ok(!pguidCmdGroup
, "pguidCmdGroup != MULL\n");
1709 ok(cCmds
== 1, "cCmds=%d, expected 1\n", cCmds
);
1710 ok(!pCmdText
, "pCmdText != NULL\n");
1712 switch(prgCmds
[0].cmdID
) {
1713 case OLECMDID_SETPROGRESSTEXT
:
1714 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT
);
1715 prgCmds
[0].cmdf
= OLECMDF_ENABLED
;
1718 CHECK_EXPECT(QueryStatus_OPEN
);
1719 prgCmds
[0].cmdf
= 0;
1722 CHECK_EXPECT(QueryStatus_NEW
);
1723 prgCmds
[0].cmdf
= 0;
1726 ok(0, "unexpected command %d\n", prgCmds
[0].cmdID
);
1732 static HRESULT WINAPI
OleCommandTarget_Exec(IOleCommandTarget
*iface
, const GUID
*pguidCmdGroup
,
1733 DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
1735 test_readyState(NULL
);
1737 if(!pguidCmdGroup
) {
1739 case OLECMDID_SETPROGRESSMAX
:
1740 CHECK_EXPECT2(Exec_SETPROGRESSMAX
);
1741 ok(nCmdexecopt
== OLECMDEXECOPT_DONTPROMPTUSER
, "nCmdexecopts=%08x\n", nCmdexecopt
);
1742 ok(pvaIn
!= NULL
, "pvaIn == NULL\n");
1744 ok(V_VT(pvaIn
) == VT_I4
, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn
));
1745 if(load_state
== LD_NO
)
1746 ok(V_I4(pvaIn
) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn
));
1748 ok(pvaOut
== NULL
, "pvaOut=%p, expected NULL\n", pvaOut
);
1750 case OLECMDID_SETPROGRESSPOS
:
1751 CHECK_EXPECT2(Exec_SETPROGRESSPOS
);
1752 ok(nCmdexecopt
== OLECMDEXECOPT_DONTPROMPTUSER
, "nCmdexecopts=%08x\n", nCmdexecopt
);
1753 ok(pvaIn
!= NULL
, "pvaIn == NULL\n");
1755 ok(V_VT(pvaIn
) == VT_I4
, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn
));
1756 if(load_state
== LD_NO
)
1757 ok(V_I4(pvaIn
) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn
));
1759 ok(pvaOut
== NULL
, "pvaOut=%p, expected NULL\n", pvaOut
);
1761 case OLECMDID_HTTPEQUIV_DONE
:
1762 CHECK_EXPECT(Exec_HTTPEQUIV_DONE
);
1763 ok(nCmdexecopt
== 0, "nCmdexecopts=%08x\n", nCmdexecopt
);
1764 ok(pvaOut
== NULL
, "pvaOut=%p\n", pvaOut
);
1765 ok(pvaIn
== NULL
, "pvaIn=%p\n", pvaIn
);
1766 load_state
= LD_COMPLETE
;
1768 case OLECMDID_SETDOWNLOADSTATE
:
1769 ok(nCmdexecopt
== OLECMDEXECOPT_DONTPROMPTUSER
, "nCmdexecopts=%08x\n", nCmdexecopt
);
1770 ok(pvaOut
== NULL
, "pvaOut=%p\n", pvaOut
);
1771 ok(pvaIn
!= NULL
, "pvaIn == NULL\n");
1772 ok(V_VT(pvaIn
) == VT_I4
, "V_VT(pvaIn)=%d\n", V_VT(pvaIn
));
1774 switch(V_I4(pvaIn
)) {
1776 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0
);
1777 load_state
= LD_INTERACTIVE
;
1780 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1
);
1783 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn
));
1787 case OLECMDID_UPDATECOMMANDS
:
1788 CHECK_EXPECT(Exec_UPDATECOMMANDS
);
1789 ok(nCmdexecopt
== OLECMDEXECOPT_DONTPROMPTUSER
, "nCmdexecopts=%08x\n", nCmdexecopt
);
1790 ok(pvaIn
== NULL
, "pvaIn=%p\n", pvaIn
);
1791 ok(pvaOut
== NULL
, "pvaOut=%p\n", pvaOut
);
1793 case OLECMDID_SETTITLE
:
1794 CHECK_EXPECT2(Exec_SETTITLE
);
1795 ok(nCmdexecopt
== OLECMDEXECOPT_DONTPROMPTUSER
, "nCmdexecopts=%08x\n", nCmdexecopt
);
1796 ok(pvaIn
!= NULL
, "pvaIn == NULL\n");
1797 ok(pvaOut
== NULL
, "pvaOut=%p\n", pvaOut
);
1798 ok(V_VT(pvaIn
) == VT_BSTR
, "V_VT(pvaIn)=%d\n", V_VT(pvaIn
));
1799 ok(V_BSTR(pvaIn
) != NULL
, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
1801 case OLECMDID_HTTPEQUIV
:
1802 CHECK_EXPECT2(Exec_HTTPEQUIV
);
1803 ok(nCmdexecopt
== OLECMDEXECOPT_DONTPROMPTUSER
, "nCmdexecopts=%08x\n", nCmdexecopt
);
1807 ok(0, "unexpected command %d\n", nCmdID
);
1812 if(IsEqualGUID(&CGID_ShellDocView
, pguidCmdGroup
)) {
1813 ok(nCmdexecopt
== 0, "nCmdexecopts=%08x\n", nCmdexecopt
);
1817 CHECK_EXPECT2(Exec_ShellDocView_37
);
1818 ok(pvaOut
== NULL
, "pvaOut=%p, expected NULL\n", pvaOut
);
1819 ok(pvaIn
!= NULL
, "pvaIn == NULL\n");
1821 ok(V_VT(pvaIn
) == VT_I4
, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn
));
1822 ok(V_I4(pvaIn
) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn
));
1826 ok(0, "unexpected command %d\n", nCmdID
);
1831 if(IsEqualGUID(&CGID_MSHTML
, pguidCmdGroup
)) {
1832 ok(nCmdexecopt
== 0, "nCmdexecopts=%08x\n", nCmdexecopt
);
1835 case IDM_PARSECOMPLETE
:
1836 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE
);
1837 ok(pvaIn
== NULL
, "pvaIn != NULL\n");
1838 ok(pvaOut
== NULL
, "pvaOut != NULL\n");
1841 ok(0, "unexpected command %d\n", nCmdID
);
1845 if(IsEqualGUID(&CGID_DocHostCmdPriv
, pguidCmdGroup
))
1846 return E_FAIL
; /* TODO */
1848 ok(0, "unexpected call\n");
1852 static IOleCommandTargetVtbl OleCommandTargetVtbl
= {
1853 OleCommandTarget_QueryInterface
,
1854 OleCommandTarget_AddRef
,
1855 OleCommandTarget_Release
,
1856 OleCommandTarget_QueryStatus
,
1857 OleCommandTarget_Exec
1860 static IOleCommandTarget OleCommandTarget
= { &OleCommandTargetVtbl
};
1862 static HRESULT WINAPI
Dispatch_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
1864 return QueryInterface(riid
, ppv
);
1867 static ULONG WINAPI
Dispatch_AddRef(IDispatch
*iface
)
1872 static ULONG WINAPI
Dispatch_Release(IDispatch
*iface
)
1877 static HRESULT WINAPI
Dispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1879 ok(0, "unexpected call\n");
1883 static HRESULT WINAPI
Dispatch_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
, LCID lcid
,
1884 ITypeInfo
**ppTInfo
)
1886 ok(0, "unexpected call\n");
1890 static HRESULT WINAPI
Dispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
1891 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1893 ok(0, "unexpected call\n");
1897 static HRESULT WINAPI
Dispatch_Invoke(IDispatch
*iface
, DISPID dispIdMember
, REFIID riid
,
1898 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
1899 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1901 ok(IsEqualGUID(&IID_NULL
, riid
), "riid != IID_NULL\n");
1902 ok(pDispParams
!= NULL
, "pDispParams == NULL\n");
1903 ok(pExcepInfo
== NULL
, "pExcepInfo=%p, expected NULL\n", pExcepInfo
);
1904 ok(puArgErr
!= NULL
, "puArgErr == NULL\n");
1905 ok(V_VT(pVarResult
) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult
));
1906 ok(wFlags
== DISPATCH_PROPERTYGET
, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags
);
1907 test_readyState(NULL
);
1909 switch(dispIdMember
) {
1910 case DISPID_AMBIENT_USERMODE
:
1911 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE
);
1912 V_VT(pVarResult
) = VT_BOOL
;
1913 V_BOOL(pVarResult
) = VARIANT_TRUE
;
1915 case DISPID_AMBIENT_DLCONTROL
:
1916 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL
);
1918 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
1919 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
1921 case DISPID_AMBIENT_SILENT
:
1922 CHECK_EXPECT2(Invoke_AMBIENT_SILENT
);
1923 V_VT(pVarResult
) = VT_BOOL
;
1924 V_BOOL(pVarResult
) = VARIANT_FALSE
;
1926 case DISPID_AMBIENT_USERAGENT
:
1927 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT
);
1929 case DISPID_AMBIENT_PALETTE
:
1930 CHECK_EXPECT(Invoke_AMBIENT_PALETTE
);
1934 ok(0, "unexpected dispid %d\n", dispIdMember
);
1938 static IDispatchVtbl DispatchVtbl
= {
1939 Dispatch_QueryInterface
,
1942 Dispatch_GetTypeInfoCount
,
1943 Dispatch_GetTypeInfo
,
1944 Dispatch_GetIDsOfNames
,
1948 static IDispatch Dispatch
= { &DispatchVtbl
};
1950 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
,
1951 REFIID riid
, void **ppv
)
1953 return QueryInterface(riid
, ppv
);
1956 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
1961 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
1966 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
1967 REFIID riid
, void **ppv
)
1970 * Services used by HTMLDocument:
1973 * IInternetSecurityManager
1975 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
1978 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
1979 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
1980 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
1982 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
1983 * IElementBehaviorFactory
1984 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
1994 if(IsEqualGUID(&IID_IHlinkFrame
, guidService
)) {
1995 ok(IsEqualGUID(&IID_IHlinkFrame
, riid
), "unexpected riid\n");
2000 return E_NOINTERFACE
;
2003 static const IServiceProviderVtbl ServiceProviderVtbl
= {
2004 ServiceProvider_QueryInterface
,
2005 ServiceProvider_AddRef
,
2006 ServiceProvider_Release
,
2007 ServiceProvider_QueryService
2010 static IServiceProvider ServiceProvider
= { &ServiceProviderVtbl
};
2012 static HRESULT
QueryInterface(REFIID riid
, void **ppv
)
2016 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
2018 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
2019 *ppv
= &DocumentSite
;
2020 else if(IsEqualGUID(&IID_IDocHostUIHandler
, riid
) || IsEqualGUID(&IID_IDocHostUIHandler2
, riid
))
2021 *ppv
= &DocHostUIHandler
;
2022 else if(IsEqualGUID(&IID_IOleContainer
, riid
))
2023 *ppv
= &OleContainer
;
2024 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
2025 *ppv
= &InPlaceSite
;
2026 else if(IsEqualGUID(&IID_IOleInPlaceUIWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceFrame
, riid
))
2027 *ppv
= &InPlaceFrame
;
2028 else if(IsEqualGUID(&IID_IOleCommandTarget
, riid
))
2029 *ppv
= &OleCommandTarget
;
2030 else if(IsEqualGUID(&IID_IDispatch
, riid
))
2032 else if(IsEqualGUID(&IID_IServiceProvider
, riid
))
2033 *ppv
= &ServiceProvider
;
2037 * {D48A6EC6-6A4A-11CF-94A7-444553540000}
2038 * {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
2039 * {000670BA-0000-0000-C000-000000000046}
2044 return E_NOINTERFACE
;
2047 static LRESULT WINAPI
wnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
2049 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
2052 static void test_readyState(IUnknown
*unk
)
2054 IHTMLDocument2
*htmldoc
;
2058 static const WCHAR wszUninitialized
[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2059 static const WCHAR wszLoading
[] = {'l','o','a','d','i','n','g',0};
2060 static const WCHAR wszInteractive
[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2061 static const WCHAR wszComplete
[] = {'c','o','m','p','l','e','t','e',0};
2063 static const LPCWSTR expected_state
[] = {
2074 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument2
, (void**)&htmldoc
);
2075 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres
);
2079 hres
= IHTMLDocument2_get_readyState(htmldoc
, NULL
);
2080 ok(hres
== E_POINTER
, "get_readyState failed: %08x, expected\n", hres
);
2082 hres
= IHTMLDocument2_get_readyState(htmldoc
, &state
);
2083 ok(hres
== S_OK
, "get_ReadyState failed: %08x\n", hres
);
2084 ok(!lstrcmpW(state
, expected_state
[load_state
]), "unexpected state, expected %d\n", load_state
);
2086 IHTMLDocument_Release(htmldoc
);
2089 static void test_ConnectionPoint(IConnectionPointContainer
*container
, REFIID riid
)
2091 IConnectionPointContainer
*tmp_container
= NULL
;
2092 IConnectionPoint
*cp
;
2096 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
2097 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
2101 hres
= IConnectionPoint_GetConnectionInterface(cp
, &iid
);
2102 ok(hres
== S_OK
, "GetConnectionInterface failed: %08x\n", hres
);
2103 ok(IsEqualGUID(riid
, &iid
), "wrong iid\n");
2105 hres
= IConnectionPoint_GetConnectionInterface(cp
, NULL
);
2106 ok(hres
== E_POINTER
, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres
);
2108 hres
= IConnectionPoint_GetConnectionPointContainer(cp
, &tmp_container
);
2109 ok(hres
== S_OK
, "GetConnectionPointContainer failed: %08x\n", hres
);
2110 ok(tmp_container
== container
, "container != tmp_container\n");
2112 IConnectionPointContainer_Release(tmp_container
);
2114 hres
= IConnectionPoint_GetConnectionPointContainer(cp
, NULL
);
2115 ok(hres
== E_POINTER
, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres
);
2117 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
2120 hres
= IConnectionPoint_Advise(cp
, (IUnknown
*)&PropertyNotifySink
, &cookie
);
2121 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
2124 IConnectionPoint_Release(cp
);
2127 static void test_ConnectionPointContainer(IUnknown
*unk
)
2129 IConnectionPointContainer
*container
;
2132 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
2133 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
2137 test_ConnectionPoint(container
, &IID_IPropertyNotifySink
);
2138 test_ConnectionPoint(container
, &DIID_HTMLDocumentEvents
);
2139 test_ConnectionPoint(container
, &DIID_HTMLDocumentEvents2
);
2141 IConnectionPointContainer_Release(container
);
2144 static void test_Load(IPersistMoniker
*persist
)
2148 WCHAR sz_html_clientsite_objectparam
[MAX_PATH
];
2150 lstrcpyW(sz_html_clientsite_objectparam
, SZ_HTML_CLIENTSITE_OBJECTPARAM
);
2152 test_readyState((IUnknown
*)persist
);
2154 CreateBindCtx(0, &bind
);
2155 IBindCtx_RegisterObjectParam(bind
, sz_html_clientsite_objectparam
,
2156 (IUnknown
*)&ClientSite
);
2158 SET_EXPECT(GetDisplayName
);
2159 if(!set_clientsite
) {
2160 SET_EXPECT(Invoke_AMBIENT_USERMODE
);
2161 SET_EXPECT(GetHostInfo
);
2162 SET_EXPECT(Invoke_AMBIENT_DLCONTROL
);
2163 SET_EXPECT(Invoke_AMBIENT_SILENT
);
2164 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2165 SET_EXPECT(Invoke_AMBIENT_USERAGENT
);
2166 SET_EXPECT(Invoke_AMBIENT_PALETTE
);
2167 SET_EXPECT(GetOptionKeyPath
);
2168 SET_EXPECT(GetOverrideKeyPath
);
2169 SET_EXPECT(GetWindow
);
2170 SET_EXPECT(QueryStatus_SETPROGRESSTEXT
);
2171 SET_EXPECT(Exec_SETPROGRESSMAX
);
2172 SET_EXPECT(Exec_SETPROGRESSPOS
);
2173 SET_EXPECT(Exec_ShellDocView_37
);
2175 if(!container_locked
) {
2176 SET_EXPECT(GetContainer
);
2177 SET_EXPECT(LockContainer
);
2179 SET_EXPECT(OnChanged_READYSTATE
);
2180 SET_EXPECT(BindToStorage
);
2181 if(set_clientsite
) {
2182 SET_EXPECT(Invoke_AMBIENT_SILENT
);
2183 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2184 SET_EXPECT(Exec_ShellDocView_37
);
2186 expect_LockContainer_fLock
= TRUE
;
2187 readystate_set_loading
= TRUE
;
2189 hres
= IPersistMoniker_Load(persist
, FALSE
, &Moniker
, bind
, 0x12);
2190 ok(hres
== S_OK
, "Load failed: %08x\n", hres
);
2192 CHECK_CALLED(GetDisplayName
);
2193 if(!set_clientsite
) {
2194 CHECK_CALLED(Invoke_AMBIENT_USERMODE
);
2195 CHECK_CALLED(GetHostInfo
);
2196 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL
);
2197 CHECK_CALLED(Invoke_AMBIENT_SILENT
);
2198 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2199 CHECK_CALLED(Invoke_AMBIENT_USERAGENT
);
2200 CHECK_CALLED(Invoke_AMBIENT_PALETTE
);
2201 CHECK_CALLED(GetOptionKeyPath
);
2202 CHECK_CALLED(GetOverrideKeyPath
);
2203 CHECK_CALLED(GetWindow
);
2204 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT
);
2205 CHECK_CALLED(Exec_SETPROGRESSMAX
);
2206 CHECK_CALLED(Exec_SETPROGRESSPOS
);
2207 CHECK_CALLED(Exec_ShellDocView_37
);
2209 if(!container_locked
) {
2210 CHECK_CALLED(GetContainer
);
2211 CHECK_CALLED(LockContainer
);
2212 container_locked
= TRUE
;
2214 CHECK_CALLED(OnChanged_READYSTATE
);
2215 CHECK_CALLED(BindToStorage
);
2216 if(set_clientsite
) {
2217 CHECK_CALLED(Invoke_AMBIENT_SILENT
);
2218 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2219 CHECK_CALLED(Exec_ShellDocView_37
);
2222 set_clientsite
= container_locked
= TRUE
;
2224 IBindCtx_Release(bind
);
2226 test_readyState((IUnknown
*)persist
);
2229 static void test_download(BOOL verb_done
, BOOL css_dwl
)
2234 hwnd
= FindWindowA("Internet Explorer_Hidden", NULL
);
2235 ok(hwnd
!= NULL
, "Could not find hidden window\n");
2237 test_readyState(NULL
);
2240 SET_EXPECT(Exec_SETPROGRESSMAX
);
2241 if(!load_from_stream
)
2242 SET_EXPECT(GetHostInfo
);
2244 SET_EXPECT(SetStatusText
);
2245 SET_EXPECT(Exec_SETDOWNLOADSTATE_1
);
2246 SET_EXPECT(GetDropTarget
);
2248 SET_EXPECT(CreateInstance
);
2250 SET_EXPECT(LockRequest
);
2251 SET_EXPECT(Terminate
);
2252 SET_EXPECT(Protocol_Read
);
2253 SET_EXPECT(UnlockRequest
);
2255 SET_EXPECT(OnChanged_1005
);
2256 SET_EXPECT(OnChanged_READYSTATE
);
2257 SET_EXPECT(Exec_SETPROGRESSPOS
);
2258 SET_EXPECT(Exec_SETDOWNLOADSTATE_0
);
2259 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE
);
2260 SET_EXPECT(Exec_HTTPEQUIV_DONE
);
2261 SET_EXPECT(Exec_SETTITLE
);
2262 expect_status_text
= (LPWSTR
)0xdeadbeef; /* TODO */
2264 while(!called_Exec_HTTPEQUIV_DONE
&& GetMessage(&msg
, hwnd
, 0, 0)) {
2265 TranslateMessage(&msg
);
2266 DispatchMessage(&msg
);
2270 CHECK_CALLED(Exec_SETPROGRESSMAX
);
2271 if(!load_from_stream
)
2272 CHECK_CALLED(GetHostInfo
);
2274 CHECK_CALLED(SetStatusText
);
2275 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1
);
2276 CHECK_CALLED(GetDropTarget
);
2278 if(called_CreateInstance
) {
2279 CHECK_CALLED(CreateInstance
);
2280 CHECK_CALLED(Start
);
2281 CHECK_CALLED(LockRequest
);
2282 CHECK_CALLED(Terminate
);
2283 CHECK_CALLED(Protocol_Read
);
2284 CHECK_CALLED(UnlockRequest
);
2286 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2288 SET_CALLED(CreateInstance
);
2290 SET_CALLED(LockRequest
);
2291 SET_CALLED(Terminate
);
2292 SET_CALLED(Protocol_Read
);
2293 SET_CALLED(UnlockRequest
);
2296 CHECK_CALLED(OnChanged_1005
);
2297 CHECK_CALLED(OnChanged_READYSTATE
);
2298 CHECK_CALLED(Exec_SETPROGRESSPOS
);
2299 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0
);
2300 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE
);
2301 CHECK_CALLED(Exec_HTTPEQUIV_DONE
);
2302 CHECK_CALLED(Exec_SETTITLE
);
2304 load_state
= LD_COMPLETE
;
2306 test_readyState(NULL
);
2309 static void test_Persist(IUnknown
*unk
)
2311 IPersistMoniker
*persist_mon
;
2312 IPersistFile
*persist_file
;
2316 hres
= IUnknown_QueryInterface(unk
, &IID_IPersistFile
, (void**)&persist_file
);
2317 ok(hres
== S_OK
, "QueryInterface(IID_IPersist) failed: %08x\n", hres
);
2318 if(SUCCEEDED(hres
)) {
2319 hres
= IPersist_GetClassID(persist_file
, NULL
);
2320 ok(hres
== E_INVALIDARG
, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres
);
2322 hres
= IPersist_GetClassID(persist_file
, &guid
);
2323 ok(hres
== S_OK
, "GetClassID failed: %08x\n", hres
);
2324 ok(IsEqualGUID(&CLSID_HTMLDocument
, &guid
), "guid != CLSID_HTMLDocument\n");
2326 IPersist_Release(persist_file
);
2329 hres
= IUnknown_QueryInterface(unk
, &IID_IPersistMoniker
, (void**)&persist_mon
);
2330 ok(hres
== S_OK
, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres
);
2331 if(SUCCEEDED(hres
)) {
2332 hres
= IPersistMoniker_GetClassID(persist_mon
, NULL
);
2333 ok(hres
== E_INVALIDARG
, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres
);
2335 hres
= IPersistMoniker_GetClassID(persist_mon
, &guid
);
2336 ok(hres
== S_OK
, "GetClassID failed: %08x\n", hres
);
2337 ok(IsEqualGUID(&CLSID_HTMLDocument
, &guid
), "guid != CLSID_HTMLDocument\n");
2339 if(load_state
== LD_DOLOAD
)
2340 test_Load(persist_mon
);
2342 test_readyState(unk
);
2344 IPersistMoniker_Release(persist_mon
);
2348 static const OLECMDF expect_cmds
[OLECMDID_GETPRINTTEMPLATE
+1] = {
2350 OLECMDF_SUPPORTED
, /* OLECMDID_OPEN */
2351 OLECMDF_SUPPORTED
, /* OLECMDID_NEW */
2352 OLECMDF_SUPPORTED
, /* OLECMDID_SAVE */
2353 OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, /* OLECMDID_SAVEAS */
2354 OLECMDF_SUPPORTED
, /* OLECMDID_SAVECOPYAS */
2355 OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, /* OLECMDID_PRINT */
2356 OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, /* OLECMDID_PRINTPREVIEW */
2357 OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, /* OLECMDID_PAGESETUP */
2358 OLECMDF_SUPPORTED
, /* OLECMDID_SPELL */
2359 OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, /* OLECMDID_PROPERTIES */
2360 OLECMDF_SUPPORTED
, /* OLECMDID_CUT */
2361 OLECMDF_SUPPORTED
, /* OLECMDID_COPY */
2362 OLECMDF_SUPPORTED
, /* OLECMDID_PASTE */
2363 OLECMDF_SUPPORTED
, /* OLECMDID_PASTESPECIAL */
2364 OLECMDF_SUPPORTED
, /* OLECMDID_UNDO */
2365 OLECMDF_SUPPORTED
, /* OLECMDID_REDO */
2366 OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, /* OLECMDID_SELECTALL */
2367 OLECMDF_SUPPORTED
, /* OLECMDID_CLEARSELECTION */
2368 OLECMDF_SUPPORTED
, /* OLECMDID_ZOOM */
2369 OLECMDF_SUPPORTED
, /* OLECMDID_GETZOOMRANGE */
2371 OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, /* OLECMDID_REFRESH */
2372 OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, /* OLECMDID_STOP */
2374 OLECMDF_SUPPORTED
, /* OLECMDID_STOPDOWNLOAD */
2376 OLECMDF_SUPPORTED
, /* OLECMDID_DELETE */
2378 OLECMDF_SUPPORTED
, /* OLECMDID_ENABLE_INTERACTION */
2379 OLECMDF_SUPPORTED
, /* OLECMDID_ONUNLOAD */
2381 OLECMDF_SUPPORTED
, /* OLECMDID_SHOWPAGESETUP */
2382 OLECMDF_SUPPORTED
, /* OLECMDID_SHOWPRINT */
2384 OLECMDF_SUPPORTED
, /* OLECMDID_CLOSE */
2386 OLECMDF_SUPPORTED
, /* OLECMDID_SETPRINTTEMPLATE */
2387 OLECMDF_SUPPORTED
/* OLECMDID_GETPRINTTEMPLATE */
2390 static void test_QueryStatus(IUnknown
*unk
, REFIID cgid
, ULONG cmdid
, DWORD cmdf
)
2392 IOleCommandTarget
*cmdtrg
;
2393 OLECMD olecmd
= {cmdid
, 0};
2396 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2397 ok(hres
== S_OK
, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres
);
2401 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, cgid
, 1, &olecmd
, NULL
);
2402 ok(hres
== S_OK
, "QueryStatus failed: %08x\n", hres
);
2404 IOleCommandTarget_Release(cmdtrg
);
2406 ok(olecmd
.cmdID
== cmdid
, "cmdID changed\n");
2407 ok(olecmd
.cmdf
== cmdf
, "cmdf=%08x, expected %08x\n", olecmd
.cmdf
, cmdf
);
2410 static void test_MSHTML_QueryStatus(IUnknown
*unk
, DWORD cmdf
)
2415 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_FONTNAME
, cmdf
);
2416 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_FONTSIZE
, cmdf
);
2417 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_BOLD
, cmdf
);
2418 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_FORECOLOR
, cmdf
);
2419 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_JUSTIFYCENTER
, cmdf
);
2420 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_JUSTIFYLEFT
, cmdf
);
2421 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_JUSTIFYRIGHT
, cmdf
);
2422 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_ITALIC
, cmdf
);
2423 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_UNDERLINE
, cmdf
);
2424 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_HORIZONTALLINE
, cmdf
);
2425 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_ORDERLIST
, cmdf
);
2426 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_UNORDERLIST
, cmdf
);
2427 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_INDENT
, cmdf
);
2428 test_QueryStatus(unk
, &CGID_MSHTML
, IDM_OUTDENT
, cmdf
);
2431 static void test_OleCommandTarget(IUnknown
*unk
)
2433 IOleCommandTarget
*cmdtrg
;
2434 OLECMD cmds
[OLECMDID_GETPRINTTEMPLATE
];
2438 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2439 ok(hres
== S_OK
, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres
);
2443 for(i
=0; i
<OLECMDID_GETPRINTTEMPLATE
; i
++) {
2444 cmds
[i
].cmdID
= i
+1;
2445 cmds
[i
].cmdf
= 0xf0f0;
2448 SET_EXPECT(QueryStatus_OPEN
);
2449 SET_EXPECT(QueryStatus_NEW
);
2450 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, NULL
, sizeof(cmds
)/sizeof(cmds
[0]), cmds
, NULL
);
2451 ok(hres
== S_OK
, "QueryStatus failed: %08x\n", hres
);
2452 CHECK_CALLED(QueryStatus_OPEN
);
2453 CHECK_CALLED(QueryStatus_NEW
);
2455 for(i
=0; i
<OLECMDID_GETPRINTTEMPLATE
; i
++) {
2456 ok(cmds
[i
].cmdID
== i
+1, "cmds[%d].cmdID canged to %x\n", i
, cmds
[i
].cmdID
);
2457 ok(cmds
[i
].cmdf
== expect_cmds
[i
+1], "cmds[%d].cmdf=%x, expected %x\n",
2458 i
+1, cmds
[i
].cmdf
, expect_cmds
[i
+1]);
2461 IOleCommandTarget_Release(cmdtrg
);
2464 static void test_OleCommandTarget_fail(IUnknown
*unk
)
2466 IOleCommandTarget
*cmdtrg
;
2471 {OLECMDID_OPEN
, 0xf0f0},
2472 {OLECMDID_GETPRINTTEMPLATE
+1, 0xf0f0}
2475 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2476 ok(hres
== S_OK
, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres
);
2480 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, NULL
, 0, NULL
, NULL
);
2481 ok(hres
== S_OK
, "QueryStatus failed: %08x\n", hres
);
2483 SET_EXPECT(QueryStatus_OPEN
);
2484 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, NULL
, 2, cmd
, NULL
);
2485 CHECK_CALLED(QueryStatus_OPEN
);
2487 ok(hres
== OLECMDERR_E_NOTSUPPORTED
,
2488 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres
);
2489 ok(cmd
[1].cmdID
== OLECMDID_GETPRINTTEMPLATE
+1,
2490 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd
[0].cmdID
);
2491 ok(cmd
[1].cmdf
== 0, "cmd[0].cmdf=%x, expected 0\n", cmd
[0].cmdf
);
2492 ok(cmd
[0].cmdf
== OLECMDF_SUPPORTED
,
2493 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd
[1].cmdf
);
2495 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, &IID_IHTMLDocument2
, 2, cmd
, NULL
);
2496 ok(hres
== OLECMDERR_E_UNKNOWNGROUP
,
2497 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres
);
2499 for(i
=0; i
<OLECMDID_GETPRINTTEMPLATE
; i
++) {
2500 if(!expect_cmds
[i
]) {
2501 hres
= IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_UPDATECOMMANDS
,
2502 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
2503 ok(hres
== OLECMDERR_E_NOTSUPPORTED
,
2504 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres
);
2508 hres
= IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_GETPRINTTEMPLATE
+1,
2509 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
2510 ok(hres
== OLECMDERR_E_NOTSUPPORTED
,
2511 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres
);
2513 IOleCommandTarget_Release(cmdtrg
);
2516 static void test_exec_onunload(IUnknown
*unk
)
2518 IOleCommandTarget
*cmdtrg
;
2522 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2523 ok(hres
== S_OK
, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres
);
2527 memset(&var
, 0x0a, sizeof(var
));
2528 hres
= IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_ONUNLOAD
,
2529 OLECMDEXECOPT_DODEFAULT
, NULL
, &var
);
2530 ok(hres
== S_OK
, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres
);
2531 ok(V_VT(&var
) == VT_BOOL
, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var
));
2532 ok(V_BOOL(&var
) == VARIANT_TRUE
, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var
));
2534 hres
= IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_ONUNLOAD
,
2535 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
2536 ok(hres
== S_OK
, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres
);
2538 IOleCommandTarget_Release(cmdtrg
);
2541 static void test_exec_editmode(IUnknown
*unk
)
2543 IOleCommandTarget
*cmdtrg
;
2546 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
2547 ok(hres
== S_OK
, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres
);
2551 SET_EXPECT(SetStatusText
);
2552 SET_EXPECT(Exec_ShellDocView_37
);
2553 SET_EXPECT(GetHostInfo
);
2554 SET_EXPECT(Invoke_AMBIENT_SILENT
);
2555 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2556 SET_EXPECT(OnChanged_READYSTATE
);
2557 expect_status_text
= NULL
;
2558 readystate_set_loading
= TRUE
;
2560 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_MSHTML
, IDM_EDITMODE
,
2561 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
2562 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
2564 CHECK_CALLED(SetStatusText
);
2565 CHECK_CALLED(Exec_ShellDocView_37
);
2566 CHECK_CALLED(GetHostInfo
);
2567 CHECK_CALLED(Invoke_AMBIENT_SILENT
);
2568 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2569 CHECK_CALLED(OnChanged_READYSTATE
);
2571 IOleCommandTarget_Release(cmdtrg
);
2576 static HWND
create_container_window(void)
2578 static const WCHAR wszHTMLDocumentTest
[] =
2579 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
2580 static WNDCLASSEXW wndclass
= {
2581 sizeof(WNDCLASSEXW
),
2584 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
2585 wszHTMLDocumentTest
,
2589 RegisterClassExW(&wndclass
);
2590 return CreateWindowW(wszHTMLDocumentTest
, wszHTMLDocumentTest
,
2591 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
2592 CW_USEDEFAULT
, NULL
, NULL
, NULL
, NULL
);
2595 static HRESULT
test_DoVerb(IOleObject
*oleobj
)
2597 RECT rect
= {0,0,500,500};
2600 if(!container_locked
) {
2601 SET_EXPECT(GetContainer
);
2602 SET_EXPECT(LockContainer
);
2604 SET_EXPECT(ActivateMe
);
2605 expect_LockContainer_fLock
= TRUE
;
2607 hres
= IOleObject_DoVerb(oleobj
, OLEIVERB_SHOW
, NULL
, &ClientSite
, -1, container_hwnd
, &rect
);
2610 ok(hres
== S_OK
, "DoVerb failed: %08x\n", hres
);
2612 if(!container_locked
) {
2613 CHECK_CALLED(GetContainer
);
2614 CHECK_CALLED(LockContainer
);
2615 container_locked
= TRUE
;
2617 CHECK_CALLED(ActivateMe
);
2622 #define CLIENTSITE_EXPECTPATH 0x00000001
2623 #define CLIENTSITE_SETNULL 0x00000002
2624 #define CLIENTSITE_DONTSET 0x00000004
2626 static void test_ClientSite(IOleObject
*oleobj
, DWORD flags
)
2628 IOleClientSite
*clientsite
;
2631 if(flags
& CLIENTSITE_SETNULL
) {
2632 hres
= IOleObject_GetClientSite(oleobj
, &clientsite
);
2633 ok(clientsite
== &ClientSite
, "clientsite=%p, expected %p\n", clientsite
, &ClientSite
);
2635 hres
= IOleObject_SetClientSite(oleobj
, NULL
);
2636 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
2638 set_clientsite
= FALSE
;
2641 if(flags
& CLIENTSITE_DONTSET
)
2644 hres
= IOleObject_GetClientSite(oleobj
, &clientsite
);
2645 ok(hres
== S_OK
, "GetClientSite failed: %08x\n", hres
);
2646 ok(clientsite
== (set_clientsite
? &ClientSite
: NULL
), "GetClientSite() = %p, expected %p\n",
2647 clientsite
, set_clientsite
? &ClientSite
: NULL
);
2649 if(!set_clientsite
) {
2650 SET_EXPECT(GetHostInfo
);
2651 if(flags
& CLIENTSITE_EXPECTPATH
) {
2652 SET_EXPECT(GetOptionKeyPath
);
2653 SET_EXPECT(GetOverrideKeyPath
);
2655 SET_EXPECT(GetWindow
);
2656 SET_EXPECT(QueryStatus_SETPROGRESSTEXT
);
2657 SET_EXPECT(Exec_SETPROGRESSMAX
);
2658 SET_EXPECT(Exec_SETPROGRESSPOS
);
2659 SET_EXPECT(Invoke_AMBIENT_USERMODE
);
2660 SET_EXPECT(Invoke_AMBIENT_DLCONTROL
);
2661 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2662 SET_EXPECT(Invoke_AMBIENT_SILENT
);
2663 SET_EXPECT(Invoke_AMBIENT_USERAGENT
);
2664 SET_EXPECT(Invoke_AMBIENT_PALETTE
);
2666 hres
= IOleObject_SetClientSite(oleobj
, &ClientSite
);
2667 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
2669 CHECK_CALLED(GetHostInfo
);
2670 if(flags
& CLIENTSITE_EXPECTPATH
) {
2671 CHECK_CALLED(GetOptionKeyPath
);
2672 CHECK_CALLED(GetOverrideKeyPath
);
2674 CHECK_CALLED(GetWindow
);
2675 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT
);
2676 CHECK_CALLED(Exec_SETPROGRESSMAX
);
2677 CHECK_CALLED(Exec_SETPROGRESSPOS
);
2678 CHECK_CALLED(Invoke_AMBIENT_USERMODE
);
2679 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL
);
2680 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2681 CHECK_CALLED(Invoke_AMBIENT_SILENT
);
2682 CHECK_CALLED(Invoke_AMBIENT_USERAGENT
);
2683 CHECK_CALLED(Invoke_AMBIENT_PALETTE
);
2685 set_clientsite
= TRUE
;
2688 hres
= IOleObject_SetClientSite(oleobj
, &ClientSite
);
2689 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
2691 hres
= IOleObject_GetClientSite(oleobj
, &clientsite
);
2692 ok(hres
== S_OK
, "GetClientSite failed: %08x\n", hres
);
2693 ok(clientsite
== &ClientSite
, "GetClientSite() = %p, expected %p\n", clientsite
, &ClientSite
);
2696 static void test_OnAmbientPropertyChange(IUnknown
*unk
)
2698 IOleControl
*control
= NULL
;
2701 hres
= IUnknown_QueryInterface(unk
, &IID_IOleControl
, (void**)&control
);
2702 ok(hres
== S_OK
, "QueryInterface(IID_IOleControl failed: %08x\n", hres
);
2706 SET_EXPECT(Invoke_AMBIENT_USERMODE
);
2707 hres
= IOleControl_OnAmbientPropertyChange(control
, DISPID_AMBIENT_USERMODE
);
2708 ok(hres
== S_OK
, "OnAmbientChange failed: %08x\n", hres
);
2709 CHECK_CALLED(Invoke_AMBIENT_USERMODE
);
2711 SET_EXPECT(Invoke_AMBIENT_DLCONTROL
);
2712 hres
= IOleControl_OnAmbientPropertyChange(control
, DISPID_AMBIENT_DLCONTROL
);
2713 ok(hres
== S_OK
, "OnAmbientChange failed: %08x\n", hres
);
2714 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL
);
2716 SET_EXPECT(Invoke_AMBIENT_DLCONTROL
);
2717 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2718 hres
= IOleControl_OnAmbientPropertyChange(control
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
);
2719 ok(hres
== S_OK
, "OnAmbientChange failed: %08x\n", hres
);
2720 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL
);
2721 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
2723 SET_EXPECT(Invoke_AMBIENT_DLCONTROL
);
2724 SET_EXPECT(Invoke_AMBIENT_SILENT
);
2725 hres
= IOleControl_OnAmbientPropertyChange(control
, DISPID_AMBIENT_SILENT
);
2726 ok(hres
== S_OK
, "OnAmbientChange failed: %08x\n", hres
);
2727 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL
);
2728 CHECK_CALLED(Invoke_AMBIENT_SILENT
);
2730 SET_EXPECT(Invoke_AMBIENT_USERAGENT
);
2731 hres
= IOleControl_OnAmbientPropertyChange(control
, DISPID_AMBIENT_USERAGENT
);
2732 ok(hres
== S_OK
, "OnAmbientChange failed: %08x\n", hres
);
2733 CHECK_CALLED(Invoke_AMBIENT_USERAGENT
);
2735 SET_EXPECT(Invoke_AMBIENT_PALETTE
);
2736 hres
= IOleControl_OnAmbientPropertyChange(control
, DISPID_AMBIENT_PALETTE
);
2737 ok(hres
== S_OK
, "OnAmbientChange failed: %08x\n", hres
);
2738 CHECK_CALLED(Invoke_AMBIENT_PALETTE
);
2740 IOleControl_Release(control
);
2745 static void test_OnAmbientPropertyChange2(IUnknown
*unk
)
2747 IOleControl
*control
= NULL
;
2750 hres
= IUnknown_QueryInterface(unk
, &IID_IOleControl
, (void**)&control
);
2751 ok(hres
== S_OK
, "QueryInterface(IID_IOleControl failed: %08x\n", hres
);
2755 hres
= IOleControl_OnAmbientPropertyChange(control
, DISPID_AMBIENT_PALETTE
);
2756 ok(hres
== S_OK
, "OnAmbientPropertyChange failed: %08x\n", hres
);
2758 IOleControl_Release(control
);
2761 static void test_Close(IUnknown
*unk
, BOOL set_client
)
2763 IOleObject
*oleobj
= NULL
;
2766 hres
= IUnknown_QueryInterface(unk
, &IID_IOleObject
, (void**)&oleobj
);
2767 ok(hres
== S_OK
, "QueryInterface(IID_IOleObject) failed: %08x\n", hres
);
2771 SET_EXPECT(GetContainer
);
2772 SET_EXPECT(LockContainer
);
2773 expect_LockContainer_fLock
= FALSE
;
2774 hres
= IOleObject_Close(oleobj
, OLECLOSE_NOSAVE
);
2775 ok(hres
== S_OK
, "Close failed: %08x\n", hres
);
2776 CHECK_CALLED(GetContainer
);
2777 CHECK_CALLED(LockContainer
);
2778 container_locked
= FALSE
;
2781 test_ClientSite(oleobj
, CLIENTSITE_SETNULL
|CLIENTSITE_DONTSET
);
2783 IOleObject_Release(oleobj
);
2786 static void test_OnFrameWindowActivate(IUnknown
*unk
)
2788 IOleInPlaceActiveObject
*inplaceact
;
2791 hres
= IUnknown_QueryInterface(unk
, &IID_IOleInPlaceActiveObject
, (void**)&inplaceact
);
2792 ok(hres
== S_OK
, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres
);
2796 if(set_clientsite
) {
2797 expect_OnFrameWindowActivate_fActivate
= TRUE
;
2798 SET_EXPECT(OnFrameWindowActivate
);
2799 hres
= IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact
, TRUE
);
2800 ok(hres
== S_OK
, "OnFrameWindowActivate failed: %08x\n", hres
);
2801 CHECK_CALLED(OnFrameWindowActivate
);
2803 SET_EXPECT(OnFrameWindowActivate
);
2804 hres
= IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact
, TRUE
);
2805 ok(hres
== S_OK
, "OnFrameWindowActivate failed: %08x\n", hres
);
2806 CHECK_CALLED(OnFrameWindowActivate
);
2808 expect_OnFrameWindowActivate_fActivate
= FALSE
;
2809 SET_EXPECT(OnFrameWindowActivate
);
2810 hres
= IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact
, FALSE
);
2811 ok(hres
== S_OK
, "OnFrameWindowActivate failed: %08x\n", hres
);
2812 CHECK_CALLED(OnFrameWindowActivate
);
2814 expect_OnFrameWindowActivate_fActivate
= TRUE
;
2815 SET_EXPECT(OnFrameWindowActivate
);
2816 hres
= IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact
, TRUE
);
2817 ok(hres
== S_OK
, "OnFrameWindowActivate failed: %08x\n", hres
);
2818 CHECK_CALLED(OnFrameWindowActivate
);
2820 hres
= IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact
, FALSE
);
2821 ok(hres
== S_OK
, "OnFrameWindowActivate failed: %08x\n", hres
);
2823 hres
= IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact
, TRUE
);
2824 ok(hres
== S_OK
, "OnFrameWindowActivate failed: %08x\n", hres
);
2827 IOleInPlaceActiveObject_Release(inplaceact
);
2830 static void test_InPlaceDeactivate(IUnknown
*unk
, BOOL expect_call
)
2832 IOleInPlaceObjectWindowless
*windowlessobj
= NULL
;
2835 hres
= IUnknown_QueryInterface(unk
, &IID_IOleInPlaceObjectWindowless
,
2836 (void**)&windowlessobj
);
2837 ok(hres
== S_OK
, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres
);
2841 if(expect_call
) SET_EXPECT(OnInPlaceDeactivate
);
2842 hres
= IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj
);
2843 ok(hres
== S_OK
, "InPlaceDeactivate failed: %08x\n", hres
);
2844 if(expect_call
) CHECK_CALLED(OnInPlaceDeactivate
);
2846 IOleInPlaceObjectWindowless_Release(windowlessobj
);
2849 static HRESULT
test_Activate(IUnknown
*unk
, DWORD flags
)
2851 IOleObject
*oleobj
= NULL
;
2858 IOleDocumentView_Release(view
);
2861 hres
= IUnknown_QueryInterface(unk
, &IID_IOleObject
, (void**)&oleobj
);
2862 ok(hres
== S_OK
, "QueryInterface(IID_IOleObject) failed: %08x\n", hres
);
2866 hres
= IOleObject_GetUserClassID(oleobj
, NULL
);
2867 ok(hres
== E_INVALIDARG
, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres
);
2869 hres
= IOleObject_GetUserClassID(oleobj
, &guid
);
2870 ok(hres
== S_OK
, "GetUserClassID failed: %08x\n", hres
);
2871 ok(IsEqualGUID(&guid
, &CLSID_HTMLDocument
), "guid != CLSID_HTMLDocument\n");
2873 test_OnFrameWindowActivate(unk
);
2875 test_ClientSite(oleobj
, flags
);
2876 test_InPlaceDeactivate(unk
, FALSE
);
2878 hres
= test_DoVerb(oleobj
);
2880 IOleObject_Release(oleobj
);
2882 test_OnFrameWindowActivate(unk
);
2887 static void test_Window(IUnknown
*unk
, BOOL expect_success
)
2889 IOleInPlaceActiveObject
*activeobject
= NULL
;
2893 hres
= IOleDocumentView_QueryInterface(view
, &IID_IOleInPlaceActiveObject
, (void**)&activeobject
);
2894 ok(hres
== S_OK
, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres
);
2898 hres
= IOleInPlaceActiveObject_GetWindow(activeobject
, &tmp_hwnd
);
2900 if(expect_success
) {
2901 ok(hres
== S_OK
, "GetWindow failed: %08x\n", hres
);
2902 ok(tmp_hwnd
== hwnd
, "tmp_hwnd=%p, expected %p\n", tmp_hwnd
, hwnd
);
2904 ok(hres
== E_FAIL
, "GetWindow returned %08x, expected E_FAIL\n", hres
);
2905 ok(IsWindow(hwnd
), "hwnd is destroyed\n");
2908 IOleInPlaceActiveObject_Release(activeobject
);
2911 static void test_CloseView(void)
2913 IOleInPlaceSite
*inplacesite
= (IOleInPlaceSite
*)0xff00ff00;
2919 hres
= IOleDocumentView_Show(view
, FALSE
);
2920 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
2922 hres
= IOleDocumentView_CloseView(view
, 0);
2923 ok(hres
== S_OK
, "CloseView failed: %08x\n", hres
);
2925 hres
= IOleDocumentView_SetInPlaceSite(view
, NULL
);
2926 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
2928 hres
= IOleDocumentView_GetInPlaceSite(view
, &inplacesite
);
2929 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
2930 ok(inplacesite
== NULL
, "inplacesite=%p, expected NULL\n", inplacesite
);
2933 static void test_UIDeactivate(void)
2937 if(call_UIActivate
) {
2938 SET_EXPECT(SetActiveObject
);
2940 SET_EXPECT(OnUIDeactivate
);
2943 expect_SetActiveObject_active
= FALSE
;
2944 hres
= IOleDocumentView_UIActivate(view
, FALSE
);
2945 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
2947 if(call_UIActivate
) {
2948 CHECK_CALLED(SetActiveObject
);
2949 CHECK_CALLED(HideUI
);
2950 CHECK_CALLED(OnUIDeactivate
);
2954 static void test_Hide(void)
2961 hres
= IOleDocumentView_Show(view
, FALSE
);
2962 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
2965 static HRESULT
create_document(IUnknown
**unk
)
2967 HRESULT hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
2968 &IID_IUnknown
, (void**)unk
);
2969 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
2973 static void test_Navigate(IUnknown
*unk
)
2975 IHlinkTarget
*hlink
;
2978 hres
= IUnknown_QueryInterface(unk
, &IID_IHlinkTarget
, (void**)&hlink
);
2979 ok(hres
== S_OK
, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres
);
2981 SET_EXPECT(ActivateMe
);
2982 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
2983 ok(hres
== S_OK
, "Navigate failed: %08x\n", hres
);
2984 CHECK_CALLED(ActivateMe
);
2986 IHlinkTarget_Release(hlink
);
2989 static void test_StreamLoad(IUnknown
*unk
)
2991 IPersistStreamInit
*init
;
2994 hres
= IUnknown_QueryInterface(unk
, &IID_IPersistStreamInit
, (void**)&init
);
2995 ok(hres
== S_OK
, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres
);
2999 SET_EXPECT(Invoke_AMBIENT_SILENT
);
3000 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
3001 SET_EXPECT(Exec_ShellDocView_37
);
3002 SET_EXPECT(OnChanged_READYSTATE
);
3004 readystate_set_loading
= TRUE
;
3006 hres
= IPersistStreamInit_Load(init
, &Stream
);
3007 ok(hres
== S_OK
, "Load failed: %08x\n", hres
);
3009 CHECK_CALLED(Invoke_AMBIENT_SILENT
);
3010 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED
);
3011 CHECK_CALLED(Exec_ShellDocView_37
);
3012 CHECK_CALLED(OnChanged_READYSTATE
);
3015 IPersistStreamInit_Release(init
);
3018 static void test_QueryInterface(IUnknown
*unk
)
3020 IRunnableObject
*runnable
= (IRunnableObject
*)0xdeadbeef;
3023 hres
= IUnknown_QueryInterface(unk
, &IID_IRunnableObject
, (void**)&runnable
);
3024 ok(hres
== E_NOINTERFACE
, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres
);
3025 ok(runnable
== NULL
, "runnable=%p, ezpected NULL\n", runnable
);
3028 static void init_test(enum load_state_t ls
) {
3030 hwnd
= last_hwnd
= NULL
;
3031 set_clientsite
= FALSE
;
3032 load_from_stream
= FALSE
;
3033 call_UIActivate
= FALSE
;
3040 static void test_HTMLDocument(enum load_state_t ls
)
3046 trace("Testing HTMLDocument (%s)...\n", (ls
== LD_DOLOAD
? " load" : "no load"));
3050 hres
= create_document(&unk
);
3055 test_QueryInterface(unk
);
3056 test_MSHTML_QueryStatus(unk
, OLECMDF_SUPPORTED
);
3057 test_ConnectionPointContainer(unk
);
3059 if(load_state
== LD_NO
)
3060 test_OnAmbientPropertyChange2(unk
);
3062 hres
= test_Activate(unk
, CLIENTSITE_EXPECTPATH
);
3064 IUnknown_Release(unk
);
3068 if(load_state
== LD_LOADING
)
3069 test_download(FALSE
, TRUE
);
3071 test_MSHTML_QueryStatus(unk
, OLECMDF_SUPPORTED
);
3072 test_OleCommandTarget_fail(unk
);
3073 test_OleCommandTarget(unk
);
3074 test_OnAmbientPropertyChange(unk
);
3075 test_Window(unk
, TRUE
);
3076 test_UIDeactivate();
3077 test_OleCommandTarget(unk
);
3078 test_Window(unk
, TRUE
);
3079 test_InPlaceDeactivate(unk
, TRUE
);
3081 /* Calling test_OleCommandTarget here couses Segmentation Fault with native
3082 * MSHTML. It doesn't with Wine. */
3084 test_Window(unk
, FALSE
);
3086 test_InPlaceDeactivate(unk
, FALSE
);
3088 test_Close(unk
, FALSE
);
3090 /* Activate HTMLDocument again */
3091 test_Activate(unk
, CLIENTSITE_SETNULL
);
3092 test_Window(unk
, TRUE
);
3093 test_OleCommandTarget(unk
);
3094 test_UIDeactivate();
3095 test_InPlaceDeactivate(unk
, TRUE
);
3096 test_Close(unk
, FALSE
);
3098 /* Activate HTMLDocument again, this time without UIActivate */
3099 call_UIActivate
= FALSE
;
3100 test_Activate(unk
, CLIENTSITE_SETNULL
);
3101 test_Window(unk
, TRUE
);
3102 test_UIDeactivate();
3103 test_InPlaceDeactivate(unk
, TRUE
);
3106 test_Close(unk
, TRUE
);
3107 test_OnAmbientPropertyChange2(unk
);
3110 IOleDocumentView_Release(view
);
3113 ok(IsWindow(hwnd
), "hwnd is destroyed\n");
3115 ref
= IUnknown_Release(unk
);
3116 ok(ref
== 0, "ref=%d, expected 0\n", ref
);
3118 ok(!IsWindow(hwnd
), "hwnd is not destroyed\n");
3121 static void test_HTMLDocument_hlink(void)
3127 trace("Testing HTMLDocument (hlink)...\n");
3129 init_test(LD_DOLOAD
);
3131 hres
= create_document(&unk
);
3136 test_ConnectionPointContainer(unk
);
3140 test_download(FALSE
, TRUE
);
3142 test_MSHTML_QueryStatus(unk
, OLECMDF_SUPPORTED
);
3143 test_exec_onunload(unk
);
3144 test_Window(unk
, TRUE
);
3145 test_InPlaceDeactivate(unk
, TRUE
);
3146 test_Close(unk
, FALSE
);
3149 IOleDocumentView_Release(view
);
3152 ref
= IUnknown_Release(unk
);
3153 ok(ref
== 0, "ref=%d, expected 0\n", ref
);
3156 static void test_HTMLDocument_StreamLoad(void)
3163 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3165 init_test(LD_DOLOAD
);
3166 load_from_stream
= TRUE
;
3168 hres
= create_document(&unk
);
3173 hres
= IUnknown_QueryInterface(unk
, &IID_IOleObject
, (void**)&oleobj
);
3174 ok(hres
== S_OK
, "Could not get IOleObject: %08x\n", hres
);
3176 test_readyState(unk
);
3177 test_ConnectionPointContainer(unk
);
3178 test_ClientSite(oleobj
, CLIENTSITE_EXPECTPATH
);
3179 test_DoVerb(oleobj
);
3180 test_MSHTML_QueryStatus(unk
, OLECMDF_SUPPORTED
);
3182 IOleObject_Release(oleobj
);
3184 test_StreamLoad(unk
);
3185 test_download(TRUE
, FALSE
);
3187 test_MSHTML_QueryStatus(unk
, OLECMDF_SUPPORTED
);
3188 test_UIDeactivate();
3189 test_InPlaceDeactivate(unk
, TRUE
);
3190 test_Close(unk
, FALSE
);
3193 IOleDocumentView_Release(view
);
3198 ref
= IUnknown_Release(unk
);
3199 ok(ref
== 0, "ref=%d, expected 0\n", ref
);
3202 static void test_editing_mode(void)
3209 trace("Testing HTMLDocument (edit)...\n");
3211 init_test(LD_DOLOAD
);
3213 hres
= create_document(&unk
);
3218 hres
= IUnknown_QueryInterface(unk
, &IID_IOleObject
, (void**)&oleobj
);
3219 ok(hres
== S_OK
, "Could not get IOleObject: %08x\n", hres
);
3221 test_readyState(unk
);
3222 test_ConnectionPointContainer(unk
);
3223 test_ClientSite(oleobj
, CLIENTSITE_EXPECTPATH
);
3224 test_DoVerb(oleobj
);
3225 test_MSHTML_QueryStatus(unk
, OLECMDF_SUPPORTED
);
3227 IOleObject_Release(oleobj
);
3229 test_exec_editmode(unk
);
3230 test_MSHTML_QueryStatus(unk
, OLECMDF_SUPPORTED
);
3231 test_download(TRUE
, FALSE
);
3232 test_MSHTML_QueryStatus(unk
, OLECMDF_SUPPORTED
|OLECMDF_ENABLED
);
3234 test_UIDeactivate();
3235 test_InPlaceDeactivate(unk
, TRUE
);
3236 test_Close(unk
, FALSE
);
3239 IOleDocumentView_Release(view
);
3243 ref
= IUnknown_Release(unk
);
3244 ok(ref
== 0, "ref=%d, expected 0\n", ref
);
3247 static void register_protocol(void)
3249 IInternetSession
*session
;
3252 static const WCHAR wsz_winetest
[] = {'w','i','n','e','t','e','s','t',0};
3254 hres
= CoInternetGetSession(0, &session
, 0);
3255 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
3257 hres
= IInternetSession_RegisterNameSpace(session
, &ClassFactory
, &IID_NULL
,
3258 wsz_winetest
, 0, NULL
, 0);
3259 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
3261 IInternetSession_Release(session
);
3264 static void gecko_installer_workaround(BOOL disable
)
3269 static BOOL has_url
= FALSE
;
3270 static char url
[2048];
3272 if(!disable
&& !has_url
)
3275 res
= RegOpenKey(HKEY_CURRENT_USER
, "Software\\Wine\\MSHTML", &hkey
);
3276 if(res
!= ERROR_SUCCESS
)
3280 DWORD type
, size
= sizeof(url
);
3282 res
= RegQueryValueEx(hkey
, "GeckoUrl", NULL
, &type
, (PVOID
)url
, &size
);
3283 if(res
== ERROR_SUCCESS
&& type
== REG_SZ
)
3286 RegDeleteValue(hkey
, "GeckoUrl");
3288 RegSetValueEx(hkey
, "GeckoUrl", 0, REG_SZ
, (PVOID
)url
, lstrlenA(url
)+1);
3296 gecko_installer_workaround(TRUE
);
3299 container_hwnd
= create_container_window();
3300 register_protocol();
3302 test_HTMLDocument(LD_NO
);
3303 test_HTMLDocument(LD_DOLOAD
);
3304 test_HTMLDocument_hlink();
3305 test_HTMLDocument_StreamLoad();
3306 test_editing_mode();
3308 DestroyWindow(container_hwnd
);
3311 gecko_installer_workaround(FALSE
);