7a4d5eeeeaa146857357c989bd9866cd7e4b1db2
[reactos.git] / rostests / winetests / mshtml / htmldoc.c
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #define COBJMACROS
20 #define CONST_VTABLE
21
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "initguid.h"
29 #include "ole2.h"
30 #include "mshtml.h"
31 #include "docobj.h"
32 #include "mshtmhst.h"
33 #include "mshtmdid.h"
34 #include "mshtmcid.h"
35 #include "hlink.h"
36 #include "dispex.h"
37 #include "idispids.h"
38 #include "shlguid.h"
39 #include "perhist.h"
40 #include "mshtml_test.h"
41
42 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
43 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
44 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
45
46 #define DEFINE_EXPECT(func) \
47 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
48
49 #define SET_EXPECT(func) \
50 expect_ ## func = TRUE
51
52 #define SET_CALLED(func) \
53 called_ ## func = TRUE
54
55 #define CHECK_EXPECT2(func) \
56 do { \
57 ok(expect_ ##func, "unexpected call " #func "\n"); \
58 called_ ## func = TRUE; \
59 }while(0)
60
61 #define CHECK_EXPECT(func) \
62 do { \
63 CHECK_EXPECT2(func); \
64 expect_ ## func = FALSE; \
65 }while(0)
66
67 #define CHECK_CALLED(func) \
68 do { \
69 ok(called_ ## func, "expected " #func "\n"); \
70 expect_ ## func = called_ ## func = FALSE; \
71 }while(0)
72
73 static IOleDocumentView *view = NULL;
74 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
75
76 DEFINE_EXPECT(LockContainer);
77 DEFINE_EXPECT(SetActiveObject);
78 DEFINE_EXPECT(SetActiveObject_null);
79 DEFINE_EXPECT(GetWindow);
80 DEFINE_EXPECT(CanInPlaceActivate);
81 DEFINE_EXPECT(OnInPlaceActivate);
82 DEFINE_EXPECT(OnInPlaceActivateEx);
83 DEFINE_EXPECT(OnUIActivate);
84 DEFINE_EXPECT(GetWindowContext);
85 DEFINE_EXPECT(OnUIDeactivate);
86 DEFINE_EXPECT(OnInPlaceDeactivate);
87 DEFINE_EXPECT(OnInPlaceDeactivateEx);
88 DEFINE_EXPECT(GetContainer);
89 DEFINE_EXPECT(ShowUI);
90 DEFINE_EXPECT(ActivateMe);
91 DEFINE_EXPECT(GetHostInfo);
92 DEFINE_EXPECT(HideUI);
93 DEFINE_EXPECT(GetOptionKeyPath);
94 DEFINE_EXPECT(GetOverrideKeyPath);
95 DEFINE_EXPECT(SetStatusText);
96 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
97 DEFINE_EXPECT(QueryStatus_OPEN);
98 DEFINE_EXPECT(QueryStatus_NEW);
99 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
100 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
101 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
102 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
103 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
104 DEFINE_EXPECT(Exec_ShellDocView_37);
105 DEFINE_EXPECT(Exec_ShellDocView_84);
106 DEFINE_EXPECT(Exec_ShellDocView_103);
107 DEFINE_EXPECT(Exec_ShellDocView_105);
108 DEFINE_EXPECT(Exec_ShellDocView_140);
109 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
110 DEFINE_EXPECT(Exec_SETTITLE);
111 DEFINE_EXPECT(Exec_HTTPEQUIV);
112 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
113 DEFINE_EXPECT(Exec_Explorer_69);
114 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
115 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
116 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
117 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
118 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
119 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
120 DEFINE_EXPECT(GetDropTarget);
121 DEFINE_EXPECT(UpdateUI);
122 DEFINE_EXPECT(Navigate);
123 DEFINE_EXPECT(OnFrameWindowActivate);
124 DEFINE_EXPECT(OnChanged_READYSTATE);
125 DEFINE_EXPECT(OnChanged_1005);
126 DEFINE_EXPECT(OnChanged_1012);
127 DEFINE_EXPECT(GetDisplayName);
128 DEFINE_EXPECT(BindToStorage);
129 DEFINE_EXPECT(IsSystemMoniker);
130 DEFINE_EXPECT(GetBindResult);
131 DEFINE_EXPECT(GetClassID);
132 DEFINE_EXPECT(Abort);
133 DEFINE_EXPECT(Read);
134 DEFINE_EXPECT(CreateInstance);
135 DEFINE_EXPECT(Start);
136 DEFINE_EXPECT(Terminate);
137 DEFINE_EXPECT(Protocol_Read);
138 DEFINE_EXPECT(LockRequest);
139 DEFINE_EXPECT(UnlockRequest);
140 DEFINE_EXPECT(OnFocus_TRUE);
141 DEFINE_EXPECT(OnFocus_FALSE);
142 DEFINE_EXPECT(RequestUIActivate);
143 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
144 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
145 DEFINE_EXPECT(GetExternal);
146 DEFINE_EXPECT(EnableModeless_TRUE);
147 DEFINE_EXPECT(EnableModeless_FALSE);
148 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
149 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
150 DEFINE_EXPECT(Frame_GetWindow);
151
152 static IUnknown *doc_unk;
153 static IMoniker *doc_mon;
154 static BOOL expect_LockContainer_fLock;
155 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
156 static BOOL ipsex;
157 static BOOL set_clientsite = FALSE, container_locked = FALSE;
158 static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream;
159 static BOOL editmode = FALSE, show_failed;
160 static int stream_read, protocol_read;
161 static enum load_state_t {
162 LD_DOLOAD,
163 LD_LOADING,
164 LD_LOADED,
165 LD_INTERACTIVE,
166 LD_COMPLETE,
167 LD_NO
168 } load_state;
169
170 static LPCOLESTR expect_status_text = NULL;
171
172 static const char html_page[] =
173 "<html>"
174 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
175 "<body>test</body>"
176 "</html>";
177
178 static const char css_data[] = "body {color: red}";
179
180 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
181 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
182
183 static HRESULT QueryInterface(REFIID riid, void **ppv);
184 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
185 static BOOL nogecko = FALSE;
186
187 #define test_readyState(u) _test_readyState(__LINE__,u)
188 static void _test_readyState(unsigned,IUnknown*);
189
190 static const WCHAR wszTimesNewRoman[] =
191 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
192 static const WCHAR wszArial[] =
193 {'A','r','i','a','l',0};
194
195 static const char *debugstr_guid(REFIID riid)
196 {
197 static char buf[50];
198
199 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
200 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
201 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
202 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
203
204 return buf;
205 }
206
207 static int strcmp_wa(LPCWSTR strw, const char *stra)
208 {
209 CHAR buf[512];
210 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
211 return lstrcmpA(stra, buf);
212 }
213
214 static BOOL is_english(void)
215 {
216 return PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH
217 && PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
218 }
219
220 #define EXPECT_UPDATEUI 1
221 #define EXPECT_SETTITLE 2
222
223 static void test_timer(DWORD flags)
224 {
225 BOOL *b = &called_Exec_SETTITLE;
226 MSG msg;
227
228 if(flags & EXPECT_UPDATEUI) {
229 SET_EXPECT(UpdateUI);
230 SET_EXPECT(Exec_UPDATECOMMANDS);
231 b = &called_UpdateUI;
232 }
233 if(flags & EXPECT_SETTITLE)
234 SET_EXPECT(Exec_SETTITLE);
235
236 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
237 TranslateMessage(&msg);
238 DispatchMessage(&msg);
239 }
240
241 if(flags & EXPECT_UPDATEUI) {
242 CHECK_CALLED(UpdateUI);
243 CHECK_CALLED(Exec_UPDATECOMMANDS);
244 }
245 if(flags & EXPECT_SETTITLE)
246 CHECK_CALLED(Exec_SETTITLE);
247 }
248
249 static IMoniker Moniker;
250
251 #define test_GetCurMoniker(u,m,v) _test_GetCurMoniker(__LINE__,u,m,v)
252 static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
253 {
254 IHTMLDocument2 *doc;
255 IPersistMoniker *permon;
256 IMoniker *mon = (void*)0xdeadbeef;
257 BSTR doc_url = (void*)0xdeadbeef;
258 HRESULT hres;
259
260 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
261 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
262 if(FAILED(hres))
263 return;
264
265 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
266 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
267
268 hres = IHTMLDocument2_get_URL(doc, &doc_url);
269 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
270
271 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
272 IPersistMoniker_Release(permon);
273
274 if(exmon) {
275 LPOLESTR url;
276 BOOL exb = expect_GetDisplayName;
277 BOOL clb = called_GetDisplayName;
278
279 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
280 ok_(__FILE__,line)(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
281
282 if(mon == &Moniker)
283 SET_EXPECT(GetDisplayName);
284 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
285 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
286 if(mon == &Moniker)
287 CHECK_CALLED(GetDisplayName);
288 expect_GetDisplayName = exb;
289 called_GetDisplayName = clb;
290
291 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
292 CoTaskMemFree(url);
293 }else if(exurl) {
294 LPOLESTR url;
295
296 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
297
298 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
299 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
300
301 ok(!lstrcmpW(url, exurl), "unexpected url\n");
302 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
303
304 CoTaskMemFree(url);
305 }else {
306 ok(hres == E_UNEXPECTED,
307 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
308 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
309 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
310 }
311
312 SysFreeString(doc_url);
313 IHTMLDocument_Release(doc);
314 if(mon && mon != (void*)0xdeadbeef)
315 IMoniker_Release(mon);
316 }
317
318 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
319
320 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
321 {
322 *ppv = NULL;
323
324 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
325 *ppv = iface;
326 return S_OK;
327 }
328
329 if(IsEqualGUID(&IID_IProxyManager, riid))
330 return E_NOINTERFACE; /* TODO */
331 if(IsEqualGUID(&IID_IDispatchEx, riid))
332 return E_NOINTERFACE; /* TODO */
333 if(IsEqualGUID(&IID_External_unk, riid))
334 return E_NOINTERFACE; /* TODO */
335
336 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
337 return E_NOINTERFACE;
338 }
339
340 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
341 {
342 return 2;
343 }
344
345 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
346 {
347 return 1;
348 }
349
350 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
351 {
352 ok(0, "unexpected call\n");
353 return E_NOTIMPL;
354 }
355
356 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
357 ITypeInfo **ppTInfo)
358 {
359 ok(0, "unexpected call\n");
360 return E_NOTIMPL;
361 }
362
363 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
364 UINT cNames, LCID lcid, DISPID *rgDispId)
365 {
366 ok(0, "unexpected call\n");
367 return E_NOTIMPL;
368 }
369
370 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
371 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
372 EXCEPINFO *pExcepInfo, UINT *puArgErr)
373 {
374 ok(0, "unexpected call\n");
375 return E_NOTIMPL;
376 }
377
378 static const IDispatchVtbl ExternalVtbl = {
379 External_QueryInterface,
380 Dispatch_AddRef,
381 Dispatch_Release,
382 Dispatch_GetTypeInfoCount,
383 Dispatch_GetTypeInfo,
384 Dispatch_GetIDsOfNames,
385 External_Invoke
386 };
387
388 static IDispatch External = { &ExternalVtbl };
389
390 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
391 {
392 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
393 *ppv = iface;
394 return S_OK;
395 }
396
397 *ppv = NULL;
398 return E_NOINTERFACE;
399 }
400
401 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
402 {
403 return 2;
404 }
405
406 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
407 {
408 return 1;
409 }
410
411 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
412 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
413 DWORD grfPI, HANDLE_PTR dwReserved)
414 {
415 BINDINFO bindinfo;
416 DWORD bindf = 0;
417 HRESULT hres;
418
419 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
420 static const WCHAR empty_str = {0};
421
422 CHECK_EXPECT(Start);
423
424 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
425 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
426 ok(!grfPI, "grfPI = %x\n", grfPI);
427 ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
428
429 memset(&bindinfo, 0, sizeof(bindinfo));
430 bindinfo.cbSize = sizeof(bindinfo);
431 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
432 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
433 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
434 "bindf = %x\n", bindf);
435
436 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
437 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
438 /* TODO: test stgmedData */
439 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
440 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
441 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
442 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
443 ok(bindinfo.dwOptions == 0x80000 ||
444 bindinfo.dwOptions == 0x4080000, /* win2k3 */
445 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
446 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
447 /* TODO: test dwCodePage */
448 /* TODO: test securityAttributes */
449 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
450 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
451 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
452
453 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
454 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
455 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
456
457 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
458 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
459 ok(hres == S_OK,
460 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
461
462 hres = IInternetProtocolSink_ReportData(pOIProtSink,
463 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
464 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
465
466 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
467 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
468
469 return S_OK;
470 }
471
472 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
473 PROTOCOLDATA *pProtocolData)
474 {
475 ok(0, "unexpected call\n");
476 return E_NOTIMPL;
477 }
478
479 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
480 DWORD dwOptions)
481 {
482 ok(0, "unexpected call\n");
483 return E_NOTIMPL;
484 }
485
486 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
487 {
488 CHECK_EXPECT(Terminate);
489 return S_OK;
490 }
491
492 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
493 {
494 ok(0, "unexpected call\n");
495 return E_NOTIMPL;
496 }
497
498 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
499 {
500 ok(0, "unexpected call\n");
501 return E_NOTIMPL;
502 }
503
504 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
505 ULONG cb, ULONG *pcbRead)
506 {
507 CHECK_EXPECT2(Protocol_Read);
508
509 ok(pv != NULL, "pv == NULL\n");
510 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
511 ok(pcbRead != NULL, "pcbRead == NULL\n");
512 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
513
514 if(protocol_read)
515 return S_FALSE;
516
517 protocol_read += *pcbRead = sizeof(css_data)-1;
518 memcpy(pv, css_data, sizeof(css_data)-1);
519 return S_OK;
520 }
521
522 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
523 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
524 {
525 ok(0, "unexpected call\n");
526 return E_NOTIMPL;
527 }
528
529 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
530 {
531 CHECK_EXPECT(LockRequest);
532 return S_OK;
533 }
534
535 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
536 {
537 CHECK_EXPECT(UnlockRequest);
538 return S_OK;
539 }
540
541 static const IInternetProtocolVtbl ProtocolVtbl = {
542 Protocol_QueryInterface,
543 Protocol_AddRef,
544 Protocol_Release,
545 Protocol_Start,
546 Protocol_Continue,
547 Protocol_Abort,
548 Protocol_Terminate,
549 Protocol_Suspend,
550 Protocol_Resume,
551 Protocol_Read,
552 Protocol_Seek,
553 Protocol_LockRequest,
554 Protocol_UnlockRequest
555 };
556
557 static IInternetProtocol Protocol = { &ProtocolVtbl };
558
559 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
560 {
561 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
562 ok(0, "unexpected call\n");
563 return E_NOINTERFACE;
564 }
565
566 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
567 {
568 return 2;
569 }
570
571 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
572 {
573 return 1;
574 }
575
576 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
577 REFIID riid, void **ppv)
578 {
579 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
580 return E_NOINTERFACE;
581
582 CHECK_EXPECT(CreateInstance);
583 ok(ppv != NULL, "ppv == NULL\n");
584
585 *ppv = &Protocol;
586 return S_OK;
587 }
588
589 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
590 {
591 ok(0, "unexpected call\n");
592 return S_OK;
593 }
594
595 static const IClassFactoryVtbl ClassFactoryVtbl = {
596 ClassFactory_QueryInterface,
597 ClassFactory_AddRef,
598 ClassFactory_Release,
599 ClassFactory_CreateInstance,
600 ClassFactory_LockServer
601 };
602
603 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
604
605 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
606 {
607 ok(0, "unexpected call\n");
608 return E_NOTIMPL;
609 }
610
611 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
612 {
613 return 2;
614 }
615
616 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
617 {
618 return 1;
619 }
620
621 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
622 IHlinkBrowseContext *pihlbc)
623 {
624 ok(0, "unexpected call\n");
625 return E_NOTIMPL;
626 }
627
628 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
629 IHlinkBrowseContext **ppihlbc)
630 {
631 ok(0, "unexpected call\n");
632 return E_NOTIMPL;
633 }
634
635 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
636 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
637 {
638 HRESULT hres;
639
640 CHECK_EXPECT(Navigate);
641
642 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
643 ok(pbc != NULL, "pbc == NULL\n");
644 ok(pibsc != NULL, "pubsc == NULL\n");
645 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
646
647 if(pihlNavigate) {
648 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
649 LPWSTR location = (LPWSTR)0xdeadbeef;
650 IHlinkSite *site;
651 IMoniker *mon = NULL;
652 DWORD site_data = 0xdeadbeef;
653
654 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
655 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
656 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
657
658 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
659 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
660 ok(location == NULL, "location = %p\n", location);
661 ok(mon != NULL, "mon == NULL\n");
662
663 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
664 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
665 ok(site == NULL, "site = %p\n, expected NULL\n", site);
666 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
667 }
668
669 return S_OK;
670 }
671
672 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
673 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
674 {
675 ok(0, "unexpected call\n");
676 return E_NOTIMPL;
677 }
678
679 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
680 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
681 {
682 ok(0, "unexpected call\n");
683 return E_NOTIMPL;
684 }
685
686 static const IHlinkFrameVtbl HlinkFrameVtbl = {
687 HlinkFrame_QueryInterface,
688 HlinkFrame_AddRef,
689 HlinkFrame_Release,
690 HlinkFrame_SetBrowseContext,
691 HlinkFrame_GetBrowseContext,
692 HlinkFrame_Navigate,
693 HlinkFrame_OnNavigate,
694 HlinkFrame_UpdateHlink
695 };
696
697 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
698
699 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
700 REFIID riid, void**ppv)
701 {
702 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
703 *ppv = iface;
704 return S_OK;
705 }
706
707 ok(0, "unexpected call\n");
708 return E_NOINTERFACE;
709 }
710
711 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
712 {
713 return 2;
714 }
715
716 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
717 {
718 return 1;
719 }
720
721 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
722 {
723 switch(dispID) {
724 case DISPID_READYSTATE:
725 CHECK_EXPECT2(OnChanged_READYSTATE);
726
727 if(readystate_set_interactive) {
728 readystate_set_interactive = FALSE;
729 load_state = LD_INTERACTIVE;
730 }
731 else
732 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
733 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
734 ? OLECMDF_ENABLED : 0));
735
736 if(readystate_set_loading) {
737 readystate_set_loading = FALSE;
738 load_state = LD_LOADING;
739 }
740 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
741 test_readyState(NULL);
742 return S_OK;
743 case 1005:
744 CHECK_EXPECT(OnChanged_1005);
745 if(!editmode)
746 test_readyState(NULL);
747 readystate_set_interactive = (load_state != LD_INTERACTIVE);
748 return S_OK;
749 case 1012:
750 CHECK_EXPECT(OnChanged_1012);
751 return S_OK;
752 case 3000029:
753 case 3000030:
754 /* TODO */
755 return S_OK;
756 }
757
758 ok(0, "unexpected id %d\n", dispID);
759 return E_NOTIMPL;
760 }
761
762 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
763 {
764 ok(0, "unexpected call\n");
765 return E_NOTIMPL;
766 }
767
768 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
769 PropertyNotifySink_QueryInterface,
770 PropertyNotifySink_AddRef,
771 PropertyNotifySink_Release,
772 PropertyNotifySink_OnChanged,
773 PropertyNotifySink_OnRequestEdit
774 };
775
776 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
777
778 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
779 {
780 ok(0, "unexpected call\n");
781 return E_NOINTERFACE;
782 }
783
784 static ULONG WINAPI Stream_AddRef(IStream *iface)
785 {
786 return 2;
787 }
788
789 static ULONG WINAPI Stream_Release(IStream *iface)
790 {
791 return 1;
792 }
793
794 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
795 ULONG cb, ULONG *pcbRead)
796 {
797 CHECK_EXPECT2(Read);
798 ok(pv != NULL, "pv == NULL\n");
799 ok(cb > sizeof(html_page), "cb = %d\n", cb);
800 ok(pcbRead != NULL, "pcbRead == NULL\n");
801 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
802
803 if(stream_read)
804 return S_FALSE;
805
806 memcpy(pv, html_page, sizeof(html_page)-1);
807 stream_read += *pcbRead = sizeof(html_page)-1;
808 return S_OK;
809 }
810
811 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
812 ULONG cb, ULONG *pcbWritten)
813 {
814 ok(0, "unexpected call\n");
815 return E_NOTIMPL;
816 }
817
818 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
819 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
820 {
821 ok(0, "unexpected call\n");
822 return E_NOTIMPL;
823 }
824
825 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
826 {
827 ok(0, "unexpected call\n");
828 return E_NOTIMPL;
829 }
830
831 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
832 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
833 {
834 ok(0, "unexpected call\n");
835 return E_NOTIMPL;
836 }
837
838 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
839 {
840 ok(0, "unexpected call\n");
841 return E_NOTIMPL;
842 }
843
844 static HRESULT WINAPI Stream_Revert(IStream *iface)
845 {
846 ok(0, "unexpected call\n");
847 return E_NOTIMPL;
848 }
849
850 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
851 ULARGE_INTEGER cb, DWORD dwLockType)
852 {
853 ok(0, "unexpected call\n");
854 return E_NOTIMPL;
855 }
856
857 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
858 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
859 {
860 ok(0, "unexpected call\n");
861 return E_NOTIMPL;
862 }
863
864 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
865 DWORD dwStatFlag)
866 {
867 ok(0, "unexpected call\n");
868 return E_NOTIMPL;
869 }
870
871 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
872 {
873 ok(0, "unexpected call\n");
874 return E_NOTIMPL;
875 }
876
877 static const IStreamVtbl StreamVtbl = {
878 Stream_QueryInterface,
879 Stream_AddRef,
880 Stream_Release,
881 Stream_Read,
882 Stream_Write,
883 Stream_Seek,
884 Stream_SetSize,
885 Stream_CopyTo,
886 Stream_Commit,
887 Stream_Revert,
888 Stream_LockRegion,
889 Stream_UnlockRegion,
890 Stream_Stat,
891 Stream_Clone
892 };
893
894 static IStream Stream = { &StreamVtbl };
895
896 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
897 {
898 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
899 return E_NOINTERFACE; /* TODO */
900
901 if(IsEqualGUID(&IID_IWinInetInfo, riid))
902 return E_NOINTERFACE; /* TODO */
903
904 ok(0, "unexpected call\n");
905 return E_NOINTERFACE;
906 }
907
908 static ULONG WINAPI Binding_AddRef(IBinding *iface)
909 {
910 return 2;
911 }
912
913 static ULONG WINAPI Binding_Release(IBinding *iface)
914 {
915 return 1;
916 }
917
918 static HRESULT WINAPI Binding_Abort(IBinding *iface)
919 {
920 CHECK_EXPECT(Abort);
921 return S_OK;
922 }
923
924 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
925 {
926 ok(0, "unexpected call\n");
927 return E_NOTIMPL;
928 }
929
930 static HRESULT WINAPI Binding_Resume(IBinding *iface)
931 {
932 ok(0, "unexpected call\n");
933 return E_NOTIMPL;
934 }
935
936 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
937 {
938 ok(0, "unexpected call\n");
939 return E_NOTIMPL;
940 }
941
942 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
943 {
944 ok(0, "unexpected call\n");
945 return E_NOTIMPL;
946 }
947
948 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
949 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
950 {
951 CHECK_EXPECT(GetBindResult);
952 return E_NOTIMPL;
953 }
954
955 static const IBindingVtbl BindingVtbl = {
956 Binding_QueryInterface,
957 Binding_AddRef,
958 Binding_Release,
959 Binding_Abort,
960 Binding_Suspend,
961 Binding_Resume,
962 Binding_SetPriority,
963 Binding_GetPriority,
964 Binding_GetBindResult
965 };
966
967 static IBinding Binding = { &BindingVtbl };
968
969 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
970 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
971
972 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
973 {
974 *ppv = NULL;
975
976 if(IsEqualGUID(&IID_IMoniker_unk, riid))
977 return E_NOINTERFACE; /* TODO */
978 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
979 return E_NOINTERFACE; /* TODO */
980
981 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
982 return E_NOINTERFACE;
983 }
984
985 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
986 {
987 return 2;
988 }
989
990 static ULONG WINAPI Moniker_Release(IMoniker *iface)
991 {
992 return 1;
993 }
994
995 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
996 {
997 CHECK_EXPECT(GetClassID);
998 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
999 return E_FAIL;
1000 }
1001
1002 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
1003 {
1004 ok(0, "unexpected call\n");
1005 return E_NOTIMPL;
1006 }
1007
1008 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
1009 {
1010 ok(0, "unexpected call\n");
1011 return E_NOTIMPL;
1012 }
1013
1014 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
1015 {
1016 ok(0, "unexpected call\n");
1017 return E_NOTIMPL;
1018 }
1019
1020 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
1021 {
1022 ok(0, "unexpected call\n");
1023 return E_NOTIMPL;
1024 }
1025
1026 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
1027 REFIID riidResult, void **ppvResult)
1028 {
1029 ok(0, "unexpected call\n");
1030 return E_NOTIMPL;
1031 }
1032
1033 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1034 REFIID riid, void **ppv)
1035 {
1036 IBindStatusCallback *callback = NULL;
1037 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
1038 STGMEDIUM stgmedium;
1039 BINDINFO bindinfo;
1040 DWORD bindf;
1041 HRESULT hres;
1042
1043 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
1044 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
1045
1046 CHECK_EXPECT(BindToStorage);
1047
1048 load_state = LD_LOADING;
1049
1050 ok(pbc != NULL, "pbc == NULL\n");
1051 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1052 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
1053 ok(ppv != NULL, "ppv == NULL\n");
1054 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
1055
1056 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
1057 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1058 ok(callback != NULL, "callback == NULL\n");
1059
1060 memset(&bindinfo, 0xf0, sizeof(bindinfo));
1061 bindinfo.cbSize = sizeof(bindinfo);
1062
1063 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
1064 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1065 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
1066 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
1067 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
1068 /* TODO: test stgmedData */
1069 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
1070 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
1071 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
1072 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
1073 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
1074 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
1075 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
1076 /* TODO: test dwCodePage */
1077 /* TODO: test securityAttributes */
1078 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
1079 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
1080 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
1081
1082 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
1083 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1084
1085 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
1086 wszTextHtml);
1087 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1088
1089 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1090 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1091 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1092
1093 SET_EXPECT(Read);
1094 stgmedium.tymed = TYMED_ISTREAM;
1095 U(stgmedium).pstm = &Stream;
1096 stgmedium.pUnkForRelease = (IUnknown*)iface;
1097 hres = IBindStatusCallback_OnDataAvailable(callback,
1098 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1099 sizeof(html_page)-1, &formatetc, &stgmedium);
1100 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1101 CHECK_CALLED(Read);
1102
1103 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1104 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1105 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1106
1107 SET_EXPECT(GetBindResult);
1108 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1109 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1110 SET_CALLED(GetBindResult); /* IE7 */
1111
1112 IBindStatusCallback_Release(callback);
1113
1114 return S_OK;
1115 }
1116
1117 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1118 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1119 {
1120 ok(0, "unexpected call\n");
1121 return E_NOTIMPL;
1122 }
1123
1124 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1125 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1126 {
1127 ok(0, "unexpected call\n");
1128 return E_NOTIMPL;
1129 }
1130
1131 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1132 {
1133 ok(0, "unexpected call\n");
1134 return E_NOTIMPL;
1135 }
1136
1137 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1138 {
1139 ok(0, "unexpected call\n");
1140 return E_NOTIMPL;
1141 }
1142
1143 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1144 {
1145 ok(0, "unexpected call\n");
1146 return E_NOTIMPL;
1147 }
1148
1149 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1150 IMoniker *pmkNewlyRunning)
1151 {
1152 ok(0, "unexpected call\n");
1153 return E_NOTIMPL;
1154 }
1155
1156 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1157 IMoniker *pmkToLeft, FILETIME *pFileTime)
1158 {
1159 ok(0, "unexpected call\n");
1160 return E_NOTIMPL;
1161 }
1162
1163 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1164 {
1165 ok(0, "unexpected call\n");
1166 return E_NOTIMPL;
1167 }
1168
1169 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1170 IMoniker **ppmkPrefix)
1171 {
1172 ok(0, "unexpected call\n");
1173 return E_NOTIMPL;
1174 }
1175
1176 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1177 IMoniker **pmkRelPath)
1178 {
1179 ok(0, "unexpected call\n");
1180 return E_NOTIMPL;
1181 }
1182
1183 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1184 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1185 {
1186 CHECK_EXPECT2(GetDisplayName);
1187
1188 /* ok(pbc != NULL, "pbc == NULL\n"); */
1189 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1190 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1191
1192 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1193 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1194
1195 return S_OK;
1196 }
1197
1198 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1199 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1200 {
1201 ok(0, "unexpected call\n");
1202 return E_NOTIMPL;
1203 }
1204
1205 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1206 {
1207 CHECK_EXPECT(IsSystemMoniker);
1208 return E_NOTIMPL;
1209 }
1210
1211 static const IMonikerVtbl MonikerVtbl = {
1212 Moniker_QueryInterface,
1213 Moniker_AddRef,
1214 Moniker_Release,
1215 Moniker_GetClassID,
1216 Moniker_IsDirty,
1217 Moniker_Load,
1218 Moniker_Save,
1219 Moniker_GetSizeMax,
1220 Moniker_BindToObject,
1221 Moniker_BindToStorage,
1222 Moniker_Reduce,
1223 Moniker_ComposeWith,
1224 Moniker_Enum,
1225 Moniker_IsEqual,
1226 Moniker_Hash,
1227 Moniker_IsRunning,
1228 Moniker_GetTimeOfLastChange,
1229 Moniker_Inverse,
1230 Moniker_CommonPrefixWith,
1231 Moniker_RelativePathTo,
1232 Moniker_GetDisplayName,
1233 Moniker_ParseDisplayName,
1234 Moniker_IsSystemMoniker
1235 };
1236
1237 static IMoniker Moniker = { &MonikerVtbl };
1238
1239 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1240 {
1241 return QueryInterface(riid, ppv);
1242 }
1243
1244 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1245 {
1246 return 2;
1247 }
1248
1249 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1250 {
1251 return 1;
1252 }
1253
1254 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1255 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1256 {
1257 ok(0, "unexpected call\n");
1258 return E_NOTIMPL;
1259 }
1260
1261 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1262 IEnumUnknown **ppenum)
1263 {
1264 ok(0, "unexpected call\n");
1265 return E_NOTIMPL;
1266 }
1267
1268 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1269 {
1270 CHECK_EXPECT(LockContainer);
1271 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1272 return S_OK;
1273 }
1274
1275 static const IOleContainerVtbl OleContainerVtbl = {
1276 OleContainer_QueryInterface,
1277 OleContainer_AddRef,
1278 OleContainer_Release,
1279 OleContainer_ParseDisplayName,
1280 OleContainer_EnumObjects,
1281 OleContainer_LockContainer
1282 };
1283
1284 static IOleContainer OleContainer = { &OleContainerVtbl };
1285
1286 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1287 {
1288 static const GUID undocumented_frame_iid = {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
1289
1290 if(!IsEqualGUID(&undocumented_frame_iid, riid))
1291 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1292
1293 *ppv = NULL;
1294 return E_NOINTERFACE;
1295 }
1296
1297 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1298 {
1299 return 2;
1300 }
1301
1302 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1303 {
1304 return 1;
1305 }
1306
1307 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1308 {
1309 CHECK_EXPECT(Frame_GetWindow);
1310 return E_NOTIMPL;
1311 }
1312
1313 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1314 {
1315 ok(0, "unexpected call\n");
1316 return E_NOTIMPL;
1317 }
1318
1319 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1320 {
1321 ok(0, "unexpected call\n");
1322 return E_NOTIMPL;
1323 }
1324
1325 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1326 LPCBORDERWIDTHS pborderwidths)
1327 {
1328 ok(0, "unexpected call\n");
1329 return E_NOTIMPL;
1330 }
1331
1332 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1333 LPCBORDERWIDTHS pborderwidths)
1334 {
1335 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1336 return S_OK;
1337 }
1338
1339 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1340 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1341 {
1342 static const WCHAR wszHTML_Document[] =
1343 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1344
1345 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1346
1347 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1348 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1349 if(pActiveObject && is_english())
1350 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1351 }
1352 else {
1353 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1354 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1355 }
1356 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1357 return S_OK;
1358 }
1359
1360 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1361 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1362 {
1363 static const WCHAR wszHTML_Document[] =
1364 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1365
1366 if(pActiveObject) {
1367 CHECK_EXPECT2(SetActiveObject);
1368
1369 if(pActiveObject && is_english())
1370 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1371 }else {
1372 CHECK_EXPECT(SetActiveObject_null);
1373
1374 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1375 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1376 }
1377
1378 return S_OK;
1379 }
1380
1381 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1382 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1383 {
1384 ok(0, "unexpected call\n");
1385 return E_NOTIMPL;
1386 }
1387
1388 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1389 HOLEMENU holemenu, HWND hwndActiveObject)
1390 {
1391 ok(0, "unexpected call\n");
1392 return E_NOTIMPL;
1393 }
1394
1395 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1396 {
1397 ok(0, "unexpected call\n");
1398 return E_NOTIMPL;
1399 }
1400
1401 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1402 {
1403 CHECK_EXPECT2(SetStatusText);
1404 if(!expect_status_text)
1405 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1406 return S_OK;
1407 }
1408
1409 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1410 {
1411 if(fEnable)
1412 CHECK_EXPECT2(Frame_EnableModeless_TRUE);
1413 else
1414 CHECK_EXPECT2(Frame_EnableModeless_FALSE);
1415 return E_NOTIMPL;
1416 }
1417
1418 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1419 {
1420 ok(0, "unexpected call\n");
1421 return E_NOTIMPL;
1422 }
1423
1424 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1425 InPlaceFrame_QueryInterface,
1426 InPlaceFrame_AddRef,
1427 InPlaceFrame_Release,
1428 InPlaceFrame_GetWindow,
1429 InPlaceFrame_ContextSensitiveHelp,
1430 InPlaceFrame_GetBorder,
1431 InPlaceFrame_RequestBorderSpace,
1432 InPlaceFrame_SetBorderSpace,
1433 InPlaceFrame_SetActiveObject,
1434 InPlaceFrame_InsertMenus,
1435 InPlaceFrame_SetMenu,
1436 InPlaceFrame_RemoveMenus,
1437 InPlaceFrame_SetStatusText,
1438 InPlaceFrame_EnableModeless,
1439 InPlaceFrame_TranslateAccelerator
1440 };
1441
1442 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1443
1444 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1445 InPlaceFrame_QueryInterface,
1446 InPlaceFrame_AddRef,
1447 InPlaceFrame_Release,
1448 InPlaceFrame_GetWindow,
1449 InPlaceFrame_ContextSensitiveHelp,
1450 InPlaceFrame_GetBorder,
1451 InPlaceFrame_RequestBorderSpace,
1452 InPlaceFrame_SetBorderSpace,
1453 InPlaceUIWindow_SetActiveObject,
1454 };
1455
1456 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1457
1458 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1459 {
1460 return QueryInterface(riid, ppv);
1461 }
1462
1463 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1464 {
1465 return 2;
1466 }
1467
1468 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1469 {
1470 return 1;
1471 }
1472
1473 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1474 {
1475 CHECK_EXPECT2(GetWindow);
1476 ok(phwnd != NULL, "phwnd = NULL\n");
1477 *phwnd = container_hwnd;
1478 return S_OK;
1479 }
1480
1481 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1482 {
1483 ok(0, "unexpected call\n");
1484 return E_NOTIMPL;
1485 }
1486
1487 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1488 {
1489 CHECK_EXPECT(CanInPlaceActivate);
1490 return S_OK;
1491 }
1492
1493 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1494 {
1495 CHECK_EXPECT(OnInPlaceActivate);
1496 return S_OK;
1497 }
1498
1499 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1500 {
1501 CHECK_EXPECT(OnUIActivate);
1502 return S_OK;
1503 }
1504
1505 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1506 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1507 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1508 {
1509 static const RECT rect = {0,0,500,500};
1510
1511 CHECK_EXPECT(GetWindowContext);
1512
1513 ok(ppFrame != NULL, "ppFrame = NULL\n");
1514 if(ppFrame)
1515 *ppFrame = &InPlaceFrame;
1516 ok(ppDoc != NULL, "ppDoc = NULL\n");
1517 if(ppDoc)
1518 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1519 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1520 if(lprcPosRect)
1521 memcpy(lprcPosRect, &rect, sizeof(RECT));
1522 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1523 if(lprcClipRect)
1524 memcpy(lprcClipRect, &rect, sizeof(RECT));
1525 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1526 if(lpFrameInfo) {
1527 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1528 lpFrameInfo->fMDIApp = FALSE;
1529 lpFrameInfo->hwndFrame = container_hwnd;
1530 lpFrameInfo->haccel = NULL;
1531 lpFrameInfo->cAccelEntries = 0;
1532 }
1533
1534 return S_OK;
1535 }
1536
1537 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1538 {
1539 ok(0, "unexpected call\n");
1540 return E_NOTIMPL;
1541 }
1542
1543 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1544 {
1545 CHECK_EXPECT(OnUIDeactivate);
1546 ok(!fUndoable, "fUndoable = TRUE\n");
1547 return S_OK;
1548 }
1549
1550 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1551 {
1552 CHECK_EXPECT(OnInPlaceDeactivate);
1553 return S_OK;
1554 }
1555
1556 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1557 {
1558 ok(0, "unexpected call\n");
1559 return E_NOTIMPL;
1560 }
1561
1562 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1563 {
1564 ok(0, "unexpected call\n");
1565 return E_NOTIMPL;
1566 }
1567
1568 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1569 {
1570 ok(0, "unexpected call\n");
1571 return E_NOTIMPL;
1572 }
1573
1574 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1575 {
1576 CHECK_EXPECT(OnInPlaceActivateEx);
1577
1578 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1579 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1580 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1581
1582 return S_OK;
1583 }
1584
1585 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1586 {
1587 CHECK_EXPECT(OnInPlaceDeactivateEx);
1588
1589 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1590
1591 return S_OK;
1592 }
1593
1594 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1595 {
1596 CHECK_EXPECT(RequestUIActivate);
1597 return S_OK;
1598 }
1599
1600 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1601 InPlaceSite_QueryInterface,
1602 InPlaceSite_AddRef,
1603 InPlaceSite_Release,
1604 InPlaceSite_GetWindow,
1605 InPlaceSite_ContextSensitiveHelp,
1606 InPlaceSite_CanInPlaceActivate,
1607 InPlaceSite_OnInPlaceActivate,
1608 InPlaceSite_OnUIActivate,
1609 InPlaceSite_GetWindowContext,
1610 InPlaceSite_Scroll,
1611 InPlaceSite_OnUIDeactivate,
1612 InPlaceSite_OnInPlaceDeactivate,
1613 InPlaceSite_DiscardUndoState,
1614 InPlaceSite_DeactivateAndUndo,
1615 InPlaceSite_OnPosRectChange,
1616 InPlaceSiteEx_OnInPlaceActivateEx,
1617 InPlaceSiteEx_OnInPlaceDeactivateEx,
1618 InPlaceSiteEx_RequestUIActivate
1619 };
1620
1621 static IOleInPlaceSiteEx InPlaceSiteEx = { &InPlaceSiteVtbl };
1622
1623 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1624 {
1625 return QueryInterface(riid, ppv);
1626 }
1627
1628 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1629 {
1630 return 2;
1631 }
1632
1633 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1634 {
1635 return 1;
1636 }
1637
1638 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1639 {
1640 ok(0, "unexpected call\n");
1641 return E_NOTIMPL;
1642 }
1643
1644 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1645 IMoniker **ppmon)
1646 {
1647 ok(0, "unexpected call\n");
1648 return E_NOTIMPL;
1649 }
1650
1651 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1652 {
1653 CHECK_EXPECT(GetContainer);
1654 ok(ppContainer != NULL, "ppContainer = NULL\n");
1655 *ppContainer = &OleContainer;
1656 return S_OK;
1657 }
1658
1659 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1660 {
1661 ok(0, "unexpected call\n");
1662 return E_NOTIMPL;
1663 }
1664
1665 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1666 {
1667 ok(0, "unexpected call\n");
1668 return E_NOTIMPL;
1669 }
1670
1671 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1672 {
1673 ok(0, "unexpected call\n");
1674 return E_NOTIMPL;
1675 }
1676
1677 static const IOleClientSiteVtbl ClientSiteVtbl = {
1678 ClientSite_QueryInterface,
1679 ClientSite_AddRef,
1680 ClientSite_Release,
1681 ClientSite_SaveObject,
1682 ClientSite_GetMoniker,
1683 ClientSite_GetContainer,
1684 ClientSite_ShowObject,
1685 ClientSite_OnShowWindow,
1686 ClientSite_RequestNewObjectLayout
1687 };
1688
1689 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1690
1691 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1692 {
1693 return QueryInterface(riid, ppv);
1694 }
1695
1696 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1697 {
1698 return 2;
1699 }
1700
1701 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1702 {
1703 return 1;
1704 }
1705
1706 typedef enum
1707 {
1708 CallUIActivate_None,
1709 CallUIActivate_ActivateMe,
1710 CallUIActivate_AfterShow,
1711 } CallUIActivate;
1712
1713 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1714 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1715 {
1716 IOleDocument *document;
1717 HRESULT hres;
1718
1719 CHECK_EXPECT(ActivateMe);
1720 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1721
1722 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1723 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1724
1725 if(SUCCEEDED(hres)) {
1726 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteEx, NULL, 0, &view);
1727 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1728
1729 if(SUCCEEDED(hres)) {
1730 IOleInPlaceActiveObject *activeobj = NULL;
1731 IOleInPlaceSite *inplacesite = NULL;
1732 HWND tmp_hwnd = NULL;
1733 static RECT rect = {0,0,400,500};
1734
1735 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1736 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1737 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1738 inplacesite, &InPlaceSiteEx);
1739
1740 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteEx);
1741 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1742
1743 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1744 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1745 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1746 inplacesite, &InPlaceSiteEx);
1747
1748 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1749 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1750
1751 if(activeobj) {
1752 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1753 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1754 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1755 }
1756
1757 if(call_UIActivate == CallUIActivate_ActivateMe) {
1758 SET_EXPECT(CanInPlaceActivate);
1759 SET_EXPECT(GetWindowContext);
1760 SET_EXPECT(GetWindow);
1761 if(ipsex)
1762 SET_EXPECT(OnInPlaceActivateEx);
1763 else
1764 SET_EXPECT(OnInPlaceActivate);
1765 SET_EXPECT(SetStatusText);
1766 SET_EXPECT(Exec_SETPROGRESSMAX);
1767 SET_EXPECT(Exec_SETPROGRESSPOS);
1768 SET_EXPECT(OnUIActivate);
1769 SET_EXPECT(SetActiveObject);
1770 SET_EXPECT(ShowUI);
1771 expect_status_text = NULL;
1772
1773 hres = IOleDocumentView_UIActivate(view, TRUE);
1774 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1775
1776 CHECK_CALLED(CanInPlaceActivate);
1777 CHECK_CALLED(GetWindowContext);
1778 CHECK_CALLED(GetWindow);
1779 if(ipsex)
1780 CHECK_CALLED(OnInPlaceActivateEx);
1781 else
1782 CHECK_CALLED(OnInPlaceActivate);
1783 CHECK_CALLED(SetStatusText);
1784 CHECK_CALLED(Exec_SETPROGRESSMAX);
1785 CHECK_CALLED(Exec_SETPROGRESSPOS);
1786 CHECK_CALLED(OnUIActivate);
1787 CHECK_CALLED(SetActiveObject);
1788 CHECK_CALLED(ShowUI);
1789
1790 if(activeobj) {
1791 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1792 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1793 ok(hwnd != NULL, "hwnd == NULL\n");
1794 if(last_hwnd)
1795 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1796 }
1797
1798 hres = IOleDocumentView_UIActivate(view, TRUE);
1799 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1800
1801 if(activeobj) {
1802 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1803 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1804 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1805 }
1806 }
1807
1808 hres = IOleDocumentView_SetRect(view, &rect);
1809 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1810
1811 if(call_UIActivate == CallUIActivate_ActivateMe) {
1812 hres = IOleDocumentView_Show(view, TRUE);
1813 ok(hres == S_OK, "Show failed: %08x\n", hres);
1814 }else {
1815 SET_EXPECT(CanInPlaceActivate);
1816 SET_EXPECT(GetWindowContext);
1817 SET_EXPECT(GetWindow);
1818 if(ipsex)
1819 SET_EXPECT(OnInPlaceActivateEx);
1820 else
1821 SET_EXPECT(OnInPlaceActivate);
1822 SET_EXPECT(SetStatusText);
1823 SET_EXPECT(Exec_SETPROGRESSMAX);
1824 SET_EXPECT(Exec_SETPROGRESSPOS);
1825 SET_EXPECT(OnUIActivate);
1826 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1827
1828 hres = IOleDocumentView_Show(view, TRUE);
1829 if(FAILED(hres)) {
1830 win_skip("Show failed\n");
1831 if(activeobj)
1832 IOleInPlaceActiveObject_Release(activeobj);
1833 IOleDocument_Release(document);
1834 show_failed = TRUE;
1835 return S_OK;
1836 }
1837 ok(hres == S_OK, "Show failed: %08x\n", hres);
1838
1839 CHECK_CALLED(CanInPlaceActivate);
1840 CHECK_CALLED(GetWindowContext);
1841 CHECK_CALLED(GetWindow);
1842 if(ipsex)
1843 CHECK_CALLED(OnInPlaceActivateEx);
1844 else
1845 CHECK_CALLED(OnInPlaceActivate);
1846 CHECK_CALLED(SetStatusText);
1847 CHECK_CALLED(Exec_SETPROGRESSMAX);
1848 CHECK_CALLED(Exec_SETPROGRESSPOS);
1849
1850 if(activeobj) {
1851 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1852 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1853 ok(hwnd != NULL, "hwnd == NULL\n");
1854 if(last_hwnd)
1855 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1856 }
1857 }
1858
1859 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1860
1861 if(activeobj)
1862 IOleInPlaceActiveObject_Release(activeobj);
1863 }
1864
1865 IOleDocument_Release(document);
1866 }
1867
1868 return S_OK;
1869 }
1870
1871 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1872 DocumentSite_QueryInterface,
1873 DocumentSite_AddRef,
1874 DocumentSite_Release,
1875 DocumentSite_ActivateMe
1876 };
1877
1878 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1879
1880 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1881 {
1882 return QueryInterface(riid, ppv);
1883 }
1884
1885 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
1886 {
1887 return 2;
1888 }
1889
1890 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
1891 {
1892 return 1;
1893 }
1894
1895 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
1896 {
1897 ok(0, "unexpected call\n");
1898 return E_NOTIMPL;
1899 }
1900
1901 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
1902 {
1903 ok(0, "unexpected call\n");
1904 return E_NOTIMPL;
1905 }
1906
1907 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
1908 {
1909 ok(0, "unexpected call\n");
1910 return E_NOTIMPL;
1911 }
1912
1913 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
1914 POINTF *pPtfContainer, DWORD dwFlags)
1915 {
1916 ok(0, "unexpected call\n");
1917 return E_NOTIMPL;
1918 }
1919
1920 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
1921 MSG *pMsg, DWORD grfModifiers)
1922 {
1923 ok(0, "unexpected call\n");
1924 return E_NOTIMPL;
1925 }
1926
1927 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
1928 {
1929 if(fGotFocus)
1930 CHECK_EXPECT(OnFocus_TRUE);
1931 else
1932 CHECK_EXPECT2(OnFocus_FALSE);
1933 return S_OK;
1934 }
1935
1936 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
1937 {
1938 ok(0, "unexpected call\n");
1939 return E_NOTIMPL;
1940 }
1941
1942 static const IOleControlSiteVtbl OleControlSiteVtbl = {
1943 OleControlSite_QueryInterface,
1944 OleControlSite_AddRef,
1945 OleControlSite_Release,
1946 OleControlSite_OnControlInfoChanged,
1947 OleControlSite_LockInPlaceActive,
1948 OleControlSite_GetExtendedControl,
1949 OleControlSite_TransformCoords,
1950 OleControlSite_TranslateAccelerator,
1951 OleControlSite_OnFocus,
1952 OleControlSite_ShowPropertyFrame
1953 };
1954
1955 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
1956
1957 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1958 {
1959 return QueryInterface(riid, ppv);
1960 }
1961
1962 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1963 {
1964 return 2;
1965 }
1966
1967 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1968 {
1969 return 1;
1970 }
1971
1972 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1973 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1974 {
1975 ok(0, "unexpected call\n");
1976 return E_NOTIMPL;
1977 }
1978
1979 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1980 {
1981 CHECK_EXPECT(GetHostInfo);
1982 ok(pInfo != NULL, "pInfo=NULL\n");
1983 if(pInfo) {
1984 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1985 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1986 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1987 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1988 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1989 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1990 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1991 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1992 }
1993 return S_OK;
1994 }
1995
1996 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1997 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1998 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1999 {
2000 CHECK_EXPECT(ShowUI);
2001
2002 if (editmode)
2003 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
2004 else
2005 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
2006 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
2007 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
2008 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
2009 if (expect_InPlaceUIWindow_SetActiveObject_active)
2010 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
2011 else
2012 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
2013
2014 return S_OK;
2015 }
2016
2017 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
2018 {
2019 CHECK_EXPECT(HideUI);
2020 return S_OK;
2021 }
2022
2023 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
2024 {
2025 CHECK_EXPECT(UpdateUI);
2026 return S_OK;
2027 }
2028
2029 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
2030 {
2031 if(fEnable)
2032 CHECK_EXPECT2(EnableModeless_TRUE);
2033 else
2034 CHECK_EXPECT2(EnableModeless_FALSE);
2035 return E_NOTIMPL;
2036 }
2037
2038 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2039 {
2040 ok(0, "unexpected call\n");
2041 return E_NOTIMPL;
2042 }
2043
2044 static BOOL expect_OnFrameWindowActivate_fActivate;
2045 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2046 {
2047 CHECK_EXPECT2(OnFrameWindowActivate);
2048 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
2049 return S_OK;
2050 }
2051
2052 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
2053 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
2054 {
2055 ok(0, "unexpected call\n");
2056 return E_NOTIMPL;
2057 }
2058
2059 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
2060 const GUID *pguidCmdGroup, DWORD nCmdID)
2061 {
2062 ok(0, "unexpected call\n");
2063 return E_NOTIMPL;
2064 }
2065
2066 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
2067 LPOLESTR *pchKey, DWORD dw)
2068 {
2069 CHECK_EXPECT(GetOptionKeyPath);
2070 ok(pchKey != NULL, "pchKey = NULL\n");
2071 ok(!dw, "dw=%d, expected 0\n", dw);
2072 if(pchKey)
2073 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2074 return S_OK;
2075 }
2076
2077 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
2078 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
2079 {
2080 CHECK_EXPECT(GetDropTarget);
2081 /* TODO */
2082 return E_NOTIMPL;
2083 }
2084
2085 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
2086 {
2087 CHECK_EXPECT(GetExternal);
2088 *ppDispatch = &External;
2089 return S_FALSE;
2090 }
2091
2092 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2093 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2094 {
2095 ok(0, "unexpected call\n");
2096 return E_NOTIMPL;
2097 }
2098
2099 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2100 IDataObject **ppPORet)
2101 {
2102 ok(0, "unexpected call\n");
2103 return E_NOTIMPL;
2104 }
2105
2106 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2107 LPOLESTR *pchKey, DWORD dw)
2108 {
2109 CHECK_EXPECT(GetOverrideKeyPath);
2110 ok(pchKey != NULL, "pchKey = NULL\n");
2111 if(pchKey)
2112 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2113 ok(!dw, "dw=%d, xepected 0\n", dw);
2114 return S_OK;
2115 }
2116
2117 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2118 DocHostUIHandler_QueryInterface,
2119 DocHostUIHandler_AddRef,
2120 DocHostUIHandler_Release,
2121 DocHostUIHandler_ShowContextMenu,
2122 DocHostUIHandler_GetHostInfo,
2123 DocHostUIHandler_ShowUI,
2124 DocHostUIHandler_HideUI,
2125 DocHostUIHandler_UpdateUI,
2126 DocHostUIHandler_EnableModeless,
2127 DocHostUIHandler_OnDocWindowActivate,
2128 DocHostUIHandler_OnFrameWindowActivate,
2129 DocHostUIHandler_ResizeBorder,
2130 DocHostUIHandler_TranslateAccelerator,
2131 DocHostUIHandler_GetOptionKeyPath,
2132 DocHostUIHandler_GetDropTarget,
2133 DocHostUIHandler_GetExternal,
2134 DocHostUIHandler_TranslateUrl,
2135 DocHostUIHandler_FilterDataObject,
2136 DocHostUIHandler_GetOverrideKeyPath
2137 };
2138
2139 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2140
2141 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2142 REFIID riid, void **ppv)
2143 {
2144 return QueryInterface(riid, ppv);
2145 }
2146
2147 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2148 {
2149 return 2;
2150 }
2151
2152 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2153 {
2154 return 1;
2155 }
2156
2157 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2158 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2159 {
2160 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2161 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2162 ok(!pCmdText, "pCmdText != NULL\n");
2163
2164 switch(prgCmds[0].cmdID) {
2165 case OLECMDID_SETPROGRESSTEXT:
2166 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2167 prgCmds[0].cmdf = OLECMDF_ENABLED;
2168 return S_OK;
2169 case OLECMDID_OPEN:
2170 CHECK_EXPECT(QueryStatus_OPEN);
2171 prgCmds[0].cmdf = 0;
2172 return S_OK;
2173 case OLECMDID_NEW:
2174 CHECK_EXPECT(QueryStatus_NEW);
2175 prgCmds[0].cmdf = 0;
2176 return S_OK;
2177 default:
2178 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2179 };
2180
2181 return E_FAIL;
2182 }
2183
2184 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2185 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2186 {
2187 if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2188 test_readyState(NULL);
2189
2190 if(!pguidCmdGroup) {
2191 switch(nCmdID) {
2192 case OLECMDID_SETPROGRESSMAX:
2193 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2194 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2195 ok(pvaIn != NULL, "pvaIn == NULL\n");
2196 if(pvaIn) {
2197 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2198 if(load_state == LD_NO)
2199 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2200 }
2201 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2202 return S_OK;
2203 case OLECMDID_SETPROGRESSPOS:
2204 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2205 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2206 ok(pvaIn != NULL, "pvaIn == NULL\n");
2207 if(pvaIn) {
2208 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2209 if(load_state == LD_NO)
2210 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2211 }
2212 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2213 return S_OK;
2214 case OLECMDID_HTTPEQUIV_DONE:
2215 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2216 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2217 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2218 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2219 load_state = LD_COMPLETE;
2220 return S_OK;
2221 case OLECMDID_SETDOWNLOADSTATE:
2222 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2223 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2224 ok(pvaIn != NULL, "pvaIn == NULL\n");
2225 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2226
2227 switch(V_I4(pvaIn)) {
2228 case 0:
2229 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2230 load_state = LD_INTERACTIVE;
2231 break;
2232 case 1:
2233 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2234 readystate_set_interactive = (load_state != LD_INTERACTIVE);
2235 break;
2236 default:
2237 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2238 }
2239
2240 return S_OK;
2241 case OLECMDID_UPDATECOMMANDS:
2242 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2243 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2244 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2245 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2246 return S_OK;
2247 case OLECMDID_SETTITLE:
2248 CHECK_EXPECT2(Exec_SETTITLE);
2249 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2250 ok(pvaIn != NULL, "pvaIn == NULL\n");
2251 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2252 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2253 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2254 return S_OK;
2255 case OLECMDID_HTTPEQUIV:
2256 CHECK_EXPECT2(Exec_HTTPEQUIV);
2257 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
2258 ok(pvaIn != NULL, "pvaIn == NULL\n");
2259 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2260 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2261 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) = NULL\n");
2262 test_readyState(NULL);
2263 return S_OK;
2264 default:
2265 ok(0, "unexpected command %d\n", nCmdID);
2266 return E_FAIL;
2267 };
2268 }
2269
2270 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2271 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2272
2273 switch(nCmdID) {
2274 case 37:
2275 CHECK_EXPECT2(Exec_ShellDocView_37);
2276
2277 if(load_from_stream)
2278 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2279 else if(!editmode)
2280 test_GetCurMoniker(doc_unk, doc_mon, NULL);
2281
2282 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2283 ok(pvaIn != NULL, "pvaIn == NULL\n");
2284 if(pvaIn) {
2285 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2286 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2287 }
2288 return S_OK;
2289 case 84:
2290 CHECK_EXPECT2(Exec_ShellDocView_84);
2291
2292 ok(pvaIn == NULL, "pvaIn != NULL\n");
2293 ok(pvaOut != NULL, "pvaOut == NULL\n");
2294 if(pvaIn)
2295 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2296
2297 return E_NOTIMPL;
2298
2299 case 103:
2300 CHECK_EXPECT2(Exec_ShellDocView_103);
2301
2302 ok(pvaIn == NULL, "pvaIn != NULL\n");
2303 ok(pvaOut == NULL, "pvaOut != NULL\n");
2304
2305 return E_NOTIMPL;
2306
2307 case 105:
2308 CHECK_EXPECT2(Exec_ShellDocView_105);
2309
2310 ok(pvaIn != NULL, "pvaIn == NULL\n");
2311 ok(pvaOut == NULL, "pvaOut != NULL\n");
2312
2313 return E_NOTIMPL;
2314
2315 case 140:
2316 CHECK_EXPECT2(Exec_ShellDocView_140);
2317
2318 ok(pvaIn == NULL, "pvaIn != NULL\n");
2319 ok(pvaOut == NULL, "pvaOut != NULL\n");
2320
2321 return E_NOTIMPL;
2322
2323 default:
2324 ok(0, "unexpected command %d\n", nCmdID);
2325 return E_FAIL;
2326 };
2327 }
2328
2329 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2330 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2331
2332 switch(nCmdID) {
2333 case IDM_PARSECOMPLETE:
2334 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2335 ok(pvaIn == NULL, "pvaIn != NULL\n");
2336 ok(pvaOut == NULL, "pvaOut != NULL\n");
2337 return S_OK;
2338 default:
2339 ok(0, "unexpected command %d\n", nCmdID);
2340 };
2341 }
2342
2343 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
2344 return E_FAIL; /* TODO */
2345
2346 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2347 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2348
2349 switch(nCmdID) {
2350 case 69:
2351 CHECK_EXPECT2(Exec_Explorer_69);
2352 ok(pvaIn == NULL, "pvaIn != NULL\n");
2353 ok(pvaOut != NULL, "pvaOut == NULL\n");
2354 return E_NOTIMPL;
2355 default:
2356 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2357 }
2358 return E_NOTIMPL;
2359 }
2360
2361 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2362 switch (nCmdID) {
2363 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2364 SET_EXPECT(SetStatusText);
2365 ok(pvaIn == NULL, "pvaIn != NULL\n");
2366 ok(pvaOut == NULL, "pvaOut != NULL\n");
2367 return S_OK;
2368 case OLECMDID_SHOWSCRIPTERROR:
2369 /* TODO */
2370 return S_OK;
2371 default:
2372 ok(0, "unexpected command %d\n", nCmdID);
2373 return E_FAIL;
2374 }
2375 }
2376
2377 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2378 return E_NOTIMPL;
2379 }
2380
2381 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2382 OleCommandTarget_QueryInterface,
2383 OleCommandTarget_AddRef,
2384 OleCommandTarget_Release,
2385 OleCommandTarget_QueryStatus,
2386 OleCommandTarget_Exec
2387 };
2388
2389 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2390
2391 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2392 {
2393 return QueryInterface(riid, ppv);
2394 }
2395
2396 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2397 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2398 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2399 {
2400 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2401 ok(pDispParams != NULL, "pDispParams == NULL\n");
2402 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2403 ok(puArgErr != NULL, "puArgErr == NULL\n");
2404 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2405 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2406 test_readyState(NULL);
2407
2408 switch(dispIdMember) {
2409 case DISPID_AMBIENT_USERMODE:
2410 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2411 V_VT(pVarResult) = VT_BOOL;
2412 V_BOOL(pVarResult) = VARIANT_TRUE;
2413 return S_OK;
2414 case DISPID_AMBIENT_DLCONTROL:
2415 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2416 return E_FAIL;
2417 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2418 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2419 return E_FAIL;
2420 case DISPID_AMBIENT_SILENT:
2421 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2422 V_VT(pVarResult) = VT_BOOL;
2423 V_BOOL(pVarResult) = VARIANT_FALSE;
2424 return S_OK;
2425 case DISPID_AMBIENT_USERAGENT:
2426 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2427 return E_FAIL;
2428 case DISPID_AMBIENT_PALETTE:
2429 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2430 return E_FAIL;
2431 };
2432
2433 ok(0, "unexpected dispid %d\n", dispIdMember);
2434 return E_FAIL;
2435 }
2436
2437 static IDispatchVtbl DispatchVtbl = {
2438 Dispatch_QueryInterface,
2439 Dispatch_AddRef,
2440 Dispatch_Release,
2441 Dispatch_GetTypeInfoCount,
2442 Dispatch_GetTypeInfo,
2443 Dispatch_GetIDsOfNames,
2444 Dispatch_Invoke
2445 };
2446
2447 static IDispatch Dispatch = { &DispatchVtbl };
2448
2449 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2450 REFIID riid, void **ppv)
2451 {
2452 return QueryInterface(riid, ppv);
2453 }
2454
2455 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2456 {
2457 return 2;
2458 }
2459
2460 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2461 {
2462 return 1;
2463 }
2464
2465 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2466 REFIID riid, void **ppv)
2467 {
2468 /*
2469 * Services used by HTMLDocument:
2470 *
2471 * IOleUndoManager
2472 * IInternetSecurityManager
2473 * ITargetFrame
2474 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2475 * HTMLFrameBase
2476 * IShellObject
2477 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2478 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2479 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2480 * DefView (?)
2481 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2482 * IElementBehaviorFactory
2483 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2484 * STopLevelBrowser
2485 * IHTMLWindow2
2486 * IInternetProtocol
2487 * IWebBrowserApp
2488 * UrlHostory
2489 * IHTMLEditHost
2490 * IHlinkFrame
2491 */
2492
2493 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2494 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2495 *ppv = &HlinkFrame;
2496 return S_OK;
2497 }
2498
2499 return E_NOINTERFACE;
2500 }
2501
2502 static const IServiceProviderVtbl ServiceProviderVtbl = {
2503 ServiceProvider_QueryInterface,
2504 ServiceProvider_AddRef,
2505 ServiceProvider_Release,
2506 ServiceProvider_QueryService
2507 };
2508
2509 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2510
2511 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2512 DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2513 DEFINE_GUID(IID_IRenMailEditor, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2514 DEFINE_GUID(IID_unk4, 0x305104a6,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
2515 DEFINE_GUID(IID_IDocHostUIHandlerPriv, 0xf0d241d1,0x5d0e,0x4e85,0xbc,0xb4,0xfa,0xd7,0xf7,0xc5,0x52,0x8c);
2516
2517 static HRESULT QueryInterface(REFIID riid, void **ppv)
2518 {
2519 *ppv = NULL;
2520
2521 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2522 *ppv = &ClientSite;
2523 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2524 *ppv = &DocumentSite;
2525 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2526 *ppv = &DocHostUIHandler;
2527 else if(IsEqualGUID(&IID_IOleContainer, riid))
2528 *ppv = &OleContainer;
2529 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2530 *ppv = &InPlaceSiteEx;
2531 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2532 *ppv = &OleCommandTarget;
2533 else if(IsEqualGUID(&IID_IDispatch, riid))
2534 *ppv = &Dispatch;
2535 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2536 *ppv = &ServiceProvider;
2537 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2538 *ppv = ipsex ? &InPlaceSiteEx : NULL;
2539 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2540 *ppv = &OleControlSite;
2541 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2542 return E_NOINTERFACE; /* TODO */
2543 else if(IsEqualGUID(&IID_IProxyManager, riid))
2544 return E_NOINTERFACE; /* ? */
2545 else if(IsEqualGUID(&IID_unk1, riid))
2546 return E_NOINTERFACE; /* HTMLWindow2 ? */
2547 else if(IsEqualGUID(&IID_IThumbnailView, riid))
2548 return E_NOINTERFACE; /* ? */
2549 else if(IsEqualGUID(&IID_IRenMailEditor, riid))
2550 return E_NOINTERFACE; /* ? */
2551 else if(IsEqualGUID(&IID_unk4, riid))
2552 return E_NOINTERFACE; /* ? */
2553 else if(IsEqualGUID(&IID_IDocHostUIHandlerPriv, riid))
2554 return E_NOINTERFACE; /* ? */
2555 else
2556 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2557
2558 if(*ppv)
2559 return S_OK;
2560 return E_NOINTERFACE;
2561 }
2562
2563 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2564 {
2565 return DefWindowProc(hwnd, msg, wParam, lParam);
2566 }
2567
2568 static void _test_readyState(unsigned line, IUnknown *unk)
2569 {
2570 IHTMLDocument2 *htmldoc;
2571 DISPPARAMS dispparams;
2572 BSTR state;
2573 VARIANT out;
2574 HRESULT hres;
2575
2576 static const LPCSTR expected_state[] = {
2577 "uninitialized",
2578 "loading",
2579 NULL,
2580 "interactive",
2581 "complete",
2582 "uninitialized"
2583 };
2584
2585 if(!unk)
2586 unk = doc_unk;
2587
2588 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2589 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2590 if(FAILED(hres))
2591 return;
2592
2593 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2594 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2595
2596 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2597 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2598
2599 if(!strcmp_wa(state, "interactive") && load_state == LD_LOADING)
2600 load_state = LD_INTERACTIVE;
2601
2602 ok_(__FILE__, line)
2603 (!strcmp_wa(state, expected_state[load_state]), "unexpected state %s, expected %d\n",
2604 wine_dbgstr_w(state), load_state);
2605 SysFreeString(state);
2606
2607 dispparams.cArgs = 0;
2608 dispparams.cNamedArgs = 0;
2609 dispparams.rgdispidNamedArgs = NULL;
2610 dispparams.rgvarg = NULL;
2611
2612 VariantInit(&out);
2613
2614 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2615 &dispparams, &out, NULL, NULL);
2616 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2617
2618 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2619 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
2620
2621 IHTMLDocument2_Release(htmldoc);
2622 }
2623
2624 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2625 {
2626 IConnectionPointContainer *tmp_container = NULL;
2627 IConnectionPoint *cp;
2628 IID iid;
2629 HRESULT hres;
2630
2631 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2632 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2633 if(FAILED(hres))
2634 return;
2635
2636 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2637 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2638 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2639
2640 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2641 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2642
2643 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2644 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2645 ok(tmp_container == container, "container != tmp_container\n");
2646 if(SUCCEEDED(hres))
2647 IConnectionPointContainer_Release(tmp_container);
2648
2649 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2650 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2651
2652 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2653 DWORD cookie;
2654
2655 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2656 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2657 }
2658
2659 IConnectionPoint_Release(cp);
2660 }
2661
2662 static void test_ConnectionPointContainer(IUnknown *unk)
2663 {
2664 IConnectionPointContainer *container;
2665 HRESULT hres;
2666
2667 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2668 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2669 if(FAILED(hres))
2670 return;
2671
2672 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2673 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2674 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2675
2676 IConnectionPointContainer_Release(container);
2677 }
2678
2679 static void test_Load(IPersistMoniker *persist, IMoniker *mon)
2680 {
2681 IBindCtx *bind;
2682 HRESULT hres;
2683 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2684
2685 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2686
2687 test_readyState((IUnknown*)persist);
2688
2689 doc_mon = mon;
2690
2691 CreateBindCtx(0, &bind);
2692 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2693 (IUnknown*)&ClientSite);
2694
2695 if(mon == &Moniker)
2696 SET_EXPECT(GetDisplayName);
2697 if(!set_clientsite) {
2698 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2699 SET_EXPECT(GetHostInfo);
2700 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2701 SET_EXPECT(Invoke_AMBIENT_SILENT);
2702 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2703 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2704 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2705 SET_EXPECT(GetOptionKeyPath);
2706 SET_EXPECT(GetOverrideKeyPath);
2707 SET_EXPECT(GetWindow);
2708 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2709 SET_EXPECT(Exec_SETPROGRESSMAX);
2710 SET_EXPECT(Exec_SETPROGRESSPOS);
2711 SET_EXPECT(Exec_ShellDocView_37);
2712 }
2713 if(!container_locked) {
2714 SET_EXPECT(GetContainer);
2715 SET_EXPECT(LockContainer);
2716 }
2717 SET_EXPECT(OnChanged_READYSTATE);
2718 SET_EXPECT(Exec_ShellDocView_84);
2719 SET_EXPECT(IsSystemMoniker);
2720 if(mon == &Moniker)
2721 SET_EXPECT(BindToStorage);
2722 SET_EXPECT(SetActiveObject);
2723 if(set_clientsite) {
2724 SET_EXPECT(Invoke_AMBIENT_SILENT);
2725 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2726 SET_EXPECT(Exec_ShellDocView_37);
2727 }
2728 load_state = LD_DOLOAD;
2729 expect_LockContainer_fLock = TRUE;
2730 readystate_set_loading = TRUE;
2731
2732 hres = IPersistMoniker_Load(persist, FALSE, mon, bind, 0x12);
2733 ok(hres == S_OK, "Load failed: %08x\n", hres);
2734
2735 if(mon == &Moniker)
2736 CHECK_CALLED(GetDisplayName);
2737 if(!set_clientsite) {
2738 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2739 CHECK_CALLED(GetHostInfo);
2740 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2741 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2742 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2743 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2744 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2745 CHECK_CALLED(GetOptionKeyPath);
2746 CHECK_CALLED(GetOverrideKeyPath);
2747 CHECK_CALLED(GetWindow);
2748 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2749 CHECK_CALLED(Exec_SETPROGRESSMAX);
2750 CHECK_CALLED(Exec_SETPROGRESSPOS);
2751 CHECK_CALLED(Exec_ShellDocView_37);
2752 }
2753 if(!container_locked) {
2754 CHECK_CALLED(GetContainer);
2755 CHECK_CALLED(LockContainer);
2756 container_locked = TRUE;
2757 }
2758 CHECK_CALLED(OnChanged_READYSTATE);
2759 SET_CALLED(IsSystemMoniker); /* IE7 */
2760 SET_CALLED(Exec_ShellDocView_84);
2761 if(mon == &Moniker)
2762 CHECK_CALLED(BindToStorage);
2763 SET_CALLED(SetActiveObject); /* FIXME */
2764 if(set_clientsite) {
2765 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2766 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2767 CHECK_CALLED(Exec_ShellDocView_37);
2768 }
2769
2770 set_clientsite = container_locked = TRUE;
2771
2772 test_GetCurMoniker((IUnknown*)persist, mon, NULL);
2773
2774 IBindCtx_Release(bind);
2775
2776 test_readyState((IUnknown*)persist);
2777 }
2778
2779 #define DWL_VERBDONE 0x0001
2780 #define DWL_CSS 0x0002
2781 #define DWL_TRYCSS 0x0004
2782 #define DWL_HTTP 0x0008
2783
2784 static void test_download(DWORD flags)
2785 {
2786 HWND hwnd;
2787 MSG msg;
2788
2789 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2790 ok(hwnd != NULL, "Could not find hidden window\n");
2791
2792 test_readyState(NULL);
2793
2794 if(flags & (DWL_VERBDONE|DWL_HTTP))
2795 SET_EXPECT(Exec_SETPROGRESSMAX);
2796 if((flags & DWL_VERBDONE) && !load_from_stream)
2797 SET_EXPECT(GetHostInfo);
2798 SET_EXPECT(SetStatusText);
2799 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2800 SET_EXPECT(GetDropTarget);
2801 if(flags & DWL_TRYCSS)
2802 SET_EXPECT(Exec_ShellDocView_84);
2803 if(flags & DWL_CSS) {
2804 SET_EXPECT(CreateInstance);
2805 SET_EXPECT(Start);
2806 SET_EXPECT(LockRequest);
2807 SET_EXPECT(Terminate);
2808 SET_EXPECT(Protocol_Read);
2809 SET_EXPECT(UnlockRequest);
2810 }
2811 SET_EXPECT(Exec_Explorer_69);
2812 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
2813 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
2814 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
2815 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
2816 if(doc_mon != &Moniker) {
2817 SET_EXPECT(OnChanged_1012);
2818 SET_EXPECT(Exec_HTTPEQUIV);
2819 SET_EXPECT(Exec_SETTITLE);
2820 }
2821 SET_EXPECT(OnChanged_1005);
2822 SET_EXPECT(OnChanged_READYSTATE);
2823 SET_EXPECT(Exec_SETPROGRESSPOS);
2824 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2825 SET_EXPECT(Exec_ShellDocView_103);
2826 SET_EXPECT(Exec_ShellDocView_105);
2827 SET_EXPECT(Exec_ShellDocView_140);
2828 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2829 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2830 SET_EXPECT(SetStatusText);
2831 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2832
2833 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2834 TranslateMessage(&msg);
2835 DispatchMessage(&msg);
2836 }
2837
2838 if(flags & DWL_VERBDONE)
2839 CHECK_CALLED(Exec_SETPROGRESSMAX);
2840 if(flags & DWL_HTTP)
2841 SET_CALLED(Exec_SETPROGRESSMAX);
2842 if((flags & DWL_VERBDONE) && !load_from_stream)
2843 CHECK_CALLED(GetHostInfo);
2844 CHECK_CALLED(SetStatusText);
2845 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2846 CHECK_CALLED(GetDropTarget);
2847 if(flags & DWL_TRYCSS)
2848 SET_CALLED(Exec_ShellDocView_84);
2849 if(flags & DWL_CSS) {
2850 if(called_CreateInstance) {
2851 CHECK_CALLED(CreateInstance);
2852 CHECK_CALLED(Start);
2853 CHECK_CALLED(LockRequest);
2854 CHECK_CALLED(Terminate);
2855 CHECK_CALLED(Protocol_Read);
2856 CHECK_CALLED(UnlockRequest);
2857 }else {
2858 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2859
2860 SET_CALLED(Exec_ShellDocView_84);
2861 SET_CALLED(CreateInstance);
2862 SET_CALLED(Start);
2863 SET_CALLED(LockRequest);
2864 SET_CALLED(Terminate);
2865 SET_CALLED(Protocol_Read);
2866 SET_CALLED(UnlockRequest);
2867
2868 nogecko = TRUE;
2869 }
2870 }
2871 SET_CALLED(Exec_Explorer_69);
2872 SET_CALLED(EnableModeless_TRUE); /* IE7 */
2873 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
2874 SET_CALLED(EnableModeless_FALSE); /* IE7 */
2875 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
2876 if(doc_mon != &Moniker) todo_wine {
2877 CHECK_CALLED(OnChanged_1012);
2878 CHECK_CALLED(Exec_HTTPEQUIV);
2879 CHECK_CALLED(Exec_SETTITLE);
2880 }
2881 CHECK_CALLED(OnChanged_1005);
2882 CHECK_CALLED(OnChanged_READYSTATE);
2883 CHECK_CALLED(Exec_SETPROGRESSPOS);
2884 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2885 SET_CALLED(Exec_ShellDocView_103);
2886 SET_CALLED(Exec_ShellDocView_105);
2887 SET_CALLED(Exec_ShellDocView_140);
2888 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2889 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2890 SET_CALLED(SetStatusText);
2891
2892 load_state = LD_COMPLETE;
2893
2894 test_readyState(NULL);
2895 }
2896
2897 static void test_Persist(IUnknown *unk, IMoniker *mon)
2898 {
2899 IPersistMoniker *persist_mon;
2900 IPersistFile *persist_file;
2901 GUID guid;
2902 HRESULT hres;
2903
2904 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2905 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2906 if(SUCCEEDED(hres)) {
2907 hres = IPersist_GetClassID(persist_file, NULL);
2908 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2909
2910 hres = IPersist_GetClassID(persist_file, &guid);
2911 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2912 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2913
2914 IPersist_Release(persist_file);
2915 }
2916
2917 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2918 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2919 if(SUCCEEDED(hres)) {
2920 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2921 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2922
2923 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2924 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2925 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2926
2927 if(load_state == LD_DOLOAD)
2928 test_Load(persist_mon, mon);
2929
2930 test_readyState(unk);
2931
2932 IPersistMoniker_Release(persist_mon);
2933 }
2934 }
2935
2936 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2937 0,
2938 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2939 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2940 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2941 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2942 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2943 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2944 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2945 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2946 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2947 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2948 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2949 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2950 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2951 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2952 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2953 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2954 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2955 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2956 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2957 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2958 0,
2959 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2960 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2961 0,0,0,0,0,0,
2962 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2963 0,0,
2964 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2965 0,0,
2966 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2967 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2968 0,0,0,0,0,
2969 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2970 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2971 0,0,
2972 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2973 0,0,0,
2974 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2975 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2976 };
2977
2978 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
2979 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2980 {
2981 IOleCommandTarget *cmdtrg;
2982 OLECMD olecmd = {cmdid, 0};
2983 HRESULT hres;
2984
2985 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2986 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2987 if(FAILED(hres))
2988 return;
2989
2990 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2991 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2992
2993 IOleCommandTarget_Release(cmdtrg);
2994
2995 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
2996 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2997 }
2998
2999 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
3000 {
3001 if(!unk)
3002 unk = doc_unk;
3003
3004 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
3005 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
3006 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
3007 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
3008 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
3009 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
3010 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
3011 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
3012 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
3013 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
3014 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
3015 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
3016 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
3017 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
3018 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
3019 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
3020 }
3021
3022 static void test_OleCommandTarget(IUnknown *unk)
3023 {
3024 IOleCommandTarget *cmdtrg;
3025 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
3026 int i;
3027 HRESULT hres;
3028
3029 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3030 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3031 if(FAILED(hres))
3032 return;
3033
3034 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3035 cmds[i].cmdID = i+1;
3036 cmds[i].cmdf = 0xf0f0;
3037 }
3038
3039 SET_EXPECT(QueryStatus_OPEN);
3040 SET_EXPECT(QueryStatus_NEW);
3041 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
3042 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3043 CHECK_CALLED(QueryStatus_OPEN);
3044 CHECK_CALLED(QueryStatus_NEW);
3045
3046 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3047 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
3048 if(i+1 == OLECMDID_FIND)
3049 continue;
3050 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
3051 i+1, cmds[i].cmdf, expect_cmds[i+1]);
3052 }
3053
3054 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
3055 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
3056
3057 IOleCommandTarget_Release(cmdtrg);
3058 }
3059
3060 static void test_OleCommandTarget_fail(IUnknown *unk)
3061 {
3062 IOleCommandTarget *cmdtrg;
3063 int i;
3064 HRESULT hres;
3065
3066 OLECMD cmd[2] = {
3067 {OLECMDID_OPEN, 0xf0f0},
3068 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
3069 };
3070
3071 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3072 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
3073 if(FAILED(hres))
3074 return;
3075
3076 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
3077 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3078
3079 SET_EXPECT(QueryStatus_OPEN);
3080 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
3081 CHECK_CALLED(QueryStatus_OPEN);
3082
3083 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3084 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3085 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3086 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3087 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3088 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3089 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3090
3091 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3092 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3093 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3094
3095 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3096 if(!expect_cmds[i]) {
3097 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3098 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3099 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3100 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3101 }
3102 }
3103
3104 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3105 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3106 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3107 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3108
3109 IOleCommandTarget_Release(cmdtrg);
3110 }
3111
3112 static void test_exec_onunload(IUnknown *unk)
3113 {
3114 IOleCommandTarget *cmdtrg;
3115 VARIANT var;
3116 HRESULT hres;
3117
3118 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3119 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3120 if(FAILED(hres))
3121 return;
3122
3123 memset(&var, 0x0a, sizeof(var));
3124 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3125 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3126 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3127 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3128 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3129
3130 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3131 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3132 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3133
3134 IOleCommandTarget_Release(cmdtrg);
3135 }
3136
3137 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3138 {
3139 IOleCommandTarget *cmdtrg;
3140 HRESULT hres;
3141
3142 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3143 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3144 if(FAILED(hres))
3145 return;
3146
3147 editmode = TRUE;
3148
3149 if(loaded)
3150 load_state = LD_DOLOAD;
3151
3152 if(loaded)
3153 SET_EXPECT(GetClassID);
3154 SET_EXPECT(SetStatusText);
3155 SET_EXPECT(Exec_ShellDocView_37);
3156 SET_EXPECT(GetHostInfo);
3157 if(loaded)
3158 SET_EXPECT(GetDisplayName);
3159 SET_EXPECT(Invoke_AMBIENT_SILENT);
3160 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3161 SET_EXPECT(OnChanged_READYSTATE);
3162 SET_EXPECT(IsSystemMoniker);
3163 SET_EXPECT(Exec_ShellDocView_84);
3164 if(loaded)
3165 SET_EXPECT(BindToStorage);
3166 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3167 SET_EXPECT(HideUI);
3168 SET_EXPECT(ShowUI);
3169 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3170
3171 expect_status_text = NULL;
3172 readystate_set_loading = TRUE;
3173
3174 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3175 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3176 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3177
3178 if(loaded)
3179 CHECK_CALLED(GetClassID);
3180 CHECK_CALLED(SetStatusText);
3181 CHECK_CALLED(Exec_ShellDocView_37);
3182 CHECK_CALLED(GetHostInfo);
3183 if(loaded)
3184 CHECK_CALLED(GetDisplayName);
3185 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3186 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3187 CHECK_CALLED(OnChanged_READYSTATE);
3188 SET_CALLED(IsSystemMoniker); /* IE7 */
3189 SET_CALLED(Exec_ShellDocView_84);
3190 if(loaded)
3191 CHECK_CALLED(BindToStorage);
3192 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3193 CHECK_CALLED(HideUI);
3194 CHECK_CALLED(ShowUI);
3195 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3196
3197 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3198
3199 IOleCommandTarget_Release(cmdtrg);
3200
3201 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3202 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3203 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3204 }
3205
3206 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3207 {
3208 IOleCommandTarget *cmdtrg;
3209 VARIANT *in = NULL, _in, *out = NULL, _out;
3210 HRESULT hres;
3211
3212 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3213 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3214 if(FAILED(hres))
3215 return;
3216
3217 if(name) {
3218 in = &_in;
3219 V_VT(in) = VT_BSTR;
3220 V_BSTR(in) = SysAllocString(name);
3221 }
3222
3223 if(exname) {
3224 out = &_out;
3225 V_VT(out) = VT_I4;
3226 V_I4(out) = 0xdeadbeef;
3227 }
3228
3229 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3230 if(!nogecko)
3231 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3232
3233 if(in)
3234 VariantClear(in);
3235
3236 if(out && !nogecko) {
3237 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3238 if(V_VT(out) == VT_BSTR) {
3239 if(exname)
3240 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3241 "unexpected fontname %s\n", wine_dbgstr_w(name));
3242 else
3243 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3244 }
3245 VariantClear(out);
3246 }
3247
3248 IOleCommandTarget_Release(cmdtrg);
3249 }
3250
3251 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3252 {
3253 IOleCommandTarget *cmdtrg;
3254 HRESULT hres;
3255
3256 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3257 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3258 if(FAILED(hres))
3259 return;
3260
3261 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3262 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3263 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3264
3265 IOleCommandTarget_Release(cmdtrg);
3266 }
3267
3268 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
3269 {
3270 IPersistStreamInit *perinit;
3271 IPersistMoniker *permon;
3272 IPersistFile *perfile;
3273 HRESULT hres;
3274
3275 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
3276 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3277 if(SUCCEEDED(hres)) {
3278 hres = IPersistStreamInit_IsDirty(perinit);
3279 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3280 IPersistStreamInit_Release(perinit);
3281 }
3282
3283 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
3284 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3285 if(SUCCEEDED(hres)) {
3286 hres = IPersistMoniker_IsDirty(permon);
3287 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3288 IPersistMoniker_Release(permon);
3289 }
3290
3291 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
3292 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3293 if(SUCCEEDED(hres)) {
3294 hres = IPersistFile_IsDirty(perfile);
3295 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3296 IPersistFile_Release(perfile);
3297 }
3298 }
3299
3300 static HWND create_container_window(void)
3301 {
3302 static const WCHAR wszHTMLDocumentTest[] =
3303 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3304 static WNDCLASSEXW wndclass = {
3305 sizeof(WNDCLASSEXW),
3306 0,
3307 wnd_proc,
3308 0, 0, NULL, NULL, NULL, NULL, NULL,
3309 wszHTMLDocumentTest,
3310 NULL
3311 };
3312
3313 RegisterClassExW(&wndclass);
3314 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3315 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3316 515, 530, NULL, NULL, NULL, NULL);
3317 }
3318
3319 static void test_DoVerb(IOleObject *oleobj)
3320 {
3321 RECT rect = {0,0,500,500};
3322 HRESULT hres;
3323
3324 if(!container_locked) {
3325 SET_EXPECT(GetContainer);
3326 SET_EXPECT(LockContainer);
3327 }
3328 SET_EXPECT(ActivateMe);
3329 expect_LockContainer_fLock = TRUE;
3330
3331 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3332 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3333
3334 if(!container_locked) {
3335 CHECK_CALLED(GetContainer);
3336 CHECK_CALLED(LockContainer);
3337 container_locked = TRUE;
3338 }
3339 CHECK_CALLED(ActivateMe);
3340 }
3341
3342 #define CLIENTSITE_EXPECTPATH 0x00000001
3343 #define CLIENTSITE_SETNULL 0x00000002
3344 #define CLIENTSITE_DONTSET 0x00000004
3345
3346 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3347 {
3348 IOleClientSite *clientsite;
3349 HRESULT hres;
3350
3351 if(flags & CLIENTSITE_SETNULL) {
3352 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3353 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3354
3355 hres = IOleObject_SetClientSite(oleobj, NULL);
3356 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3357
3358 set_clientsite = FALSE;
3359 }
3360
3361 if(flags & CLIENTSITE_DONTSET)
3362 return;
3363
3364 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3365 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3366 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3367 clientsite, set_clientsite ? &ClientSite : NULL);
3368
3369 if(!set_clientsite) {
3370 SET_EXPECT(GetHostInfo);
3371 if(flags & CLIENTSITE_EXPECTPATH) {
3372 SET_EXPECT(GetOptionKeyPath);
3373 SET_EXPECT(GetOverrideKeyPath);
3374 }
3375 SET_EXPECT(GetWindow);
3376 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3377 SET_EXPECT(Exec_SETPROGRESSMAX);
3378 SET_EXPECT(Exec_SETPROGRESSPOS);
3379 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3380 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3381 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3382 SET_EXPECT(Invoke_AMBIENT_SILENT);
3383 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3384 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3385
3386 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3387 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3388
3389 CHECK_CALLED(GetHostInfo);
3390 if(flags & CLIENTSITE_EXPECTPATH) {
3391 CHECK_CALLED(GetOptionKeyPath);
3392 CHECK_CALLED(GetOverrideKeyPath);
3393 }
3394 CHECK_CALLED(GetWindow);
3395 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3396 CHECK_CALLED(Exec_SETPROGRESSMAX);
3397 CHECK_CALLED(Exec_SETPROGRESSPOS);
3398 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3399 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3400 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3401 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3402 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3403 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3404
3405 set_clientsite = TRUE;
3406 }
3407
3408 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3409 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3410
3411 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3412 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3413 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3414 }
3415
3416 static void test_OnAmbientPropertyChange(IUnknown *unk)
3417 {
3418 IOleControl *control = NULL;
3419 HRESULT hres;
3420
3421 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3422 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3423 if(FAILED(hres))
3424 return;
3425
3426 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3427 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3428 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3429 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3430
3431 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3432 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3433 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3434 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3435
3436 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3437 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3438 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3439 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3440 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3441 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3442
3443 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3444 SET_EXPECT(Invoke_AMBIENT_SILENT);
3445 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3446 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3447 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3448 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3449
3450 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3451 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3452 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);