mshtml: Added GetCurMoniker implementation.
[wine.git] / dlls / mshtml / tests / htmldoc.c
blobaf5d7a40806d56a318bb57a902a1821b0d27272b
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 IPersistMoniker *permon;
2193 IMoniker *mon = (void*)0xdeadbeef;
2194 HRESULT hres;
2196 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2197 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2198 if(FAILED(hres))
2199 return;
2201 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
2202 IPersistMoniker_Release(permon);
2204 if(exmon) {
2205 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2206 ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
2207 }else if(exurl) {
2208 BSTR url;
2210 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2212 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2213 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2215 ok(!lstrcmpW(url, exurl), "unexpected url\n");
2216 SysFreeString(url);
2217 }else {
2218 ok(hres == E_UNEXPECTED,
2219 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
2220 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
2223 if(mon && mon != (void*)0xdeadbeef)
2224 IMoniker_Release(mon);
2227 static void test_Load(IPersistMoniker *persist)
2229 IBindCtx *bind;
2230 HRESULT hres;
2231 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2233 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2235 test_readyState((IUnknown*)persist);
2237 CreateBindCtx(0, &bind);
2238 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2239 (IUnknown*)&ClientSite);
2241 SET_EXPECT(GetDisplayName);
2242 if(!set_clientsite) {
2243 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2244 SET_EXPECT(GetHostInfo);
2245 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2246 SET_EXPECT(Invoke_AMBIENT_SILENT);
2247 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2248 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2249 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2250 SET_EXPECT(GetOptionKeyPath);
2251 SET_EXPECT(GetOverrideKeyPath);
2252 SET_EXPECT(GetWindow);
2253 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2254 SET_EXPECT(Exec_SETPROGRESSMAX);
2255 SET_EXPECT(Exec_SETPROGRESSPOS);
2256 SET_EXPECT(Exec_ShellDocView_37);
2258 if(!container_locked) {
2259 SET_EXPECT(GetContainer);
2260 SET_EXPECT(LockContainer);
2262 SET_EXPECT(OnChanged_READYSTATE);
2263 SET_EXPECT(BindToStorage);
2264 if(set_clientsite) {
2265 SET_EXPECT(Invoke_AMBIENT_SILENT);
2266 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2267 SET_EXPECT(Exec_ShellDocView_37);
2269 expect_LockContainer_fLock = TRUE;
2270 readystate_set_loading = TRUE;
2272 hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
2273 ok(hres == S_OK, "Load failed: %08x\n", hres);
2275 CHECK_CALLED(GetDisplayName);
2276 if(!set_clientsite) {
2277 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2278 CHECK_CALLED(GetHostInfo);
2279 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2280 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2281 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2282 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2283 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2284 CHECK_CALLED(GetOptionKeyPath);
2285 CHECK_CALLED(GetOverrideKeyPath);
2286 CHECK_CALLED(GetWindow);
2287 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2288 CHECK_CALLED(Exec_SETPROGRESSMAX);
2289 CHECK_CALLED(Exec_SETPROGRESSPOS);
2290 CHECK_CALLED(Exec_ShellDocView_37);
2292 if(!container_locked) {
2293 CHECK_CALLED(GetContainer);
2294 CHECK_CALLED(LockContainer);
2295 container_locked = TRUE;
2297 CHECK_CALLED(OnChanged_READYSTATE);
2298 CHECK_CALLED(BindToStorage);
2299 if(set_clientsite) {
2300 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2301 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2302 CHECK_CALLED(Exec_ShellDocView_37);
2305 set_clientsite = container_locked = TRUE;
2307 test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
2309 IBindCtx_Release(bind);
2311 test_readyState((IUnknown*)persist);
2314 static void test_download(BOOL verb_done, BOOL css_dwl)
2316 HWND hwnd;
2317 MSG msg;
2319 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2320 ok(hwnd != NULL, "Could not find hidden window\n");
2322 test_readyState(NULL);
2324 if(verb_done) {
2325 SET_EXPECT(Exec_SETPROGRESSMAX);
2326 if(!load_from_stream)
2327 SET_EXPECT(GetHostInfo);
2329 SET_EXPECT(SetStatusText);
2330 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2331 SET_EXPECT(GetDropTarget);
2332 if(css_dwl) {
2333 SET_EXPECT(CreateInstance);
2334 SET_EXPECT(Start);
2335 SET_EXPECT(LockRequest);
2336 SET_EXPECT(Terminate);
2337 SET_EXPECT(Protocol_Read);
2338 SET_EXPECT(UnlockRequest);
2340 SET_EXPECT(OnChanged_1005);
2341 SET_EXPECT(OnChanged_READYSTATE);
2342 SET_EXPECT(Exec_SETPROGRESSPOS);
2343 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2344 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2345 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2346 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2348 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2349 TranslateMessage(&msg);
2350 DispatchMessage(&msg);
2353 if(verb_done) {
2354 CHECK_CALLED(Exec_SETPROGRESSMAX);
2355 if(!load_from_stream)
2356 CHECK_CALLED(GetHostInfo);
2358 CHECK_CALLED(SetStatusText);
2359 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2360 CHECK_CALLED(GetDropTarget);
2361 if(css_dwl) {
2362 if(called_CreateInstance) {
2363 CHECK_CALLED(CreateInstance);
2364 CHECK_CALLED(Start);
2365 CHECK_CALLED(LockRequest);
2366 CHECK_CALLED(Terminate);
2367 CHECK_CALLED(Protocol_Read);
2368 CHECK_CALLED(UnlockRequest);
2369 }else {
2370 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2372 SET_CALLED(CreateInstance);
2373 SET_CALLED(Start);
2374 SET_CALLED(LockRequest);
2375 SET_CALLED(Terminate);
2376 SET_CALLED(Protocol_Read);
2377 SET_CALLED(UnlockRequest);
2379 nogecko = TRUE;
2382 CHECK_CALLED(OnChanged_1005);
2383 CHECK_CALLED(OnChanged_READYSTATE);
2384 CHECK_CALLED(Exec_SETPROGRESSPOS);
2385 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2386 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2387 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2389 load_state = LD_COMPLETE;
2391 test_readyState(NULL);
2394 static void test_Persist(IUnknown *unk)
2396 IPersistMoniker *persist_mon;
2397 IPersistFile *persist_file;
2398 GUID guid;
2399 HRESULT hres;
2401 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2402 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2403 if(SUCCEEDED(hres)) {
2404 hres = IPersist_GetClassID(persist_file, NULL);
2405 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2407 hres = IPersist_GetClassID(persist_file, &guid);
2408 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2409 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2411 IPersist_Release(persist_file);
2414 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2415 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2416 if(SUCCEEDED(hres)) {
2417 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2418 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2420 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2421 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2422 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2424 if(load_state == LD_DOLOAD)
2425 test_Load(persist_mon);
2427 test_readyState(unk);
2429 IPersistMoniker_Release(persist_mon);
2433 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2435 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2436 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2437 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2438 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2439 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2440 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2441 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2442 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2443 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2444 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2445 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2446 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2447 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2448 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2449 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2450 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2451 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2452 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2453 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2454 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2456 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2457 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2458 0,0,0,0,0,0,
2459 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2460 0,0,
2461 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2462 0,0,
2463 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2464 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2465 0,0,0,0,0,
2466 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2467 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2468 0,0,
2469 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2470 0,0,0,
2471 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2472 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2475 static void test_QueryStatus(IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2477 IOleCommandTarget *cmdtrg;
2478 OLECMD olecmd = {cmdid, 0};
2479 HRESULT hres;
2481 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2482 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2483 if(FAILED(hres))
2484 return;
2486 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2487 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2489 IOleCommandTarget_Release(cmdtrg);
2491 ok(olecmd.cmdID == cmdid, "cmdID changed\n");
2492 ok(olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2495 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2497 if(!unk)
2498 unk = doc_unk;
2500 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2501 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2502 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2503 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2504 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2505 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2506 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2507 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2508 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2509 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2510 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2511 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2512 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2513 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2516 static void test_OleCommandTarget(IUnknown *unk)
2518 IOleCommandTarget *cmdtrg;
2519 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
2520 int i;
2521 HRESULT hres;
2523 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2524 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2525 if(FAILED(hres))
2526 return;
2528 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2529 cmds[i].cmdID = i+1;
2530 cmds[i].cmdf = 0xf0f0;
2533 SET_EXPECT(QueryStatus_OPEN);
2534 SET_EXPECT(QueryStatus_NEW);
2535 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
2536 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2537 CHECK_CALLED(QueryStatus_OPEN);
2538 CHECK_CALLED(QueryStatus_NEW);
2540 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2541 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
2542 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
2543 i+1, cmds[i].cmdf, expect_cmds[i+1]);
2546 IOleCommandTarget_Release(cmdtrg);
2549 static void test_OleCommandTarget_fail(IUnknown *unk)
2551 IOleCommandTarget *cmdtrg;
2552 int i;
2553 HRESULT hres;
2555 OLECMD cmd[2] = {
2556 {OLECMDID_OPEN, 0xf0f0},
2557 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
2560 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2561 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
2562 if(FAILED(hres))
2563 return;
2565 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
2566 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2568 SET_EXPECT(QueryStatus_OPEN);
2569 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
2570 CHECK_CALLED(QueryStatus_OPEN);
2572 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2573 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2574 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
2575 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
2576 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
2577 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
2578 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
2580 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
2581 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
2582 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
2584 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2585 if(!expect_cmds[i]) {
2586 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
2587 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2588 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2589 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2593 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
2594 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2595 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2596 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2598 IOleCommandTarget_Release(cmdtrg);
2601 static void test_exec_onunload(IUnknown *unk)
2603 IOleCommandTarget *cmdtrg;
2604 VARIANT var;
2605 HRESULT hres;
2607 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2608 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2609 if(FAILED(hres))
2610 return;
2612 memset(&var, 0x0a, sizeof(var));
2613 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
2614 OLECMDEXECOPT_DODEFAULT, NULL, &var);
2615 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
2616 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
2617 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
2619 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
2620 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2621 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
2623 IOleCommandTarget_Release(cmdtrg);
2626 static void test_exec_editmode(IUnknown *unk)
2628 IOleCommandTarget *cmdtrg;
2629 HRESULT hres;
2631 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2632 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2633 if(FAILED(hres))
2634 return;
2636 editmode = TRUE;
2638 SET_EXPECT(SetStatusText);
2639 SET_EXPECT(Exec_ShellDocView_37);
2640 SET_EXPECT(GetHostInfo);
2641 SET_EXPECT(Invoke_AMBIENT_SILENT);
2642 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2643 SET_EXPECT(OnChanged_READYSTATE);
2644 expect_status_text = NULL;
2645 readystate_set_loading = TRUE;
2647 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
2648 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2649 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2651 CHECK_CALLED(SetStatusText);
2652 CHECK_CALLED(Exec_ShellDocView_37);
2653 CHECK_CALLED(GetHostInfo);
2654 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2655 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2656 CHECK_CALLED(OnChanged_READYSTATE);
2658 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
2660 IOleCommandTarget_Release(cmdtrg);
2662 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
2663 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2664 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2667 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
2669 IOleCommandTarget *cmdtrg;
2670 VARIANT *in = NULL, _in, *out = NULL, _out;
2671 HRESULT hres;
2673 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2674 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
2675 if(FAILED(hres))
2676 return;
2678 if(name) {
2679 in = &_in;
2680 V_VT(in) = VT_BSTR;
2681 V_BSTR(in) = SysAllocString(name);
2684 if(exname) {
2685 out = &_out;
2686 V_VT(out) = VT_I4;
2687 V_I4(out) = 0xdeadbeef;
2690 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
2691 if(!nogecko)
2692 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
2694 if(in)
2695 VariantClear(in);
2697 if(out && !nogecko) {
2698 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
2699 if(V_VT(out) == VT_BSTR)
2700 ok(!lstrcmpW(V_BSTR(out), name ? name : exname), "unexpected fontname\n");
2701 VariantClear(out);
2704 IOleCommandTarget_Release(cmdtrg);
2707 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
2709 IOleCommandTarget *cmdtrg;
2710 HRESULT hres;
2712 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2713 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
2714 if(FAILED(hres))
2715 return;
2717 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
2718 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2719 ok(hres == S_OK, "Exec failed: %08x\n", hres);
2721 IOleCommandTarget_Release(cmdtrg);
2724 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
2726 IPersistStreamInit *perinit;
2727 IPersistMoniker *permon;
2728 IPersistFile *perfile;
2729 HRESULT hres;
2731 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
2732 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
2733 if(SUCCEEDED(hres)) {
2734 hres = IPersistStreamInit_IsDirty(perinit);
2735 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2736 IPersistStreamInit_Release(perinit);
2739 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2740 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
2741 if(SUCCEEDED(hres)) {
2742 hres = IPersistMoniker_IsDirty(permon);
2743 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2744 IPersistMoniker_Release(permon);
2747 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
2748 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
2749 if(SUCCEEDED(hres)) {
2750 hres = IPersistFile_IsDirty(perfile);
2751 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
2752 IPersistFile_Release(perfile);
2756 static HWND create_container_window(void)
2758 static const WCHAR wszHTMLDocumentTest[] =
2759 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
2760 static WNDCLASSEXW wndclass = {
2761 sizeof(WNDCLASSEXW),
2763 wnd_proc,
2764 0, 0, NULL, NULL, NULL, NULL, NULL,
2765 wszHTMLDocumentTest,
2766 NULL
2769 RegisterClassExW(&wndclass);
2770 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
2771 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
2772 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
2775 static HRESULT test_DoVerb(IOleObject *oleobj)
2777 RECT rect = {0,0,500,500};
2778 HRESULT hres;
2780 if(!container_locked) {
2781 SET_EXPECT(GetContainer);
2782 SET_EXPECT(LockContainer);
2784 SET_EXPECT(ActivateMe);
2785 expect_LockContainer_fLock = TRUE;
2787 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
2788 if(FAILED(hres))
2789 return hres;
2790 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
2792 if(!container_locked) {
2793 CHECK_CALLED(GetContainer);
2794 CHECK_CALLED(LockContainer);
2795 container_locked = TRUE;
2797 CHECK_CALLED(ActivateMe);
2799 return hres;
2802 #define CLIENTSITE_EXPECTPATH 0x00000001
2803 #define CLIENTSITE_SETNULL 0x00000002
2804 #define CLIENTSITE_DONTSET 0x00000004
2806 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
2808 IOleClientSite *clientsite;
2809 HRESULT hres;
2811 if(flags & CLIENTSITE_SETNULL) {
2812 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2813 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
2815 hres = IOleObject_SetClientSite(oleobj, NULL);
2816 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2818 set_clientsite = FALSE;
2821 if(flags & CLIENTSITE_DONTSET)
2822 return;
2824 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2825 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
2826 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
2827 clientsite, set_clientsite ? &ClientSite : NULL);
2829 if(!set_clientsite) {
2830 SET_EXPECT(GetHostInfo);
2831 if(flags & CLIENTSITE_EXPECTPATH) {
2832 SET_EXPECT(GetOptionKeyPath);
2833 SET_EXPECT(GetOverrideKeyPath);
2835 SET_EXPECT(GetWindow);
2836 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2837 SET_EXPECT(Exec_SETPROGRESSMAX);
2838 SET_EXPECT(Exec_SETPROGRESSPOS);
2839 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2840 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2841 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2842 SET_EXPECT(Invoke_AMBIENT_SILENT);
2843 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2844 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2846 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
2847 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2849 CHECK_CALLED(GetHostInfo);
2850 if(flags & CLIENTSITE_EXPECTPATH) {
2851 CHECK_CALLED(GetOptionKeyPath);
2852 CHECK_CALLED(GetOverrideKeyPath);
2854 CHECK_CALLED(GetWindow);
2855 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2856 CHECK_CALLED(Exec_SETPROGRESSMAX);
2857 CHECK_CALLED(Exec_SETPROGRESSPOS);
2858 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2859 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2860 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2861 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2862 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2863 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2865 set_clientsite = TRUE;
2868 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
2869 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2871 hres = IOleObject_GetClientSite(oleobj, &clientsite);
2872 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
2873 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
2876 static void test_OnAmbientPropertyChange(IUnknown *unk)
2878 IOleControl *control = NULL;
2879 HRESULT hres;
2881 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2882 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
2883 if(FAILED(hres))
2884 return;
2886 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2887 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
2888 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2889 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2891 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2892 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
2893 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2894 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2896 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2897 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2898 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2899 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2900 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2901 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2903 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2904 SET_EXPECT(Invoke_AMBIENT_SILENT);
2905 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2906 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2907 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2908 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2910 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2911 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
2912 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2913 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2915 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2916 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
2917 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
2918 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2920 IOleControl_Release(control);
2925 static void test_OnAmbientPropertyChange2(IUnknown *unk)
2927 IOleControl *control = NULL;
2928 HRESULT hres;
2930 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2931 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
2932 if(FAILED(hres))
2933 return;
2935 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
2936 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
2938 IOleControl_Release(control);
2941 static void test_Close(IUnknown *unk, BOOL set_client)
2943 IOleObject *oleobj = NULL;
2944 HRESULT hres;
2946 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2947 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
2948 if(FAILED(hres))
2949 return;
2951 SET_EXPECT(GetContainer);
2952 SET_EXPECT(LockContainer);
2953 expect_LockContainer_fLock = FALSE;
2954 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
2955 ok(hres == S_OK, "Close failed: %08x\n", hres);
2956 CHECK_CALLED(GetContainer);
2957 CHECK_CALLED(LockContainer);
2958 container_locked = FALSE;
2960 if(set_client)
2961 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
2963 IOleObject_Release(oleobj);
2966 static void test_OnFrameWindowActivate(IUnknown *unk)
2968 IOleInPlaceActiveObject *inplaceact;
2969 HRESULT hres;
2971 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
2972 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
2973 if(FAILED(hres))
2974 return;
2976 if(set_clientsite) {
2977 expect_OnFrameWindowActivate_fActivate = TRUE;
2978 SET_EXPECT(OnFrameWindowActivate);
2979 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
2980 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
2981 CHECK_CALLED(OnFrameWindowActivate);
2983 SET_EXPECT(OnFrameWindowActivate);
2984 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
2985 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
2986 CHECK_CALLED(OnFrameWindowActivate);
2988 expect_OnFrameWindowActivate_fActivate = FALSE;
2989 SET_EXPECT(OnFrameWindowActivate);
2990 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
2991 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
2992 CHECK_CALLED(OnFrameWindowActivate);
2994 expect_OnFrameWindowActivate_fActivate = TRUE;
2995 SET_EXPECT(OnFrameWindowActivate);
2996 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
2997 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
2998 CHECK_CALLED(OnFrameWindowActivate);
2999 }else {
3000 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3001 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3003 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3004 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3007 IOleInPlaceActiveObject_Release(inplaceact);
3010 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3012 IOleInPlaceObjectWindowless *windowlessobj = NULL;
3013 HRESULT hres;
3015 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3016 (void**)&windowlessobj);
3017 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3018 if(FAILED(hres))
3019 return;
3021 if(expect_call) SET_EXPECT(OnInPlaceDeactivate);
3022 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3023 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3024 if(expect_call) CHECK_CALLED(OnInPlaceDeactivate);
3026 IOleInPlaceObjectWindowless_Release(windowlessobj);
3029 static HRESULT test_Activate(IUnknown *unk, DWORD flags)
3031 IOleObject *oleobj = NULL;
3032 GUID guid;
3033 HRESULT hres;
3035 last_hwnd = hwnd;
3037 if(view)
3038 IOleDocumentView_Release(view);
3039 view = NULL;
3041 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3042 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3043 if(FAILED(hres))
3044 return hres;
3046 hres = IOleObject_GetUserClassID(oleobj, NULL);
3047 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3049 hres = IOleObject_GetUserClassID(oleobj, &guid);
3050 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3051 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3053 test_OnFrameWindowActivate(unk);
3055 test_ClientSite(oleobj, flags);
3056 test_InPlaceDeactivate(unk, FALSE);
3058 hres = test_DoVerb(oleobj);
3060 IOleObject_Release(oleobj);
3062 test_OnFrameWindowActivate(unk);
3064 return hres;
3067 static void test_Window(IUnknown *unk, BOOL expect_success)
3069 IOleInPlaceActiveObject *activeobject = NULL;
3070 HWND tmp_hwnd;
3071 HRESULT hres;
3073 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3074 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3075 if(FAILED(hres))
3076 return;
3078 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3080 if(expect_success) {
3081 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3082 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3083 }else {
3084 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3085 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3088 IOleInPlaceActiveObject_Release(activeobject);
3091 static void test_CloseView(void)
3093 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3094 HRESULT hres;
3096 if(!view)
3097 return;
3099 hres = IOleDocumentView_Show(view, FALSE);
3100 ok(hres == S_OK, "Show failed: %08x\n", hres);
3102 hres = IOleDocumentView_CloseView(view, 0);
3103 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3105 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3106 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3108 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3109 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3110 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3113 static void test_UIDeactivate(void)
3115 HRESULT hres;
3117 if(call_UIActivate) {
3118 SET_EXPECT(SetActiveObject);
3119 SET_EXPECT(HideUI);
3120 SET_EXPECT(OnUIDeactivate);
3123 expect_SetActiveObject_active = FALSE;
3124 hres = IOleDocumentView_UIActivate(view, FALSE);
3125 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3127 if(call_UIActivate) {
3128 CHECK_CALLED(SetActiveObject);
3129 CHECK_CALLED(HideUI);
3130 CHECK_CALLED(OnUIDeactivate);
3134 static void test_Hide(void)
3136 HRESULT hres;
3138 if(!view)
3139 return;
3141 hres = IOleDocumentView_Show(view, FALSE);
3142 ok(hres == S_OK, "Show failed: %08x\n", hres);
3145 static HRESULT create_document(IUnknown **unk)
3147 HRESULT hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3148 &IID_IUnknown, (void**)unk);
3149 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3150 return hres;
3153 static void test_Navigate(IUnknown *unk)
3155 IHlinkTarget *hlink;
3156 HRESULT hres;
3158 hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3159 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3161 SET_EXPECT(ActivateMe);
3162 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3163 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3164 CHECK_CALLED(ActivateMe);
3166 IHlinkTarget_Release(hlink);
3169 static void test_StreamLoad(IUnknown *unk)
3171 IPersistStreamInit *init;
3172 HRESULT hres;
3174 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3175 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3176 if(FAILED(hres))
3177 return;
3179 SET_EXPECT(Invoke_AMBIENT_SILENT);
3180 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3181 SET_EXPECT(Exec_ShellDocView_37);
3182 SET_EXPECT(OnChanged_READYSTATE);
3183 SET_EXPECT(Read);
3184 readystate_set_loading = TRUE;
3186 hres = IPersistStreamInit_Load(init, &Stream);
3187 ok(hres == S_OK, "Load failed: %08x\n", hres);
3189 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3190 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3191 CHECK_CALLED(Exec_ShellDocView_37);
3192 CHECK_CALLED(OnChanged_READYSTATE);
3193 CHECK_CALLED(Read);
3195 test_timer(EXPECT_SETTITLE);
3196 test_GetCurMoniker(unk, NULL, about_blank_url);
3198 IPersistStreamInit_Release(init);
3201 static void test_QueryInterface(IUnknown *unk)
3203 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
3204 HRESULT hres;
3206 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
3207 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3208 ok(runnable == NULL, "runnable=%p, ezpected NULL\n", runnable);
3211 static void init_test(enum load_state_t ls) {
3212 doc_unk = NULL;
3213 hwnd = last_hwnd = NULL;
3214 set_clientsite = FALSE;
3215 load_from_stream = FALSE;
3216 call_UIActivate = FALSE;
3217 load_state = ls;
3218 editmode = FALSE;
3219 stream_read = 0;
3220 protocol_read = 0;
3223 static void test_HTMLDocument(enum load_state_t ls)
3225 IUnknown *unk;
3226 HRESULT hres;
3227 ULONG ref;
3229 trace("Testing HTMLDocument (%s)...\n", (ls == LD_DOLOAD ? " load" : "no load"));
3231 init_test(ls);
3233 hres = create_document(&unk);
3234 if(FAILED(hres))
3235 return;
3236 doc_unk = unk;
3238 test_QueryInterface(unk);
3239 test_IsDirty(unk, S_FALSE);
3240 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3241 test_ConnectionPointContainer(unk);
3242 test_GetCurMoniker(unk, NULL, NULL);
3243 test_Persist(unk);
3244 if(load_state == LD_NO)
3245 test_OnAmbientPropertyChange2(unk);
3247 hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
3248 if(FAILED(hres)) {
3249 IUnknown_Release(unk);
3250 return;
3253 if(load_state == LD_LOADING) {
3254 test_download(FALSE, TRUE);
3255 test_GetCurMoniker(unk, &Moniker, NULL);
3258 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3259 test_OleCommandTarget_fail(unk);
3260 test_OleCommandTarget(unk);
3261 test_OnAmbientPropertyChange(unk);
3262 test_Window(unk, TRUE);
3264 test_UIDeactivate();
3265 test_OleCommandTarget(unk);
3266 test_Window(unk, TRUE);
3267 test_InPlaceDeactivate(unk, TRUE);
3269 /* Calling test_OleCommandTarget here couses Segmentation Fault with native
3270 * MSHTML. It doesn't with Wine. */
3272 test_Window(unk, FALSE);
3273 test_Hide();
3274 test_InPlaceDeactivate(unk, FALSE);
3275 test_CloseView();
3276 test_Close(unk, FALSE);
3278 /* Activate HTMLDocument again */
3279 test_Activate(unk, CLIENTSITE_SETNULL);
3280 test_Window(unk, TRUE);
3281 test_OleCommandTarget(unk);
3282 test_UIDeactivate();
3283 test_InPlaceDeactivate(unk, TRUE);
3284 test_Close(unk, FALSE);
3286 /* Activate HTMLDocument again, this time without UIActivate */
3287 call_UIActivate = FALSE;
3288 test_Activate(unk, CLIENTSITE_SETNULL);
3289 test_Window(unk, TRUE);
3290 test_UIDeactivate();
3291 test_InPlaceDeactivate(unk, TRUE);
3292 test_CloseView();
3293 test_CloseView();
3294 test_Close(unk, TRUE);
3295 test_OnAmbientPropertyChange2(unk);
3296 test_GetCurMoniker(unk, load_state == LD_NO ? NULL : &Moniker, NULL);
3298 if(view)
3299 IOleDocumentView_Release(view);
3300 view = NULL;
3302 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3304 ref = IUnknown_Release(unk);
3305 ok(ref == 0, "ref=%d, expected 0\n", ref);
3307 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3310 static void test_HTMLDocument_hlink(void)
3312 IUnknown *unk;
3313 HRESULT hres;
3314 ULONG ref;
3316 trace("Testing HTMLDocument (hlink)...\n");
3318 init_test(LD_DOLOAD);
3320 hres = create_document(&unk);
3321 if(FAILED(hres))
3322 return;
3323 doc_unk = unk;
3325 test_ConnectionPointContainer(unk);
3326 test_GetCurMoniker(unk, NULL, NULL);
3327 test_Persist(unk);
3328 test_Navigate(unk);
3330 test_download(FALSE, TRUE);
3332 test_IsDirty(unk, S_FALSE);
3333 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3334 test_exec_onunload(unk);
3335 test_Window(unk, TRUE);
3336 test_InPlaceDeactivate(unk, TRUE);
3337 test_Close(unk, FALSE);
3338 test_IsDirty(unk, S_FALSE);
3339 test_GetCurMoniker(unk, &Moniker, NULL);
3341 if(view)
3342 IOleDocumentView_Release(view);
3343 view = NULL;
3345 ref = IUnknown_Release(unk);
3346 ok(ref == 0, "ref=%d, expected 0\n", ref);
3349 static void test_HTMLDocument_StreamLoad(void)
3351 IOleObject *oleobj;
3352 IUnknown *unk;
3353 HRESULT hres;
3354 ULONG ref;
3356 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3358 init_test(LD_DOLOAD);
3359 load_from_stream = TRUE;
3361 hres = create_document(&unk);
3362 if(FAILED(hres))
3363 return;
3364 doc_unk = unk;
3366 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3367 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3369 test_readyState(unk);
3370 test_IsDirty(unk, S_FALSE);
3371 test_ConnectionPointContainer(unk);
3372 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3373 test_DoVerb(oleobj);
3374 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3376 IOleObject_Release(oleobj);
3378 test_GetCurMoniker(unk, NULL, NULL);
3379 test_StreamLoad(unk);
3380 test_download(TRUE, FALSE);
3382 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3383 test_UIDeactivate();
3384 test_InPlaceDeactivate(unk, TRUE);
3385 test_Close(unk, FALSE);
3386 test_IsDirty(unk, S_FALSE);
3388 if(view) {
3389 IOleDocumentView_Release(view);
3390 view = NULL;
3394 ref = IUnknown_Release(unk);
3395 ok(ref == 0, "ref=%d, expected 0\n", ref);
3398 static void test_editing_mode(void)
3400 IUnknown *unk;
3401 IOleObject *oleobj;
3402 HRESULT hres;
3403 ULONG ref;
3405 trace("Testing HTMLDocument (edit)...\n");
3407 init_test(LD_DOLOAD);
3409 hres = create_document(&unk);
3410 if(FAILED(hres))
3411 return;
3412 doc_unk = unk;
3414 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3415 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3417 test_readyState(unk);
3418 test_ConnectionPointContainer(unk);
3419 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3420 test_DoVerb(oleobj);
3421 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3423 IOleObject_Release(oleobj);
3425 test_exec_editmode(unk);
3426 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3427 test_download(TRUE, FALSE);
3428 test_timer(EXPECT_UPDATEUI);
3429 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3431 test_exec_fontname(unk, NULL, wszTimesNewRoman);
3432 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
3433 test_timer(EXPECT_UPDATEUI);
3434 test_exec_fontname(unk, NULL, wszArial);
3436 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
3437 test_timer(EXPECT_UPDATEUI);
3438 if(!nogecko)
3439 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
3440 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
3442 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
3443 test_timer(EXPECT_UPDATEUI);
3444 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
3445 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3446 if(!nogecko)
3447 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
3448 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
3450 test_exec_noargs(unk, IDM_HORIZONTALLINE);
3451 test_timer(EXPECT_UPDATEUI);
3452 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
3453 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3455 test_UIDeactivate();
3456 test_InPlaceDeactivate(unk, TRUE);
3457 test_Close(unk, FALSE);
3459 if(view) {
3460 IOleDocumentView_Release(view);
3461 view = NULL;
3464 ref = IUnknown_Release(unk);
3465 ok(ref == 0, "ref=%d, expected 0\n", ref);
3468 static void register_protocol(void)
3470 IInternetSession *session;
3471 HRESULT hres;
3473 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
3475 hres = CoInternetGetSession(0, &session, 0);
3476 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3478 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
3479 wsz_winetest, 0, NULL, 0);
3480 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3482 IInternetSession_Release(session);
3485 static void gecko_installer_workaround(BOOL disable)
3487 HKEY hkey;
3488 DWORD res;
3490 static BOOL has_url = FALSE;
3491 static char url[2048];
3493 if(!disable && !has_url)
3494 return;
3496 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
3497 if(res != ERROR_SUCCESS)
3498 return;
3500 if(disable) {
3501 DWORD type, size = sizeof(url);
3503 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
3504 if(res == ERROR_SUCCESS && type == REG_SZ)
3505 has_url = TRUE;
3507 RegDeleteValue(hkey, "GeckoUrl");
3508 }else {
3509 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
3512 RegCloseKey(hkey);
3515 START_TEST(htmldoc)
3517 gecko_installer_workaround(TRUE);
3519 CoInitialize(NULL);
3520 container_hwnd = create_container_window();
3521 register_protocol();
3523 test_HTMLDocument(LD_NO);
3524 test_HTMLDocument(LD_DOLOAD);
3525 test_HTMLDocument_hlink();
3526 test_HTMLDocument_StreamLoad();
3527 test_editing_mode();
3529 DestroyWindow(container_hwnd);
3530 CoUninitialize();
3532 gecko_installer_workaround(FALSE);