4 * Copyright 2004 Kevin Koltzau
5 * Copyright 2004-2007 Jacek Caban for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define NONAMELESSUNION
36 #include "wine/test.h"
38 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
39 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
40 DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
42 #define DEFINE_EXPECT(func) \
43 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
45 #define SET_EXPECT(func) \
46 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
48 #define CHECK_EXPECT2(func) \
50 ok(expect_ ##func, "unexpected call " #func "\n"); \
51 called_ ## func = TRUE; \
54 #define CHECK_EXPECT(func) \
56 CHECK_EXPECT2(func); \
57 expect_ ## func = FALSE; \
60 #define CHECK_CALLED(func) \
62 ok(called_ ## func, "expected " #func "\n"); \
63 expect_ ## func = called_ ## func = FALSE; \
66 #define CHECK_NOT_CALLED(func) \
68 ok(!called_ ## func, "unexpected " #func "\n"); \
69 expect_ ## func = called_ ## func = FALSE; \
72 #define CHECK_CALLED_BROKEN(func) \
74 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
75 expect_ ## func = called_ ## func = FALSE; \
78 #define CLEAR_CALLED(func) \
79 expect_ ## func = called_ ## func = FALSE
81 DEFINE_EXPECT(QueryInterface_IServiceProvider);
82 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
83 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
84 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx);
85 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
86 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
87 DEFINE_EXPECT(QueryInterface_IAuthenticate);
88 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
89 DEFINE_EXPECT(QueryInterface_IWindowForBindingUI);
90 DEFINE_EXPECT(QueryService_IAuthenticate);
91 DEFINE_EXPECT(QueryService_IInternetProtocol);
92 DEFINE_EXPECT(QueryService_IInternetBindInfo);
93 DEFINE_EXPECT(QueryService_IWindowForBindingUI);
94 DEFINE_EXPECT(BeginningTransaction);
95 DEFINE_EXPECT(OnResponse);
96 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
97 DEFINE_EXPECT(GetRootSecurityId);
98 DEFINE_EXPECT(GetBindInfo);
99 DEFINE_EXPECT(GetBindInfoEx);
100 DEFINE_EXPECT(OnStartBinding);
101 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
102 DEFINE_EXPECT(OnProgress_CONNECTING);
103 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
104 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
105 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
106 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
107 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
108 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
109 DEFINE_EXPECT(OnStopBinding);
110 DEFINE_EXPECT(OnDataAvailable);
111 DEFINE_EXPECT(OnObjectAvailable);
112 DEFINE_EXPECT(Obj_OnStartBinding);
113 DEFINE_EXPECT(Obj_OnStopBinding);
114 DEFINE_EXPECT(Obj_GetBindInfo);
115 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
116 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
117 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
118 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
119 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
120 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
121 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
122 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
123 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
124 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
125 DEFINE_EXPECT(Start);
127 DEFINE_EXPECT(LockRequest);
128 DEFINE_EXPECT(Terminate);
129 DEFINE_EXPECT(UnlockRequest);
130 DEFINE_EXPECT(Continue);
131 DEFINE_EXPECT(CreateInstance);
133 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
134 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
135 DEFINE_EXPECT(SetPriority);
137 static const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
138 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
140 static const WCHAR WINE_ABOUT_URL[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
141 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
142 static const WCHAR SHORT_RESPONSE_URL[] =
143 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
144 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
145 'p','o','s','t','t','e','s','t','.','p','h','p',0};
146 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
147 static WCHAR INDEX_HTML[MAX_PATH];
148 static const WCHAR ITS_URL[] =
149 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
150 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
151 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
152 static const WCHAR https_urlW[] =
153 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',
154 '/','t','e','s','t','.','h','t','m','l',0};
155 static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
156 '/','p','u','b','/','o','t','h','e','r','/',
157 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
160 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
162 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
164 static const WCHAR wszWineHQSite[] =
165 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
166 static const WCHAR wszWineHQIP[] =
167 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
168 static const CHAR wszIndexHtmlA[] = "index.html";
169 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
170 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
171 static const CHAR dwl_htmlA[] = "dwl.html";
172 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
173 static const WCHAR emptyW[] = {0};
175 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
176 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api;
177 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed;
178 static CHAR mime_type[512];
179 static IInternetProtocolSink *protocol_sink = NULL;
180 static IBinding *current_binding;
181 static HANDLE complete_event, complete_event2;
182 static HRESULT binding_hres;
183 static BOOL have_IHttpNegotiate2, use_bscex;
185 static LPCWSTR urls[] = {
195 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
213 static const char *debugstr_guid(REFIID riid)
217 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
218 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
219 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
220 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
225 static BOOL is_urlmon_protocol(int prot)
227 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST;
230 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
233 IMoniker *mon1 = NULL;
234 IMoniker *mon2 = NULL;
236 hr = CreateURLMoniker(NULL, url1, &mon1);
237 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
239 hr = CreateURLMoniker(mon1, url2, &mon2);
240 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
242 if(mon1) IMoniker_Release(mon1);
243 if(mon2) IMoniker_Release(mon2);
246 static void test_create(void)
248 test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
251 static HRESULT WINAPI Priority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
253 ok(0, "unexpected call\n");
254 return E_NOINTERFACE;
257 static ULONG WINAPI Priority_AddRef(IInternetPriority *iface)
262 static ULONG WINAPI Priority_Release(IInternetPriority *iface)
267 static HRESULT WINAPI Priority_SetPriority(IInternetPriority *iface, LONG nPriority)
269 CHECK_EXPECT(SetPriority);
270 ok(!nPriority, "nPriority = %d\n", nPriority);
274 static HRESULT WINAPI Priority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
276 ok(0, "unexpected call\n");
280 static const IInternetPriorityVtbl InternetPriorityVtbl = {
281 Priority_QueryInterface,
284 Priority_SetPriority,
288 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
290 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
294 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
299 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
300 if(!is_urlmon_protocol(test_protocol))
301 return E_NOINTERFACE;
303 *ppv = &InternetPriority;
307 if(IsEqualGUID(&IID_IInternetProtocolEx, riid))
308 return E_NOINTERFACE; /* TODO */
310 ok(0, "unexpected call %s\n", debugstr_guid(riid));
311 return E_NOINTERFACE;
314 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
319 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
324 static void test_switch_fail(void)
326 IInternetProtocolSink *binding_sink;
327 PROTOCOLDATA protocoldata;
330 static BOOL tested_switch_fail;
332 if(tested_switch_fail)
335 tested_switch_fail = TRUE;
337 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink);
338 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres);
339 if(SUCCEEDED(hres)) {
340 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
341 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres);
342 IInternetProtocolSink_Release(binding_sink);
346 static DWORD WINAPI thread_proc(PVOID arg)
348 PROTOCOLDATA protocoldata;
352 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
354 SET_EXPECT(OnProgress_FINDINGRESOURCE);
355 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
356 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
357 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
358 WaitForSingleObject(complete_event, INFINITE);
360 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
362 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
365 SET_EXPECT(Obj_OnProgress_CONNECTING);
367 SET_EXPECT(OnProgress_CONNECTING);
368 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
369 BINDSTATUS_CONNECTING, wszWineHQIP);
370 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
371 WaitForSingleObject(complete_event, INFINITE);
373 CHECK_CALLED(Obj_OnProgress_CONNECTING);
375 CHECK_CALLED(OnProgress_CONNECTING);
378 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
380 SET_EXPECT(OnProgress_SENDINGREQUEST);
381 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
382 BINDSTATUS_SENDINGREQUEST, NULL);
383 ok(hres == S_OK, "ReportProxgress failed: %08x\n", hres);
384 WaitForSingleObject(complete_event, INFINITE);
386 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
388 CHECK_CALLED(OnProgress_SENDINGREQUEST);
392 SET_EXPECT(Continue);
394 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
395 ok(hres == S_OK, "Switch failed: %08x\n", hres);
396 WaitForSingleObject(complete_event, INFINITE);
398 CHECK_CALLED(Continue);
401 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
402 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
403 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
404 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
405 CHECK_CALLED(CreateInstance);
406 CHECK_CALLED(PutProperty_MIMETYPEPROP);
407 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
409 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
410 CHECK_CALLED(OnObjectAvailable);
411 CHECK_CALLED(Obj_OnStopBinding);
413 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
414 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
415 CHECK_CALLED(LockRequest);
416 CHECK_CALLED(OnDataAvailable);
419 SET_EXPECT(Continue);
421 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
422 ok(hres == S_OK, "Switch failed: %08x\n", hres);
423 WaitForSingleObject(complete_event, INFINITE);
424 CHECK_CALLED(Continue);
426 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
427 CHECK_CALLED(OnDataAvailable);
429 SET_EXPECT(Continue);
431 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
432 ok(hres == S_OK, "Switch failed: %08x\n", hres);
433 WaitForSingleObject(complete_event, INFINITE);
434 CHECK_CALLED(Continue);
436 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
437 CHECK_CALLED(OnDataAvailable);
439 SET_EXPECT(Continue);
441 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
442 ok(hres == S_OK, "Switch failed: %08x\n", hres);
443 WaitForSingleObject(complete_event, INFINITE);
444 CHECK_CALLED(Continue);
446 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
447 CHECK_CALLED(OnDataAvailable);
448 CHECK_CALLED(OnStopBinding);
452 SetEvent(complete_event2);
456 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
457 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
458 DWORD grfPI, HANDLE_PTR dwReserved)
461 DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
464 static const STGMEDIUM stgmed_zero = {0};
465 static const SECURITY_ATTRIBUTES sa_zero = {0};
471 if(!filedwl_api) /* FIXME */
472 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", wine_dbgstr_w(szUrl));
473 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
474 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
475 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
476 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved);
478 if(!filedwl_api && binding_hres != S_OK) {
479 SET_EXPECT(OnStopBinding);
480 SET_EXPECT(Terminate);
481 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
482 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
483 CHECK_CALLED(OnStopBinding);
484 CHECK_CALLED(Terminate);
489 memset(&bindinfo, 0, sizeof(bindinfo));
490 bindinfo.cbSize = sizeof(bindinfo);
491 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
492 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
495 ok(bindf == (BINDF_PULLDATA|BINDF_FROMURLMON|BINDF_NEEDFILE), "bindf=%08x\n", bindf);
496 }else if(tymed == TYMED_ISTREAM && is_urlmon_protocol(test_protocol)) {
497 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
499 "bindf=%08x\n", bindf);
501 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
502 |BINDF_FROMURLMON|BINDF_NEEDFILE),
503 "bindf=%08x\n", bindf);
506 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
507 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
508 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
509 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
510 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
511 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
512 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
513 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
514 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
515 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
516 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
517 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
518 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
519 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
521 switch(test_protocol) {
523 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
524 BINDSTATUS_DIRECTBIND, NULL);
526 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
531 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
533 SET_EXPECT(OnProgress_SENDINGREQUEST);
534 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
535 BINDSTATUS_SENDINGREQUEST, emptyW);
537 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
539 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
541 CHECK_CALLED(OnProgress_SENDINGREQUEST);
546 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
547 IServiceProvider *service_provider;
548 IHttpNegotiate *http_negotiate;
549 IHttpNegotiate2 *http_negotiate2;
550 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
551 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
553 DWORD fetched = 256, size = 100;
556 static const WCHAR wszMimes[] = {'*','/','*',0};
558 SET_EXPECT(QueryInterface_IInternetBindInfo);
559 SET_EXPECT(QueryService_IInternetBindInfo);
560 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
562 CLEAR_CALLED(QueryInterface_IInternetBindInfo); /* IE <8 */
563 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */
565 ok(hres == E_NOINTERFACE,
566 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
567 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
568 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
570 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
571 accept_mimes, 256, &fetched);
573 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
574 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
575 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
577 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
578 NULL, 256, &fetched);
579 ok(hres == E_INVALIDARG,
580 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
582 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
583 accept_mimes, 256, NULL);
584 ok(hres == E_INVALIDARG,
585 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
587 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
588 (void**)&service_provider);
589 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
591 SET_EXPECT(QueryInterface_IHttpNegotiate);
592 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
593 &IID_IHttpNegotiate, (void**)&http_negotiate);
594 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
595 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
597 SET_EXPECT(BeginningTransaction);
598 SET_EXPECT(QueryInterface_IHttpNegotiate);
599 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
600 NULL, 0, &additional_headers);
601 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
602 CHECK_CALLED(BeginningTransaction);
603 IHttpNegotiate_Release(http_negotiate);
604 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
605 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
607 SET_EXPECT(QueryInterface_IHttpNegotiate2);
608 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
609 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
610 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
611 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
614 SET_EXPECT(QueryInterface_IHttpNegotiate2);
615 SET_EXPECT(GetRootSecurityId);
616 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
617 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2);
618 CHECK_CALLED(GetRootSecurityId);
619 IHttpNegotiate2_Release(http_negotiate2);
620 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
621 ok(size == 13, "size=%d\n", size);
623 IServiceProvider_Release(service_provider);
625 IInternetProtocolSink_AddRef(pOIProtSink);
626 protocol_sink = pOIProtSink;
627 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
632 if(test_protocol == FILE_TEST) {
633 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
634 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
636 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
639 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
641 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
642 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
643 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
645 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
647 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
649 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
651 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
652 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
654 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
657 if(test_protocol == ABOUT_TEST)
658 bscf |= BSCF_DATAFULLYAVAILABLE;
659 if(test_protocol == ITS_TEST)
660 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
664 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
665 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
666 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
667 if(test_protocol == FILE_TEST)
668 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
669 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
670 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
671 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
672 SET_EXPECT(CreateInstance);
673 SET_EXPECT(PutProperty_MIMETYPEPROP);
674 SET_EXPECT(PutProperty_CLASSIDPROP);
676 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
677 SET_EXPECT(OnObjectAvailable);
678 SET_EXPECT(Obj_OnStopBinding);
680 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
681 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
682 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
683 if(test_protocol == FILE_TEST)
684 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
685 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
686 SET_EXPECT(LockRequest);
688 SET_EXPECT(OnDataAvailable);
689 SET_EXPECT(OnStopBinding);
692 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
693 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
697 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
698 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
699 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
700 if(test_protocol == FILE_TEST)
701 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
702 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
703 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
704 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
705 CHECK_CALLED(CreateInstance);
706 CHECK_CALLED(PutProperty_MIMETYPEPROP);
707 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
709 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
710 CHECK_CALLED(OnObjectAvailable);
711 CHECK_CALLED(Obj_OnStopBinding);
713 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
714 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
715 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
716 if(test_protocol == FILE_TEST)
717 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
718 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
719 CHECK_CALLED(LockRequest);
721 CHECK_CALLED(OnDataAvailable);
722 CHECK_CALLED(OnStopBinding);
725 if(test_protocol == ITS_TEST) {
727 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
728 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
732 SET_EXPECT(Terminate);
733 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
734 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
735 CHECK_CALLED(Terminate);
740 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
741 PROTOCOLDATA *pProtocolData)
746 CHECK_EXPECT(Continue);
748 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
750 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
756 IServiceProvider *service_provider;
757 IHttpNegotiate *http_negotiate;
758 static WCHAR header[] = {'?',0};
760 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
761 (void**)&service_provider);
762 ok(hres == S_OK, "Could not get IServiceProvicder\n");
764 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
765 &IID_IHttpNegotiate, (void**)&http_negotiate);
766 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
768 SET_EXPECT(QueryInterface_IHttpNegotiate);
769 SET_EXPECT(OnResponse);
770 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
771 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
772 CHECK_CALLED(OnResponse);
773 IHttpNegotiate_Release(http_negotiate);
774 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
776 if(test_protocol == HTTPS_TEST) {
777 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
778 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
781 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
782 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
784 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
786 if(tymed == TYMED_FILE) {
787 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
788 BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_fileW);
790 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
793 bscf |= BSCF_FIRSTDATANOTIFICATION;
798 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
802 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
803 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
809 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
810 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
811 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
812 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
813 SET_EXPECT(CreateInstance);
814 SET_EXPECT(PutProperty_MIMETYPEPROP);
815 SET_EXPECT(PutProperty_CLASSIDPROP);
817 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
818 SET_EXPECT(OnObjectAvailable);
819 SET_EXPECT(Obj_OnStopBinding);
821 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
822 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
823 SET_EXPECT(LockRequest);
827 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
830 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
831 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
833 if(!bind_to_object || prot_state >= 2)
834 SET_EXPECT(OnDataAvailable);
836 SET_EXPECT(OnStopBinding);
841 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
844 ok(0, "unexpected call\n");
848 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
850 CHECK_EXPECT(Terminate);
852 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
855 IInternetProtocolSink_Release(protocol_sink);
856 protocol_sink = NULL;
862 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
864 ok(0, "unexpected call\n");
868 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
870 ok(0, "unexpected call\n");
874 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
875 ULONG cb, ULONG *pcbRead)
877 static const char data[] = "<HTML></HTML>";
881 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
884 static BOOL pending = TRUE;
906 hres = IInternetProtocolSink_ReportData(protocol_sink,
907 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
908 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
910 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
911 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
925 ok(pv != NULL, "pv == NULL\n");
926 ok(cb != 0, "cb == 0\n");
927 ok(pcbRead != NULL, "pcbRead == NULL\n");
929 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
930 read += *pcbRead = sizeof(data)-1;
933 memcpy(pv, data, sizeof(data));
938 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
939 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
941 ok(0, "unexpected call\n");
945 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
947 CHECK_EXPECT(LockRequest);
951 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
953 CHECK_EXPECT(UnlockRequest);
957 static const IInternetProtocolVtbl ProtocolVtbl = {
958 Protocol_QueryInterface,
969 Protocol_LockRequest,
970 Protocol_UnlockRequest
973 static IInternetProtocol Protocol = { &ProtocolVtbl };
975 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
977 if(IsEqualGUID(&IID_IUnknown, riid)
978 || IsEqualGUID(&IID_IHttpNegotiate, riid)
979 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
984 ok(0, "unexpected call\n");
985 return E_NOINTERFACE;
988 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
993 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
998 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
999 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
1001 CHECK_EXPECT(BeginningTransaction);
1003 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1005 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
1006 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
1007 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1008 if(pszAdditionalHeaders)
1009 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1014 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
1015 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
1017 CHECK_EXPECT(OnResponse);
1019 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1021 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
1022 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
1023 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
1024 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1025 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1026 if(pszAdditionalRequestHeaders)
1027 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1032 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
1033 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
1035 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1037 CHECK_EXPECT(GetRootSecurityId);
1039 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1041 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
1042 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
1043 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
1045 if(pbSecurityId == (void*)0xdeadbeef)
1049 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
1050 *pcbSecurityId = sizeof(sec_id);
1054 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
1059 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
1060 HttpNegotiate_QueryInterface,
1061 HttpNegotiate_AddRef,
1062 HttpNegotiate_Release,
1063 HttpNegotiate_BeginningTransaction,
1064 HttpNegotiate_OnResponse,
1065 HttpNegotiate_GetRootSecurityId
1068 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
1070 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1072 ok(0, "unexpected call\n");
1073 return E_NOINTERFACE;
1076 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1081 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1086 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1087 REFGUID guidService, REFIID riid, void **ppv)
1089 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1090 CHECK_EXPECT(QueryService_IAuthenticate);
1094 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1095 CHECK_EXPECT2(QueryService_IInternetProtocol);
1099 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1100 CHECK_EXPECT(QueryService_IInternetBindInfo);
1104 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
1105 CHECK_EXPECT(QueryService_IWindowForBindingUI);
1109 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
1110 return E_NOINTERFACE;
1113 static IServiceProviderVtbl ServiceProviderVtbl = {
1114 ServiceProvider_QueryInterface,
1115 ServiceProvider_AddRef,
1116 ServiceProvider_Release,
1117 ServiceProvider_QueryService
1120 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1122 static IBindStatusCallbackEx objbsc;
1124 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv)
1126 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1128 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1129 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1130 if(emulate_protocol) {
1134 return E_NOINTERFACE;
1137 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1139 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1140 *ppv = &ServiceProvider;
1143 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1145 CHECK_EXPECT2(QueryInterface_IHttpNegotiate);
1146 *ppv = &HttpNegotiate;
1149 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1151 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1152 *ppv = &HttpNegotiate;
1155 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1157 CHECK_EXPECT(QueryInterface_IAuthenticate);
1158 return E_NOINTERFACE;
1160 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1162 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1166 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1168 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1169 return E_NOINTERFACE;
1171 else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid))
1173 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx);
1175 return E_NOINTERFACE;
1179 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1182 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1184 else if(IsEqualGUID(&IID_IWindowForBindingUI, riid))
1186 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI);
1187 return E_NOINTERFACE;
1191 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1194 return E_NOINTERFACE;
1197 static ULONG WINAPI statusclb_AddRef(IBindStatusCallbackEx *iface)
1202 static ULONG WINAPI statusclb_Release(IBindStatusCallbackEx *iface)
1207 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallbackEx *iface, DWORD dwReserved,
1210 IWinInetHttpInfo *http_info;
1214 if(iface == &objbsc)
1215 CHECK_EXPECT(Obj_OnStartBinding);
1217 CHECK_EXPECT(OnStartBinding);
1219 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1221 ok(pib != NULL, "pib should not be NULL\n");
1222 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1224 if(pib == (void*)0xdeadbeef)
1227 current_binding = pib;
1229 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1230 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1232 IMoniker_Release(mon);
1234 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1235 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1240 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority)
1242 ok(0, "unexpected call\n");
1246 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved)
1248 ok(0, "unexpected call\n");
1252 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress,
1253 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1255 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1257 switch(ulStatusCode) {
1258 case BINDSTATUS_FINDINGRESOURCE:
1259 if(iface == &objbsc)
1260 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1261 else if(test_protocol == FTP_TEST)
1262 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1264 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1265 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1266 SetEvent(complete_event);
1268 case BINDSTATUS_CONNECTING:
1269 if(iface == &objbsc)
1270 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1271 else if(test_protocol == FTP_TEST)
1272 todo_wine CHECK_EXPECT(OnProgress_CONNECTING);
1274 CHECK_EXPECT(OnProgress_CONNECTING);
1275 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1276 SetEvent(complete_event);
1278 case BINDSTATUS_SENDINGREQUEST:
1279 if(iface == &objbsc)
1280 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1281 else if(test_protocol == FTP_TEST)
1282 CHECK_EXPECT2(OnProgress_SENDINGREQUEST);
1284 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1285 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1286 SetEvent(complete_event);
1288 case BINDSTATUS_MIMETYPEAVAILABLE:
1289 if(iface == &objbsc)
1290 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1292 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1294 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1296 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1298 case BINDSTATUS_BEGINDOWNLOADDATA:
1299 if(iface == &objbsc)
1300 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1302 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1303 ok(szStatusText != NULL, "szStatusText == NULL\n");
1308 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1312 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1314 download_state = DOWNLOADING;
1316 case BINDSTATUS_DOWNLOADINGDATA:
1317 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1318 ok(iface != &objbsc, "unexpected call\n");
1319 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1322 case BINDSTATUS_ENDDOWNLOADDATA:
1323 if(iface == &objbsc)
1324 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1326 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1327 ok(szStatusText != NULL, "szStatusText == NULL\n");
1332 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1335 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1337 download_state = END_DOWNLOAD;
1339 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1340 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST) {
1341 if(iface == &objbsc)
1342 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1344 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1346 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1347 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1350 ok(szStatusText != NULL, "szStatusText == NULL\n");
1351 if(szStatusText && test_protocol == FILE_TEST)
1352 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1354 case BINDSTATUS_CLASSIDAVAILABLE:
1358 if(iface != &objbsc)
1359 ok(0, "unexpected call\n");
1360 else if(1||emulate_protocol)
1361 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1363 todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1364 hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
1365 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1366 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1367 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1370 case BINDSTATUS_BEGINSYNCOPERATION:
1371 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1372 if(iface != &objbsc)
1373 ok(0, "unexpected call\n");
1374 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1376 case BINDSTATUS_ENDSYNCOPERATION:
1377 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1378 if(iface != &objbsc)
1379 ok(0, "unexpected call\n");
1380 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1382 case BINDSTATUS_PROXYDETECTING:
1383 trace("BINDSTATUS_PROXYDETECTING\n");
1385 case BINDSTATUS_COOKIE_SENT:
1386 trace("BINDSTATUS_COOKIE_SENT\n");
1389 ok(0, "unexpected code %d\n", ulStatusCode);
1392 if(current_binding) {
1393 IWinInetHttpInfo *http_info;
1396 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info);
1397 if(!emulate_protocol && test_protocol != FILE_TEST && is_urlmon_protocol(test_protocol))
1398 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres);
1400 ok(hres == E_NOINTERFACE,
1401 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres);
1403 IWinInetHttpInfo_Release(http_info);
1409 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallbackEx *iface, HRESULT hresult, LPCWSTR szError)
1411 if(iface == &objbsc) {
1412 CHECK_EXPECT(Obj_OnStopBinding);
1413 stopped_obj_binding = TRUE;
1415 CHECK_EXPECT(OnStopBinding);
1416 stopped_binding = TRUE;
1419 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1421 /* ignore DNS failure */
1422 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1426 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1428 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1429 ok(szError == NULL, "szError should be NULL\n");
1431 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) && emulate_protocol) {
1432 SetEvent(complete_event);
1433 if(iface != &objbsc)
1434 WaitForSingleObject(complete_event2, INFINITE);
1440 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1444 if(iface == &objbsc)
1445 CHECK_EXPECT(Obj_GetBindInfo);
1447 CHECK_EXPECT(GetBindInfo);
1449 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1452 cbSize = pbindinfo->cbSize;
1453 memset(pbindinfo, 0, cbSize);
1454 pbindinfo->cbSize = cbSize;
1459 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallbackEx *iface, DWORD grfBSCF,
1460 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1467 if(iface == &objbsc)
1468 ok(0, "unexpected call\n");
1470 CHECK_EXPECT2(OnDataAvailable);
1472 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1474 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1475 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1477 data_available = TRUE;
1479 ok(pformatetc != NULL, "pformatetx == NULL\n");
1483 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1484 "GetClipboardFormatName failed, error %d\n", GetLastError());
1485 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1486 pformatetc->cfFormat, clipfmt, mime_type);
1488 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1490 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1491 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1492 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1493 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1496 ok(pstgmed != NULL, "stgmeg == NULL\n");
1497 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1498 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1500 switch(pstgmed->tymed) {
1502 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1503 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1504 ok(hres == STG_E_ACCESSDENIED,
1505 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1507 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1508 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1510 hres = IStream_Revert(U(*pstgmed).pstm);
1511 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1514 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1515 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1516 while(hres == S_OK);
1517 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1521 if(test_protocol == FILE_TEST)
1522 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1523 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1524 else if(emulate_protocol)
1525 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1526 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1528 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1531 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
1532 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1533 SetEvent(complete_event);
1538 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallbackEx *iface, REFIID riid, IUnknown *punk)
1540 CHECK_EXPECT(OnObjectAvailable);
1542 if(iface != &objbsc)
1543 ok(0, "unexpected call\n");
1545 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1546 ok(punk != NULL, "punk == NULL\n");
1551 static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo,
1552 DWORD *grfBINDF2, DWORD *pdwReserved)
1554 CHECK_EXPECT(GetBindInfoEx);
1556 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
1557 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n");
1558 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
1559 ok(pdwReserved != NULL, "dwReserved == NULL\n");
1564 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = {
1565 statusclb_QueryInterface,
1568 statusclb_OnStartBinding,
1569 statusclb_GetPriority,
1570 statusclb_OnLowResource,
1571 statusclb_OnProgress,
1572 statusclb_OnStopBinding,
1573 statusclb_GetBindInfo,
1574 statusclb_OnDataAvailable,
1575 statusclb_OnObjectAvailable,
1576 statusclb_GetBindInfoEx
1579 static IBindStatusCallbackEx bsc = { &BindStatusCallbackVtbl };
1580 static IBindStatusCallbackEx objbsc = { &BindStatusCallbackVtbl };
1582 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1585 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1586 return E_NOINTERFACE;
1589 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
1594 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
1599 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
1603 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
1604 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val));
1607 CHECK_EXPECT(PutProperty_CLASSIDPROP);
1616 static const IMonikerPropVtbl MonikerPropVtbl = {
1617 MonikerProp_QueryInterface,
1619 MonikerProp_Release,
1620 MonikerProp_PutProperty
1623 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
1625 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
1629 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
1631 else if(IsEqualGUID(&IID_IMonikerProp, riid))
1632 *ppv = &MonikerProp;
1637 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1638 return E_NOINTERFACE;
1641 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
1646 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
1651 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
1653 ok(0, "unexpected call\n");
1657 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
1659 ok(0, "unexpected call\n");
1663 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
1664 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
1669 static WCHAR cbinding_contextW[] =
1670 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1673 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1675 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
1676 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1678 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1679 ok(pimkName != NULL, "pimkName == NULL\n");
1680 ok(pibc != NULL, "pibc == NULL\n");
1681 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
1683 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
1684 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
1685 if(SUCCEEDED(hres)) {
1688 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
1689 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
1691 IBinding_Release(binding);
1692 IUnknown_Release(unk);
1695 SET_EXPECT(QueryInterface_IServiceProvider);
1696 hres = RegisterBindStatusCallback(pibc, (IBindStatusCallback*)&bsc, NULL, 0);
1697 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1698 CHECK_CALLED(QueryInterface_IServiceProvider);
1700 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1701 SET_EXPECT(GetBindInfo);
1702 SET_EXPECT(OnStartBinding);
1703 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1704 if(test_protocol == FILE_TEST)
1705 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1706 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1707 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1708 SET_EXPECT(LockRequest);
1709 SET_EXPECT(OnDataAvailable);
1710 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1711 SET_EXPECT(OnStopBinding);
1713 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
1714 ok(hres == S_OK, "Load failed: %08x\n", hres);
1716 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
1717 CHECK_CALLED(GetBindInfo);
1718 CHECK_CALLED(OnStartBinding);
1719 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1720 if(test_protocol == FILE_TEST)
1721 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1722 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1723 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1724 CHECK_CALLED(LockRequest);
1725 CHECK_CALLED(OnDataAvailable);
1726 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1727 CHECK_CALLED(OnStopBinding);
1730 IUnknown_Release(unk);
1735 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
1737 ok(0, "unexpected call\n");
1741 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
1743 ok(0, "unexpected call\n");
1747 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
1749 ok(0, "unexpected call\n");
1753 static const IPersistMonikerVtbl PersistMonikerVtbl = {
1754 PersistMoniker_QueryInterface,
1755 PersistMoniker_AddRef,
1756 PersistMoniker_Release,
1757 PersistMoniker_GetClassID,
1758 PersistMoniker_IsDirty,
1759 PersistMoniker_Load,
1760 PersistMoniker_Save,
1761 PersistMoniker_SaveCompleted,
1762 PersistMoniker_GetCurMoniker
1765 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
1767 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1771 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1776 if(IsEqualGUID(&IID_IMarshal, riid))
1777 return E_NOINTERFACE;
1778 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1779 return E_NOINTERFACE;
1781 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1785 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1790 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1795 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1797 CHECK_EXPECT(CreateInstance);
1798 ok(!outer, "outer = %p\n", outer);
1799 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1800 *ppv = &PersistMoniker;
1804 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1806 ok(0, "unexpected call\n");
1810 static const IClassFactoryVtbl ClassFactoryVtbl = {
1811 ClassFactory_QueryInterface,
1812 ClassFactory_AddRef,
1813 ClassFactory_Release,
1814 ClassFactory_CreateInstance,
1815 ClassFactory_LockServer
1818 static IClassFactory mime_cf = { &ClassFactoryVtbl };
1820 static void test_CreateAsyncBindCtx(void)
1822 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1828 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1829 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1830 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1832 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1833 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1835 SET_EXPECT(QueryInterface_IServiceProvider);
1836 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
1837 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1838 CHECK_CALLED(QueryInterface_IServiceProvider);
1840 bindopts.cbStruct = sizeof(bindopts);
1841 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1842 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1843 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1844 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1845 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1846 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1848 ok(bindopts.dwTickCountDeadline == 0,
1849 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1851 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1852 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1854 IUnknown_Release(unk);
1856 ref = IBindCtx_Release(bctx);
1857 ok(ref == 0, "bctx should be destroyed here\n");
1860 static void test_CreateAsyncBindCtxEx(void)
1862 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1867 static WCHAR testW[] = {'t','e','s','t',0};
1869 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1870 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1872 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1873 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1875 if(SUCCEEDED(hres)) {
1876 bindopts.cbStruct = sizeof(bindopts);
1877 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1878 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1879 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1880 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1881 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1882 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1884 ok(bindopts.dwTickCountDeadline == 0,
1885 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1887 IBindCtx_Release(bctx);
1890 CreateBindCtx(0, &bctx_arg);
1891 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1892 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1894 if(SUCCEEDED(hres)) {
1895 bindopts.cbStruct = sizeof(bindopts);
1896 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1897 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1898 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1899 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1900 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1901 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1903 ok(bindopts.dwTickCountDeadline == 0,
1904 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1906 IBindCtx_Release(bctx);
1909 IBindCtx_Release(bctx_arg);
1911 SET_EXPECT(QueryInterface_IServiceProvider);
1912 hres = CreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
1913 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1914 CHECK_CALLED(QueryInterface_IServiceProvider);
1916 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1917 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1919 IUnknown_Release(unk);
1921 IBindCtx_Release(bctx);
1923 hres = CreateBindCtx(0, &bctx2);
1924 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1926 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1927 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1929 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1930 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1932 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1933 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1934 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1936 IBindCtx_Release(bctx);
1937 IBindCtx_Release(bctx2);
1940 static void test_GetBindInfoEx(IBindStatusCallback *holder)
1942 IBindStatusCallbackEx *bscex;
1943 BINDINFO bindinfo = {sizeof(bindinfo)};
1944 DWORD bindf, bindf2, dw;
1947 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex);
1949 win_skip("IBindStatusCallbackEx not supported\n");
1956 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1957 SET_EXPECT(GetBindInfoEx);
1958 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo);
1959 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1960 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1961 CHECK_CALLED(GetBindInfoEx);
1963 bindf = bindf2 = dw = 0;
1964 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1965 SET_EXPECT(GetBindInfoEx);
1966 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
1967 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1968 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1969 CHECK_CALLED(GetBindInfoEx);
1973 bindf = bindf2 = dw = 0xdeadbeef;
1974 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1975 SET_EXPECT(GetBindInfo);
1976 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
1977 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1978 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1979 CHECK_CALLED(GetBindInfo);
1980 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2);
1981 ok(dw == 0xdeadbeef, "dw = %x\n", dw);
1983 IBindStatusCallbackEx_Release(bscex);
1986 static BOOL test_bscholder(IBindStatusCallback *holder)
1988 IServiceProvider *serv_prov;
1989 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1990 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1991 IAuthenticate *authenticate, *authenticate_serv;
1992 IInternetProtocol *protocol;
1993 BINDINFO bindinfo = {sizeof(bindinfo)};
1999 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
2000 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
2003 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2004 SET_EXPECT(GetBindInfo);
2005 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
2006 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2007 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2008 CHECK_CALLED(GetBindInfo);
2010 test_GetBindInfoEx(holder);
2012 SET_EXPECT(OnStartBinding);
2013 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
2014 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
2015 CHECK_CALLED(OnStartBinding);
2017 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
2018 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
2020 SET_EXPECT(QueryInterface_IHttpNegotiate);
2021 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2022 (void**)&http_negotiate_serv);
2023 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2024 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
2026 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2028 wstr = (void*)0xdeadbeef;
2029 SET_EXPECT(QueryInterface_IHttpNegotiate);
2030 SET_EXPECT(BeginningTransaction);
2031 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
2032 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2033 CHECK_CALLED(BeginningTransaction);
2034 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
2035 ok(wstr == NULL, "wstr = %p\n", wstr);
2037 IHttpNegotiate_Release(http_negotiate_serv);
2039 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2040 (void**)&http_negotiate_serv);
2041 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2042 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2043 IHttpNegotiate_Release(http_negotiate_serv);
2045 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
2046 if(SUCCEEDED(hres)) {
2047 have_IHttpNegotiate2 = TRUE;
2049 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2050 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
2051 (void**)&http_negotiate2_serv);
2052 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
2053 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
2054 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
2056 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2057 SET_EXPECT(GetRootSecurityId);
2058 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2059 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
2060 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */
2061 CHECK_CALLED(GetRootSecurityId);
2063 IHttpNegotiate_Release(http_negotiate2_serv);
2064 IHttpNegotiate_Release(http_negotiate2);
2066 skip("Could not get IHttpNegotiate2\n");
2070 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2071 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
2072 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
2073 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2075 SET_EXPECT(QueryInterface_IHttpNegotiate);
2076 SET_EXPECT(OnResponse);
2077 wstr = (void*)0xdeadbeef;
2078 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
2079 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
2080 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2081 CHECK_CALLED(OnResponse);
2083 IHttpNegotiate_Release(http_negotiate);
2085 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
2086 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
2088 SET_EXPECT(QueryInterface_IAuthenticate);
2089 SET_EXPECT(QueryService_IAuthenticate);
2090 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2091 (void**)&authenticate_serv);
2092 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2093 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */
2094 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */
2095 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2096 IAuthenticate_Release(authenticate_serv);
2098 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2099 (void**)&authenticate_serv);
2100 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2101 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2103 IAuthenticate_Release(authenticate);
2104 IAuthenticate_Release(authenticate_serv);
2106 SET_EXPECT(OnStopBinding);
2107 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
2108 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
2109 CHECK_CALLED(OnStopBinding);
2111 SET_EXPECT(QueryInterface_IInternetProtocol);
2112 SET_EXPECT(QueryService_IInternetProtocol);
2113 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
2115 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
2116 CHECK_CALLED(QueryInterface_IInternetProtocol);
2117 CHECK_CALLED(QueryService_IInternetProtocol);
2119 IServiceProvider_Release(serv_prov);
2123 static BOOL test_RegisterBindStatusCallback(void)
2125 IBindStatusCallback *prevbsc, *clb;
2131 hres = CreateBindCtx(0, &bindctx);
2132 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
2134 SET_EXPECT(QueryInterface_IServiceProvider);
2136 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
2137 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2139 SET_EXPECT(QueryInterface_IBindStatusCallback);
2140 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
2141 prevbsc = (void*)0xdeadbeef;
2142 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2143 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2144 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc);
2145 CHECK_CALLED(QueryInterface_IBindStatusCallback);
2146 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
2148 CHECK_CALLED(QueryInterface_IServiceProvider);
2150 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2151 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2153 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2154 IUnknown_Release(unk);
2155 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2156 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2158 if(!test_bscholder(clb))
2161 IBindStatusCallback_Release(clb);
2163 hres = RevokeBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc);
2164 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2166 unk = (void*)0xdeadbeef;
2167 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2168 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
2169 ok(unk == NULL, "unk != NULL\n");
2172 IUnknown_Release(unk);
2174 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
2175 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2177 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
2178 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2180 hres = RevokeBindStatusCallback(bindctx, NULL);
2181 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2183 IBindCtx_Release(bindctx);
2187 #define BINDTEST_EMULATE 0x0001
2188 #define BINDTEST_TOOBJECT 0x0002
2189 #define BINDTEST_FILEDWLAPI 0x0004
2190 #define BINDTEST_HTTPRESPONSE 0x0008
2192 static void init_bind_test(int protocol, DWORD flags, DWORD t)
2194 test_protocol = protocol;
2195 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
2196 download_state = BEFORE_DOWNLOAD;
2197 stopped_binding = FALSE;
2198 stopped_obj_binding = FALSE;
2199 data_available = FALSE;
2201 binding_hres = S_OK;
2202 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
2204 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
2205 if(flags & BINDTEST_HTTPRESPONSE)
2206 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
2208 urls[HTTP_TEST] = WINE_ABOUT_URL;
2211 static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
2215 LPOLESTR display_name;
2218 IBindStatusCallback *previousclb;
2219 IUnknown *unk = (IUnknown*)0x00ff00ff;
2222 init_bind_test(protocol, flags, t);
2224 SET_EXPECT(QueryInterface_IServiceProvider);
2225 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2226 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2227 CHECK_CALLED(QueryInterface_IServiceProvider);
2231 SET_EXPECT(QueryInterface_IServiceProvider);
2232 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0);
2233 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2234 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2235 CHECK_CALLED(QueryInterface_IServiceProvider);
2237 IBindStatusCallback_Release(previousclb);
2239 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2240 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2242 IBindCtx_Release(bctx);
2246 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2247 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2249 IBinding_Release(bind);
2251 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2252 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2253 ok(!lstrcmpW(display_name, urls[test_protocol]),
2254 "GetDisplayName got wrong name %s\n", wine_dbgstr_w(display_name));
2255 CoTaskMemFree(display_name);
2257 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2258 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2260 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2261 SET_EXPECT(GetBindInfo);
2262 SET_EXPECT(QueryInterface_IInternetProtocol);
2263 if(!emulate_protocol)
2264 SET_EXPECT(QueryService_IInternetProtocol);
2265 SET_EXPECT(OnStartBinding);
2266 if(emulate_protocol) {
2267 if(is_urlmon_protocol(test_protocol))
2268 SET_EXPECT(SetPriority);
2270 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2271 SET_EXPECT(Terminate);
2272 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2273 SET_EXPECT(UnlockRequest);
2275 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2276 SET_EXPECT(QueryInterface_IInternetBindInfo);
2277 SET_EXPECT(QueryService_IInternetBindInfo);
2278 SET_EXPECT(QueryInterface_IHttpNegotiate);
2279 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2280 SET_EXPECT(QueryService_IWindowForBindingUI);
2281 SET_EXPECT(BeginningTransaction);
2282 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2283 SET_EXPECT(GetRootSecurityId);
2284 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2285 SET_EXPECT(OnProgress_CONNECTING);
2287 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST
2288 || test_protocol == FILE_TEST)
2289 SET_EXPECT(OnProgress_SENDINGREQUEST);
2290 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2291 SET_EXPECT(QueryInterface_IHttpNegotiate);
2292 SET_EXPECT(OnResponse);
2294 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2295 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2296 if(test_protocol == FILE_TEST)
2297 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2298 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST)
2299 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2300 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2301 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2302 SET_EXPECT(OnDataAvailable);
2303 SET_EXPECT(OnStopBinding);
2306 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2307 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2308 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2310 skip("Network unreachable, skipping tests\n");
2314 if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2315 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2316 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2317 ok(unk == NULL, "istr should be NULL\n");
2318 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2319 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2320 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2321 ok(unk == NULL, "istr should be NULL\n");
2323 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2324 ok(unk != NULL, "unk == NULL\n");
2327 IUnknown_Release(unk);
2332 while((bindf & BINDF_ASYNCHRONOUS) &&
2333 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
2334 TranslateMessage(&msg);
2335 DispatchMessage(&msg);
2338 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2339 CHECK_CALLED(GetBindInfo);
2340 CHECK_CALLED(QueryInterface_IInternetProtocol);
2341 if(!emulate_protocol)
2342 CHECK_CALLED(QueryService_IInternetProtocol);
2343 CHECK_CALLED(OnStartBinding);
2344 if(emulate_protocol) {
2345 if(is_urlmon_protocol(test_protocol))
2346 CHECK_CALLED(SetPriority);
2347 CHECK_CALLED(Start);
2348 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2349 if(tymed == TYMED_FILE)
2351 CHECK_CALLED(Terminate);
2353 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2354 CHECK_CALLED(UnlockRequest);
2356 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2357 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2358 CLEAR_CALLED(QueryService_IInternetBindInfo);
2359 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2360 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2361 CLEAR_CALLED(QueryService_IWindowForBindingUI);
2362 CHECK_CALLED(BeginningTransaction);
2363 if (have_IHttpNegotiate2)
2365 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2366 CHECK_CALLED(GetRootSecurityId);
2368 if(http_is_first || test_protocol == HTTPS_TEST) {
2369 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2370 CHECK_CALLED(OnProgress_CONNECTING);
2372 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2373 /* IE7 does call this */
2374 CLEAR_CALLED(OnProgress_CONNECTING);
2377 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2378 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2379 else if(test_protocol == FTP_TEST)
2380 todo_wine CHECK_CALLED(OnProgress_SENDINGREQUEST);
2381 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2382 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2383 CHECK_CALLED(OnResponse);
2385 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2386 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2387 if(test_protocol == FILE_TEST)
2388 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2389 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST)
2390 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2391 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2392 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2393 CHECK_CALLED(OnDataAvailable);
2394 CHECK_CALLED(OnStopBinding);
2397 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2398 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2400 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2401 http_is_first = FALSE;
2404 static void test_BindToObject(int protocol, BOOL emul)
2408 LPOLESTR display_name;
2412 IUnknown *unk = (IUnknown*)0x00ff00ff;
2415 init_bind_test(protocol, BINDTEST_TOOBJECT | (emul ? BINDTEST_EMULATE : 0), TYMED_ISTREAM);
2418 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
2419 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
2421 SET_EXPECT(QueryInterface_IServiceProvider);
2422 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&objbsc, NULL, &bctx);
2423 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
2424 CHECK_CALLED(QueryInterface_IServiceProvider);
2428 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2429 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2431 IBindCtx_Release(bctx);
2435 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2436 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2438 IBinding_Release(bind);
2440 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2441 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2442 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
2444 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2445 SET_EXPECT(Obj_GetBindInfo);
2446 SET_EXPECT(QueryInterface_IInternetProtocol);
2447 if(!emulate_protocol)
2448 SET_EXPECT(QueryService_IInternetProtocol);
2449 SET_EXPECT(Obj_OnStartBinding);
2450 if(emulate_protocol) {
2451 if(is_urlmon_protocol(test_protocol))
2452 SET_EXPECT(SetPriority);
2454 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2455 SET_EXPECT(Terminate);
2456 if(test_protocol == FILE_TEST)
2457 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2458 SET_EXPECT(UnlockRequest);
2460 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2461 SET_EXPECT(QueryInterface_IHttpNegotiate);
2462 SET_EXPECT(BeginningTransaction);
2463 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2464 SET_EXPECT(GetRootSecurityId);
2465 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
2466 SET_EXPECT(Obj_OnProgress_CONNECTING);
2467 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2468 SET_EXPECT(QueryService_IWindowForBindingUI);
2470 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2471 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
2472 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2473 SET_EXPECT(QueryInterface_IHttpNegotiate);
2474 SET_EXPECT(OnResponse);
2476 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
2477 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
2478 if(test_protocol == FILE_TEST)
2479 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2480 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2481 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2482 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
2483 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
2484 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
2485 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
2486 SET_EXPECT(OnObjectAvailable);
2487 SET_EXPECT(Obj_OnStopBinding);
2490 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
2492 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2493 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2495 skip( "Network unreachable, skipping tests\n" );
2499 /* no point testing the calls if binding didn't even work */
2500 if (FAILED(hres)) return;
2502 if(bindf & BINDF_ASYNCHRONOUS) {
2503 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
2504 ok(unk == NULL, "istr should be NULL\n");
2506 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2507 ok(unk != NULL, "unk == NULL\n");
2509 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
2512 IUnknown_Release(unk);
2514 while((bindf & BINDF_ASYNCHRONOUS) &&
2515 !((!emul || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
2516 TranslateMessage(&msg);
2517 DispatchMessage(&msg);
2520 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx);
2521 CHECK_CALLED(Obj_GetBindInfo);
2522 CHECK_CALLED(QueryInterface_IInternetProtocol);
2523 if(!emulate_protocol)
2524 CHECK_CALLED(QueryService_IInternetProtocol);
2525 CHECK_CALLED(Obj_OnStartBinding);
2526 if(emulate_protocol) {
2527 if(is_urlmon_protocol(test_protocol))
2528 CHECK_CALLED(SetPriority);
2529 CHECK_CALLED(Start);
2530 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2531 CHECK_CALLED(Terminate);
2532 if(test_protocol == FILE_TEST)
2533 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
2534 CHECK_CALLED(UnlockRequest);
2536 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2537 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2538 CHECK_CALLED(BeginningTransaction);
2539 if (have_IHttpNegotiate2)
2541 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2542 CHECK_CALLED(GetRootSecurityId);
2545 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2546 CHECK_CALLED(Obj_OnProgress_CONNECTING);
2548 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2549 /* IE7 does call this */
2550 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
2552 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2553 CLEAR_CALLED(QueryService_IWindowForBindingUI);
2555 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) {
2556 if(urls[test_protocol] == SHORT_RESPONSE_URL)
2557 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
2559 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
2561 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2562 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2563 CHECK_CALLED(OnResponse);
2565 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
2566 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
2567 if(test_protocol == FILE_TEST)
2568 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2569 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2570 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2571 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
2572 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
2573 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
2574 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
2575 CHECK_CALLED(OnObjectAvailable);
2576 CHECK_CALLED(Obj_OnStopBinding);
2579 if(test_protocol != HTTP_TEST || emul || !(bindf & BINDF_ASYNCHRONOUS)) {
2580 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2581 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2583 todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2584 IBindCtx_Release(bctx);
2588 CoRevokeClassObject(regid);
2590 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2591 http_is_first = FALSE;
2594 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
2599 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
2601 SET_EXPECT(GetBindInfo);
2602 SET_EXPECT(QueryInterface_IInternetProtocol);
2603 if(!emulate_protocol) {
2604 SET_EXPECT(QueryInterface_IServiceProvider);
2605 SET_EXPECT(QueryService_IInternetProtocol);
2607 SET_EXPECT(OnStartBinding);
2608 if(emulate_protocol) {
2609 if(is_urlmon_protocol(test_protocol))
2610 SET_EXPECT(SetPriority);
2612 SET_EXPECT(UnlockRequest);
2614 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2615 SET_EXPECT(QueryInterface_IHttpNegotiate);
2616 SET_EXPECT(BeginningTransaction);
2617 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2618 SET_EXPECT(GetRootSecurityId);
2619 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2621 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2622 SET_EXPECT(OnProgress_SENDINGREQUEST);
2623 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2624 SET_EXPECT(QueryInterface_IHttpNegotiate);
2625 SET_EXPECT(OnResponse);
2627 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2628 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2629 if(test_protocol == FILE_TEST)
2630 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2631 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2632 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2633 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2634 SET_EXPECT(OnStopBinding);
2637 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol],
2638 dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
2639 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2641 CHECK_CALLED(GetBindInfo);
2642 CHECK_CALLED(QueryInterface_IInternetProtocol);
2643 if(!emulate_protocol) {
2644 CHECK_CALLED(QueryInterface_IServiceProvider);
2645 CHECK_CALLED(QueryService_IInternetProtocol);
2647 CHECK_CALLED(OnStartBinding);
2648 if(emulate_protocol) {
2649 if(is_urlmon_protocol(test_protocol))
2650 CHECK_CALLED(SetPriority);
2651 CHECK_CALLED(Start);
2652 CHECK_CALLED(UnlockRequest);
2654 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2655 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2656 CHECK_CALLED(BeginningTransaction);
2657 if (have_IHttpNegotiate2)
2659 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2660 CHECK_CALLED(GetRootSecurityId);
2662 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2664 if(test_protocol == FILE_TEST)
2665 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2666 else if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2667 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
2668 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2669 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2670 CHECK_CALLED(OnResponse);
2672 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2673 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2674 if(test_protocol == FILE_TEST)
2675 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2676 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2677 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2678 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2679 CHECK_CALLED(OnStopBinding);
2682 res = DeleteFileA(dwl_htmlA);
2683 ok(res, "DeleteFile failed: %u\n", GetLastError());
2685 if(prot != FILE_TEST || emul)
2688 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
2689 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2691 res = DeleteFileA(dwl_htmlA);
2692 ok(res, "DeleteFile failed: %u\n", GetLastError());
2695 static void set_file_url(char *path)
2697 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
2698 CHAR INDEX_HTMLA[MAX_PATH];
2700 lstrcpyA(file_urlA, "file:///");
2701 lstrcatA(file_urlA, path);
2702 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
2704 lstrcpyA(INDEX_HTMLA, "file://");
2705 lstrcatA(INDEX_HTMLA, path);
2706 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
2709 static void create_file(void)
2713 CHAR path[MAX_PATH];
2715 static const char html_doc[] = "<HTML></HTML>";
2717 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2718 FILE_ATTRIBUTE_NORMAL, NULL);
2719 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2720 if(file == INVALID_HANDLE_VALUE)
2723 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2726 GetCurrentDirectoryA(MAX_PATH, path);
2727 lstrcatA(path, "\\");
2728 lstrcatA(path, wszIndexHtmlA);
2732 static void test_ReportResult(HRESULT exhres)
2734 IMoniker *mon = NULL;
2735 IBindCtx *bctx = NULL;
2736 IUnknown *unk = (void*)0xdeadbeef;
2739 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2740 binding_hres = exhres;
2742 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2743 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2745 SET_EXPECT(QueryInterface_IServiceProvider);
2746 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2747 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2748 CHECK_CALLED(QueryInterface_IServiceProvider);
2750 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2751 SET_EXPECT(GetBindInfo);
2752 SET_EXPECT(QueryInterface_IInternetProtocol);
2753 SET_EXPECT(OnStartBinding);
2754 if(is_urlmon_protocol(test_protocol))
2755 SET_EXPECT(SetPriority);
2758 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2759 if(SUCCEEDED(exhres))
2760 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
2762 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
2763 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
2765 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2766 CHECK_CALLED(GetBindInfo);
2767 CHECK_CALLED(QueryInterface_IInternetProtocol);
2768 CHECK_CALLED(OnStartBinding);
2769 if(is_urlmon_protocol(test_protocol))
2770 CHECK_CALLED(SetPriority);
2771 CHECK_CALLED(Start);
2773 ok(unk == NULL, "unk=%p\n", unk);
2775 IBindCtx_Release(bctx);
2776 IMoniker_Release(mon);
2779 static void test_BindToStorage_fail(void)
2781 IMoniker *mon = NULL;
2782 IBindCtx *bctx = NULL;
2786 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2787 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2791 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2792 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2794 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2795 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
2796 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
2798 IBindCtx_Release(bctx);
2800 IMoniker_Release(mon);
2802 test_ReportResult(E_NOTIMPL);
2803 test_ReportResult(S_FALSE);
2806 static void test_StdURLMoniker(void)
2808 IMoniker *mon, *async_mon;
2809 LPOLESTR display_name;
2812 hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2813 &IID_IMoniker, (void**)&mon);
2814 ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres);
2818 hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon);
2819 ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres);
2820 ok(mon == async_mon, "mon != async_mon\n");
2821 IMoniker_Release(async_mon);
2823 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
2824 ok(hres == E_OUTOFMEMORY, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres);
2826 IMoniker_Release(mon);
2831 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2832 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2833 thread_id = GetCurrentThreadId();
2838 trace("test CreateAsyncBindCtx...\n");
2839 test_CreateAsyncBindCtx();
2841 trace("test CreateAsyncBindCtxEx...\n");
2842 test_CreateAsyncBindCtxEx();
2844 trace("test RegisterBindStatusCallback...\n");
2845 if(test_RegisterBindStatusCallback()) {
2846 trace("test BindToStorage failures...\n");
2847 test_BindToStorage_fail();
2849 trace("synchronous http test (COM not initialised)...\n");
2850 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
2854 trace("test StdURLMoniker...\n");
2855 test_StdURLMoniker();
2857 trace("synchronous http test...\n");
2858 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
2860 trace("synchronous http test (to object)...\n");
2861 test_BindToObject(HTTP_TEST, FALSE);
2863 trace("synchronous file test...\n");
2864 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
2866 trace("synchronous file test (to object)...\n");
2867 test_BindToObject(FILE_TEST, FALSE);
2869 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2871 trace("http test...\n");
2872 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
2874 trace("http test (to file)...\n");
2875 test_BindToStorage(HTTP_TEST, 0, TYMED_FILE);
2877 trace("http test (to object)...\n");
2878 test_BindToObject(HTTP_TEST, FALSE);
2880 trace("http test (short response)...\n");
2881 http_is_first = TRUE;
2882 test_BindToStorage(HTTP_TEST, BINDTEST_HTTPRESPONSE, TYMED_ISTREAM);
2884 trace("http test (short response, to object)...\n");
2885 test_BindToObject(HTTP_TEST, FALSE);
2887 trace("emulated http test...\n");
2888 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2890 trace("emulated http test (to object)...\n");
2891 test_BindToObject(HTTP_TEST, TRUE);
2893 trace("emulated http test (to file)...\n");
2894 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
2896 trace("asynchronous https test...\n");
2897 test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
2899 trace("emulated https test...\n");
2900 test_BindToStorage(HTTPS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2902 trace("about test...\n");
2903 test_BindToStorage(ABOUT_TEST, 0, TYMED_ISTREAM);
2905 trace("about test (to file)...\n");
2906 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_FILE);
2908 trace("about test (to object)...\n");
2909 test_BindToObject(ABOUT_TEST, FALSE);
2911 trace("emulated about test...\n");
2912 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2914 trace("emulated about test (to file)...\n");
2915 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_FILE);
2917 trace("emulated about test (to object)...\n");
2918 test_BindToObject(ABOUT_TEST, TRUE);
2920 trace("file test...\n");
2921 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
2923 trace("file test (to file)...\n");
2924 test_BindToStorage(FILE_TEST, 0, TYMED_FILE);
2926 trace("file test (to object)...\n");
2927 test_BindToObject(FILE_TEST, FALSE);
2929 trace("emulated file test...\n");
2930 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2932 trace("emulated file test (to file)...\n");
2933 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
2935 trace("emulated file test (to object)...\n");
2936 test_BindToObject(FILE_TEST, TRUE);
2938 trace("emulated its test...\n");
2939 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2941 trace("emulated its test (to file)...\n");
2942 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_FILE);
2944 trace("emulated mk test...\n");
2945 test_BindToStorage(MK_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2947 trace("test URLDownloadToFile for file protocol...\n");
2948 test_URLDownloadToFile(FILE_TEST, FALSE);
2950 trace("test URLDownloadToFile for emulated file protocol...\n");
2951 test_URLDownloadToFile(FILE_TEST, TRUE);
2953 trace("test URLDownloadToFile for http protocol...\n");
2954 test_URLDownloadToFile(HTTP_TEST, FALSE);
2956 bindf |= BINDF_NOWRITECACHE;
2958 trace("ftp test...\n");
2959 test_BindToStorage(FTP_TEST, 0, TYMED_ISTREAM);
2961 trace("test failures...\n");
2962 test_BindToStorage_fail();
2965 DeleteFileA(wszIndexHtmlA);
2966 CloseHandle(complete_event);
2967 CloseHandle(complete_event2);