mshtml: Added get_URL implementation.
[wine.git] / dlls / mshtml / tests / htmldoc.c
blob619d36eb7c7a7c10a378cac2c9f7ec334152336f
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(OnUIActivate);
76 DEFINE_EXPECT(GetWindowContext);
77 DEFINE_EXPECT(OnUIDeactivate);
78 DEFINE_EXPECT(OnInPlaceDeactivate);
79 DEFINE_EXPECT(GetContainer);
80 DEFINE_EXPECT(ShowUI);
81 DEFINE_EXPECT(ActivateMe);
82 DEFINE_EXPECT(GetHostInfo);
83 DEFINE_EXPECT(HideUI);
84 DEFINE_EXPECT(GetOptionKeyPath);
85 DEFINE_EXPECT(GetOverrideKeyPath);
86 DEFINE_EXPECT(SetStatusText);
87 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
88 DEFINE_EXPECT(QueryStatus_OPEN);
89 DEFINE_EXPECT(QueryStatus_NEW);
90 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
91 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
92 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
93 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
94 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
95 DEFINE_EXPECT(Exec_ShellDocView_37);
96 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
97 DEFINE_EXPECT(Exec_SETTITLE);
98 DEFINE_EXPECT(Exec_HTTPEQUIV);
99 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
100 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
101 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
102 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
103 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
104 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
105 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
106 DEFINE_EXPECT(GetDropTarget);
107 DEFINE_EXPECT(UpdateUI);
108 DEFINE_EXPECT(Navigate);
109 DEFINE_EXPECT(OnFrameWindowActivate);
110 DEFINE_EXPECT(OnChanged_READYSTATE);
111 DEFINE_EXPECT(OnChanged_1005);
112 DEFINE_EXPECT(GetDisplayName);
113 DEFINE_EXPECT(BindToStorage);
114 DEFINE_EXPECT(Abort);
115 DEFINE_EXPECT(Read);
116 DEFINE_EXPECT(CreateInstance);
117 DEFINE_EXPECT(Start);
118 DEFINE_EXPECT(Terminate);
119 DEFINE_EXPECT(Protocol_Read);
120 DEFINE_EXPECT(LockRequest);
121 DEFINE_EXPECT(UnlockRequest);
123 static IUnknown *doc_unk;
124 static BOOL expect_LockContainer_fLock;
125 static BOOL expect_SetActiveObject_active;
126 static BOOL set_clientsite = FALSE, container_locked = FALSE;
127 static BOOL readystate_set_loading = FALSE, load_from_stream;
128 static BOOL editmode = FALSE;
129 static int stream_read, protocol_read;
130 static enum load_state_t {
131 LD_DOLOAD,
132 LD_LOADING,
133 LD_INTERACTIVE,
134 LD_COMPLETE,
135 LD_NO
136 } load_state;
138 static LPCOLESTR expect_status_text = NULL;
140 static const char html_page[] =
141 "<html>"
142 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
143 "<body>test</body>"
144 "</html>";
146 static const char css_data[] = "body {color: red}";
148 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
149 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
151 static HRESULT QueryInterface(REFIID riid, void **ppv);
152 static void test_readyState(IUnknown*);
153 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
154 static BOOL nogecko = FALSE;
156 static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
158 static const WCHAR wszTimesNewRoman[] =
159 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
160 static const WCHAR wszArial[] =
161 {'A','r','i','a','l',0};
163 #define EXPECT_UPDATEUI 1
164 #define EXPECT_SETTITLE 2
166 static void test_timer(DWORD flags)
168 BOOL *b = &called_Exec_SETTITLE;
169 MSG msg;
171 if(flags & EXPECT_UPDATEUI) {
172 SET_EXPECT(UpdateUI);
173 SET_EXPECT(Exec_UPDATECOMMANDS);
174 b = &called_UpdateUI;
176 if(flags & EXPECT_SETTITLE)
177 SET_EXPECT(Exec_SETTITLE);
179 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
180 TranslateMessage(&msg);
181 DispatchMessage(&msg);
184 if(flags & EXPECT_UPDATEUI) {
185 CHECK_CALLED(UpdateUI);
186 CHECK_CALLED(Exec_UPDATECOMMANDS);
188 if(flags & EXPECT_SETTITLE)
189 CHECK_CALLED(Exec_SETTITLE);
192 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
194 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
195 *ppv = iface;
196 return S_OK;
199 *ppv = NULL;
200 return E_NOINTERFACE;
203 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
205 return 2;
208 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
210 return 1;
213 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
214 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
215 DWORD grfPI, DWORD dwReserved)
217 BINDINFO bindinfo;
218 DWORD bindf = 0;
219 HRESULT hres;
221 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
222 static const WCHAR empty_str = {0};
224 CHECK_EXPECT(Start);
226 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
227 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
228 ok(!grfPI, "grfPI = %x\n", grfPI);
229 ok(!dwReserved, "dwReserved = %d\n", dwReserved);
231 memset(&bindinfo, 0, sizeof(bindinfo));
232 bindinfo.cbSize = sizeof(bindinfo);
233 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
234 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
235 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
236 "bindf = %x\n", bindf);
238 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
239 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
240 /* TODO: test stgmedData */
241 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
242 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
243 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
244 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
245 ok(bindinfo.dwOptions == 0x80000, "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
246 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
247 /* TODO: test dwCodePage */
248 /* TODO: test securityAttributes */
249 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
250 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
251 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
253 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
254 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
255 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
257 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
258 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
259 ok(hres == S_OK,
260 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
262 hres = IInternetProtocolSink_ReportData(pOIProtSink,
263 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
264 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
266 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
267 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
269 return S_OK;
272 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
273 PROTOCOLDATA *pProtocolData)
275 ok(0, "unexpected call\n");
276 return E_NOTIMPL;
279 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
280 DWORD dwOptions)
282 ok(0, "unexpected call\n");
283 return E_NOTIMPL;
286 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
288 CHECK_EXPECT(Terminate);
289 return S_OK;
292 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
294 ok(0, "unexpected call\n");
295 return E_NOTIMPL;
298 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
300 ok(0, "unexpected call\n");
301 return E_NOTIMPL;
304 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
305 ULONG cb, ULONG *pcbRead)
307 CHECK_EXPECT2(Protocol_Read);
309 ok(pv != NULL, "pv == NULL\n");
310 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
311 ok(pcbRead != NULL, "pcbRead == NULL\n");
312 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
314 if(protocol_read)
315 return S_FALSE;
317 protocol_read += *pcbRead = sizeof(css_data)-1;
318 memcpy(pv, css_data, sizeof(css_data)-1);
319 return S_OK;
322 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
323 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
325 ok(0, "unexpected call\n");
326 return E_NOTIMPL;
329 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
331 CHECK_EXPECT(LockRequest);
332 return S_OK;
335 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
337 CHECK_EXPECT(UnlockRequest);
338 return S_OK;
341 static const IInternetProtocolVtbl ProtocolVtbl = {
342 Protocol_QueryInterface,
343 Protocol_AddRef,
344 Protocol_Release,
345 Protocol_Start,
346 Protocol_Continue,
347 Protocol_Abort,
348 Protocol_Terminate,
349 Protocol_Suspend,
350 Protocol_Resume,
351 Protocol_Read,
352 Protocol_Seek,
353 Protocol_LockRequest,
354 Protocol_UnlockRequest
357 static IInternetProtocol Protocol = { &ProtocolVtbl };
359 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
361 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
362 ok(0, "unexpected call\n");
363 return E_NOINTERFACE;
366 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
368 return 2;
371 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
373 return 1;
376 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
377 REFIID riid, void **ppv)
379 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
380 return E_NOINTERFACE;
382 CHECK_EXPECT(CreateInstance);
383 ok(ppv != NULL, "ppv == NULL\n");
385 *ppv = &Protocol;
386 return S_OK;
389 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
391 ok(0, "unexpected call\n");
392 return S_OK;
395 static const IClassFactoryVtbl ClassFactoryVtbl = {
396 ClassFactory_QueryInterface,
397 ClassFactory_AddRef,
398 ClassFactory_Release,
399 ClassFactory_CreateInstance,
400 ClassFactory_LockServer
403 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
405 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
407 ok(0, "unexpected call\n");
408 return E_NOTIMPL;
411 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
413 return 2;
416 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
418 return 1;
421 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
422 IHlinkBrowseContext *pihlbc)
424 ok(0, "unexpected call\n");
425 return E_NOTIMPL;
428 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
429 IHlinkBrowseContext **ppihlbc)
431 ok(0, "unexpected call\n");
432 return E_NOTIMPL;
435 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
436 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
438 HRESULT hres;
440 CHECK_EXPECT(Navigate);
442 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
443 ok(pbc != NULL, "pbc == NULL\n");
444 ok(pibsc != NULL, "pubsc == NULL\n");
445 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
447 if(pihlNavigate) {
448 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
449 LPWSTR location = (LPWSTR)0xdeadbeef;
450 IHlinkSite *site;
451 IMoniker *mon = NULL;
452 DWORD site_data = 0xdeadbeef;
454 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
455 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
456 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
458 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
459 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
460 ok(location == NULL, "location = %p\n", location);
461 ok(mon != NULL, "mon == NULL\n");
463 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
464 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
465 ok(site == NULL, "site = %p\n, expected NULL\n", site);
466 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
469 return S_OK;
472 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
473 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
475 ok(0, "unexpected call\n");
476 return E_NOTIMPL;
479 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
480 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
482 ok(0, "unexpected call\n");
483 return E_NOTIMPL;
486 static const IHlinkFrameVtbl HlinkFrameVtbl = {
487 HlinkFrame_QueryInterface,
488 HlinkFrame_AddRef,
489 HlinkFrame_Release,
490 HlinkFrame_SetBrowseContext,
491 HlinkFrame_GetBrowseContext,
492 HlinkFrame_Navigate,
493 HlinkFrame_OnNavigate,
494 HlinkFrame_UpdateHlink
497 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
499 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
500 REFIID riid, void**ppv)
502 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
503 *ppv = iface;
504 return S_OK;
507 ok(0, "unexpected call\n");
508 return E_NOINTERFACE;
511 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
513 return 2;
516 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
518 return 1;
521 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
523 switch(dispID) {
524 case DISPID_READYSTATE:
525 CHECK_EXPECT2(OnChanged_READYSTATE);
526 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
527 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
528 ? OLECMDF_ENABLED : 0));
530 if(readystate_set_loading) {
531 readystate_set_loading = FALSE;
532 load_state = LD_LOADING;
534 test_readyState(NULL);
535 return S_OK;
536 case 1005:
537 CHECK_EXPECT(OnChanged_1005);
538 test_readyState(NULL);
539 load_state = LD_INTERACTIVE;
540 return S_OK;
543 ok(0, "unexpected id %d\n", dispID);
544 return E_NOTIMPL;
547 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
549 ok(0, "unexpected call\n");
550 return E_NOTIMPL;
553 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
554 PropertyNotifySink_QueryInterface,
555 PropertyNotifySink_AddRef,
556 PropertyNotifySink_Release,
557 PropertyNotifySink_OnChanged,
558 PropertyNotifySink_OnRequestEdit
561 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
563 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
565 ok(0, "unexpected call\n");
566 return E_NOINTERFACE;
569 static ULONG WINAPI Stream_AddRef(IStream *iface)
571 return 2;
574 static ULONG WINAPI Stream_Release(IStream *iface)
576 return 1;
579 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
580 ULONG cb, ULONG *pcbRead)
582 CHECK_EXPECT2(Read);
583 ok(pv != NULL, "pv == NULL\n");
584 ok(cb > sizeof(html_page), "cb = %d\n", cb);
585 ok(pcbRead != NULL, "pcbRead == NULL\n");
586 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
588 if(stream_read)
589 return S_FALSE;
591 memcpy(pv, html_page, sizeof(html_page)-1);
592 stream_read += *pcbRead = sizeof(html_page)-1;
593 return S_OK;
596 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
597 ULONG cb, ULONG *pcbWritten)
599 ok(0, "unexpected call\n");
600 return E_NOTIMPL;
603 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
604 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
606 ok(0, "unexpected call\n");
607 return E_NOTIMPL;
610 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
612 ok(0, "unexpected call\n");
613 return E_NOTIMPL;
616 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
617 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
619 ok(0, "unexpected call\n");
620 return E_NOTIMPL;
623 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
625 ok(0, "unexpected call\n");
626 return E_NOTIMPL;
629 static HRESULT WINAPI Stream_Revert(IStream *iface)
631 ok(0, "unexpected call\n");
632 return E_NOTIMPL;
635 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
636 ULARGE_INTEGER cb, DWORD dwLockType)
638 ok(0, "unexpected call\n");
639 return E_NOTIMPL;
642 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
643 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
645 ok(0, "unexpected call\n");
646 return E_NOTIMPL;
649 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
650 DWORD dwStatFlag)
652 ok(0, "unexpected call\n");
653 return E_NOTIMPL;
656 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
658 ok(0, "unexpected call\n");
659 return E_NOTIMPL;
662 static const IStreamVtbl StreamVtbl = {
663 Stream_QueryInterface,
664 Stream_AddRef,
665 Stream_Release,
666 Stream_Read,
667 Stream_Write,
668 Stream_Seek,
669 Stream_SetSize,
670 Stream_CopyTo,
671 Stream_Commit,
672 Stream_Revert,
673 Stream_LockRegion,
674 Stream_UnlockRegion,
675 Stream_Stat,
676 Stream_Clone
679 static IStream Stream = { &StreamVtbl };
681 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
683 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
684 return E_NOINTERFACE; /* TODO */
686 if(IsEqualGUID(&IID_IWinInetInfo, riid))
687 return E_NOINTERFACE; /* TODO */
689 ok(0, "unexpected call\n");
690 return E_NOINTERFACE;
693 static ULONG WINAPI Binding_AddRef(IBinding *iface)
695 return 2;
698 static ULONG WINAPI Binding_Release(IBinding *iface)
700 return 1;
703 static HRESULT WINAPI Binding_Abort(IBinding *iface)
705 CHECK_EXPECT(Abort);
706 return S_OK;
709 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
711 ok(0, "unexpected call\n");
712 return E_NOTIMPL;
715 static HRESULT WINAPI Binding_Resume(IBinding *iface)
717 ok(0, "unexpected call\n");
718 return E_NOTIMPL;
721 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
723 ok(0, "unexpected call\n");
724 return E_NOTIMPL;
727 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
729 ok(0, "unexpected call\n");
730 return E_NOTIMPL;
733 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
734 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
736 ok(0, "unexpected call\n");
737 return E_NOTIMPL;
740 static const IBindingVtbl BindingVtbl = {
741 Binding_QueryInterface,
742 Binding_AddRef,
743 Binding_Release,
744 Binding_Abort,
745 Binding_Suspend,
746 Binding_Resume,
747 Binding_SetPriority,
748 Binding_GetPriority,
749 Binding_GetBindResult
752 static IBinding Binding = { &BindingVtbl };
754 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
756 ok(0, "unexpected call\n");
757 return E_NOINTERFACE;
760 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
762 return 2;
765 static ULONG WINAPI Moniker_Release(IMoniker *iface)
767 return 1;
770 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
772 ok(0, "unexpected call\n");
773 return E_NOTIMPL;
776 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
778 ok(0, "unexpected call\n");
779 return E_NOTIMPL;
782 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
784 ok(0, "unexpected call\n");
785 return E_NOTIMPL;
788 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
790 ok(0, "unexpected call\n");
791 return E_NOTIMPL;
794 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
796 ok(0, "unexpected call\n");
797 return E_NOTIMPL;
800 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
801 REFIID riidResult, void **ppvResult)
803 ok(0, "unexpected call\n");
804 return E_NOTIMPL;
807 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
808 REFIID riid, void **ppv)
810 IBindStatusCallback *callback = NULL;
811 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
812 STGMEDIUM stgmedium;
813 BINDINFO bindinfo;
814 DWORD bindf;
815 HRESULT hres;
817 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
818 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
820 CHECK_EXPECT(BindToStorage);
822 ok(pbc != NULL, "pbc == NULL\n");
823 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
824 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
825 ok(ppv != NULL, "ppv == NULL\n");
826 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
828 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
829 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
830 ok(callback != NULL, "callback == NULL\n");
832 memset(&bindinfo, 0xf0, sizeof(bindinfo));
833 bindinfo.cbSize = sizeof(bindinfo);
835 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
836 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
837 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
838 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
839 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
840 /* TODO: test stgmedData */
841 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
842 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
843 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
844 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
845 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
846 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
847 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
848 /* TODO: test dwCodePage */
849 /* TODO: test securityAttributes */
850 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
851 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
852 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
854 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
855 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
857 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
858 wszTextHtml);
859 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
861 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
862 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
863 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
865 SET_EXPECT(Read);
866 stgmedium.tymed = TYMED_ISTREAM;
867 U(stgmedium).pstm = &Stream;
868 stgmedium.pUnkForRelease = (IUnknown*)iface;
869 hres = IBindStatusCallback_OnDataAvailable(callback,
870 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
871 sizeof(html_page)-1, &formatetc, &stgmedium);
872 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
873 CHECK_CALLED(Read);
875 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
876 BINDSTATUS_ENDDOWNLOADDATA, NULL);
877 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
879 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
880 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
882 IBindStatusCallback_Release(callback);
884 return S_OK;
887 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
888 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
890 ok(0, "unexpected call\n");
891 return E_NOTIMPL;
894 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
895 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
897 ok(0, "unexpected call\n");
898 return E_NOTIMPL;
901 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
903 ok(0, "unexpected call\n");
904 return E_NOTIMPL;
907 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
909 ok(0, "unexpected call\n");
910 return E_NOTIMPL;
913 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
915 ok(0, "unexpected call\n");
916 return E_NOTIMPL;
919 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
920 IMoniker *pmkNewlyRunning)
922 ok(0, "unexpected call\n");
923 return E_NOTIMPL;
926 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
927 IMoniker *pmkToLeft, FILETIME *pFileTime)
929 ok(0, "unexpected call\n");
930 return E_NOTIMPL;
933 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
935 ok(0, "unexpected call\n");
936 return E_NOTIMPL;
939 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
940 IMoniker **ppmkPrefix)
942 ok(0, "unexpected call\n");
943 return E_NOTIMPL;
946 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
947 IMoniker **pmkRelPath)
949 ok(0, "unexpected call\n");
950 return E_NOTIMPL;
953 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
954 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
956 CHECK_EXPECT2(GetDisplayName);
958 /* ok(pbc != NULL, "pbc == NULL\n"); */
959 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
960 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
962 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
963 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
965 return S_OK;
968 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
969 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
971 ok(0, "unexpected call\n");
972 return E_NOTIMPL;
975 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
977 ok(0, "unexpected call\n");
978 return E_NOTIMPL;
981 static const IMonikerVtbl MonikerVtbl = {
982 Moniker_QueryInterface,
983 Moniker_AddRef,
984 Moniker_Release,
985 Moniker_GetClassID,
986 Moniker_IsDirty,
987 Moniker_Load,
988 Moniker_Save,
989 Moniker_GetSizeMax,
990 Moniker_BindToObject,
991 Moniker_BindToStorage,
992 Moniker_Reduce,
993 Moniker_ComposeWith,
994 Moniker_Enum,
995 Moniker_IsEqual,
996 Moniker_Hash,
997 Moniker_IsRunning,
998 Moniker_GetTimeOfLastChange,
999 Moniker_Inverse,
1000 Moniker_CommonPrefixWith,
1001 Moniker_RelativePathTo,
1002 Moniker_GetDisplayName,
1003 Moniker_ParseDisplayName,
1004 Moniker_IsSystemMoniker
1007 static IMoniker Moniker = { &MonikerVtbl };
1009 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1011 return QueryInterface(riid, ppv);
1014 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1016 return 2;
1019 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1021 return 1;
1024 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1025 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1027 ok(0, "unexpected call\n");
1028 return E_NOTIMPL;
1031 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1032 IEnumUnknown **ppenum)
1034 ok(0, "unexpected call\n");
1035 return E_NOTIMPL;
1038 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1040 CHECK_EXPECT(LockContainer);
1041 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1042 return S_OK;
1045 static const IOleContainerVtbl OleContainerVtbl = {
1046 OleContainer_QueryInterface,
1047 OleContainer_AddRef,
1048 OleContainer_Release,
1049 OleContainer_ParseDisplayName,
1050 OleContainer_EnumObjects,
1051 OleContainer_LockContainer
1054 static IOleContainer OleContainer = { &OleContainerVtbl };
1056 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1058 return QueryInterface(riid, ppv);
1061 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1063 return 2;
1066 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1068 return 1;
1071 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1073 ok(0, "unexpected call\n");
1074 return E_NOTIMPL;
1077 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1079 ok(0, "unexpected call\n");
1080 return E_NOTIMPL;
1083 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1085 ok(0, "unexpected call\n");
1086 return E_NOTIMPL;
1089 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1090 LPCBORDERWIDTHS pborderwidths)
1092 ok(0, "unexpected call\n");
1093 return E_NOTIMPL;
1096 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1097 LPCBORDERWIDTHS pborderwidths)
1099 ok(0, "unexpected call\n");
1100 return E_NOTIMPL;
1103 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1104 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1106 static const WCHAR wszHTML_Document[] =
1107 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1109 CHECK_EXPECT2(SetActiveObject);
1111 if(expect_SetActiveObject_active) {
1112 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1113 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1114 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1115 }else {
1116 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1117 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1120 return S_OK;
1123 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1124 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1126 ok(0, "unexpected call\n");
1127 return E_NOTIMPL;
1130 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1131 HOLEMENU holemenu, HWND hwndActiveObject)
1133 ok(0, "unexpected call\n");
1134 return E_NOTIMPL;
1137 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1139 ok(0, "unexpected call\n");
1140 return E_NOTIMPL;
1143 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1145 CHECK_EXPECT2(SetStatusText);
1146 if(!expect_status_text)
1147 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1148 return S_OK;
1151 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1153 ok(0, "unexpected call\n");
1154 return E_NOTIMPL;
1157 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1159 ok(0, "unexpected call\n");
1160 return E_NOTIMPL;
1163 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1164 InPlaceFrame_QueryInterface,
1165 InPlaceFrame_AddRef,
1166 InPlaceFrame_Release,
1167 InPlaceFrame_GetWindow,
1168 InPlaceFrame_ContextSensitiveHelp,
1169 InPlaceFrame_GetBorder,
1170 InPlaceFrame_RequestBorderSpace,
1171 InPlaceFrame_SetBorderSpace,
1172 InPlaceFrame_SetActiveObject,
1173 InPlaceFrame_InsertMenus,
1174 InPlaceFrame_SetMenu,
1175 InPlaceFrame_RemoveMenus,
1176 InPlaceFrame_SetStatusText,
1177 InPlaceFrame_EnableModeless,
1178 InPlaceFrame_TranslateAccelerator
1181 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1183 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
1185 return QueryInterface(riid, ppv);
1188 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
1190 return 2;
1193 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
1195 return 1;
1198 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
1200 CHECK_EXPECT(GetWindow);
1201 ok(phwnd != NULL, "phwnd = NULL\n");
1202 *phwnd = container_hwnd;
1203 return S_OK;
1206 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
1208 ok(0, "unexpected call\n");
1209 return E_NOTIMPL;
1212 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
1214 CHECK_EXPECT(CanInPlaceActivate);
1215 return S_OK;
1218 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
1220 CHECK_EXPECT(OnInPlaceActivate);
1221 return S_OK;
1224 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
1226 CHECK_EXPECT(OnUIActivate);
1227 return S_OK;
1230 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
1231 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1232 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1234 static const RECT rect = {0,0,500,500};
1236 CHECK_EXPECT(GetWindowContext);
1238 ok(ppFrame != NULL, "ppFrame = NULL\n");
1239 if(ppFrame)
1240 *ppFrame = &InPlaceFrame;
1241 ok(ppDoc != NULL, "ppDoc = NULL\n");
1242 if(ppDoc)
1243 *ppDoc = NULL;
1244 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1245 if(lprcPosRect)
1246 memcpy(lprcPosRect, &rect, sizeof(RECT));
1247 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1248 if(lprcClipRect)
1249 memcpy(lprcClipRect, &rect, sizeof(RECT));
1250 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1251 if(lpFrameInfo) {
1252 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1253 lpFrameInfo->fMDIApp = FALSE;
1254 lpFrameInfo->hwndFrame = container_hwnd;
1255 lpFrameInfo->haccel = NULL;
1256 lpFrameInfo->cAccelEntries = 0;
1259 return S_OK;
1262 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtant)
1264 ok(0, "unexpected call\n");
1265 return E_NOTIMPL;
1268 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
1270 CHECK_EXPECT(OnUIDeactivate);
1271 ok(!fUndoable, "fUndoable = TRUE\n");
1272 return S_OK;
1275 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
1277 CHECK_EXPECT(OnInPlaceDeactivate);
1278 return S_OK;
1281 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
1283 ok(0, "unexpected call\n");
1284 return E_NOTIMPL;
1287 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
1289 ok(0, "unexpected call\n");
1290 return E_NOTIMPL;
1293 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
1295 ok(0, "unexpected call\n");
1296 return E_NOTIMPL;
1299 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl = {
1300 InPlaceSite_QueryInterface,
1301 InPlaceSite_AddRef,
1302 InPlaceSite_Release,
1303 InPlaceSite_GetWindow,
1304 InPlaceSite_ContextSensitiveHelp,
1305 InPlaceSite_CanInPlaceActivate,
1306 InPlaceSite_OnInPlaceActivate,
1307 InPlaceSite_OnUIActivate,
1308 InPlaceSite_GetWindowContext,
1309 InPlaceSite_Scroll,
1310 InPlaceSite_OnUIDeactivate,
1311 InPlaceSite_OnInPlaceDeactivate,
1312 InPlaceSite_DiscardUndoState,
1313 InPlaceSite_DeactivateAndUndo,
1314 InPlaceSite_OnPosRectChange
1317 static IOleInPlaceSite InPlaceSite = { &InPlaceSiteVtbl };
1319 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1321 return QueryInterface(riid, ppv);
1324 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1326 return 2;
1329 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1331 return 1;
1334 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1336 ok(0, "unexpected call\n");
1337 return E_NOTIMPL;
1340 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAsign, DWORD dwWhichMoniker,
1341 IMoniker **ppmon)
1343 ok(0, "unexpected call\n");
1344 return E_NOTIMPL;
1347 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1349 CHECK_EXPECT(GetContainer);
1350 ok(ppContainer != NULL, "ppContainer = NULL\n");
1351 *ppContainer = &OleContainer;
1352 return S_OK;
1355 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1357 ok(0, "unexpected call\n");
1358 return E_NOTIMPL;
1361 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1363 ok(0, "unexpected call\n");
1364 return E_NOTIMPL;
1367 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1369 ok(0, "unexpected call\n");
1370 return E_NOTIMPL;
1373 static const IOleClientSiteVtbl ClientSiteVtbl = {
1374 ClientSite_QueryInterface,
1375 ClientSite_AddRef,
1376 ClientSite_Release,
1377 ClientSite_SaveObject,
1378 ClientSite_GetMoniker,
1379 ClientSite_GetContainer,
1380 ClientSite_ShowObject,
1381 ClientSite_OnShowWindow,
1382 ClientSite_RequestNewObjectLayout
1385 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1387 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1389 return QueryInterface(riid, ppv);
1392 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1394 return 2;
1397 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1399 return 1;
1402 static BOOL call_UIActivate = TRUE;
1403 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1405 IOleDocument *document;
1406 HRESULT hres;
1408 CHECK_EXPECT(ActivateMe);
1409 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1411 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1412 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1414 if(SUCCEEDED(hres)) {
1415 hres = IOleDocument_CreateView(document, &InPlaceSite, NULL, 0, &view);
1416 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1418 if(SUCCEEDED(hres)) {
1419 IOleInPlaceActiveObject *activeobj = NULL;
1420 IOleInPlaceSite *inplacesite = NULL;
1421 HWND tmp_hwnd = NULL;
1422 static RECT rect = {0,0,400,500};
1424 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1425 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1426 ok(inplacesite == &InPlaceSite, "inplacesite=%p, expected %p\n",
1427 inplacesite, &InPlaceSite);
1429 hres = IOleDocumentView_SetInPlaceSite(view, &InPlaceSite);
1430 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1432 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1433 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1434 ok(inplacesite == &InPlaceSite, "inplacesite=%p, expected %p\n",
1435 inplacesite, &InPlaceSite);
1437 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1438 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1440 if(activeobj) {
1441 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1442 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1443 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1446 if(call_UIActivate) {
1447 SET_EXPECT(CanInPlaceActivate);
1448 SET_EXPECT(GetWindowContext);
1449 SET_EXPECT(GetWindow);
1450 SET_EXPECT(OnInPlaceActivate);
1451 SET_EXPECT(SetStatusText);
1452 SET_EXPECT(Exec_SETPROGRESSMAX);
1453 SET_EXPECT(Exec_SETPROGRESSPOS);
1454 SET_EXPECT(OnUIActivate);
1455 SET_EXPECT(SetActiveObject);
1456 SET_EXPECT(ShowUI);
1457 expect_SetActiveObject_active = TRUE;
1458 expect_status_text = NULL;
1460 hres = IOleDocumentView_UIActivate(view, TRUE);
1462 if(FAILED(hres)) {
1463 trace("UIActivate failed: %08x\n", hres);
1464 return hres;
1466 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1468 CHECK_CALLED(CanInPlaceActivate);
1469 CHECK_CALLED(GetWindowContext);
1470 CHECK_CALLED(GetWindow);
1471 CHECK_CALLED(OnInPlaceActivate);
1472 CHECK_CALLED(SetStatusText);
1473 CHECK_CALLED(Exec_SETPROGRESSMAX);
1474 CHECK_CALLED(Exec_SETPROGRESSPOS);
1475 CHECK_CALLED(OnUIActivate);
1476 CHECK_CALLED(SetActiveObject);
1477 CHECK_CALLED(ShowUI);
1479 if(activeobj) {
1480 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1481 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1482 ok(hwnd != NULL, "hwnd == NULL\n");
1483 if(last_hwnd)
1484 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1487 hres = IOleDocumentView_UIActivate(view, TRUE);
1488 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1490 if(activeobj) {
1491 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1492 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1493 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1497 hres = IOleDocumentView_SetRect(view, &rect);
1498 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1500 if(call_UIActivate) {
1501 hres = IOleDocumentView_Show(view, TRUE);
1502 ok(hres == S_OK, "Show failed: %08x\n", hres);
1503 }else {
1504 SET_EXPECT(CanInPlaceActivate);
1505 SET_EXPECT(GetWindowContext);
1506 SET_EXPECT(GetWindow);
1507 SET_EXPECT(OnInPlaceActivate);
1508 SET_EXPECT(SetStatusText);
1509 SET_EXPECT(Exec_SETPROGRESSMAX);
1510 SET_EXPECT(Exec_SETPROGRESSPOS);
1511 SET_EXPECT(OnUIActivate);
1512 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1514 hres = IOleDocumentView_Show(view, TRUE);
1515 ok(hres == S_OK, "Show failed: %08x\n", hres);
1517 CHECK_CALLED(CanInPlaceActivate);
1518 CHECK_CALLED(GetWindowContext);
1519 CHECK_CALLED(GetWindow);
1520 CHECK_CALLED(OnInPlaceActivate);
1521 CHECK_CALLED(SetStatusText);
1522 CHECK_CALLED(Exec_SETPROGRESSMAX);
1523 CHECK_CALLED(Exec_SETPROGRESSPOS);
1525 if(activeobj) {
1526 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1527 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1528 ok(hwnd != NULL, "hwnd == NULL\n");
1529 if(last_hwnd)
1530 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1534 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1536 if(activeobj)
1537 IOleInPlaceActiveObject_Release(activeobj);
1540 IOleDocument_Release(document);
1543 return S_OK;
1546 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1547 DocumentSite_QueryInterface,
1548 DocumentSite_AddRef,
1549 DocumentSite_Release,
1550 DocumentSite_ActivateMe
1553 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1555 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1557 return QueryInterface(riid, ppv);
1560 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1562 return 2;
1565 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1567 return 1;
1570 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1571 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1573 ok(0, "unexpected call\n");
1574 return E_NOTIMPL;
1577 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1579 CHECK_EXPECT(GetHostInfo);
1580 ok(pInfo != NULL, "pInfo=NULL\n");
1581 if(pInfo) {
1582 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1583 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1584 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1585 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1586 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1587 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1588 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1589 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1591 return S_OK;
1594 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1595 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1596 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1598 CHECK_EXPECT(ShowUI);
1600 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
1601 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1602 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
1603 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
1604 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
1606 return S_OK;
1609 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1611 CHECK_EXPECT(HideUI);
1612 return S_OK;
1615 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1617 CHECK_EXPECT(UpdateUI);
1618 return S_OK;
1621 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1623 ok(0, "unexpected call\n");
1624 return E_NOTIMPL;
1627 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1629 ok(0, "unexpected call\n");
1630 return E_NOTIMPL;
1633 static BOOL expect_OnFrameWindowActivate_fActivate;
1634 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1636 CHECK_EXPECT2(OnFrameWindowActivate);
1637 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
1638 return S_OK;
1641 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1642 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1644 ok(0, "unexpected call\n");
1645 return E_NOTIMPL;
1648 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1649 const GUID *pguidCmdGroup, DWORD nCmdID)
1651 ok(0, "unexpected call\n");
1652 return E_NOTIMPL;
1655 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1656 LPOLESTR *pchKey, DWORD dw)
1658 CHECK_EXPECT(GetOptionKeyPath);
1659 ok(pchKey != NULL, "pchKey = NULL\n");
1660 ok(!dw, "dw=%d, expected 0\n", dw);
1661 if(pchKey)
1662 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1663 return S_OK;
1666 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1667 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1669 CHECK_EXPECT(GetDropTarget);
1670 /* TODO */
1671 return E_NOTIMPL;
1674 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1676 ok(0, "unexpected call\n");
1677 return E_NOTIMPL;
1680 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1681 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1683 ok(0, "unexpected call\n");
1684 return E_NOTIMPL;
1687 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1688 IDataObject **ppPORet)
1690 ok(0, "unexpected call\n");
1691 return E_NOTIMPL;
1694 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1695 LPOLESTR *pchKey, DWORD dw)
1697 CHECK_EXPECT(GetOverrideKeyPath);
1698 ok(pchKey != NULL, "pchKey = NULL\n");
1699 if(pchKey)
1700 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1701 ok(!dw, "dw=%d, xepected 0\n", dw);
1702 return S_OK;
1705 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1706 DocHostUIHandler_QueryInterface,
1707 DocHostUIHandler_AddRef,
1708 DocHostUIHandler_Release,
1709 DocHostUIHandler_ShowContextMenu,
1710 DocHostUIHandler_GetHostInfo,
1711 DocHostUIHandler_ShowUI,
1712 DocHostUIHandler_HideUI,
1713 DocHostUIHandler_UpdateUI,
1714 DocHostUIHandler_EnableModeless,
1715 DocHostUIHandler_OnDocWindowActivate,
1716 DocHostUIHandler_OnFrameWindowActivate,
1717 DocHostUIHandler_ResizeBorder,
1718 DocHostUIHandler_TranslateAccelerator,
1719 DocHostUIHandler_GetOptionKeyPath,
1720 DocHostUIHandler_GetDropTarget,
1721 DocHostUIHandler_GetExternal,
1722 DocHostUIHandler_TranslateUrl,
1723 DocHostUIHandler_FilterDataObject,
1724 DocHostUIHandler_GetOverrideKeyPath
1727 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1729 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
1730 REFIID riid, void **ppv)
1732 return QueryInterface(riid, ppv);
1735 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
1737 return 2;
1740 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
1742 return 1;
1745 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
1746 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
1748 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
1749 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
1750 ok(!pCmdText, "pCmdText != NULL\n");
1752 switch(prgCmds[0].cmdID) {
1753 case OLECMDID_SETPROGRESSTEXT:
1754 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
1755 prgCmds[0].cmdf = OLECMDF_ENABLED;
1756 return S_OK;
1757 case OLECMDID_OPEN:
1758 CHECK_EXPECT(QueryStatus_OPEN);
1759 prgCmds[0].cmdf = 0;
1760 return S_OK;
1761 case OLECMDID_NEW:
1762 CHECK_EXPECT(QueryStatus_NEW);
1763 prgCmds[0].cmdf = 0;
1764 return S_OK;
1765 default:
1766 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
1769 return E_FAIL;
1772 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
1773 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
1775 test_readyState(NULL);
1777 if(!pguidCmdGroup) {
1778 switch(nCmdID) {
1779 case OLECMDID_SETPROGRESSMAX:
1780 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
1781 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1782 ok(pvaIn != NULL, "pvaIn == NULL\n");
1783 if(pvaIn) {
1784 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
1785 if(load_state == LD_NO)
1786 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
1788 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
1789 return S_OK;
1790 case OLECMDID_SETPROGRESSPOS:
1791 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
1792 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1793 ok(pvaIn != NULL, "pvaIn == NULL\n");
1794 if(pvaIn) {
1795 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
1796 if(load_state == LD_NO)
1797 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
1799 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
1800 return S_OK;
1801 case OLECMDID_HTTPEQUIV_DONE:
1802 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
1803 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
1804 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
1805 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
1806 load_state = LD_COMPLETE;
1807 return S_OK;
1808 case OLECMDID_SETDOWNLOADSTATE:
1809 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1810 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
1811 ok(pvaIn != NULL, "pvaIn == NULL\n");
1812 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
1814 switch(V_I4(pvaIn)) {
1815 case 0:
1816 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
1817 load_state = LD_INTERACTIVE;
1818 break;
1819 case 1:
1820 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
1821 break;
1822 default:
1823 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
1826 return S_OK;
1827 case OLECMDID_UPDATECOMMANDS:
1828 CHECK_EXPECT(Exec_UPDATECOMMANDS);
1829 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1830 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
1831 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
1832 return S_OK;
1833 case OLECMDID_SETTITLE:
1834 CHECK_EXPECT2(Exec_SETTITLE);
1835 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1836 ok(pvaIn != NULL, "pvaIn == NULL\n");
1837 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
1838 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
1839 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
1840 return S_OK;
1841 case OLECMDID_HTTPEQUIV:
1842 CHECK_EXPECT2(Exec_HTTPEQUIV);
1843 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
1844 /* TODO */
1845 return S_OK;
1846 default:
1847 ok(0, "unexpected command %d\n", nCmdID);
1848 return E_FAIL;
1852 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
1853 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
1855 switch(nCmdID) {
1856 case 37:
1857 CHECK_EXPECT2(Exec_ShellDocView_37);
1859 if(load_from_stream)
1860 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
1861 else if(!editmode)
1862 test_GetCurMoniker(doc_unk, &Moniker, NULL);
1864 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
1865 ok(pvaIn != NULL, "pvaIn == NULL\n");
1866 if(pvaIn) {
1867 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
1868 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
1870 return S_OK;
1871 default:
1872 ok(0, "unexpected command %d\n", nCmdID);
1873 return E_FAIL;
1877 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
1878 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
1880 switch(nCmdID) {
1881 case IDM_PARSECOMPLETE:
1882 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
1883 ok(pvaIn == NULL, "pvaIn != NULL\n");
1884 ok(pvaOut == NULL, "pvaOut != NULL\n");
1885 return S_OK;
1886 default:
1887 ok(0, "unexpected command %d\n", nCmdID);
1891 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
1892 return E_FAIL; /* TODO */
1894 ok(0, "unexpected call\n");
1895 return E_NOTIMPL;
1898 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
1899 OleCommandTarget_QueryInterface,
1900 OleCommandTarget_AddRef,
1901 OleCommandTarget_Release,
1902 OleCommandTarget_QueryStatus,
1903 OleCommandTarget_Exec
1906 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
1908 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
1910 return QueryInterface(riid, ppv);
1913 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
1915 return 2;
1918 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
1920 return 1;
1923 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
1925 ok(0, "unexpected call\n");
1926 return E_NOTIMPL;
1929 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
1930 ITypeInfo **ppTInfo)
1932 ok(0, "unexpected call\n");
1933 return E_NOTIMPL;
1936 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
1937 UINT cNames, LCID lcid, DISPID *rgDispId)
1939 ok(0, "unexpected call\n");
1940 return E_NOTIMPL;
1943 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
1944 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1945 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1947 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
1948 ok(pDispParams != NULL, "pDispParams == NULL\n");
1949 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
1950 ok(puArgErr != NULL, "puArgErr == NULL\n");
1951 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
1952 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
1953 test_readyState(NULL);
1955 switch(dispIdMember) {
1956 case DISPID_AMBIENT_USERMODE:
1957 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
1958 V_VT(pVarResult) = VT_BOOL;
1959 V_BOOL(pVarResult) = VARIANT_TRUE;
1960 return S_OK;
1961 case DISPID_AMBIENT_DLCONTROL:
1962 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
1963 return E_FAIL;
1964 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
1965 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1966 return E_FAIL;
1967 case DISPID_AMBIENT_SILENT:
1968 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
1969 V_VT(pVarResult) = VT_BOOL;
1970 V_BOOL(pVarResult) = VARIANT_FALSE;
1971 return S_OK;
1972 case DISPID_AMBIENT_USERAGENT:
1973 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
1974 return E_FAIL;
1975 case DISPID_AMBIENT_PALETTE:
1976 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
1977 return E_FAIL;
1980 ok(0, "unexpected dispid %d\n", dispIdMember);
1981 return E_FAIL;
1984 static IDispatchVtbl DispatchVtbl = {
1985 Dispatch_QueryInterface,
1986 Dispatch_AddRef,
1987 Dispatch_Release,
1988 Dispatch_GetTypeInfoCount,
1989 Dispatch_GetTypeInfo,
1990 Dispatch_GetIDsOfNames,
1991 Dispatch_Invoke
1994 static IDispatch Dispatch = { &DispatchVtbl };
1996 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
1997 REFIID riid, void **ppv)
1999 return QueryInterface(riid, ppv);
2002 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2004 return 2;
2007 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2009 return 1;
2012 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2013 REFIID riid, void **ppv)
2016 * Services used by HTMLDocument:
2018 * IOleUndoManager
2019 * IInternetSecurityManager
2020 * ITargetFrame
2021 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2022 * HTMLFrameBase
2023 * IShellObject
2024 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2025 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2026 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2027 * DefView (?)
2028 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2029 * IElementBehaviorFactory
2030 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2031 * STopLevelBrowser
2032 * IHTMLWindow2
2033 * IInternetProtocol
2034 * IWebBrowserApp
2035 * UrlHostory
2036 * IHTMLEditHost
2037 * IHlinkFrame
2040 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2041 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2042 *ppv = &HlinkFrame;
2043 return S_OK;
2046 return E_NOINTERFACE;
2049 static const IServiceProviderVtbl ServiceProviderVtbl = {
2050 ServiceProvider_QueryInterface,
2051 ServiceProvider_AddRef,
2052 ServiceProvider_Release,
2053 ServiceProvider_QueryService
2056 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2058 static HRESULT QueryInterface(REFIID riid, void **ppv)
2060 *ppv = NULL;
2062 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2063 *ppv = &ClientSite;
2064 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2065 *ppv = &DocumentSite;
2066 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2067 *ppv = &DocHostUIHandler;
2068 else if(IsEqualGUID(&IID_IOleContainer, riid))
2069 *ppv = &OleContainer;
2070 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2071 *ppv = &InPlaceSite;
2072 else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid) || IsEqualGUID(&IID_IOleInPlaceFrame, riid))
2073 *ppv = &InPlaceFrame;
2074 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2075 *ppv = &OleCommandTarget;
2076 else if(IsEqualGUID(&IID_IDispatch, riid))
2077 *ppv = &Dispatch;
2078 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2079 *ppv = &ServiceProvider;
2081 /* TODO:
2082 * IOleInPlaceSiteEx
2083 * {D48A6EC6-6A4A-11CF-94A7-444553540000}
2084 * {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
2085 * {000670BA-0000-0000-C000-000000000046}
2088 if(*ppv)
2089 return S_OK;
2090 return E_NOINTERFACE;
2093 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2095 return DefWindowProc(hwnd, msg, wParam, lParam);
2098 static void test_readyState(IUnknown *unk)
2100 IHTMLDocument2 *htmldoc;
2101 BSTR state;
2102 HRESULT hres;
2104 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2105 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
2106 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2107 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
2109 static const LPCWSTR expected_state[] = {
2110 wszUninitialized,
2111 wszLoading,
2112 wszInteractive,
2113 wszComplete,
2114 wszUninitialized
2117 if(!unk)
2118 unk = doc_unk;
2120 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2121 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2122 if(FAILED(hres))
2123 return;
2125 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2126 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2128 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2129 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2130 ok(!lstrcmpW(state, expected_state[load_state]), "unexpected state, expected %d\n", load_state);
2132 IHTMLDocument_Release(htmldoc);
2135 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2137 IConnectionPointContainer *tmp_container = NULL;
2138 IConnectionPoint *cp;
2139 IID iid;
2140 HRESULT hres;
2142 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2143 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2144 if(FAILED(hres))
2145 return;
2147 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2148 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2149 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2151 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2152 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2154 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2155 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2156 ok(tmp_container == container, "container != tmp_container\n");
2157 if(SUCCEEDED(hres))
2158 IConnectionPointContainer_Release(tmp_container);
2160 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2161 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2163 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2164 DWORD cookie;
2166 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2167 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2170 IConnectionPoint_Release(cp);
2173 static void test_ConnectionPointContainer(IUnknown *unk)
2175 IConnectionPointContainer *container;
2176 HRESULT hres;
2178 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2179 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2180 if(FAILED(hres))
2181 return;
2183 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2184 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2185 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2187 IConnectionPointContainer_Release(container);
2190 static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
2192 IHTMLDocument2 *doc;
2193 IPersistMoniker *permon;
2194 IMoniker *mon = (void*)0xdeadbeef;
2195 BSTR doc_url = (void*)0xdeadbeef;
2196 HRESULT hres;
2198 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2199 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2200 if(FAILED(hres))
2201 return;
2203 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
2204 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2206 hres = IHTMLDocument2_get_URL(doc, &doc_url);
2207 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
2209 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
2210 IPersistMoniker_Release(permon);
2212 if(exmon) {
2213 BSTR url;
2214 BOOL exb = expect_GetDisplayName;
2215 BOOL clb = called_GetDisplayName;
2217 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2218 ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
2220 SET_EXPECT(GetDisplayName);
2221 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2222 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2223 CHECK_CALLED(GetDisplayName);
2224 expect_GetDisplayName = exb;
2225 called_GetDisplayName = clb;
2227 SysFreeString(url);
2228 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2229 }else if(exurl) {
2230 BSTR url;
2232 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2234 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2235 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2237 ok(!lstrcmpW(url, exurl), "unexpected url\n");
2238 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2240 SysFreeString(url);
2241 }else {
2242 ok(hres == E_UNEXPECTED,
2243 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
2244 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
2245 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
2248 SysFreeString(doc_url);
2249 IHTMLDocument_Release(doc);
2250 if(mon && mon != (void*)0xdeadbeef)
2251 IMoniker_Release(mon);
2254 static void test_Load(IPersistMoniker *persist)
2256 IBindCtx *bind;
2257 HRESULT hres;
2258 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2260 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2262 test_readyState((IUnknown*)persist);
2264 CreateBindCtx(0, &bind);
2265 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2266 (IUnknown*)&ClientSite);
2268 SET_EXPECT(GetDisplayName);
2269 if(!set_clientsite) {
2270 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2271 SET_EXPECT(GetHostInfo);
2272 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2273 SET_EXPECT(Invoke_AMBIENT_SILENT);
2274 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2275 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2276 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2277 SET_EXPECT(GetOptionKeyPath);
2278 SET_EXPECT(GetOverrideKeyPath);
2279 SET_EXPECT(GetWindow);
2280 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2281 SET_EXPECT(Exec_SETPROGRESSMAX);
2282 SET_EXPECT(Exec_SETPROGRESSPOS);
2283 SET_EXPECT(Exec_ShellDocView_37);
2285 if(!container_locked) {
2286 SET_EXPECT(GetContainer);
2287 SET_EXPECT(LockContainer);
2289 SET_EXPECT(OnChanged_READYSTATE);
2290 SET_EXPECT(BindToStorage);
2291 if(set_clientsite) {
2292 SET_EXPECT(Invoke_AMBIENT_SILENT);
2293 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2294 SET_EXPECT(Exec_ShellDocView_37);
2296 expect_LockContainer_fLock = TRUE;
2297 readystate_set_loading = TRUE;
2299 hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
2300 ok(hres == S_OK, "Load failed: %08x\n", hres);
2302 CHECK_CALLED(GetDisplayName);
2303 if(!set_clientsite) {
2304 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2305 CHECK_CALLED(GetHostInfo);
2306 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2307 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2308 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2309 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2310 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2311 CHECK_CALLED(GetOptionKeyPath);
2312 CHECK_CALLED(GetOverrideKeyPath);
2313 CHECK_CALLED(GetWindow);
2314 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2315 CHECK_CALLED(Exec_SETPROGRESSMAX);
2316 CHECK_CALLED(Exec_SETPROGRESSPOS);
2317 CHECK_CALLED(Exec_ShellDocView_37);
2319 if(!container_locked) {
2320 CHECK_CALLED(GetContainer);
2321 CHECK_CALLED(LockContainer);
2322 container_locked = TRUE;
2324 CHECK_CALLED(OnChanged_READYSTATE);
2325 CHECK_CALLED(BindToStorage);
2326 if(set_clientsite) {
2327 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2328 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2329 CHECK_CALLED(Exec_ShellDocView_37);
2332 set_clientsite = container_locked = TRUE;
2334 test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
2336 IBindCtx_Release(bind);
2338 test_readyState((IUnknown*)persist);
2341 static void test_download(BOOL verb_done, BOOL css_dwl)
2343 HWND hwnd;
2344 MSG msg;
2346 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2347 ok(hwnd != NULL, "Could not find hidden window\n");
2349 test_readyState(NULL);
2351 if(verb_done) {
2352 SET_EXPECT(Exec_SETPROGRESSMAX);
2353 if(!load_from_stream)
2354 SET_EXPECT(GetHostInfo);
2356 SET_EXPECT(SetStatusText);
2357 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2358 SET_EXPECT(GetDropTarget);
2359 if(css_dwl) {
2360 SET_EXPECT(CreateInstance);
2361 SET_EXPECT(Start);
2362 SET_EXPECT(LockRequest);
2363 SET_EXPECT(Terminate);
2364 SET_EXPECT(Protocol_Read);
2365 SET_EXPECT(UnlockRequest);
2367 SET_EXPECT(OnChanged_1005);
2368 SET_EXPECT(OnChanged_READYSTATE);
2369 SET_EXPECT(Exec_SETPROGRESSPOS);
2370 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2371 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2372 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2373 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2375 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2376 TranslateMessage(&msg);
2377 DispatchMessage(&msg);
2380 if(verb_done) {
2381 CHECK_CALLED(Exec_SETPROGRESSMAX);
2382 if(!load_from_stream)
2383 CHECK_CALLED(GetHostInfo);
2385 CHECK_CALLED(SetStatusText);
2386 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2387 CHECK_CALLED(GetDropTarget);
2388 if(css_dwl) {
2389 if(called_CreateInstance) {
2390 CHECK_CALLED(CreateInstance);
2391 CHECK_CALLED(Start);
2392 CHECK_CALLED(LockRequest);
2393 CHECK_CALLED(Terminate);
2394 CHECK_CALLED(Protocol_Read);
2395 CHECK_CALLED(UnlockRequest);
2396 }else {
2397 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2399 SET_CALLED(CreateInstance);
2400 SET_CALLED(Start);
2401 SET_CALLED(LockRequest);
2402 SET_CALLED(Terminate);
2403 SET_CALLED(Protocol_Read);
2404 SET_CALLED(UnlockRequest);
2406 nogecko = TRUE;
2409 CHECK_CALLED(OnChanged_1005);
2410 CHECK_CALLED(OnChanged_READYSTATE);
2411 CHECK_CALLED(Exec_SETPROGRESSPOS);
2412 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2413 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2414 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2416 load_state = LD_COMPLETE;
2418 test_readyState(NULL);
2421 static void test_Persist(IUnknown *unk)
2423 IPersistMoniker *persist_mon;
2424 IPersistFile *persist_file;
2425 GUID guid;
2426 HRESULT hres;
2428 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2429 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2430 if(SUCCEEDED(hres)) {
2431 hres = IPersist_GetClassID(persist_file, NULL);
2432 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2434 hres = IPersist_GetClassID(persist_file, &guid);
2435 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2436 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2438 IPersist_Release(persist_file);
2441 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2442 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2443 if(SUCCEEDED(hres)) {
2444 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2445 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2447 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2448 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2449 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2451 if(load_state == LD_DOLOAD)
2452 test_Load(persist_mon);
2454 test_readyState(unk);
2456 IPersistMoniker_Release(persist_mon);
2460 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2462 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2463 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2464 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2465 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2466 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2467 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2468 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2469 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2470 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2471 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2472 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2473 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2474 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2475 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2476 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2477 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2478 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2479 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2480 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2481 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2483 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2484 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2485 0,0,0,0,0,0,
2486 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2487 0,0,
2488 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2489 0,0,
2490 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2491 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2492 0,0,0,0,0,
2493 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2494 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2495 0,0,
2496 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2497 0,0,0,
2498 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2499 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2502 static void test_QueryStatus(IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2504 IOleCommandTarget *cmdtrg;
2505 OLECMD olecmd = {cmdid, 0};
2506 HRESULT hres;
2508 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2509 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2510 if(FAILED(hres))
2511 return;
2513 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2514 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2516 IOleCommandTarget_Release(cmdtrg);
2518 ok(olecmd.cmdID == cmdid, "cmdID changed\n");
2519 ok(olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2522 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2524 if(!unk)
2525 unk = doc_unk;
2527 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2528 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2529 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2530 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2531 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2532 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2533 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2534 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2535 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2536 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2537 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2538 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2539 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2540 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2543 static void test_OleCommandTarget(IUnknown *unk)
2545 IOleCommandTarget *cmdtrg;
2546 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
2547 int i;
2548 HRESULT hres;
2550 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2551 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2552 if(FAILED(hres))
2553 return;
2555 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2556 cmds[i].cmdID = i+1;
2557 cmds[i].cmdf = 0xf0f0;
2560 SET_EXPECT(QueryStatus_OPEN);
2561 SET_EXPECT(QueryStatus_NEW);
2562 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
2563 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2564 CHECK_CALLED(QueryStatus_OPEN);
2565 CHECK_CALLED(QueryStatus_NEW);
2567 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2568 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
2569 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
2570 i+1, cmds[i].cmdf, expect_cmds[i+1]);
2573 IOleCommandTarget_Release(cmdtrg);
2576 static void test_OleCommandTarget_fail(IUnknown *unk)
2578 IOleCommandTarget *cmdtrg;
2579 int i;
2580 HRESULT hres;
2582 OLECMD cmd[2] = {
2583 {OLECMDID_OPEN, 0xf0f0},
2584 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
2587 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2588 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
2589 if(FAILED(hres))
2590 return;
2592 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
2593 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2595 SET_EXPECT(QueryStatus_OPEN);
2596 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
2597 CHECK_CALLED(QueryStatus_OPEN);
2599 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2600 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2601 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
2602 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
2603 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
2604 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
2605 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
2607 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
2608 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
2609 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
2611 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2612 if(!expect_cmds[i]) {
2613 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
2614 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2615 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2616 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2620 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
2621 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2622 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2623 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2625 IOleCommandTarget_Release(cmdtrg);
2628 static void test_exec_onunload(IUnknown *unk)
2630 IOleCommandTarget *cmdtrg;
2631 VARIANT var;
2632 HRESULT hres;
2634 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2635 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2636 if(FAILED(hres))
2637 return;
2639 memset(&var, 0x0a, sizeof(var));
2640 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
2641 OLECMDEXECOPT_DODEFAULT, NULL, &var);
2642 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
2643 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
2644 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
2646 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
2647 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2648 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
2650 IOleCommandTarget_Release(cmdtrg);
2653 static void test_exec_editmode(IUnknown *unk)
2655 IOleCommandTarget *cmdtrg;
2656 HRESULT hres;
2658 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2659 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2660 if(FAILED(hres))
2661 return;
2663 editmode = TRUE;
2665 SET_EXPECT(SetStatusText);
2666 SET_EXPECT(Exec_ShellDocView_37);
2667 SET_EXPECT(GetHostInfo);
2668 SET_EXPECT(Invoke_AMBIENT_SILENT);
2669 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2670 SET_EXPECT(OnChanged_READYSTATE);
2671 expect_status_text = NULL;
2672 readystate_set_loading = TRUE;
2674 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
2675 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2676 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2678 CHECK_CALLED(SetStatusText);
2679 CHECK_CALLED(Exec_ShellDocView_37);
2680 CHECK_CALLED(GetHostInfo);
2681 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2682 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2683 CHECK_CALLED(OnChanged_READYSTATE);
2685 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
2687 IOleCommandTarget_Release(cmdtrg);
2689 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
2690 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2691 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2694 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
2696 IOleCommandTarget *cmdtrg;
2697 VARIANT *in = NULL, _in, *out = NULL, _out;
2698 HRESULT hres;
2700 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2701 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
2702 if(FAILED(hres))
2703 return;
2705 if(name) {
2706 in = &_in;
2707 V_VT(in) = VT_BSTR;
2708 V_BSTR(in) = SysAllocString(name);
2711 if(exname) {
2712 out = &_out;
2713 V_VT(out) = VT_I4;
2714 V_I4(out) = 0xdeadbeef;
2717 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
2718 if(!nogecko)
2719 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
2721 if(in)
2722 VariantClear(in);
2724 if(out && !nogecko) {
2725 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
2726 if(V_VT(out) == VT_BSTR)
2727 ok(!lstrcmpW(V_BSTR(out), name ? name : exname), "unexpected fontname\n");
2728 VariantClear(out);
2731 IOleCommandTarget_Release(cmdtrg);
2734 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
2736 IOleCommandTarget *cmdtrg;
2737 HRESULT hres;
2739 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2740 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2741 if(FAILED(hres))
2742 return;
2744 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
2745 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2746 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2748 IOleCommandTarget_Release(cmdtrg);
2751 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
2753 IPersistStreamInit *perinit;
2754 IPersistMoniker *permon;
2755 IPersistFile *perfile;
2756 HRESULT hres;
2758 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
2759 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
2760 if(SUCCEEDED(hres)) {
2761 hres = IPersistStreamInit_IsDirty(perinit);
2762 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2763 IPersistStreamInit_Release(perinit);
2766 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2767 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
2768 if(SUCCEEDED(hres)) {
2769 hres = IPersistMoniker_IsDirty(permon);
2770 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2771 IPersistMoniker_Release(permon);
2774 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
2775 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
2776 if(SUCCEEDED(hres)) {
2777 hres = IPersistFile_IsDirty(perfile);
2778 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2779 IPersistFile_Release(perfile);
2783 static HWND create_container_window(void)
2785 static const WCHAR wszHTMLDocumentTest[] =
2786 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
2787 static WNDCLASSEXW wndclass = {
2788 sizeof(WNDCLASSEXW),
2790 wnd_proc,
2791 0, 0, NULL, NULL, NULL, NULL, NULL,
2792 wszHTMLDocumentTest,
2793 NULL
2796 RegisterClassExW(&wndclass);
2797 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
2798 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
2799 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
2802 static HRESULT test_DoVerb(IOleObject *oleobj)
2804 RECT rect = {0,0,500,500};
2805 HRESULT hres;
2807 if(!container_locked) {
2808 SET_EXPECT(GetContainer);
2809 SET_EXPECT(LockContainer);
2811 SET_EXPECT(ActivateMe);
2812 expect_LockContainer_fLock = TRUE;
2814 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
2815 if(FAILED(hres))
2816 return hres;
2817 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
2819 if(!container_locked) {
2820 CHECK_CALLED(GetContainer);
2821 CHECK_CALLED(LockContainer);
2822 container_locked = TRUE;
2824 CHECK_CALLED(ActivateMe);
2826 return hres;
2829 #define CLIENTSITE_EXPECTPATH 0x00000001
2830 #define CLIENTSITE_SETNULL 0x00000002
2831 #define CLIENTSITE_DONTSET 0x00000004
2833 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
2835 IOleClientSite *clientsite;
2836 HRESULT hres;
2838 if(flags & CLIENTSITE_SETNULL) {
2839 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2840 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
2842 hres = IOleObject_SetClientSite(oleobj, NULL);
2843 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2845 set_clientsite = FALSE;
2848 if(flags & CLIENTSITE_DONTSET)
2849 return;
2851 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2852 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
2853 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
2854 clientsite, set_clientsite ? &ClientSite : NULL);
2856 if(!set_clientsite) {
2857 SET_EXPECT(GetHostInfo);
2858 if(flags & CLIENTSITE_EXPECTPATH) {
2859 SET_EXPECT(GetOptionKeyPath);
2860 SET_EXPECT(GetOverrideKeyPath);
2862 SET_EXPECT(GetWindow);
2863 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2864 SET_EXPECT(Exec_SETPROGRESSMAX);
2865 SET_EXPECT(Exec_SETPROGRESSPOS);
2866 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2867 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2868 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2869 SET_EXPECT(Invoke_AMBIENT_SILENT);
2870 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2871 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2873 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
2874 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2876 CHECK_CALLED(GetHostInfo);
2877 if(flags & CLIENTSITE_EXPECTPATH) {
2878 CHECK_CALLED(GetOptionKeyPath);
2879 CHECK_CALLED(GetOverrideKeyPath);
2881 CHECK_CALLED(GetWindow);
2882 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2883 CHECK_CALLED(Exec_SETPROGRESSMAX);
2884 CHECK_CALLED(Exec_SETPROGRESSPOS);
2885 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2886 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2887 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2888 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2889 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2890 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2892 set_clientsite = TRUE;
2895 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
2896 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2898 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2899 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
2900 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
2903 static void test_OnAmbientPropertyChange(IUnknown *unk)
2905 IOleControl *control = NULL;
2906 HRESULT hres;
2908 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2909 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
2910 if(FAILED(hres))
2911 return;
2913 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2914 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
2915 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2916 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2918 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2919 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
2920 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2921 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2923 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2924 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2925 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2926 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2927 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2928 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2930 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2931 SET_EXPECT(Invoke_AMBIENT_SILENT);
2932 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2933 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2934 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2935 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2937 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2938 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
2939 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2940 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2942 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2943 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
2944 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2945 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2947 IOleControl_Release(control);
2952 static void test_OnAmbientPropertyChange2(IUnknown *unk)
2954 IOleControl *control = NULL;
2955 HRESULT hres;
2957 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2958 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
2959 if(FAILED(hres))
2960 return;
2962 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
2963 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
2965 IOleControl_Release(control);
2968 static void test_Close(IUnknown *unk, BOOL set_client)
2970 IOleObject *oleobj = NULL;
2971 HRESULT hres;
2973 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2974 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
2975 if(FAILED(hres))
2976 return;
2978 SET_EXPECT(GetContainer);
2979 SET_EXPECT(LockContainer);
2980 expect_LockContainer_fLock = FALSE;
2981 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
2982 ok(hres == S_OK, "Close failed: %08x\n", hres);
2983 CHECK_CALLED(GetContainer);
2984 CHECK_CALLED(LockContainer);
2985 container_locked = FALSE;
2987 if(set_client)
2988 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
2990 IOleObject_Release(oleobj);
2993 static void test_OnFrameWindowActivate(IUnknown *unk)
2995 IOleInPlaceActiveObject *inplaceact;
2996 HRESULT hres;
2998 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
2999 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3000 if(FAILED(hres))
3001 return;
3003 if(set_clientsite) {
3004 expect_OnFrameWindowActivate_fActivate = TRUE;
3005 SET_EXPECT(OnFrameWindowActivate);
3006 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3007 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3008 CHECK_CALLED(OnFrameWindowActivate);
3010 SET_EXPECT(OnFrameWindowActivate);
3011 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3012 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3013 CHECK_CALLED(OnFrameWindowActivate);
3015 expect_OnFrameWindowActivate_fActivate = FALSE;
3016 SET_EXPECT(OnFrameWindowActivate);
3017 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3018 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3019 CHECK_CALLED(OnFrameWindowActivate);
3021 expect_OnFrameWindowActivate_fActivate = TRUE;
3022 SET_EXPECT(OnFrameWindowActivate);
3023 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3024 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3025 CHECK_CALLED(OnFrameWindowActivate);
3026 }else {
3027 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3028 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3030 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3031 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3034 IOleInPlaceActiveObject_Release(inplaceact);
3037 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3039 IOleInPlaceObjectWindowless *windowlessobj = NULL;
3040 HRESULT hres;
3042 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3043 (void**)&windowlessobj);
3044 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3045 if(FAILED(hres))
3046 return;
3048 if(expect_call) SET_EXPECT(OnInPlaceDeactivate);
3049 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3050 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3051 if(expect_call) CHECK_CALLED(OnInPlaceDeactivate);
3053 IOleInPlaceObjectWindowless_Release(windowlessobj);
3056 static HRESULT test_Activate(IUnknown *unk, DWORD flags)
3058 IOleObject *oleobj = NULL;
3059 GUID guid;
3060 HRESULT hres;
3062 last_hwnd = hwnd;
3064 if(view)
3065 IOleDocumentView_Release(view);
3066 view = NULL;
3068 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3069 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3070 if(FAILED(hres))
3071 return hres;
3073 hres = IOleObject_GetUserClassID(oleobj, NULL);
3074 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3076 hres = IOleObject_GetUserClassID(oleobj, &guid);
3077 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3078 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3080 test_OnFrameWindowActivate(unk);
3082 test_ClientSite(oleobj, flags);
3083 test_InPlaceDeactivate(unk, FALSE);
3085 hres = test_DoVerb(oleobj);
3087 IOleObject_Release(oleobj);
3089 test_OnFrameWindowActivate(unk);
3091 return hres;
3094 static void test_Window(IUnknown *unk, BOOL expect_success)
3096 IOleInPlaceActiveObject *activeobject = NULL;
3097 HWND tmp_hwnd;
3098 HRESULT hres;
3100 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3101 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3102 if(FAILED(hres))
3103 return;
3105 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3107 if(expect_success) {
3108 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3109 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3110 }else {
3111 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3112 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3115 IOleInPlaceActiveObject_Release(activeobject);
3118 static void test_CloseView(void)
3120 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3121 HRESULT hres;
3123 if(!view)
3124 return;
3126 hres = IOleDocumentView_Show(view, FALSE);
3127 ok(hres == S_OK, "Show failed: %08x\n", hres);
3129 hres = IOleDocumentView_CloseView(view, 0);
3130 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3132 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3133 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3135 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3136 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3137 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3140 static void test_UIDeactivate(void)
3142 HRESULT hres;
3144 if(call_UIActivate) {
3145 SET_EXPECT(SetActiveObject);
3146 SET_EXPECT(HideUI);
3147 SET_EXPECT(OnUIDeactivate);
3150 expect_SetActiveObject_active = FALSE;
3151 hres = IOleDocumentView_UIActivate(view, FALSE);
3152 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3154 if(call_UIActivate) {
3155 CHECK_CALLED(SetActiveObject);
3156 CHECK_CALLED(HideUI);
3157 CHECK_CALLED(OnUIDeactivate);
3161 static void test_Hide(void)
3163 HRESULT hres;
3165 if(!view)
3166 return;
3168 hres = IOleDocumentView_Show(view, FALSE);
3169 ok(hres == S_OK, "Show failed: %08x\n", hres);
3172 static HRESULT create_document(IUnknown **unk)
3174 HRESULT hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3175 &IID_IUnknown, (void**)unk);
3176 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3177 return hres;
3180 static void test_Navigate(IUnknown *unk)
3182 IHlinkTarget *hlink;
3183 HRESULT hres;
3185 hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3186 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3188 SET_EXPECT(ActivateMe);
3189 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3190 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3191 CHECK_CALLED(ActivateMe);
3193 IHlinkTarget_Release(hlink);
3196 static void test_StreamLoad(IUnknown *unk)
3198 IPersistStreamInit *init;
3199 HRESULT hres;
3201 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3202 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3203 if(FAILED(hres))
3204 return;
3206 SET_EXPECT(Invoke_AMBIENT_SILENT);
3207 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3208 SET_EXPECT(Exec_ShellDocView_37);
3209 SET_EXPECT(OnChanged_READYSTATE);
3210 SET_EXPECT(Read);
3211 readystate_set_loading = TRUE;
3213 hres = IPersistStreamInit_Load(init, &Stream);
3214 ok(hres == S_OK, "Load failed: %08x\n", hres);
3216 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3217 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3218 CHECK_CALLED(Exec_ShellDocView_37);
3219 CHECK_CALLED(OnChanged_READYSTATE);
3220 CHECK_CALLED(Read);
3222 test_timer(EXPECT_SETTITLE);
3223 test_GetCurMoniker(unk, NULL, about_blank_url);
3225 IPersistStreamInit_Release(init);
3228 static void test_QueryInterface(IUnknown *unk)
3230 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
3231 HRESULT hres;
3233 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
3234 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3235 ok(runnable == NULL, "runnable=%p, ezpected NULL\n", runnable);
3238 static void init_test(enum load_state_t ls) {
3239 doc_unk = NULL;
3240 hwnd = last_hwnd = NULL;
3241 set_clientsite = FALSE;
3242 load_from_stream = FALSE;
3243 call_UIActivate = FALSE;
3244 load_state = ls;
3245 editmode = FALSE;
3246 stream_read = 0;
3247 protocol_read = 0;
3250 static void test_HTMLDocument(enum load_state_t ls)
3252 IUnknown *unk;
3253 HRESULT hres;
3254 ULONG ref;
3256 trace("Testing HTMLDocument (%s)...\n", (ls == LD_DOLOAD ? " load" : "no load"));
3258 init_test(ls);
3260 hres = create_document(&unk);
3261 if(FAILED(hres))
3262 return;
3263 doc_unk = unk;
3265 test_QueryInterface(unk);
3266 test_IsDirty(unk, S_FALSE);
3267 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3268 test_ConnectionPointContainer(unk);
3269 test_GetCurMoniker(unk, NULL, NULL);
3270 test_Persist(unk);
3271 if(load_state == LD_NO)
3272 test_OnAmbientPropertyChange2(unk);
3274 hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
3275 if(FAILED(hres)) {
3276 IUnknown_Release(unk);
3277 return;
3280 if(load_state == LD_LOADING) {
3281 test_download(FALSE, TRUE);
3282 test_GetCurMoniker(unk, &Moniker, NULL);
3285 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3286 test_OleCommandTarget_fail(unk);
3287 test_OleCommandTarget(unk);
3288 test_OnAmbientPropertyChange(unk);
3289 test_Window(unk, TRUE);
3291 test_UIDeactivate();
3292 test_OleCommandTarget(unk);
3293 test_Window(unk, TRUE);
3294 test_InPlaceDeactivate(unk, TRUE);
3296 /* Calling test_OleCommandTarget here couses Segmentation Fault with native
3297 * MSHTML. It doesn't with Wine. */
3299 test_Window(unk, FALSE);
3300 test_Hide();
3301 test_InPlaceDeactivate(unk, FALSE);
3302 test_CloseView();
3303 test_Close(unk, FALSE);
3305 /* Activate HTMLDocument again */
3306 test_Activate(unk, CLIENTSITE_SETNULL);
3307 test_Window(unk, TRUE);
3308 test_OleCommandTarget(unk);
3309 test_UIDeactivate();
3310 test_InPlaceDeactivate(unk, TRUE);
3311 test_Close(unk, FALSE);
3313 /* Activate HTMLDocument again, this time without UIActivate */
3314 call_UIActivate = FALSE;
3315 test_Activate(unk, CLIENTSITE_SETNULL);
3316 test_Window(unk, TRUE);
3317 test_UIDeactivate();
3318 test_InPlaceDeactivate(unk, TRUE);
3319 test_CloseView();
3320 test_CloseView();
3321 test_Close(unk, TRUE);
3322 test_OnAmbientPropertyChange2(unk);
3323 test_GetCurMoniker(unk, load_state == LD_NO ? NULL : &Moniker, NULL);
3325 if(view)
3326 IOleDocumentView_Release(view);
3327 view = NULL;
3329 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3331 ref = IUnknown_Release(unk);
3332 ok(ref == 0, "ref=%d, expected 0\n", ref);
3334 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3337 static void test_HTMLDocument_hlink(void)
3339 IUnknown *unk;
3340 HRESULT hres;
3341 ULONG ref;
3343 trace("Testing HTMLDocument (hlink)...\n");
3345 init_test(LD_DOLOAD);
3347 hres = create_document(&unk);
3348 if(FAILED(hres))
3349 return;
3350 doc_unk = unk;
3352 test_ConnectionPointContainer(unk);
3353 test_GetCurMoniker(unk, NULL, NULL);
3354 test_Persist(unk);
3355 test_Navigate(unk);
3357 test_download(FALSE, TRUE);
3359 test_IsDirty(unk, S_FALSE);
3360 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3361 test_exec_onunload(unk);
3362 test_Window(unk, TRUE);
3363 test_InPlaceDeactivate(unk, TRUE);
3364 test_Close(unk, FALSE);
3365 test_IsDirty(unk, S_FALSE);
3366 test_GetCurMoniker(unk, &Moniker, NULL);
3368 if(view)
3369 IOleDocumentView_Release(view);
3370 view = NULL;
3372 ref = IUnknown_Release(unk);
3373 ok(ref == 0, "ref=%d, expected 0\n", ref);
3376 static void test_HTMLDocument_StreamLoad(void)
3378 IOleObject *oleobj;
3379 IUnknown *unk;
3380 HRESULT hres;
3381 ULONG ref;
3383 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3385 init_test(LD_DOLOAD);
3386 load_from_stream = TRUE;
3388 hres = create_document(&unk);
3389 if(FAILED(hres))
3390 return;
3391 doc_unk = unk;
3393 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3394 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3396 test_readyState(unk);
3397 test_IsDirty(unk, S_FALSE);
3398 test_ConnectionPointContainer(unk);
3399 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3400 test_DoVerb(oleobj);
3401 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3403 IOleObject_Release(oleobj);
3405 test_GetCurMoniker(unk, NULL, NULL);
3406 test_StreamLoad(unk);
3407 test_download(TRUE, FALSE);
3409 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3410 test_UIDeactivate();
3411 test_InPlaceDeactivate(unk, TRUE);
3412 test_Close(unk, FALSE);
3413 test_IsDirty(unk, S_FALSE);
3415 if(view) {
3416 IOleDocumentView_Release(view);
3417 view = NULL;
3421 ref = IUnknown_Release(unk);
3422 ok(ref == 0, "ref=%d, expected 0\n", ref);
3425 static void test_editing_mode(void)
3427 IUnknown *unk;
3428 IOleObject *oleobj;
3429 HRESULT hres;
3430 ULONG ref;
3432 trace("Testing HTMLDocument (edit)...\n");
3434 init_test(LD_DOLOAD);
3436 hres = create_document(&unk);
3437 if(FAILED(hres))
3438 return;
3439 doc_unk = unk;
3441 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3442 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3444 test_readyState(unk);
3445 test_ConnectionPointContainer(unk);
3446 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3447 test_DoVerb(oleobj);
3448 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3450 IOleObject_Release(oleobj);
3452 test_exec_editmode(unk);
3453 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3454 test_download(TRUE, FALSE);
3455 test_timer(EXPECT_UPDATEUI);
3456 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3458 test_exec_fontname(unk, NULL, wszTimesNewRoman);
3459 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
3460 test_timer(EXPECT_UPDATEUI);
3461 test_exec_fontname(unk, NULL, wszArial);
3463 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
3464 test_timer(EXPECT_UPDATEUI);
3465 if(!nogecko)
3466 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
3467 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
3469 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
3470 test_timer(EXPECT_UPDATEUI);
3471 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
3472 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3473 if(!nogecko)
3474 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
3475 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
3477 test_exec_noargs(unk, IDM_HORIZONTALLINE);
3478 test_timer(EXPECT_UPDATEUI);
3479 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
3480 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3482 test_UIDeactivate();
3483 test_InPlaceDeactivate(unk, TRUE);
3484 test_Close(unk, FALSE);
3486 if(view) {
3487 IOleDocumentView_Release(view);
3488 view = NULL;
3491 ref = IUnknown_Release(unk);
3492 ok(ref == 0, "ref=%d, expected 0\n", ref);
3495 static void register_protocol(void)
3497 IInternetSession *session;
3498 HRESULT hres;
3500 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
3502 hres = CoInternetGetSession(0, &session, 0);
3503 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3505 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
3506 wsz_winetest, 0, NULL, 0);
3507 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3509 IInternetSession_Release(session);
3512 static void gecko_installer_workaround(BOOL disable)
3514 HKEY hkey;
3515 DWORD res;
3517 static BOOL has_url = FALSE;
3518 static char url[2048];
3520 if(!disable && !has_url)
3521 return;
3523 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
3524 if(res != ERROR_SUCCESS)
3525 return;
3527 if(disable) {
3528 DWORD type, size = sizeof(url);
3530 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
3531 if(res == ERROR_SUCCESS && type == REG_SZ)
3532 has_url = TRUE;
3534 RegDeleteValue(hkey, "GeckoUrl");
3535 }else {
3536 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
3539 RegCloseKey(hkey);
3542 START_TEST(htmldoc)
3544 gecko_installer_workaround(TRUE);
3546 CoInitialize(NULL);
3547 container_hwnd = create_container_window();
3548 register_protocol();
3550 test_HTMLDocument(LD_NO);
3551 test_HTMLDocument(LD_DOLOAD);
3552 test_HTMLDocument_hlink();
3553 test_HTMLDocument_StreamLoad();
3554 test_editing_mode();
3556 DestroyWindow(container_hwnd);
3557 CoUninitialize();
3559 gecko_installer_workaround(FALSE);