push a3069cb3bfd71d4719e515a5e2d9729e18e3f983
[wine/hacks.git] / dlls / mshtml / tests / htmldoc.c
blob90b0295dc6420c48a7ce985aae59eea51c0505eb
1 /*
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
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "ole2.h"
28 #include "mshtml.h"
29 #include "docobj.h"
30 #include "mshtmhst.h"
31 #include "mshtmdid.h"
32 #include "mshtmcid.h"
33 #include "hlink.h"
34 #include "idispids.h"
35 #include "shlguid.h"
37 #include "initguid.h"
38 DEFINE_OLEGUID(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) \
50 do { \
51 ok(expect_ ##func, "unexpected call " #func "\n"); \
52 called_ ## func = TRUE; \
53 }while(0)
55 #define CHECK_EXPECT(func) \
56 do { \
57 CHECK_EXPECT2(func); \
58 expect_ ## func = FALSE; \
59 }while(0)
61 #define CHECK_CALLED(func) \
62 do { \
63 ok(called_ ## func, "expected " #func "\n"); \
64 expect_ ## func = called_ ## func = FALSE; \
65 }while(0)
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(OnInPlaceActivateEx);
76 DEFINE_EXPECT(OnUIActivate);
77 DEFINE_EXPECT(GetWindowContext);
78 DEFINE_EXPECT(OnUIDeactivate);
79 DEFINE_EXPECT(OnInPlaceDeactivate);
80 DEFINE_EXPECT(OnInPlaceDeactivateEx);
81 DEFINE_EXPECT(GetContainer);
82 DEFINE_EXPECT(ShowUI);
83 DEFINE_EXPECT(ActivateMe);
84 DEFINE_EXPECT(GetHostInfo);
85 DEFINE_EXPECT(HideUI);
86 DEFINE_EXPECT(GetOptionKeyPath);
87 DEFINE_EXPECT(GetOverrideKeyPath);
88 DEFINE_EXPECT(SetStatusText);
89 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
90 DEFINE_EXPECT(QueryStatus_OPEN);
91 DEFINE_EXPECT(QueryStatus_NEW);
92 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
93 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
94 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
95 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
96 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
97 DEFINE_EXPECT(Exec_ShellDocView_37);
98 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
99 DEFINE_EXPECT(Exec_SETTITLE);
100 DEFINE_EXPECT(Exec_HTTPEQUIV);
101 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
102 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
103 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
104 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
105 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
106 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
107 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
108 DEFINE_EXPECT(GetDropTarget);
109 DEFINE_EXPECT(UpdateUI);
110 DEFINE_EXPECT(Navigate);
111 DEFINE_EXPECT(OnFrameWindowActivate);
112 DEFINE_EXPECT(OnChanged_READYSTATE);
113 DEFINE_EXPECT(OnChanged_1005);
114 DEFINE_EXPECT(GetDisplayName);
115 DEFINE_EXPECT(BindToStorage);
116 DEFINE_EXPECT(Abort);
117 DEFINE_EXPECT(Read);
118 DEFINE_EXPECT(CreateInstance);
119 DEFINE_EXPECT(Start);
120 DEFINE_EXPECT(Terminate);
121 DEFINE_EXPECT(Protocol_Read);
122 DEFINE_EXPECT(LockRequest);
123 DEFINE_EXPECT(UnlockRequest);
125 static IUnknown *doc_unk;
126 static BOOL expect_LockContainer_fLock;
127 static BOOL expect_SetActiveObject_active, ipsex;
128 static BOOL set_clientsite = FALSE, container_locked = FALSE;
129 static BOOL readystate_set_loading = FALSE, load_from_stream;
130 static BOOL editmode = FALSE;
131 static int stream_read, protocol_read;
132 static enum load_state_t {
133 LD_DOLOAD,
134 LD_LOADING,
135 LD_INTERACTIVE,
136 LD_COMPLETE,
137 LD_NO
138 } load_state;
140 static LPCOLESTR expect_status_text = NULL;
142 static const char html_page[] =
143 "<html>"
144 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
145 "<body>test</body>"
146 "</html>";
148 static const char css_data[] = "body {color: red}";
150 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
151 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
153 static HRESULT QueryInterface(REFIID riid, void **ppv);
154 static void test_readyState(IUnknown*);
155 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
156 static BOOL nogecko = FALSE;
158 static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
160 static const WCHAR wszTimesNewRoman[] =
161 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
162 static const WCHAR wszArial[] =
163 {'A','r','i','a','l',0};
165 #define EXPECT_UPDATEUI 1
166 #define EXPECT_SETTITLE 2
168 static void test_timer(DWORD flags)
170 BOOL *b = &called_Exec_SETTITLE;
171 MSG msg;
173 if(flags & EXPECT_UPDATEUI) {
174 SET_EXPECT(UpdateUI);
175 SET_EXPECT(Exec_UPDATECOMMANDS);
176 b = &called_UpdateUI;
178 if(flags & EXPECT_SETTITLE)
179 SET_EXPECT(Exec_SETTITLE);
181 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
182 TranslateMessage(&msg);
183 DispatchMessage(&msg);
186 if(flags & EXPECT_UPDATEUI) {
187 CHECK_CALLED(UpdateUI);
188 CHECK_CALLED(Exec_UPDATECOMMANDS);
190 if(flags & EXPECT_SETTITLE)
191 CHECK_CALLED(Exec_SETTITLE);
194 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
196 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
197 *ppv = iface;
198 return S_OK;
201 *ppv = NULL;
202 return E_NOINTERFACE;
205 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
207 return 2;
210 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
212 return 1;
215 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
216 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
217 DWORD grfPI, DWORD dwReserved)
219 BINDINFO bindinfo;
220 DWORD bindf = 0;
221 HRESULT hres;
223 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
224 static const WCHAR empty_str = {0};
226 CHECK_EXPECT(Start);
228 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
229 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
230 ok(!grfPI, "grfPI = %x\n", grfPI);
231 ok(!dwReserved, "dwReserved = %d\n", dwReserved);
233 memset(&bindinfo, 0, sizeof(bindinfo));
234 bindinfo.cbSize = sizeof(bindinfo);
235 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
236 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
237 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
238 "bindf = %x\n", bindf);
240 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
241 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
242 /* TODO: test stgmedData */
243 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
244 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
245 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
246 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
247 ok(bindinfo.dwOptions == 0x80000, "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
248 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
249 /* TODO: test dwCodePage */
250 /* TODO: test securityAttributes */
251 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
252 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
253 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
255 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
256 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
257 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
259 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
260 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
261 ok(hres == S_OK,
262 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
264 hres = IInternetProtocolSink_ReportData(pOIProtSink,
265 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
266 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
268 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
269 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
271 return S_OK;
274 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
275 PROTOCOLDATA *pProtocolData)
277 ok(0, "unexpected call\n");
278 return E_NOTIMPL;
281 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
282 DWORD dwOptions)
284 ok(0, "unexpected call\n");
285 return E_NOTIMPL;
288 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
290 CHECK_EXPECT(Terminate);
291 return S_OK;
294 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
296 ok(0, "unexpected call\n");
297 return E_NOTIMPL;
300 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
302 ok(0, "unexpected call\n");
303 return E_NOTIMPL;
306 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
307 ULONG cb, ULONG *pcbRead)
309 CHECK_EXPECT2(Protocol_Read);
311 ok(pv != NULL, "pv == NULL\n");
312 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
313 ok(pcbRead != NULL, "pcbRead == NULL\n");
314 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
316 if(protocol_read)
317 return S_FALSE;
319 protocol_read += *pcbRead = sizeof(css_data)-1;
320 memcpy(pv, css_data, sizeof(css_data)-1);
321 return S_OK;
324 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
325 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
327 ok(0, "unexpected call\n");
328 return E_NOTIMPL;
331 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
333 CHECK_EXPECT(LockRequest);
334 return S_OK;
337 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
339 CHECK_EXPECT(UnlockRequest);
340 return S_OK;
343 static const IInternetProtocolVtbl ProtocolVtbl = {
344 Protocol_QueryInterface,
345 Protocol_AddRef,
346 Protocol_Release,
347 Protocol_Start,
348 Protocol_Continue,
349 Protocol_Abort,
350 Protocol_Terminate,
351 Protocol_Suspend,
352 Protocol_Resume,
353 Protocol_Read,
354 Protocol_Seek,
355 Protocol_LockRequest,
356 Protocol_UnlockRequest
359 static IInternetProtocol Protocol = { &ProtocolVtbl };
361 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
363 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
364 ok(0, "unexpected call\n");
365 return E_NOINTERFACE;
368 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
370 return 2;
373 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
375 return 1;
378 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
379 REFIID riid, void **ppv)
381 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
382 return E_NOINTERFACE;
384 CHECK_EXPECT(CreateInstance);
385 ok(ppv != NULL, "ppv == NULL\n");
387 *ppv = &Protocol;
388 return S_OK;
391 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
393 ok(0, "unexpected call\n");
394 return S_OK;
397 static const IClassFactoryVtbl ClassFactoryVtbl = {
398 ClassFactory_QueryInterface,
399 ClassFactory_AddRef,
400 ClassFactory_Release,
401 ClassFactory_CreateInstance,
402 ClassFactory_LockServer
405 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
407 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
409 ok(0, "unexpected call\n");
410 return E_NOTIMPL;
413 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
415 return 2;
418 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
420 return 1;
423 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
424 IHlinkBrowseContext *pihlbc)
426 ok(0, "unexpected call\n");
427 return E_NOTIMPL;
430 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
431 IHlinkBrowseContext **ppihlbc)
433 ok(0, "unexpected call\n");
434 return E_NOTIMPL;
437 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
438 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
440 HRESULT hres;
442 CHECK_EXPECT(Navigate);
444 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
445 ok(pbc != NULL, "pbc == NULL\n");
446 ok(pibsc != NULL, "pubsc == NULL\n");
447 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
449 if(pihlNavigate) {
450 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
451 LPWSTR location = (LPWSTR)0xdeadbeef;
452 IHlinkSite *site;
453 IMoniker *mon = NULL;
454 DWORD site_data = 0xdeadbeef;
456 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
457 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
458 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
460 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
461 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
462 ok(location == NULL, "location = %p\n", location);
463 ok(mon != NULL, "mon == NULL\n");
465 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
466 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
467 ok(site == NULL, "site = %p\n, expected NULL\n", site);
468 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
471 return S_OK;
474 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
475 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
477 ok(0, "unexpected call\n");
478 return E_NOTIMPL;
481 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
482 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
484 ok(0, "unexpected call\n");
485 return E_NOTIMPL;
488 static const IHlinkFrameVtbl HlinkFrameVtbl = {
489 HlinkFrame_QueryInterface,
490 HlinkFrame_AddRef,
491 HlinkFrame_Release,
492 HlinkFrame_SetBrowseContext,
493 HlinkFrame_GetBrowseContext,
494 HlinkFrame_Navigate,
495 HlinkFrame_OnNavigate,
496 HlinkFrame_UpdateHlink
499 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
501 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
502 REFIID riid, void**ppv)
504 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
505 *ppv = iface;
506 return S_OK;
509 ok(0, "unexpected call\n");
510 return E_NOINTERFACE;
513 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
515 return 2;
518 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
520 return 1;
523 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
525 switch(dispID) {
526 case DISPID_READYSTATE:
527 CHECK_EXPECT2(OnChanged_READYSTATE);
528 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
529 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
530 ? OLECMDF_ENABLED : 0));
532 if(readystate_set_loading) {
533 readystate_set_loading = FALSE;
534 load_state = LD_LOADING;
536 test_readyState(NULL);
537 return S_OK;
538 case 1005:
539 CHECK_EXPECT(OnChanged_1005);
540 test_readyState(NULL);
541 load_state = LD_INTERACTIVE;
542 return S_OK;
545 ok(0, "unexpected id %d\n", dispID);
546 return E_NOTIMPL;
549 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
551 ok(0, "unexpected call\n");
552 return E_NOTIMPL;
555 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
556 PropertyNotifySink_QueryInterface,
557 PropertyNotifySink_AddRef,
558 PropertyNotifySink_Release,
559 PropertyNotifySink_OnChanged,
560 PropertyNotifySink_OnRequestEdit
563 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
565 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
567 ok(0, "unexpected call\n");
568 return E_NOINTERFACE;
571 static ULONG WINAPI Stream_AddRef(IStream *iface)
573 return 2;
576 static ULONG WINAPI Stream_Release(IStream *iface)
578 return 1;
581 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
582 ULONG cb, ULONG *pcbRead)
584 CHECK_EXPECT2(Read);
585 ok(pv != NULL, "pv == NULL\n");
586 ok(cb > sizeof(html_page), "cb = %d\n", cb);
587 ok(pcbRead != NULL, "pcbRead == NULL\n");
588 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
590 if(stream_read)
591 return S_FALSE;
593 memcpy(pv, html_page, sizeof(html_page)-1);
594 stream_read += *pcbRead = sizeof(html_page)-1;
595 return S_OK;
598 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
599 ULONG cb, ULONG *pcbWritten)
601 ok(0, "unexpected call\n");
602 return E_NOTIMPL;
605 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
606 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
608 ok(0, "unexpected call\n");
609 return E_NOTIMPL;
612 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
614 ok(0, "unexpected call\n");
615 return E_NOTIMPL;
618 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
619 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
621 ok(0, "unexpected call\n");
622 return E_NOTIMPL;
625 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
627 ok(0, "unexpected call\n");
628 return E_NOTIMPL;
631 static HRESULT WINAPI Stream_Revert(IStream *iface)
633 ok(0, "unexpected call\n");
634 return E_NOTIMPL;
637 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
638 ULARGE_INTEGER cb, DWORD dwLockType)
640 ok(0, "unexpected call\n");
641 return E_NOTIMPL;
644 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
645 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
647 ok(0, "unexpected call\n");
648 return E_NOTIMPL;
651 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
652 DWORD dwStatFlag)
654 ok(0, "unexpected call\n");
655 return E_NOTIMPL;
658 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
660 ok(0, "unexpected call\n");
661 return E_NOTIMPL;
664 static const IStreamVtbl StreamVtbl = {
665 Stream_QueryInterface,
666 Stream_AddRef,
667 Stream_Release,
668 Stream_Read,
669 Stream_Write,
670 Stream_Seek,
671 Stream_SetSize,
672 Stream_CopyTo,
673 Stream_Commit,
674 Stream_Revert,
675 Stream_LockRegion,
676 Stream_UnlockRegion,
677 Stream_Stat,
678 Stream_Clone
681 static IStream Stream = { &StreamVtbl };
683 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
685 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
686 return E_NOINTERFACE; /* TODO */
688 if(IsEqualGUID(&IID_IWinInetInfo, riid))
689 return E_NOINTERFACE; /* TODO */
691 ok(0, "unexpected call\n");
692 return E_NOINTERFACE;
695 static ULONG WINAPI Binding_AddRef(IBinding *iface)
697 return 2;
700 static ULONG WINAPI Binding_Release(IBinding *iface)
702 return 1;
705 static HRESULT WINAPI Binding_Abort(IBinding *iface)
707 CHECK_EXPECT(Abort);
708 return S_OK;
711 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
713 ok(0, "unexpected call\n");
714 return E_NOTIMPL;
717 static HRESULT WINAPI Binding_Resume(IBinding *iface)
719 ok(0, "unexpected call\n");
720 return E_NOTIMPL;
723 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
725 ok(0, "unexpected call\n");
726 return E_NOTIMPL;
729 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
731 ok(0, "unexpected call\n");
732 return E_NOTIMPL;
735 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
736 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
738 ok(0, "unexpected call\n");
739 return E_NOTIMPL;
742 static const IBindingVtbl BindingVtbl = {
743 Binding_QueryInterface,
744 Binding_AddRef,
745 Binding_Release,
746 Binding_Abort,
747 Binding_Suspend,
748 Binding_Resume,
749 Binding_SetPriority,
750 Binding_GetPriority,
751 Binding_GetBindResult
754 static IBinding Binding = { &BindingVtbl };
756 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
758 ok(0, "unexpected call\n");
759 return E_NOINTERFACE;
762 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
764 return 2;
767 static ULONG WINAPI Moniker_Release(IMoniker *iface)
769 return 1;
772 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
774 ok(0, "unexpected call\n");
775 return E_NOTIMPL;
778 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
780 ok(0, "unexpected call\n");
781 return E_NOTIMPL;
784 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
786 ok(0, "unexpected call\n");
787 return E_NOTIMPL;
790 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
792 ok(0, "unexpected call\n");
793 return E_NOTIMPL;
796 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
798 ok(0, "unexpected call\n");
799 return E_NOTIMPL;
802 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
803 REFIID riidResult, void **ppvResult)
805 ok(0, "unexpected call\n");
806 return E_NOTIMPL;
809 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
810 REFIID riid, void **ppv)
812 IBindStatusCallback *callback = NULL;
813 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
814 STGMEDIUM stgmedium;
815 BINDINFO bindinfo;
816 DWORD bindf;
817 HRESULT hres;
819 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
820 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
822 CHECK_EXPECT(BindToStorage);
824 ok(pbc != NULL, "pbc == NULL\n");
825 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
826 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
827 ok(ppv != NULL, "ppv == NULL\n");
828 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
830 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
831 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
832 ok(callback != NULL, "callback == NULL\n");
834 memset(&bindinfo, 0xf0, sizeof(bindinfo));
835 bindinfo.cbSize = sizeof(bindinfo);
837 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
838 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
839 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
840 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
841 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
842 /* TODO: test stgmedData */
843 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
844 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
845 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
846 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
847 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
848 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
849 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
850 /* TODO: test dwCodePage */
851 /* TODO: test securityAttributes */
852 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
853 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
854 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
856 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
857 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
859 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
860 wszTextHtml);
861 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
863 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
864 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
865 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
867 SET_EXPECT(Read);
868 stgmedium.tymed = TYMED_ISTREAM;
869 U(stgmedium).pstm = &Stream;
870 stgmedium.pUnkForRelease = (IUnknown*)iface;
871 hres = IBindStatusCallback_OnDataAvailable(callback,
872 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
873 sizeof(html_page)-1, &formatetc, &stgmedium);
874 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
875 CHECK_CALLED(Read);
877 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
878 BINDSTATUS_ENDDOWNLOADDATA, NULL);
879 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
881 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
882 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
884 IBindStatusCallback_Release(callback);
886 return S_OK;
889 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
890 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
892 ok(0, "unexpected call\n");
893 return E_NOTIMPL;
896 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
897 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
899 ok(0, "unexpected call\n");
900 return E_NOTIMPL;
903 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
905 ok(0, "unexpected call\n");
906 return E_NOTIMPL;
909 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
911 ok(0, "unexpected call\n");
912 return E_NOTIMPL;
915 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
917 ok(0, "unexpected call\n");
918 return E_NOTIMPL;
921 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
922 IMoniker *pmkNewlyRunning)
924 ok(0, "unexpected call\n");
925 return E_NOTIMPL;
928 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
929 IMoniker *pmkToLeft, FILETIME *pFileTime)
931 ok(0, "unexpected call\n");
932 return E_NOTIMPL;
935 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
937 ok(0, "unexpected call\n");
938 return E_NOTIMPL;
941 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
942 IMoniker **ppmkPrefix)
944 ok(0, "unexpected call\n");
945 return E_NOTIMPL;
948 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
949 IMoniker **pmkRelPath)
951 ok(0, "unexpected call\n");
952 return E_NOTIMPL;
955 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
956 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
958 CHECK_EXPECT2(GetDisplayName);
960 /* ok(pbc != NULL, "pbc == NULL\n"); */
961 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
962 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
964 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
965 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
967 return S_OK;
970 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
971 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
973 ok(0, "unexpected call\n");
974 return E_NOTIMPL;
977 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
979 ok(0, "unexpected call\n");
980 return E_NOTIMPL;
983 static const IMonikerVtbl MonikerVtbl = {
984 Moniker_QueryInterface,
985 Moniker_AddRef,
986 Moniker_Release,
987 Moniker_GetClassID,
988 Moniker_IsDirty,
989 Moniker_Load,
990 Moniker_Save,
991 Moniker_GetSizeMax,
992 Moniker_BindToObject,
993 Moniker_BindToStorage,
994 Moniker_Reduce,
995 Moniker_ComposeWith,
996 Moniker_Enum,
997 Moniker_IsEqual,
998 Moniker_Hash,
999 Moniker_IsRunning,
1000 Moniker_GetTimeOfLastChange,
1001 Moniker_Inverse,
1002 Moniker_CommonPrefixWith,
1003 Moniker_RelativePathTo,
1004 Moniker_GetDisplayName,
1005 Moniker_ParseDisplayName,
1006 Moniker_IsSystemMoniker
1009 static IMoniker Moniker = { &MonikerVtbl };
1011 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1013 return QueryInterface(riid, ppv);
1016 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1018 return 2;
1021 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1023 return 1;
1026 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1027 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1029 ok(0, "unexpected call\n");
1030 return E_NOTIMPL;
1033 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1034 IEnumUnknown **ppenum)
1036 ok(0, "unexpected call\n");
1037 return E_NOTIMPL;
1040 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1042 CHECK_EXPECT(LockContainer);
1043 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1044 return S_OK;
1047 static const IOleContainerVtbl OleContainerVtbl = {
1048 OleContainer_QueryInterface,
1049 OleContainer_AddRef,
1050 OleContainer_Release,
1051 OleContainer_ParseDisplayName,
1052 OleContainer_EnumObjects,
1053 OleContainer_LockContainer
1056 static IOleContainer OleContainer = { &OleContainerVtbl };
1058 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1060 return QueryInterface(riid, ppv);
1063 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1065 return 2;
1068 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1070 return 1;
1073 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1075 ok(0, "unexpected call\n");
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1081 ok(0, "unexpected call\n");
1082 return E_NOTIMPL;
1085 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1087 ok(0, "unexpected call\n");
1088 return E_NOTIMPL;
1091 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1092 LPCBORDERWIDTHS pborderwidths)
1094 ok(0, "unexpected call\n");
1095 return E_NOTIMPL;
1098 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1099 LPCBORDERWIDTHS pborderwidths)
1101 ok(0, "unexpected call\n");
1102 return E_NOTIMPL;
1105 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1106 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1108 static const WCHAR wszHTML_Document[] =
1109 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1111 CHECK_EXPECT2(SetActiveObject);
1113 if(expect_SetActiveObject_active) {
1114 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1115 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1116 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1117 }else {
1118 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1119 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1122 return S_OK;
1125 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1126 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1128 ok(0, "unexpected call\n");
1129 return E_NOTIMPL;
1132 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1133 HOLEMENU holemenu, HWND hwndActiveObject)
1135 ok(0, "unexpected call\n");
1136 return E_NOTIMPL;
1139 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1141 ok(0, "unexpected call\n");
1142 return E_NOTIMPL;
1145 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1147 CHECK_EXPECT2(SetStatusText);
1148 if(!expect_status_text)
1149 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1150 return S_OK;
1153 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1155 ok(0, "unexpected call\n");
1156 return E_NOTIMPL;
1159 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1161 ok(0, "unexpected call\n");
1162 return E_NOTIMPL;
1165 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1166 InPlaceFrame_QueryInterface,
1167 InPlaceFrame_AddRef,
1168 InPlaceFrame_Release,
1169 InPlaceFrame_GetWindow,
1170 InPlaceFrame_ContextSensitiveHelp,
1171 InPlaceFrame_GetBorder,
1172 InPlaceFrame_RequestBorderSpace,
1173 InPlaceFrame_SetBorderSpace,
1174 InPlaceFrame_SetActiveObject,
1175 InPlaceFrame_InsertMenus,
1176 InPlaceFrame_SetMenu,
1177 InPlaceFrame_RemoveMenus,
1178 InPlaceFrame_SetStatusText,
1179 InPlaceFrame_EnableModeless,
1180 InPlaceFrame_TranslateAccelerator
1183 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1185 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1187 return QueryInterface(riid, ppv);
1190 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1192 return 2;
1195 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1197 return 1;
1200 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1202 CHECK_EXPECT(GetWindow);
1203 ok(phwnd != NULL, "phwnd = NULL\n");
1204 *phwnd = container_hwnd;
1205 return S_OK;
1208 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1210 ok(0, "unexpected call\n");
1211 return E_NOTIMPL;
1214 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1216 CHECK_EXPECT(CanInPlaceActivate);
1217 return S_OK;
1220 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1222 CHECK_EXPECT(OnInPlaceActivate);
1223 return S_OK;
1226 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1228 CHECK_EXPECT(OnUIActivate);
1229 return S_OK;
1232 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1233 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1234 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1236 static const RECT rect = {0,0,500,500};
1238 CHECK_EXPECT(GetWindowContext);
1240 ok(ppFrame != NULL, "ppFrame = NULL\n");
1241 if(ppFrame)
1242 *ppFrame = &InPlaceFrame;
1243 ok(ppDoc != NULL, "ppDoc = NULL\n");
1244 if(ppDoc)
1245 *ppDoc = NULL;
1246 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1247 if(lprcPosRect)
1248 memcpy(lprcPosRect, &rect, sizeof(RECT));
1249 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1250 if(lprcClipRect)
1251 memcpy(lprcClipRect, &rect, sizeof(RECT));
1252 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1253 if(lpFrameInfo) {
1254 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1255 lpFrameInfo->fMDIApp = FALSE;
1256 lpFrameInfo->hwndFrame = container_hwnd;
1257 lpFrameInfo->haccel = NULL;
1258 lpFrameInfo->cAccelEntries = 0;
1261 return S_OK;
1264 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1266 ok(0, "unexpected call\n");
1267 return E_NOTIMPL;
1270 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1272 CHECK_EXPECT(OnUIDeactivate);
1273 ok(!fUndoable, "fUndoable = TRUE\n");
1274 return S_OK;
1277 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1279 CHECK_EXPECT(OnInPlaceDeactivate);
1280 return S_OK;
1283 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1285 ok(0, "unexpected call\n");
1286 return E_NOTIMPL;
1289 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1291 ok(0, "unexpected call\n");
1292 return E_NOTIMPL;
1295 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1297 ok(0, "unexpected call\n");
1298 return E_NOTIMPL;
1301 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1303 CHECK_EXPECT(OnInPlaceActivateEx);
1305 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1306 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1307 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1309 return S_OK;
1312 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1314 CHECK_EXPECT(OnInPlaceDeactivateEx);
1316 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1318 return S_OK;
1321 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1323 ok(0, "unexpected call\n");
1324 return E_NOTIMPL;
1327 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1328 InPlaceSite_QueryInterface,
1329 InPlaceSite_AddRef,
1330 InPlaceSite_Release,
1331 InPlaceSite_GetWindow,
1332 InPlaceSite_ContextSensitiveHelp,
1333 InPlaceSite_CanInPlaceActivate,
1334 InPlaceSite_OnInPlaceActivate,
1335 InPlaceSite_OnUIActivate,
1336 InPlaceSite_GetWindowContext,
1337 InPlaceSite_Scroll,
1338 InPlaceSite_OnUIDeactivate,
1339 InPlaceSite_OnInPlaceDeactivate,
1340 InPlaceSite_DiscardUndoState,
1341 InPlaceSite_DeactivateAndUndo,
1342 InPlaceSite_OnPosRectChange,
1343 InPlaceSiteEx_OnInPlaceActivateEx,
1344 InPlaceSiteEx_OnInPlaceDeactivateEx,
1345 InPlaceSiteEx_RequestUIActivate
1348 static IOleInPlaceSiteEx InPlaceSiteEx = { &InPlaceSiteVtbl };
1350 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1352 return QueryInterface(riid, ppv);
1355 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1357 return 2;
1360 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1362 return 1;
1365 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1367 ok(0, "unexpected call\n");
1368 return E_NOTIMPL;
1371 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAsign, DWORD dwWhichMoniker,
1372 IMoniker **ppmon)
1374 ok(0, "unexpected call\n");
1375 return E_NOTIMPL;
1378 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1380 CHECK_EXPECT(GetContainer);
1381 ok(ppContainer != NULL, "ppContainer = NULL\n");
1382 *ppContainer = &OleContainer;
1383 return S_OK;
1386 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1388 ok(0, "unexpected call\n");
1389 return E_NOTIMPL;
1392 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1394 ok(0, "unexpected call\n");
1395 return E_NOTIMPL;
1398 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1400 ok(0, "unexpected call\n");
1401 return E_NOTIMPL;
1404 static const IOleClientSiteVtbl ClientSiteVtbl = {
1405 ClientSite_QueryInterface,
1406 ClientSite_AddRef,
1407 ClientSite_Release,
1408 ClientSite_SaveObject,
1409 ClientSite_GetMoniker,
1410 ClientSite_GetContainer,
1411 ClientSite_ShowObject,
1412 ClientSite_OnShowWindow,
1413 ClientSite_RequestNewObjectLayout
1416 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1418 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1420 return QueryInterface(riid, ppv);
1423 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1425 return 2;
1428 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1430 return 1;
1433 static BOOL call_UIActivate = TRUE;
1434 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1436 IOleDocument *document;
1437 HRESULT hres;
1439 CHECK_EXPECT(ActivateMe);
1440 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1442 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1443 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1445 if(SUCCEEDED(hres)) {
1446 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteEx, NULL, 0, &view);
1447 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1449 if(SUCCEEDED(hres)) {
1450 IOleInPlaceActiveObject *activeobj = NULL;
1451 IOleInPlaceSite *inplacesite = NULL;
1452 HWND tmp_hwnd = NULL;
1453 static RECT rect = {0,0,400,500};
1455 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1456 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1457 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1458 inplacesite, &InPlaceSiteEx);
1460 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteEx);
1461 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1463 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1464 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1465 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1466 inplacesite, &InPlaceSiteEx);
1468 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1469 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1471 if(activeobj) {
1472 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1473 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1474 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1477 if(call_UIActivate) {
1478 SET_EXPECT(CanInPlaceActivate);
1479 SET_EXPECT(GetWindowContext);
1480 SET_EXPECT(GetWindow);
1481 if(ipsex)
1482 SET_EXPECT(OnInPlaceActivateEx);
1483 else
1484 SET_EXPECT(OnInPlaceActivate);
1485 SET_EXPECT(SetStatusText);
1486 SET_EXPECT(Exec_SETPROGRESSMAX);
1487 SET_EXPECT(Exec_SETPROGRESSPOS);
1488 SET_EXPECT(OnUIActivate);
1489 SET_EXPECT(SetActiveObject);
1490 SET_EXPECT(ShowUI);
1491 expect_SetActiveObject_active = TRUE;
1492 expect_status_text = NULL;
1494 hres = IOleDocumentView_UIActivate(view, TRUE);
1496 if(FAILED(hres)) {
1497 trace("UIActivate failed: %08x\n", hres);
1498 return hres;
1500 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1502 CHECK_CALLED(CanInPlaceActivate);
1503 CHECK_CALLED(GetWindowContext);
1504 CHECK_CALLED(GetWindow);
1505 if(ipsex)
1506 CHECK_CALLED(OnInPlaceActivateEx);
1507 else
1508 CHECK_CALLED(OnInPlaceActivate);
1509 CHECK_CALLED(SetStatusText);
1510 CHECK_CALLED(Exec_SETPROGRESSMAX);
1511 CHECK_CALLED(Exec_SETPROGRESSPOS);
1512 CHECK_CALLED(OnUIActivate);
1513 CHECK_CALLED(SetActiveObject);
1514 CHECK_CALLED(ShowUI);
1516 if(activeobj) {
1517 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1518 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1519 ok(hwnd != NULL, "hwnd == NULL\n");
1520 if(last_hwnd)
1521 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1524 hres = IOleDocumentView_UIActivate(view, TRUE);
1525 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1527 if(activeobj) {
1528 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1529 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1530 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1534 hres = IOleDocumentView_SetRect(view, &rect);
1535 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1537 if(call_UIActivate) {
1538 hres = IOleDocumentView_Show(view, TRUE);
1539 ok(hres == S_OK, "Show failed: %08x\n", hres);
1540 }else {
1541 SET_EXPECT(CanInPlaceActivate);
1542 SET_EXPECT(GetWindowContext);
1543 SET_EXPECT(GetWindow);
1544 if(ipsex)
1545 SET_EXPECT(OnInPlaceActivateEx);
1546 else
1547 SET_EXPECT(OnInPlaceActivate);
1548 SET_EXPECT(SetStatusText);
1549 SET_EXPECT(Exec_SETPROGRESSMAX);
1550 SET_EXPECT(Exec_SETPROGRESSPOS);
1551 SET_EXPECT(OnUIActivate);
1552 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1554 hres = IOleDocumentView_Show(view, TRUE);
1555 ok(hres == S_OK, "Show failed: %08x\n", hres);
1557 CHECK_CALLED(CanInPlaceActivate);
1558 CHECK_CALLED(GetWindowContext);
1559 CHECK_CALLED(GetWindow);
1560 if(ipsex)
1561 CHECK_CALLED(OnInPlaceActivateEx);
1562 else
1563 CHECK_CALLED(OnInPlaceActivate);
1564 CHECK_CALLED(SetStatusText);
1565 CHECK_CALLED(Exec_SETPROGRESSMAX);
1566 CHECK_CALLED(Exec_SETPROGRESSPOS);
1568 if(activeobj) {
1569 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1570 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1571 ok(hwnd != NULL, "hwnd == NULL\n");
1572 if(last_hwnd)
1573 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1577 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1579 if(activeobj)
1580 IOleInPlaceActiveObject_Release(activeobj);
1583 IOleDocument_Release(document);
1586 return S_OK;
1589 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1590 DocumentSite_QueryInterface,
1591 DocumentSite_AddRef,
1592 DocumentSite_Release,
1593 DocumentSite_ActivateMe
1596 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1598 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1600 return QueryInterface(riid, ppv);
1603 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1605 return 2;
1608 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1610 return 1;
1613 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1614 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1616 ok(0, "unexpected call\n");
1617 return E_NOTIMPL;
1620 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1622 CHECK_EXPECT(GetHostInfo);
1623 ok(pInfo != NULL, "pInfo=NULL\n");
1624 if(pInfo) {
1625 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1626 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1627 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1628 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1629 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1630 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1631 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1632 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1634 return S_OK;
1637 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1638 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1639 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1641 CHECK_EXPECT(ShowUI);
1643 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
1644 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1645 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
1646 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
1647 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
1649 return S_OK;
1652 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1654 CHECK_EXPECT(HideUI);
1655 return S_OK;
1658 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1660 CHECK_EXPECT(UpdateUI);
1661 return S_OK;
1664 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1666 ok(0, "unexpected call\n");
1667 return E_NOTIMPL;
1670 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1672 ok(0, "unexpected call\n");
1673 return E_NOTIMPL;
1676 static BOOL expect_OnFrameWindowActivate_fActivate;
1677 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1679 CHECK_EXPECT2(OnFrameWindowActivate);
1680 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
1681 return S_OK;
1684 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1685 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1687 ok(0, "unexpected call\n");
1688 return E_NOTIMPL;
1691 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1692 const GUID *pguidCmdGroup, DWORD nCmdID)
1694 ok(0, "unexpected call\n");
1695 return E_NOTIMPL;
1698 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1699 LPOLESTR *pchKey, DWORD dw)
1701 CHECK_EXPECT(GetOptionKeyPath);
1702 ok(pchKey != NULL, "pchKey = NULL\n");
1703 ok(!dw, "dw=%d, expected 0\n", dw);
1704 if(pchKey)
1705 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1706 return S_OK;
1709 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1710 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1712 CHECK_EXPECT(GetDropTarget);
1713 /* TODO */
1714 return E_NOTIMPL;
1717 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1719 ok(0, "unexpected call\n");
1720 return E_NOTIMPL;
1723 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1724 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1726 ok(0, "unexpected call\n");
1727 return E_NOTIMPL;
1730 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1731 IDataObject **ppPORet)
1733 ok(0, "unexpected call\n");
1734 return E_NOTIMPL;
1737 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1738 LPOLESTR *pchKey, DWORD dw)
1740 CHECK_EXPECT(GetOverrideKeyPath);
1741 ok(pchKey != NULL, "pchKey = NULL\n");
1742 if(pchKey)
1743 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1744 ok(!dw, "dw=%d, xepected 0\n", dw);
1745 return S_OK;
1748 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1749 DocHostUIHandler_QueryInterface,
1750 DocHostUIHandler_AddRef,
1751 DocHostUIHandler_Release,
1752 DocHostUIHandler_ShowContextMenu,
1753 DocHostUIHandler_GetHostInfo,
1754 DocHostUIHandler_ShowUI,
1755 DocHostUIHandler_HideUI,
1756 DocHostUIHandler_UpdateUI,
1757 DocHostUIHandler_EnableModeless,
1758 DocHostUIHandler_OnDocWindowActivate,
1759 DocHostUIHandler_OnFrameWindowActivate,
1760 DocHostUIHandler_ResizeBorder,
1761 DocHostUIHandler_TranslateAccelerator,
1762 DocHostUIHandler_GetOptionKeyPath,
1763 DocHostUIHandler_GetDropTarget,
1764 DocHostUIHandler_GetExternal,
1765 DocHostUIHandler_TranslateUrl,
1766 DocHostUIHandler_FilterDataObject,
1767 DocHostUIHandler_GetOverrideKeyPath
1770 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1772 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
1773 REFIID riid, void **ppv)
1775 return QueryInterface(riid, ppv);
1778 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
1780 return 2;
1783 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
1785 return 1;
1788 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
1789 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
1791 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
1792 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
1793 ok(!pCmdText, "pCmdText != NULL\n");
1795 switch(prgCmds[0].cmdID) {
1796 case OLECMDID_SETPROGRESSTEXT:
1797 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
1798 prgCmds[0].cmdf = OLECMDF_ENABLED;
1799 return S_OK;
1800 case OLECMDID_OPEN:
1801 CHECK_EXPECT(QueryStatus_OPEN);
1802 prgCmds[0].cmdf = 0;
1803 return S_OK;
1804 case OLECMDID_NEW:
1805 CHECK_EXPECT(QueryStatus_NEW);
1806 prgCmds[0].cmdf = 0;
1807 return S_OK;
1808 default:
1809 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
1812 return E_FAIL;
1815 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
1816 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1818 test_readyState(NULL);
1820 if(!pguidCmdGroup) {
1821 switch(nCmdID) {
1822 case OLECMDID_SETPROGRESSMAX:
1823 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
1824 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1825 ok(pvaIn != NULL, "pvaIn == NULL\n");
1826 if(pvaIn) {
1827 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
1828 if(load_state == LD_NO)
1829 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
1831 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
1832 return S_OK;
1833 case OLECMDID_SETPROGRESSPOS:
1834 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
1835 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1836 ok(pvaIn != NULL, "pvaIn == NULL\n");
1837 if(pvaIn) {
1838 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
1839 if(load_state == LD_NO)
1840 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
1842 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
1843 return S_OK;
1844 case OLECMDID_HTTPEQUIV_DONE:
1845 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
1846 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
1847 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
1848 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
1849 load_state = LD_COMPLETE;
1850 return S_OK;
1851 case OLECMDID_SETDOWNLOADSTATE:
1852 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1853 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
1854 ok(pvaIn != NULL, "pvaIn == NULL\n");
1855 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
1857 switch(V_I4(pvaIn)) {
1858 case 0:
1859 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
1860 load_state = LD_INTERACTIVE;
1861 break;
1862 case 1:
1863 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
1864 break;
1865 default:
1866 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
1869 return S_OK;
1870 case OLECMDID_UPDATECOMMANDS:
1871 CHECK_EXPECT(Exec_UPDATECOMMANDS);
1872 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1873 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
1874 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
1875 return S_OK;
1876 case OLECMDID_SETTITLE:
1877 CHECK_EXPECT2(Exec_SETTITLE);
1878 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1879 ok(pvaIn != NULL, "pvaIn == NULL\n");
1880 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
1881 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
1882 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
1883 return S_OK;
1884 case OLECMDID_HTTPEQUIV:
1885 CHECK_EXPECT2(Exec_HTTPEQUIV);
1886 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1887 /* TODO */
1888 return S_OK;
1889 default:
1890 ok(0, "unexpected command %d\n", nCmdID);
1891 return E_FAIL;
1895 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
1896 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
1898 switch(nCmdID) {
1899 case 37:
1900 CHECK_EXPECT2(Exec_ShellDocView_37);
1902 if(load_from_stream)
1903 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
1904 else if(!editmode)
1905 test_GetCurMoniker(doc_unk, &Moniker, NULL);
1907 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
1908 ok(pvaIn != NULL, "pvaIn == NULL\n");
1909 if(pvaIn) {
1910 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
1911 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
1913 return S_OK;
1914 default:
1915 ok(0, "unexpected command %d\n", nCmdID);
1916 return E_FAIL;
1920 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
1921 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
1923 switch(nCmdID) {
1924 case IDM_PARSECOMPLETE:
1925 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
1926 ok(pvaIn == NULL, "pvaIn != NULL\n");
1927 ok(pvaOut == NULL, "pvaOut != NULL\n");
1928 return S_OK;
1929 default:
1930 ok(0, "unexpected command %d\n", nCmdID);
1934 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
1935 return E_FAIL; /* TODO */
1937 ok(0, "unexpected call\n");
1938 return E_NOTIMPL;
1941 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
1942 OleCommandTarget_QueryInterface,
1943 OleCommandTarget_AddRef,
1944 OleCommandTarget_Release,
1945 OleCommandTarget_QueryStatus,
1946 OleCommandTarget_Exec
1949 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
1951 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
1953 return QueryInterface(riid, ppv);
1956 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
1958 return 2;
1961 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
1963 return 1;
1966 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
1968 ok(0, "unexpected call\n");
1969 return E_NOTIMPL;
1972 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
1973 ITypeInfo **ppTInfo)
1975 ok(0, "unexpected call\n");
1976 return E_NOTIMPL;
1979 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
1980 UINT cNames, LCID lcid, DISPID *rgDispId)
1982 ok(0, "unexpected call\n");
1983 return E_NOTIMPL;
1986 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
1987 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1988 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1990 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
1991 ok(pDispParams != NULL, "pDispParams == NULL\n");
1992 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
1993 ok(puArgErr != NULL, "puArgErr == NULL\n");
1994 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
1995 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
1996 test_readyState(NULL);
1998 switch(dispIdMember) {
1999 case DISPID_AMBIENT_USERMODE:
2000 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2001 V_VT(pVarResult) = VT_BOOL;
2002 V_BOOL(pVarResult) = VARIANT_TRUE;
2003 return S_OK;
2004 case DISPID_AMBIENT_DLCONTROL:
2005 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2006 return E_FAIL;
2007 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2008 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2009 return E_FAIL;
2010 case DISPID_AMBIENT_SILENT:
2011 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2012 V_VT(pVarResult) = VT_BOOL;
2013 V_BOOL(pVarResult) = VARIANT_FALSE;
2014 return S_OK;
2015 case DISPID_AMBIENT_USERAGENT:
2016 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2017 return E_FAIL;
2018 case DISPID_AMBIENT_PALETTE:
2019 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2020 return E_FAIL;
2023 ok(0, "unexpected dispid %d\n", dispIdMember);
2024 return E_FAIL;
2027 static IDispatchVtbl DispatchVtbl = {
2028 Dispatch_QueryInterface,
2029 Dispatch_AddRef,
2030 Dispatch_Release,
2031 Dispatch_GetTypeInfoCount,
2032 Dispatch_GetTypeInfo,
2033 Dispatch_GetIDsOfNames,
2034 Dispatch_Invoke
2037 static IDispatch Dispatch = { &DispatchVtbl };
2039 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2040 REFIID riid, void **ppv)
2042 return QueryInterface(riid, ppv);
2045 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2047 return 2;
2050 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2052 return 1;
2055 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2056 REFIID riid, void **ppv)
2059 * Services used by HTMLDocument:
2061 * IOleUndoManager
2062 * IInternetSecurityManager
2063 * ITargetFrame
2064 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2065 * HTMLFrameBase
2066 * IShellObject
2067 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2068 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2069 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2070 * DefView (?)
2071 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2072 * IElementBehaviorFactory
2073 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2074 * STopLevelBrowser
2075 * IHTMLWindow2
2076 * IInternetProtocol
2077 * IWebBrowserApp
2078 * UrlHostory
2079 * IHTMLEditHost
2080 * IHlinkFrame
2083 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2084 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2085 *ppv = &HlinkFrame;
2086 return S_OK;
2089 return E_NOINTERFACE;
2092 static const IServiceProviderVtbl ServiceProviderVtbl = {
2093 ServiceProvider_QueryInterface,
2094 ServiceProvider_AddRef,
2095 ServiceProvider_Release,
2096 ServiceProvider_QueryService
2099 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2101 static HRESULT QueryInterface(REFIID riid, void **ppv)
2103 *ppv = NULL;
2105 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2106 *ppv = &ClientSite;
2107 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2108 *ppv = &DocumentSite;
2109 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2110 *ppv = &DocHostUIHandler;
2111 else if(IsEqualGUID(&IID_IOleContainer, riid))
2112 *ppv = &OleContainer;
2113 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2114 *ppv = &InPlaceSiteEx;
2115 else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid) || IsEqualGUID(&IID_IOleInPlaceFrame, riid))
2116 *ppv = &InPlaceFrame;
2117 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2118 *ppv = &OleCommandTarget;
2119 else if(IsEqualGUID(&IID_IDispatch, riid))
2120 *ppv = &Dispatch;
2121 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2122 *ppv = &ServiceProvider;
2123 else if(ipsex && IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2124 *ppv = &InPlaceSiteEx;
2126 /* TODO:
2127 * {D48A6EC6-6A4A-11CF-94A7-444553540000}
2128 * {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
2129 * {000670BA-0000-0000-C000-000000000046}
2132 if(*ppv)
2133 return S_OK;
2134 return E_NOINTERFACE;
2137 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2139 return DefWindowProc(hwnd, msg, wParam, lParam);
2142 static void test_readyState(IUnknown *unk)
2144 IHTMLDocument2 *htmldoc;
2145 BSTR state;
2146 HRESULT hres;
2148 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2149 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
2150 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2151 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
2153 static const LPCWSTR expected_state[] = {
2154 wszUninitialized,
2155 wszLoading,
2156 wszInteractive,
2157 wszComplete,
2158 wszUninitialized
2161 if(!unk)
2162 unk = doc_unk;
2164 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2165 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2166 if(FAILED(hres))
2167 return;
2169 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2170 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2172 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2173 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2174 ok(!lstrcmpW(state, expected_state[load_state]), "unexpected state, expected %d\n", load_state);
2176 IHTMLDocument_Release(htmldoc);
2179 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2181 IConnectionPointContainer *tmp_container = NULL;
2182 IConnectionPoint *cp;
2183 IID iid;
2184 HRESULT hres;
2186 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2187 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2188 if(FAILED(hres))
2189 return;
2191 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2192 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2193 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2195 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2196 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2198 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2199 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2200 ok(tmp_container == container, "container != tmp_container\n");
2201 if(SUCCEEDED(hres))
2202 IConnectionPointContainer_Release(tmp_container);
2204 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2205 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2207 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2208 DWORD cookie;
2210 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2211 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2214 IConnectionPoint_Release(cp);
2217 static void test_ConnectionPointContainer(IUnknown *unk)
2219 IConnectionPointContainer *container;
2220 HRESULT hres;
2222 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2223 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2224 if(FAILED(hres))
2225 return;
2227 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2228 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2229 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2231 IConnectionPointContainer_Release(container);
2234 static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
2236 IHTMLDocument2 *doc;
2237 IPersistMoniker *permon;
2238 IMoniker *mon = (void*)0xdeadbeef;
2239 BSTR doc_url = (void*)0xdeadbeef;
2240 HRESULT hres;
2242 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2243 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2244 if(FAILED(hres))
2245 return;
2247 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
2248 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2250 hres = IHTMLDocument2_get_URL(doc, &doc_url);
2251 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
2253 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
2254 IPersistMoniker_Release(permon);
2256 if(exmon) {
2257 BSTR url;
2258 BOOL exb = expect_GetDisplayName;
2259 BOOL clb = called_GetDisplayName;
2261 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2262 ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
2264 SET_EXPECT(GetDisplayName);
2265 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2266 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2267 CHECK_CALLED(GetDisplayName);
2268 expect_GetDisplayName = exb;
2269 called_GetDisplayName = clb;
2271 SysFreeString(url);
2272 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2273 }else if(exurl) {
2274 BSTR url;
2276 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2278 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2279 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2281 ok(!lstrcmpW(url, exurl), "unexpected url\n");
2282 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2284 SysFreeString(url);
2285 }else {
2286 ok(hres == E_UNEXPECTED,
2287 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
2288 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
2289 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
2292 SysFreeString(doc_url);
2293 IHTMLDocument_Release(doc);
2294 if(mon && mon != (void*)0xdeadbeef)
2295 IMoniker_Release(mon);
2298 static void test_Load(IPersistMoniker *persist)
2300 IBindCtx *bind;
2301 HRESULT hres;
2302 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2304 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2306 test_readyState((IUnknown*)persist);
2308 CreateBindCtx(0, &bind);
2309 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2310 (IUnknown*)&ClientSite);
2312 SET_EXPECT(GetDisplayName);
2313 if(!set_clientsite) {
2314 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2315 SET_EXPECT(GetHostInfo);
2316 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2317 SET_EXPECT(Invoke_AMBIENT_SILENT);
2318 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2319 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2320 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2321 SET_EXPECT(GetOptionKeyPath);
2322 SET_EXPECT(GetOverrideKeyPath);
2323 SET_EXPECT(GetWindow);
2324 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2325 SET_EXPECT(Exec_SETPROGRESSMAX);
2326 SET_EXPECT(Exec_SETPROGRESSPOS);
2327 SET_EXPECT(Exec_ShellDocView_37);
2329 if(!container_locked) {
2330 SET_EXPECT(GetContainer);
2331 SET_EXPECT(LockContainer);
2333 SET_EXPECT(OnChanged_READYSTATE);
2334 SET_EXPECT(BindToStorage);
2335 if(set_clientsite) {
2336 SET_EXPECT(Invoke_AMBIENT_SILENT);
2337 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2338 SET_EXPECT(Exec_ShellDocView_37);
2340 expect_LockContainer_fLock = TRUE;
2341 readystate_set_loading = TRUE;
2343 hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
2344 ok(hres == S_OK, "Load failed: %08x\n", hres);
2346 CHECK_CALLED(GetDisplayName);
2347 if(!set_clientsite) {
2348 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2349 CHECK_CALLED(GetHostInfo);
2350 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2351 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2352 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2353 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2354 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2355 CHECK_CALLED(GetOptionKeyPath);
2356 CHECK_CALLED(GetOverrideKeyPath);
2357 CHECK_CALLED(GetWindow);
2358 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2359 CHECK_CALLED(Exec_SETPROGRESSMAX);
2360 CHECK_CALLED(Exec_SETPROGRESSPOS);
2361 CHECK_CALLED(Exec_ShellDocView_37);
2363 if(!container_locked) {
2364 CHECK_CALLED(GetContainer);
2365 CHECK_CALLED(LockContainer);
2366 container_locked = TRUE;
2368 CHECK_CALLED(OnChanged_READYSTATE);
2369 CHECK_CALLED(BindToStorage);
2370 if(set_clientsite) {
2371 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2372 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2373 CHECK_CALLED(Exec_ShellDocView_37);
2376 set_clientsite = container_locked = TRUE;
2378 test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
2380 IBindCtx_Release(bind);
2382 test_readyState((IUnknown*)persist);
2385 static void test_download(BOOL verb_done, BOOL css_dwl)
2387 HWND hwnd;
2388 MSG msg;
2390 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2391 ok(hwnd != NULL, "Could not find hidden window\n");
2393 test_readyState(NULL);
2395 if(verb_done) {
2396 SET_EXPECT(Exec_SETPROGRESSMAX);
2397 if(!load_from_stream)
2398 SET_EXPECT(GetHostInfo);
2400 SET_EXPECT(SetStatusText);
2401 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2402 SET_EXPECT(GetDropTarget);
2403 if(css_dwl) {
2404 SET_EXPECT(CreateInstance);
2405 SET_EXPECT(Start);
2406 SET_EXPECT(LockRequest);
2407 SET_EXPECT(Terminate);
2408 SET_EXPECT(Protocol_Read);
2409 SET_EXPECT(UnlockRequest);
2411 SET_EXPECT(OnChanged_1005);
2412 SET_EXPECT(OnChanged_READYSTATE);
2413 SET_EXPECT(Exec_SETPROGRESSPOS);
2414 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2415 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2416 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2417 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2419 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2420 TranslateMessage(&msg);
2421 DispatchMessage(&msg);
2424 if(verb_done) {
2425 CHECK_CALLED(Exec_SETPROGRESSMAX);
2426 if(!load_from_stream)
2427 CHECK_CALLED(GetHostInfo);
2429 CHECK_CALLED(SetStatusText);
2430 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2431 CHECK_CALLED(GetDropTarget);
2432 if(css_dwl) {
2433 if(called_CreateInstance) {
2434 CHECK_CALLED(CreateInstance);
2435 CHECK_CALLED(Start);
2436 CHECK_CALLED(LockRequest);
2437 CHECK_CALLED(Terminate);
2438 CHECK_CALLED(Protocol_Read);
2439 CHECK_CALLED(UnlockRequest);
2440 }else {
2441 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2443 SET_CALLED(CreateInstance);
2444 SET_CALLED(Start);
2445 SET_CALLED(LockRequest);
2446 SET_CALLED(Terminate);
2447 SET_CALLED(Protocol_Read);
2448 SET_CALLED(UnlockRequest);
2450 nogecko = TRUE;
2453 CHECK_CALLED(OnChanged_1005);
2454 CHECK_CALLED(OnChanged_READYSTATE);
2455 CHECK_CALLED(Exec_SETPROGRESSPOS);
2456 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2457 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2458 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2460 load_state = LD_COMPLETE;
2462 test_readyState(NULL);
2465 static void test_Persist(IUnknown *unk)
2467 IPersistMoniker *persist_mon;
2468 IPersistFile *persist_file;
2469 GUID guid;
2470 HRESULT hres;
2472 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2473 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2474 if(SUCCEEDED(hres)) {
2475 hres = IPersist_GetClassID(persist_file, NULL);
2476 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2478 hres = IPersist_GetClassID(persist_file, &guid);
2479 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2480 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2482 IPersist_Release(persist_file);
2485 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2486 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2487 if(SUCCEEDED(hres)) {
2488 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2489 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2491 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2492 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2493 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2495 if(load_state == LD_DOLOAD)
2496 test_Load(persist_mon);
2498 test_readyState(unk);
2500 IPersistMoniker_Release(persist_mon);
2504 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2506 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2507 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2508 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2509 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2510 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2511 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2512 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2513 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2514 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2515 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2516 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2517 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2518 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2519 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2520 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2521 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2522 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2523 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2524 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2525 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2527 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2528 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2529 0,0,0,0,0,0,
2530 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2531 0,0,
2532 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2533 0,0,
2534 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2535 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2536 0,0,0,0,0,
2537 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2538 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2539 0,0,
2540 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2541 0,0,0,
2542 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2543 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2546 static void test_QueryStatus(IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2548 IOleCommandTarget *cmdtrg;
2549 OLECMD olecmd = {cmdid, 0};
2550 HRESULT hres;
2552 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2553 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2554 if(FAILED(hres))
2555 return;
2557 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2558 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2560 IOleCommandTarget_Release(cmdtrg);
2562 ok(olecmd.cmdID == cmdid, "cmdID changed\n");
2563 ok(olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2566 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2568 if(!unk)
2569 unk = doc_unk;
2571 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2572 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2573 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2574 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2575 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2576 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2577 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2578 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2579 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2580 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2581 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2582 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2583 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2584 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2587 static void test_OleCommandTarget(IUnknown *unk)
2589 IOleCommandTarget *cmdtrg;
2590 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
2591 int i;
2592 HRESULT hres;
2594 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2595 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2596 if(FAILED(hres))
2597 return;
2599 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2600 cmds[i].cmdID = i+1;
2601 cmds[i].cmdf = 0xf0f0;
2604 SET_EXPECT(QueryStatus_OPEN);
2605 SET_EXPECT(QueryStatus_NEW);
2606 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
2607 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2608 CHECK_CALLED(QueryStatus_OPEN);
2609 CHECK_CALLED(QueryStatus_NEW);
2611 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2612 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
2613 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
2614 i+1, cmds[i].cmdf, expect_cmds[i+1]);
2617 IOleCommandTarget_Release(cmdtrg);
2620 static void test_OleCommandTarget_fail(IUnknown *unk)
2622 IOleCommandTarget *cmdtrg;
2623 int i;
2624 HRESULT hres;
2626 OLECMD cmd[2] = {
2627 {OLECMDID_OPEN, 0xf0f0},
2628 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
2631 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2632 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
2633 if(FAILED(hres))
2634 return;
2636 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
2637 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2639 SET_EXPECT(QueryStatus_OPEN);
2640 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
2641 CHECK_CALLED(QueryStatus_OPEN);
2643 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2644 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2645 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
2646 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
2647 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
2648 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
2649 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
2651 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
2652 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
2653 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
2655 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2656 if(!expect_cmds[i]) {
2657 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
2658 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2659 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2660 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2664 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
2665 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2666 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2667 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2669 IOleCommandTarget_Release(cmdtrg);
2672 static void test_exec_onunload(IUnknown *unk)
2674 IOleCommandTarget *cmdtrg;
2675 VARIANT var;
2676 HRESULT hres;
2678 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2679 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2680 if(FAILED(hres))
2681 return;
2683 memset(&var, 0x0a, sizeof(var));
2684 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
2685 OLECMDEXECOPT_DODEFAULT, NULL, &var);
2686 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
2687 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
2688 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
2690 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
2691 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2692 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
2694 IOleCommandTarget_Release(cmdtrg);
2697 static void test_exec_editmode(IUnknown *unk)
2699 IOleCommandTarget *cmdtrg;
2700 HRESULT hres;
2702 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2703 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2704 if(FAILED(hres))
2705 return;
2707 editmode = TRUE;
2709 SET_EXPECT(SetStatusText);
2710 SET_EXPECT(Exec_ShellDocView_37);
2711 SET_EXPECT(GetHostInfo);
2712 SET_EXPECT(Invoke_AMBIENT_SILENT);
2713 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2714 SET_EXPECT(OnChanged_READYSTATE);
2715 expect_status_text = NULL;
2716 readystate_set_loading = TRUE;
2718 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
2719 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2720 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2722 CHECK_CALLED(SetStatusText);
2723 CHECK_CALLED(Exec_ShellDocView_37);
2724 CHECK_CALLED(GetHostInfo);
2725 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2726 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2727 CHECK_CALLED(OnChanged_READYSTATE);
2729 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
2731 IOleCommandTarget_Release(cmdtrg);
2733 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
2734 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2735 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2738 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
2740 IOleCommandTarget *cmdtrg;
2741 VARIANT *in = NULL, _in, *out = NULL, _out;
2742 HRESULT hres;
2744 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2745 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
2746 if(FAILED(hres))
2747 return;
2749 if(name) {
2750 in = &_in;
2751 V_VT(in) = VT_BSTR;
2752 V_BSTR(in) = SysAllocString(name);
2755 if(exname) {
2756 out = &_out;
2757 V_VT(out) = VT_I4;
2758 V_I4(out) = 0xdeadbeef;
2761 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
2762 if(!nogecko)
2763 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
2765 if(in)
2766 VariantClear(in);
2768 if(out && !nogecko) {
2769 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
2770 if(V_VT(out) == VT_BSTR)
2771 ok(!lstrcmpW(V_BSTR(out), name ? name : exname), "unexpected fontname\n");
2772 VariantClear(out);
2775 IOleCommandTarget_Release(cmdtrg);
2778 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
2780 IOleCommandTarget *cmdtrg;
2781 HRESULT hres;
2783 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2784 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2785 if(FAILED(hres))
2786 return;
2788 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
2789 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2790 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2792 IOleCommandTarget_Release(cmdtrg);
2795 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
2797 IPersistStreamInit *perinit;
2798 IPersistMoniker *permon;
2799 IPersistFile *perfile;
2800 HRESULT hres;
2802 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
2803 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
2804 if(SUCCEEDED(hres)) {
2805 hres = IPersistStreamInit_IsDirty(perinit);
2806 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2807 IPersistStreamInit_Release(perinit);
2810 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2811 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
2812 if(SUCCEEDED(hres)) {
2813 hres = IPersistMoniker_IsDirty(permon);
2814 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2815 IPersistMoniker_Release(permon);
2818 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
2819 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
2820 if(SUCCEEDED(hres)) {
2821 hres = IPersistFile_IsDirty(perfile);
2822 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2823 IPersistFile_Release(perfile);
2827 static HWND create_container_window(void)
2829 static const WCHAR wszHTMLDocumentTest[] =
2830 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
2831 static WNDCLASSEXW wndclass = {
2832 sizeof(WNDCLASSEXW),
2834 wnd_proc,
2835 0, 0, NULL, NULL, NULL, NULL, NULL,
2836 wszHTMLDocumentTest,
2837 NULL
2840 RegisterClassExW(&wndclass);
2841 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
2842 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
2843 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
2846 static HRESULT test_DoVerb(IOleObject *oleobj)
2848 RECT rect = {0,0,500,500};
2849 HRESULT hres;
2851 if(!container_locked) {
2852 SET_EXPECT(GetContainer);
2853 SET_EXPECT(LockContainer);
2855 SET_EXPECT(ActivateMe);
2856 expect_LockContainer_fLock = TRUE;
2858 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
2859 if(FAILED(hres))
2860 return hres;
2861 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
2863 if(!container_locked) {
2864 CHECK_CALLED(GetContainer);
2865 CHECK_CALLED(LockContainer);
2866 container_locked = TRUE;
2868 CHECK_CALLED(ActivateMe);
2870 return hres;
2873 #define CLIENTSITE_EXPECTPATH 0x00000001
2874 #define CLIENTSITE_SETNULL 0x00000002
2875 #define CLIENTSITE_DONTSET 0x00000004
2877 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
2879 IOleClientSite *clientsite;
2880 HRESULT hres;
2882 if(flags & CLIENTSITE_SETNULL) {
2883 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2884 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
2886 hres = IOleObject_SetClientSite(oleobj, NULL);
2887 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2889 set_clientsite = FALSE;
2892 if(flags & CLIENTSITE_DONTSET)
2893 return;
2895 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2896 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
2897 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
2898 clientsite, set_clientsite ? &ClientSite : NULL);
2900 if(!set_clientsite) {
2901 SET_EXPECT(GetHostInfo);
2902 if(flags & CLIENTSITE_EXPECTPATH) {
2903 SET_EXPECT(GetOptionKeyPath);
2904 SET_EXPECT(GetOverrideKeyPath);
2906 SET_EXPECT(GetWindow);
2907 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2908 SET_EXPECT(Exec_SETPROGRESSMAX);
2909 SET_EXPECT(Exec_SETPROGRESSPOS);
2910 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2911 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2912 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2913 SET_EXPECT(Invoke_AMBIENT_SILENT);
2914 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2915 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2917 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
2918 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2920 CHECK_CALLED(GetHostInfo);
2921 if(flags & CLIENTSITE_EXPECTPATH) {
2922 CHECK_CALLED(GetOptionKeyPath);
2923 CHECK_CALLED(GetOverrideKeyPath);
2925 CHECK_CALLED(GetWindow);
2926 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2927 CHECK_CALLED(Exec_SETPROGRESSMAX);
2928 CHECK_CALLED(Exec_SETPROGRESSPOS);
2929 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2930 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2931 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2932 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2933 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2934 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2936 set_clientsite = TRUE;
2939 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
2940 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2942 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2943 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
2944 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
2947 static void test_OnAmbientPropertyChange(IUnknown *unk)
2949 IOleControl *control = NULL;
2950 HRESULT hres;
2952 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2953 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
2954 if(FAILED(hres))
2955 return;
2957 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2958 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
2959 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2960 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2962 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2963 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
2964 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2965 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2967 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2968 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2969 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2970 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2971 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2972 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2974 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2975 SET_EXPECT(Invoke_AMBIENT_SILENT);
2976 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2977 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2978 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2979 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2981 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2982 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
2983 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2984 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2986 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2987 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
2988 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2989 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2991 IOleControl_Release(control);
2996 static void test_OnAmbientPropertyChange2(IUnknown *unk)
2998 IOleControl *control = NULL;
2999 HRESULT hres;
3001 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3002 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3003 if(FAILED(hres))
3004 return;
3006 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3007 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3009 IOleControl_Release(control);
3012 static void test_Close(IUnknown *unk, BOOL set_client)
3014 IOleObject *oleobj = NULL;
3015 HRESULT hres;
3017 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3018 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3019 if(FAILED(hres))
3020 return;
3022 SET_EXPECT(GetContainer);
3023 SET_EXPECT(LockContainer);
3024 expect_LockContainer_fLock = FALSE;
3025 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3026 ok(hres == S_OK, "Close failed: %08x\n", hres);
3027 CHECK_CALLED(GetContainer);
3028 CHECK_CALLED(LockContainer);
3029 container_locked = FALSE;
3031 if(set_client)
3032 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3034 IOleObject_Release(oleobj);
3037 static void test_OnFrameWindowActivate(IUnknown *unk)
3039 IOleInPlaceActiveObject *inplaceact;
3040 HRESULT hres;
3042 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
3043 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3044 if(FAILED(hres))
3045 return;
3047 if(set_clientsite) {
3048 expect_OnFrameWindowActivate_fActivate = TRUE;
3049 SET_EXPECT(OnFrameWindowActivate);
3050 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3051 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3052 CHECK_CALLED(OnFrameWindowActivate);
3054 SET_EXPECT(OnFrameWindowActivate);
3055 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3056 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3057 CHECK_CALLED(OnFrameWindowActivate);
3059 expect_OnFrameWindowActivate_fActivate = FALSE;
3060 SET_EXPECT(OnFrameWindowActivate);
3061 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3062 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3063 CHECK_CALLED(OnFrameWindowActivate);
3065 expect_OnFrameWindowActivate_fActivate = TRUE;
3066 SET_EXPECT(OnFrameWindowActivate);
3067 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3068 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3069 CHECK_CALLED(OnFrameWindowActivate);
3070 }else {
3071 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3072 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3074 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3075 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3078 IOleInPlaceActiveObject_Release(inplaceact);
3081 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3083 IOleInPlaceObjectWindowless *windowlessobj = NULL;
3084 HRESULT hres;
3086 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3087 (void**)&windowlessobj);
3088 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3089 if(FAILED(hres))
3090 return;
3092 if(expect_call) {
3093 if(ipsex)
3094 SET_EXPECT(OnInPlaceDeactivateEx);
3095 else
3096 SET_EXPECT(OnInPlaceDeactivate);
3098 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3099 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3100 if(expect_call) {
3101 if(ipsex)
3102 CHECK_CALLED(OnInPlaceDeactivateEx);
3103 else
3104 CHECK_CALLED(OnInPlaceDeactivate);
3107 IOleInPlaceObjectWindowless_Release(windowlessobj);
3110 static HRESULT test_Activate(IUnknown *unk, DWORD flags)
3112 IOleObject *oleobj = NULL;
3113 GUID guid;
3114 HRESULT hres;
3116 last_hwnd = hwnd;
3118 if(view)
3119 IOleDocumentView_Release(view);
3120 view = NULL;
3122 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3123 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3124 if(FAILED(hres))
3125 return hres;
3127 hres = IOleObject_GetUserClassID(oleobj, NULL);
3128 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3130 hres = IOleObject_GetUserClassID(oleobj, &guid);
3131 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3132 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3134 test_OnFrameWindowActivate(unk);
3136 test_ClientSite(oleobj, flags);
3137 test_InPlaceDeactivate(unk, FALSE);
3139 hres = test_DoVerb(oleobj);
3141 IOleObject_Release(oleobj);
3143 test_OnFrameWindowActivate(unk);
3145 return hres;
3148 static void test_Window(IUnknown *unk, BOOL expect_success)
3150 IOleInPlaceActiveObject *activeobject = NULL;
3151 HWND tmp_hwnd;
3152 HRESULT hres;
3154 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3155 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3156 if(FAILED(hres))
3157 return;
3159 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3161 if(expect_success) {
3162 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3163 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3164 }else {
3165 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3166 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3169 IOleInPlaceActiveObject_Release(activeobject);
3172 static void test_CloseView(void)
3174 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3175 HRESULT hres;
3177 if(!view)
3178 return;
3180 hres = IOleDocumentView_Show(view, FALSE);
3181 ok(hres == S_OK, "Show failed: %08x\n", hres);
3183 hres = IOleDocumentView_CloseView(view, 0);
3184 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3186 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3187 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3189 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3190 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3191 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3194 static void test_UIDeactivate(void)
3196 HRESULT hres;
3198 if(call_UIActivate) {
3199 SET_EXPECT(SetActiveObject);
3200 SET_EXPECT(HideUI);
3201 SET_EXPECT(OnUIDeactivate);
3204 expect_SetActiveObject_active = FALSE;
3205 hres = IOleDocumentView_UIActivate(view, FALSE);
3206 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3208 if(call_UIActivate) {
3209 CHECK_CALLED(SetActiveObject);
3210 CHECK_CALLED(HideUI);
3211 CHECK_CALLED(OnUIDeactivate);
3215 static void test_Hide(void)
3217 HRESULT hres;
3219 if(!view)
3220 return;
3222 hres = IOleDocumentView_Show(view, FALSE);
3223 ok(hres == S_OK, "Show failed: %08x\n", hres);
3226 static HRESULT create_document(IUnknown **unk)
3228 HRESULT hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3229 &IID_IUnknown, (void**)unk);
3230 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3231 return hres;
3234 static void test_Navigate(IUnknown *unk)
3236 IHlinkTarget *hlink;
3237 HRESULT hres;
3239 hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3240 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3242 SET_EXPECT(ActivateMe);
3243 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3244 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3245 CHECK_CALLED(ActivateMe);
3247 IHlinkTarget_Release(hlink);
3250 static void test_StreamLoad(IUnknown *unk)
3252 IPersistStreamInit *init;
3253 HRESULT hres;
3255 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3256 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3257 if(FAILED(hres))
3258 return;
3260 SET_EXPECT(Invoke_AMBIENT_SILENT);
3261 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3262 SET_EXPECT(Exec_ShellDocView_37);
3263 SET_EXPECT(OnChanged_READYSTATE);
3264 SET_EXPECT(Read);
3265 readystate_set_loading = TRUE;
3267 hres = IPersistStreamInit_Load(init, &Stream);
3268 ok(hres == S_OK, "Load failed: %08x\n", hres);
3270 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3271 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3272 CHECK_CALLED(Exec_ShellDocView_37);
3273 CHECK_CALLED(OnChanged_READYSTATE);
3274 CHECK_CALLED(Read);
3276 test_timer(EXPECT_SETTITLE);
3277 test_GetCurMoniker(unk, NULL, about_blank_url);
3279 IPersistStreamInit_Release(init);
3282 static void test_QueryInterface(IUnknown *unk)
3284 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
3285 HRESULT hres;
3287 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
3288 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3289 ok(runnable == NULL, "runnable=%p, ezpected NULL\n", runnable);
3292 static void init_test(enum load_state_t ls) {
3293 doc_unk = NULL;
3294 hwnd = last_hwnd = NULL;
3295 set_clientsite = FALSE;
3296 load_from_stream = FALSE;
3297 call_UIActivate = FALSE;
3298 load_state = ls;
3299 editmode = FALSE;
3300 stream_read = 0;
3301 protocol_read = 0;
3302 ipsex = FALSE;
3305 static void test_HTMLDocument(enum load_state_t ls)
3307 IUnknown *unk;
3308 HRESULT hres;
3309 ULONG ref;
3311 trace("Testing HTMLDocument (%s)...\n", (ls == LD_DOLOAD ? " load" : "no load"));
3313 init_test(ls);
3315 hres = create_document(&unk);
3316 if(FAILED(hres))
3317 return;
3318 doc_unk = unk;
3320 test_QueryInterface(unk);
3321 test_IsDirty(unk, S_FALSE);
3322 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3323 test_ConnectionPointContainer(unk);
3324 test_GetCurMoniker(unk, NULL, NULL);
3325 test_Persist(unk);
3326 if(load_state == LD_NO)
3327 test_OnAmbientPropertyChange2(unk);
3329 hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
3330 if(FAILED(hres)) {
3331 IUnknown_Release(unk);
3332 return;
3335 if(load_state == LD_LOADING) {
3336 test_download(FALSE, TRUE);
3337 test_GetCurMoniker(unk, &Moniker, NULL);
3340 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3341 test_OleCommandTarget_fail(unk);
3342 test_OleCommandTarget(unk);
3343 test_OnAmbientPropertyChange(unk);
3344 test_Window(unk, TRUE);
3346 test_UIDeactivate();
3347 test_OleCommandTarget(unk);
3348 test_Window(unk, TRUE);
3349 test_InPlaceDeactivate(unk, TRUE);
3351 /* Calling test_OleCommandTarget here couses Segmentation Fault with native
3352 * MSHTML. It doesn't with Wine. */
3354 test_Window(unk, FALSE);
3355 test_Hide();
3356 test_InPlaceDeactivate(unk, FALSE);
3357 test_CloseView();
3358 test_Close(unk, FALSE);
3360 /* Activate HTMLDocument again */
3361 test_Activate(unk, CLIENTSITE_SETNULL);
3362 test_Window(unk, TRUE);
3363 test_OleCommandTarget(unk);
3364 test_UIDeactivate();
3365 test_InPlaceDeactivate(unk, TRUE);
3366 test_Close(unk, FALSE);
3368 /* Activate HTMLDocument again, this time without UIActivate */
3369 call_UIActivate = FALSE;
3370 test_Activate(unk, CLIENTSITE_SETNULL);
3371 test_Window(unk, TRUE);
3372 test_UIDeactivate();
3373 test_InPlaceDeactivate(unk, TRUE);
3374 test_CloseView();
3375 test_CloseView();
3376 test_Close(unk, TRUE);
3377 test_OnAmbientPropertyChange2(unk);
3378 test_GetCurMoniker(unk, load_state == LD_NO ? NULL : &Moniker, NULL);
3380 if(view)
3381 IOleDocumentView_Release(view);
3382 view = NULL;
3384 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3386 ref = IUnknown_Release(unk);
3387 ok(ref == 0, "ref=%d, expected 0\n", ref);
3389 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3392 static void test_HTMLDocument_hlink(void)
3394 IUnknown *unk;
3395 HRESULT hres;
3396 ULONG ref;
3398 trace("Testing HTMLDocument (hlink)...\n");
3400 init_test(LD_DOLOAD);
3401 ipsex = TRUE;
3403 hres = create_document(&unk);
3404 if(FAILED(hres))
3405 return;
3406 doc_unk = unk;
3408 test_ConnectionPointContainer(unk);
3409 test_GetCurMoniker(unk, NULL, NULL);
3410 test_Persist(unk);
3411 test_Navigate(unk);
3413 test_download(FALSE, TRUE);
3415 test_IsDirty(unk, S_FALSE);
3416 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3417 test_exec_onunload(unk);
3418 test_Window(unk, TRUE);
3419 test_InPlaceDeactivate(unk, TRUE);
3420 test_Close(unk, FALSE);
3421 test_IsDirty(unk, S_FALSE);
3422 test_GetCurMoniker(unk, &Moniker, NULL);
3424 if(view)
3425 IOleDocumentView_Release(view);
3426 view = NULL;
3428 ref = IUnknown_Release(unk);
3429 ok(ref == 0, "ref=%d, expected 0\n", ref);
3432 static void test_HTMLDocument_StreamLoad(void)
3434 IOleObject *oleobj;
3435 IUnknown *unk;
3436 HRESULT hres;
3437 ULONG ref;
3439 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3441 init_test(LD_DOLOAD);
3442 load_from_stream = TRUE;
3444 hres = create_document(&unk);
3445 if(FAILED(hres))
3446 return;
3447 doc_unk = unk;
3449 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3450 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3452 test_readyState(unk);
3453 test_IsDirty(unk, S_FALSE);
3454 test_ConnectionPointContainer(unk);
3455 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3456 test_DoVerb(oleobj);
3457 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3459 IOleObject_Release(oleobj);
3461 test_GetCurMoniker(unk, NULL, NULL);
3462 test_StreamLoad(unk);
3463 test_download(TRUE, FALSE);
3465 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3466 test_UIDeactivate();
3467 test_InPlaceDeactivate(unk, TRUE);
3468 test_Close(unk, FALSE);
3469 test_IsDirty(unk, S_FALSE);
3471 if(view) {
3472 IOleDocumentView_Release(view);
3473 view = NULL;
3477 ref = IUnknown_Release(unk);
3478 ok(ref == 0, "ref=%d, expected 0\n", ref);
3481 static void test_editing_mode(void)
3483 IUnknown *unk;
3484 IOleObject *oleobj;
3485 HRESULT hres;
3486 ULONG ref;
3488 trace("Testing HTMLDocument (edit)...\n");
3490 init_test(LD_DOLOAD);
3492 hres = create_document(&unk);
3493 if(FAILED(hres))
3494 return;
3495 doc_unk = unk;
3497 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3498 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3500 test_readyState(unk);
3501 test_ConnectionPointContainer(unk);
3502 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3503 test_DoVerb(oleobj);
3504 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3506 IOleObject_Release(oleobj);
3508 test_exec_editmode(unk);
3509 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3510 test_download(TRUE, FALSE);
3511 test_timer(EXPECT_UPDATEUI);
3512 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3514 test_exec_fontname(unk, NULL, wszTimesNewRoman);
3515 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
3516 test_timer(EXPECT_UPDATEUI);
3517 test_exec_fontname(unk, NULL, wszArial);
3519 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
3520 test_timer(EXPECT_UPDATEUI);
3521 if(!nogecko)
3522 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
3523 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
3525 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
3526 test_timer(EXPECT_UPDATEUI);
3527 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
3528 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3529 if(!nogecko)
3530 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
3531 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
3533 test_exec_noargs(unk, IDM_HORIZONTALLINE);
3534 test_timer(EXPECT_UPDATEUI);
3535 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
3536 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3538 test_UIDeactivate();
3539 test_InPlaceDeactivate(unk, TRUE);
3540 test_Close(unk, FALSE);
3542 if(view) {
3543 IOleDocumentView_Release(view);
3544 view = NULL;
3547 ref = IUnknown_Release(unk);
3548 ok(ref == 0, "ref=%d, expected 0\n", ref);
3551 static void register_protocol(void)
3553 IInternetSession *session;
3554 HRESULT hres;
3556 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
3558 hres = CoInternetGetSession(0, &session, 0);
3559 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3561 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
3562 wsz_winetest, 0, NULL, 0);
3563 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3565 IInternetSession_Release(session);
3568 static void gecko_installer_workaround(BOOL disable)
3570 HKEY hkey;
3571 DWORD res;
3573 static BOOL has_url = FALSE;
3574 static char url[2048];
3576 if(!disable && !has_url)
3577 return;
3579 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
3580 if(res != ERROR_SUCCESS)
3581 return;
3583 if(disable) {
3584 DWORD type, size = sizeof(url);
3586 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
3587 if(res == ERROR_SUCCESS && type == REG_SZ)
3588 has_url = TRUE;
3590 RegDeleteValue(hkey, "GeckoUrl");
3591 }else {
3592 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
3595 RegCloseKey(hkey);
3598 START_TEST(htmldoc)
3600 gecko_installer_workaround(TRUE);
3602 CoInitialize(NULL);
3603 container_hwnd = create_container_window();
3604 register_protocol();
3606 test_HTMLDocument(LD_NO);
3607 test_HTMLDocument(LD_DOLOAD);
3608 test_HTMLDocument_hlink();
3609 test_HTMLDocument_StreamLoad();
3610 test_editing_mode();
3612 DestroyWindow(container_hwnd);
3613 CoUninitialize();
3615 gecko_installer_workaround(FALSE);