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 CLEAR_CALLED(func) \
73 expect_ ## func = called_ ## func = FALSE
75 DEFINE_EXPECT(QueryInterface_IServiceProvider);
76 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
77 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
78 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
79 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
80 DEFINE_EXPECT(QueryInterface_IAuthenticate);
81 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
82 DEFINE_EXPECT(QueryService_IAuthenticate);
83 DEFINE_EXPECT(QueryService_IInternetProtocol);
84 DEFINE_EXPECT(QueryService_IInternetBindInfo);
85 DEFINE_EXPECT(BeginningTransaction);
86 DEFINE_EXPECT(OnResponse);
87 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
88 DEFINE_EXPECT(GetRootSecurityId);
89 DEFINE_EXPECT(GetBindInfo);
90 DEFINE_EXPECT(OnStartBinding);
91 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
92 DEFINE_EXPECT(OnProgress_CONNECTING);
93 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
94 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
95 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
96 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
97 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
98 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
99 DEFINE_EXPECT(OnStopBinding);
100 DEFINE_EXPECT(OnDataAvailable);
101 DEFINE_EXPECT(OnObjectAvailable);
102 DEFINE_EXPECT(Obj_OnStartBinding);
103 DEFINE_EXPECT(Obj_OnStopBinding);
104 DEFINE_EXPECT(Obj_GetBindInfo);
105 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
106 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
107 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
108 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
109 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
110 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
111 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
112 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
113 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
114 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
115 DEFINE_EXPECT(Start);
117 DEFINE_EXPECT(LockRequest);
118 DEFINE_EXPECT(Terminate);
119 DEFINE_EXPECT(UnlockRequest);
120 DEFINE_EXPECT(Continue);
121 DEFINE_EXPECT(CreateInstance);
123 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
124 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
126 static const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
127 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
129 static const WCHAR WINE_ABOUT_URL[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
130 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
131 static const WCHAR SHORT_RESPONSE_URL[] =
132 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
133 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
134 'p','o','s','t','t','e','s','t','.','p','h','p',0};
135 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
136 static WCHAR INDEX_HTML[MAX_PATH];
137 static const WCHAR ITS_URL[] =
138 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
139 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
140 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
142 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
144 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
146 static const WCHAR wszWineHQSite[] =
147 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
148 static const WCHAR wszWineHQIP[] =
149 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
150 static const CHAR wszIndexHtmlA[] = "index.html";
151 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
152 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
153 static const CHAR dwl_htmlA[] = "dwl.html";
154 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
155 static const WCHAR emptyW[] = {0};
157 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
158 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api;
159 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed;
160 static CHAR mime_type[512];
161 static IInternetProtocolSink *protocol_sink = NULL;
162 static HANDLE complete_event, complete_event2;
163 static HRESULT binding_hres;
164 static BOOL have_IHttpNegotiate2;
166 static LPCWSTR urls[] = {
174 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
190 static const char *debugstr_w(LPCWSTR str)
192 static char buf[1024];
193 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
197 static const char *debugstr_guid(REFIID riid)
201 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
202 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
203 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
204 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
209 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
212 IMoniker *mon1 = NULL;
213 IMoniker *mon2 = NULL;
215 hr = CreateURLMoniker(NULL, url1, &mon1);
216 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
218 hr = CreateURLMoniker(mon1, url2, &mon2);
219 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
221 if(mon1) IMoniker_Release(mon1);
222 if(mon2) IMoniker_Release(mon2);
225 static void test_create(void)
227 test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
230 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
232 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
238 return E_NOINTERFACE;
241 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
246 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
251 static DWORD WINAPI thread_proc(PVOID arg)
253 PROTOCOLDATA protocoldata;
257 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
259 SET_EXPECT(OnProgress_FINDINGRESOURCE);
260 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
261 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
262 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
263 WaitForSingleObject(complete_event, INFINITE);
265 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
267 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
270 SET_EXPECT(Obj_OnProgress_CONNECTING);
272 SET_EXPECT(OnProgress_CONNECTING);
273 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
274 BINDSTATUS_CONNECTING, wszWineHQIP);
275 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
276 WaitForSingleObject(complete_event, INFINITE);
278 CHECK_CALLED(Obj_OnProgress_CONNECTING);
280 CHECK_CALLED(OnProgress_CONNECTING);
283 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
285 SET_EXPECT(OnProgress_SENDINGREQUEST);
286 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
287 BINDSTATUS_SENDINGREQUEST, NULL);
288 ok(hres == S_OK, "ReportProxgress failed: %08x\n", hres);
289 WaitForSingleObject(complete_event, INFINITE);
291 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
293 CHECK_CALLED(OnProgress_SENDINGREQUEST);
295 SET_EXPECT(Continue);
297 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
298 ok(hres == S_OK, "Switch failed: %08x\n", hres);
299 WaitForSingleObject(complete_event, INFINITE);
301 CHECK_CALLED(Continue);
304 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
305 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
306 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
307 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
308 CHECK_CALLED(CreateInstance);
309 CHECK_CALLED(PutProperty_MIMETYPEPROP);
310 CLEAR_CALLED(PutProperty_CLASSIDPROP);
312 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
313 CHECK_CALLED(OnObjectAvailable);
314 CHECK_CALLED(Obj_OnStopBinding);
316 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
317 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
318 CHECK_CALLED(LockRequest);
319 CHECK_CALLED(OnDataAvailable);
322 SET_EXPECT(Continue);
324 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
325 ok(hres == S_OK, "Switch failed: %08x\n", hres);
326 WaitForSingleObject(complete_event, INFINITE);
327 CHECK_CALLED(Continue);
329 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
330 CHECK_CALLED(OnDataAvailable);
332 SET_EXPECT(Continue);
334 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
335 ok(hres == S_OK, "Switch failed: %08x\n", hres);
336 WaitForSingleObject(complete_event, INFINITE);
337 CHECK_CALLED(Continue);
339 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
340 CHECK_CALLED(OnDataAvailable);
342 SET_EXPECT(Continue);
344 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
345 ok(hres == S_OK, "Switch failed: %08x\n", hres);
346 WaitForSingleObject(complete_event, INFINITE);
347 CHECK_CALLED(Continue);
349 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
350 CHECK_CALLED(OnDataAvailable);
351 CHECK_CALLED(OnStopBinding);
355 SetEvent(complete_event2);
359 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
360 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
361 DWORD grfPI, DWORD dwReserved)
364 DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
367 static const STGMEDIUM stgmed_zero = {0};
368 static const SECURITY_ATTRIBUTES sa_zero = {0};
374 if(!filedwl_api) /* FIXME */
375 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", debugstr_w(szUrl));
376 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
377 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
378 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
379 ok(dwReserved == 0, "dwReserved=%d, expected 0\n", dwReserved);
381 if(!filedwl_api && binding_hres != S_OK) {
382 SET_EXPECT(OnStopBinding);
383 SET_EXPECT(Terminate);
384 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
385 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
386 CHECK_CALLED(OnStopBinding);
387 CHECK_CALLED(Terminate);
392 memset(&bindinfo, 0, sizeof(bindinfo));
393 bindinfo.cbSize = sizeof(bindinfo);
394 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
395 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
398 ok(bindf == (BINDF_PULLDATA|BINDF_FROMURLMON|BINDF_NEEDFILE), "bindf=%08x\n", bindf);
399 }else if(tymed == TYMED_ISTREAM
400 && (test_protocol == FILE_TEST || test_protocol == MK_TEST || test_protocol == HTTP_TEST)) {
401 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
403 "bindf=%08x\n", bindf);
405 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
406 |BINDF_FROMURLMON|BINDF_NEEDFILE),
407 "bindf=%08x\n", bindf);
410 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
411 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
412 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
413 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
414 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
415 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
416 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
417 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
418 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
419 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
420 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
421 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
422 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
423 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
425 switch(test_protocol) {
427 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
428 BINDSTATUS_DIRECTBIND, NULL);
430 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
435 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
437 SET_EXPECT(OnProgress_SENDINGREQUEST);
438 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
439 BINDSTATUS_SENDINGREQUEST, emptyW);
441 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
443 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
445 CHECK_CALLED(OnProgress_SENDINGREQUEST);
450 if(test_protocol == HTTP_TEST) {
451 IServiceProvider *service_provider;
452 IHttpNegotiate *http_negotiate;
453 IHttpNegotiate2 *http_negotiate2;
454 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
455 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
457 DWORD fetched = 256, size = 100;
460 static const WCHAR wszMimes[] = {'*','/','*',0};
462 SET_EXPECT(QueryInterface_IInternetBindInfo);
463 SET_EXPECT(QueryService_IInternetBindInfo);
464 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
467 CHECK_CALLED(QueryInterface_IInternetBindInfo);
468 CHECK_CALLED(QueryService_IInternetBindInfo);
470 ok(hres == E_NOINTERFACE,
471 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
472 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
473 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
475 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
476 accept_mimes, 256, &fetched);
478 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
479 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
480 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
482 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
483 NULL, 256, &fetched);
484 ok(hres == E_INVALIDARG,
485 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
487 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
488 accept_mimes, 256, NULL);
489 ok(hres == E_INVALIDARG,
490 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
492 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
493 (void**)&service_provider);
494 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
496 SET_EXPECT(QueryInterface_IHttpNegotiate);
497 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
498 &IID_IHttpNegotiate, (void**)&http_negotiate);
499 CHECK_CALLED(QueryInterface_IHttpNegotiate);
500 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
502 SET_EXPECT(BeginningTransaction);
503 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
504 NULL, 0, &additional_headers);
505 CHECK_CALLED(BeginningTransaction);
506 IHttpNegotiate_Release(http_negotiate);
507 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
508 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
510 SET_EXPECT(QueryInterface_IHttpNegotiate2);
511 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
512 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
513 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
514 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
517 SET_EXPECT(GetRootSecurityId);
518 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
519 CHECK_CALLED(GetRootSecurityId);
520 IHttpNegotiate2_Release(http_negotiate2);
521 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
522 ok(size == 13, "size=%d\n", size);
524 IServiceProvider_Release(service_provider);
526 IInternetProtocolSink_AddRef(pOIProtSink);
527 protocol_sink = pOIProtSink;
528 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
533 if(test_protocol == FILE_TEST) {
534 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
535 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
537 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
540 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
542 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
543 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
544 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
546 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
548 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
550 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
552 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
553 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
555 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
558 if(test_protocol == ABOUT_TEST)
559 bscf |= BSCF_DATAFULLYAVAILABLE;
560 if(test_protocol == ITS_TEST)
561 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
565 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
566 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
567 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
568 if(test_protocol == FILE_TEST)
569 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
570 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
571 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
572 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
573 SET_EXPECT(CreateInstance);
574 SET_EXPECT(PutProperty_MIMETYPEPROP);
575 SET_EXPECT(PutProperty_CLASSIDPROP);
577 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
578 SET_EXPECT(OnObjectAvailable);
579 SET_EXPECT(Obj_OnStopBinding);
581 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
582 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
583 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
584 if(test_protocol == FILE_TEST)
585 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
586 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
587 SET_EXPECT(LockRequest);
589 SET_EXPECT(OnDataAvailable);
590 SET_EXPECT(OnStopBinding);
593 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
594 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
598 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
599 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
600 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
601 if(test_protocol == FILE_TEST)
602 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
603 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
604 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
605 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
606 CHECK_CALLED(CreateInstance);
607 CHECK_CALLED(PutProperty_MIMETYPEPROP);
608 CLEAR_CALLED(PutProperty_CLASSIDPROP);
610 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
611 CHECK_CALLED(OnObjectAvailable);
612 CHECK_CALLED(Obj_OnStopBinding);
614 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
615 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
616 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
617 if(test_protocol == FILE_TEST)
618 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
619 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
620 CHECK_CALLED(LockRequest);
622 CHECK_CALLED(OnDataAvailable);
623 CHECK_CALLED(OnStopBinding);
626 if(test_protocol == ITS_TEST) {
628 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
629 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
633 SET_EXPECT(Terminate);
634 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
635 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
636 CHECK_CALLED(Terminate);
641 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
642 PROTOCOLDATA *pProtocolData)
647 CHECK_EXPECT(Continue);
649 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
651 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
657 IServiceProvider *service_provider;
658 IHttpNegotiate *http_negotiate;
659 static WCHAR header[] = {'?',0};
661 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
662 (void**)&service_provider);
663 ok(hres == S_OK, "Could not get IServiceProvicder\n");
665 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
666 &IID_IHttpNegotiate, (void**)&http_negotiate);
667 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
669 SET_EXPECT(OnResponse);
670 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
671 CHECK_CALLED(OnResponse);
672 IHttpNegotiate_Release(http_negotiate);
673 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
675 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
676 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
678 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
680 if(tymed == TYMED_FILE) {
681 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
682 BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_fileW);
684 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
687 bscf |= BSCF_FIRSTDATANOTIFICATION;
692 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
696 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
697 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
703 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
704 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
705 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
706 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
707 SET_EXPECT(CreateInstance);
708 SET_EXPECT(PutProperty_MIMETYPEPROP);
709 SET_EXPECT(PutProperty_CLASSIDPROP);
711 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
712 SET_EXPECT(OnObjectAvailable);
713 SET_EXPECT(Obj_OnStopBinding);
715 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
716 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
717 SET_EXPECT(LockRequest);
721 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
724 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
725 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
727 if(!bind_to_object || prot_state >= 2)
728 SET_EXPECT(OnDataAvailable);
730 SET_EXPECT(OnStopBinding);
735 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
738 ok(0, "unexpected call\n");
742 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
744 CHECK_EXPECT(Terminate);
746 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
749 IInternetProtocolSink_Release(protocol_sink);
750 protocol_sink = NULL;
756 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
758 ok(0, "unexpected call\n");
762 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
764 ok(0, "unexpected call\n");
768 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
769 ULONG cb, ULONG *pcbRead)
771 static const char data[] = "<HTML></HTML>";
775 if(test_protocol == HTTP_TEST) {
778 static BOOL pending = TRUE;
800 hres = IInternetProtocolSink_ReportData(protocol_sink,
801 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
802 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
804 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
805 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
819 ok(pv != NULL, "pv == NULL\n");
820 ok(cb != 0, "cb == 0\n");
821 ok(pcbRead != NULL, "pcbRead == NULL\n");
823 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
824 read += *pcbRead = sizeof(data)-1;
827 memcpy(pv, data, sizeof(data));
832 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
833 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
835 ok(0, "unexpected call\n");
839 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
841 CHECK_EXPECT(LockRequest);
845 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
847 CHECK_EXPECT(UnlockRequest);
851 static const IInternetProtocolVtbl ProtocolVtbl = {
852 Protocol_QueryInterface,
863 Protocol_LockRequest,
864 Protocol_UnlockRequest
867 static IInternetProtocol Protocol = { &ProtocolVtbl };
869 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
871 if(IsEqualGUID(&IID_IUnknown, riid)
872 || IsEqualGUID(&IID_IHttpNegotiate, riid)
873 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
878 ok(0, "unexpected call\n");
879 return E_NOINTERFACE;
882 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
887 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
892 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
893 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
895 CHECK_EXPECT(BeginningTransaction);
897 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
899 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
900 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
901 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
902 if(pszAdditionalHeaders)
903 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
908 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
909 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
911 CHECK_EXPECT(OnResponse);
913 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
915 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
916 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
917 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
918 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
919 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
920 if(pszAdditionalRequestHeaders)
921 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
926 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
927 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
929 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
931 CHECK_EXPECT(GetRootSecurityId);
933 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
935 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
936 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
937 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
939 if(pbSecurityId == (void*)0xdeadbeef)
943 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
944 *pcbSecurityId = sizeof(sec_id);
948 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
953 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
954 HttpNegotiate_QueryInterface,
955 HttpNegotiate_AddRef,
956 HttpNegotiate_Release,
957 HttpNegotiate_BeginningTransaction,
958 HttpNegotiate_OnResponse,
959 HttpNegotiate_GetRootSecurityId
962 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
964 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
966 ok(0, "unexpected call\n");
967 return E_NOINTERFACE;
970 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
975 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
980 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
981 REFGUID guidService, REFIID riid, void **ppv)
983 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
984 CHECK_EXPECT(QueryService_IAuthenticate);
988 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
989 CHECK_EXPECT2(QueryService_IInternetProtocol);
993 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
994 CHECK_EXPECT(QueryService_IInternetBindInfo);
998 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
999 return E_NOINTERFACE;
1002 static IServiceProviderVtbl ServiceProviderVtbl = {
1003 ServiceProvider_QueryInterface,
1004 ServiceProvider_AddRef,
1005 ServiceProvider_Release,
1006 ServiceProvider_QueryService
1009 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1011 static IBindStatusCallback objbsc;
1013 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
1015 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1017 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1018 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1019 if(emulate_protocol) {
1023 return E_NOINTERFACE;
1026 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1028 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1029 *ppv = &ServiceProvider;
1032 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1034 CHECK_EXPECT(QueryInterface_IHttpNegotiate);
1035 *ppv = &HttpNegotiate;
1038 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1040 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1041 *ppv = &HttpNegotiate;
1044 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1046 CHECK_EXPECT(QueryInterface_IAuthenticate);
1047 return E_NOINTERFACE;
1049 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1051 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1055 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1057 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1058 return E_NOINTERFACE;
1060 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1063 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1067 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1070 return E_NOINTERFACE;
1073 static ULONG WINAPI statusclb_AddRef(IBindStatusCallback *iface)
1078 static ULONG WINAPI statusclb_Release(IBindStatusCallback *iface)
1083 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved,
1086 IWinInetHttpInfo *http_info;
1090 if(iface == &objbsc)
1091 CHECK_EXPECT(Obj_OnStartBinding);
1093 CHECK_EXPECT(OnStartBinding);
1095 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1097 ok(pib != NULL, "pib should not be NULL\n");
1098 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1100 if(pib == (void*)0xdeadbeef)
1103 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1104 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1106 IMoniker_Release(mon);
1108 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1109 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1114 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
1116 ok(0, "unexpected call\n");
1120 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
1122 ok(0, "unexpected call\n");
1126 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
1127 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1129 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1131 switch(ulStatusCode) {
1132 case BINDSTATUS_FINDINGRESOURCE:
1133 if(iface == &objbsc)
1134 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1136 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1137 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1138 SetEvent(complete_event);
1140 case BINDSTATUS_CONNECTING:
1141 if(iface == &objbsc)
1142 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1144 CHECK_EXPECT(OnProgress_CONNECTING);
1145 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1146 SetEvent(complete_event);
1148 case BINDSTATUS_SENDINGREQUEST:
1149 if(iface == &objbsc)
1150 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1152 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1153 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1154 SetEvent(complete_event);
1156 case BINDSTATUS_MIMETYPEAVAILABLE:
1157 if(iface == &objbsc)
1158 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1160 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1162 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1164 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1166 case BINDSTATUS_BEGINDOWNLOADDATA:
1167 if(iface == &objbsc)
1168 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1170 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1171 ok(szStatusText != NULL, "szStatusText == NULL\n");
1176 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1180 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1182 download_state = DOWNLOADING;
1184 case BINDSTATUS_DOWNLOADINGDATA:
1185 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1186 if(iface == &objbsc)
1187 todo_wine ok(0, "unexpected call\n");
1188 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1191 case BINDSTATUS_ENDDOWNLOADDATA:
1192 if(iface == &objbsc)
1193 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1195 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1196 ok(szStatusText != NULL, "szStatusText == NULL\n");
1201 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1204 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1206 download_state = END_DOWNLOAD;
1208 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1209 if(test_protocol != HTTP_TEST) {
1210 if(iface == &objbsc)
1211 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1213 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1215 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1216 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1219 ok(szStatusText != NULL, "szStatusText == NULL\n");
1220 if(szStatusText && test_protocol == FILE_TEST)
1221 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1223 case BINDSTATUS_CLASSIDAVAILABLE:
1227 if(iface != &objbsc)
1228 ok(0, "unexpected call\n");
1229 else if(1||emulate_protocol)
1230 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1232 todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1233 hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
1234 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1235 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1236 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1239 case BINDSTATUS_BEGINSYNCOPERATION:
1240 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1241 if(iface != &objbsc)
1242 ok(0, "unexpected call\n");
1243 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1245 case BINDSTATUS_ENDSYNCOPERATION:
1246 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1247 if(iface != &objbsc)
1248 ok(0, "unexpected call\n");
1249 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1251 case BINDSTATUS_PROXYDETECTING:
1252 trace("BINDSTATUS_PROXYDETECTING\n");
1255 ok(0, "unexpected code %d\n", ulStatusCode);
1260 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
1262 if(iface == &objbsc) {
1263 CHECK_EXPECT(Obj_OnStopBinding);
1264 stopped_obj_binding = TRUE;
1266 CHECK_EXPECT(OnStopBinding);
1267 stopped_binding = TRUE;
1270 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1272 /* ignore DNS failure */
1273 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1277 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1279 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1280 ok(szError == NULL, "szError should be NULL\n");
1282 if(test_protocol == HTTP_TEST && emulate_protocol) {
1283 SetEvent(complete_event);
1284 if(iface != &objbsc)
1285 WaitForSingleObject(complete_event2, INFINITE);
1291 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1295 if(iface == &objbsc)
1296 CHECK_EXPECT(Obj_GetBindInfo);
1298 CHECK_EXPECT(GetBindInfo);
1300 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1303 cbSize = pbindinfo->cbSize;
1304 memset(pbindinfo, 0, cbSize);
1305 pbindinfo->cbSize = cbSize;
1310 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
1311 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1318 if(iface == &objbsc)
1319 ok(0, "unexpected call\n");
1321 CHECK_EXPECT2(OnDataAvailable);
1323 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1325 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1326 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1328 data_available = TRUE;
1330 ok(pformatetc != NULL, "pformatetx == NULL\n");
1334 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1335 "GetClipboardFormatName failed, error %d\n", GetLastError());
1336 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1337 pformatetc->cfFormat, clipfmt, mime_type);
1339 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1341 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1342 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1343 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1344 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1347 ok(pstgmed != NULL, "stgmeg == NULL\n");
1348 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1349 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1351 switch(pstgmed->tymed) {
1353 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1354 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1355 ok(hres == STG_E_ACCESSDENIED,
1356 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1358 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1359 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1361 hres = IStream_Revert(U(*pstgmed).pstm);
1362 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1365 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1366 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1367 while(hres == S_OK);
1368 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1372 if(test_protocol == FILE_TEST)
1373 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1374 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1375 else if(emulate_protocol)
1376 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1377 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1379 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1382 if(test_protocol == HTTP_TEST && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1383 SetEvent(complete_event);
1388 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
1390 CHECK_EXPECT(OnObjectAvailable);
1392 if(iface != &objbsc)
1393 ok(0, "unexpected call\n");
1395 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1396 ok(punk != NULL, "punk == NULL\n");
1401 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
1402 statusclb_QueryInterface,
1405 statusclb_OnStartBinding,
1406 statusclb_GetPriority,
1407 statusclb_OnLowResource,
1408 statusclb_OnProgress,
1409 statusclb_OnStopBinding,
1410 statusclb_GetBindInfo,
1411 statusclb_OnDataAvailable,
1412 statusclb_OnObjectAvailable
1415 static IBindStatusCallback bsc = { &BindStatusCallbackVtbl };
1416 static IBindStatusCallback objbsc = { &BindStatusCallbackVtbl };
1418 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1421 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1422 return E_NOINTERFACE;
1425 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
1430 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
1435 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
1439 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
1440 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", debugstr_w(val));
1443 CHECK_EXPECT(PutProperty_CLASSIDPROP);
1452 static const IMonikerPropVtbl MonikerPropVtbl = {
1453 MonikerProp_QueryInterface,
1455 MonikerProp_Release,
1456 MonikerProp_PutProperty
1459 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
1461 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
1465 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
1467 else if(IsEqualGUID(&IID_IMonikerProp, riid))
1468 *ppv = &MonikerProp;
1473 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1474 return E_NOINTERFACE;
1477 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
1482 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
1487 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
1489 ok(0, "unexpected call\n");
1493 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
1495 ok(0, "unexpected call\n");
1499 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
1500 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
1505 static WCHAR cbinding_contextW[] =
1506 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1509 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1511 if(test_protocol == HTTP_TEST)
1512 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1514 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1515 ok(pimkName != NULL, "pimkName == NULL\n");
1516 ok(pibc != NULL, "pibc == NULL\n");
1517 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
1519 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
1520 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
1521 if(SUCCEEDED(hres)) {
1524 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
1525 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
1527 IBinding_Release(binding);
1528 IUnknown_Release(unk);
1531 SET_EXPECT(QueryInterface_IServiceProvider);
1532 hres = RegisterBindStatusCallback(pibc, &bsc, NULL, 0);
1533 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1534 CHECK_CALLED(QueryInterface_IServiceProvider);
1536 SET_EXPECT(GetBindInfo);
1537 SET_EXPECT(OnStartBinding);
1538 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1539 if(test_protocol == FILE_TEST)
1540 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1541 if(test_protocol != HTTP_TEST)
1542 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1543 SET_EXPECT(LockRequest);
1544 SET_EXPECT(OnDataAvailable);
1545 if(test_protocol != HTTP_TEST)
1546 SET_EXPECT(OnStopBinding);
1548 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
1549 ok(hres == S_OK, "Load failed: %08x\n", hres);
1551 CHECK_CALLED(GetBindInfo);
1552 CHECK_CALLED(OnStartBinding);
1553 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1554 if(test_protocol == FILE_TEST)
1555 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1556 if(test_protocol != HTTP_TEST)
1557 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1558 CHECK_CALLED(LockRequest);
1559 CHECK_CALLED(OnDataAvailable);
1560 if(test_protocol != HTTP_TEST)
1561 CHECK_CALLED(OnStopBinding);
1564 IUnknown_Release(unk);
1569 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
1571 ok(0, "unexpected call\n");
1575 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
1577 ok(0, "unexpected call\n");
1581 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
1583 ok(0, "unexpected call\n");
1587 static const IPersistMonikerVtbl PersistMonikerVtbl = {
1588 PersistMoniker_QueryInterface,
1589 PersistMoniker_AddRef,
1590 PersistMoniker_Release,
1591 PersistMoniker_GetClassID,
1592 PersistMoniker_IsDirty,
1593 PersistMoniker_Load,
1594 PersistMoniker_Save,
1595 PersistMoniker_SaveCompleted,
1596 PersistMoniker_GetCurMoniker
1599 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
1601 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1605 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1610 if(IsEqualGUID(&IID_IMarshal, riid))
1611 return E_NOINTERFACE;
1612 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1613 return E_NOINTERFACE;
1615 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1619 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1624 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1629 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1631 CHECK_EXPECT(CreateInstance);
1632 ok(!outer, "outer = %p\n", outer);
1633 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1634 *ppv = &PersistMoniker;
1638 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1640 ok(0, "unexpected call\n");
1644 static const IClassFactoryVtbl ClassFactoryVtbl = {
1645 ClassFactory_QueryInterface,
1646 ClassFactory_AddRef,
1647 ClassFactory_Release,
1648 ClassFactory_CreateInstance,
1649 ClassFactory_LockServer
1652 static IClassFactory mime_cf = { &ClassFactoryVtbl };
1654 static void test_CreateAsyncBindCtx(void)
1656 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1662 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1663 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1664 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1666 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1667 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1669 SET_EXPECT(QueryInterface_IServiceProvider);
1670 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1671 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1672 CHECK_CALLED(QueryInterface_IServiceProvider);
1674 bindopts.cbStruct = sizeof(bindopts);
1675 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1676 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1677 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1678 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1679 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1680 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1682 ok(bindopts.dwTickCountDeadline == 0,
1683 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1685 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1686 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1688 IUnknown_Release(unk);
1690 ref = IBindCtx_Release(bctx);
1691 ok(ref == 0, "bctx should be destroyed here\n");
1694 static void test_CreateAsyncBindCtxEx(void)
1696 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1701 static WCHAR testW[] = {'t','e','s','t',0};
1703 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1704 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1706 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1707 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1709 if(SUCCEEDED(hres)) {
1710 bindopts.cbStruct = sizeof(bindopts);
1711 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1712 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1713 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1714 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1715 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1716 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1718 ok(bindopts.dwTickCountDeadline == 0,
1719 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1721 IBindCtx_Release(bctx);
1724 CreateBindCtx(0, &bctx_arg);
1725 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1726 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1728 if(SUCCEEDED(hres)) {
1729 bindopts.cbStruct = sizeof(bindopts);
1730 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1731 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1732 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1733 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1734 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1735 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1737 ok(bindopts.dwTickCountDeadline == 0,
1738 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1740 IBindCtx_Release(bctx);
1743 IBindCtx_Release(bctx_arg);
1745 SET_EXPECT(QueryInterface_IServiceProvider);
1746 hres = CreateAsyncBindCtxEx(NULL, 0, &bsc, NULL, &bctx, 0);
1747 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1748 CHECK_CALLED(QueryInterface_IServiceProvider);
1750 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1751 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1753 IUnknown_Release(unk);
1755 IBindCtx_Release(bctx);
1757 hres = CreateBindCtx(0, &bctx2);
1758 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1760 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1761 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1763 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1764 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1766 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1767 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1768 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1770 IBindCtx_Release(bctx);
1771 IBindCtx_Release(bctx2);
1774 static BOOL test_bscholder(IBindStatusCallback *holder)
1776 IServiceProvider *serv_prov;
1777 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1778 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1779 IAuthenticate *authenticate, *authenticate_serv;
1780 IInternetProtocol *protocol;
1781 BINDINFO bindinfo = {sizeof(bindinfo)};
1787 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
1788 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
1791 SET_EXPECT(GetBindInfo);
1792 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
1793 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1794 CHECK_CALLED(GetBindInfo);
1796 SET_EXPECT(OnStartBinding);
1797 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
1798 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1799 CHECK_CALLED(OnStartBinding);
1801 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
1802 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
1804 wstr = (void*)0xdeadbeef;
1805 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol], (void*)0xdeadbeef, 0xff, &wstr);
1806 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1807 ok(wstr == NULL, "wstr = %p\n", wstr);
1809 SET_EXPECT(QueryInterface_IHttpNegotiate);
1810 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1811 (void**)&http_negotiate_serv);
1812 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1813 CHECK_CALLED(QueryInterface_IHttpNegotiate);
1815 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1817 wstr = (void*)0xdeadbeef;
1818 SET_EXPECT(BeginningTransaction);
1819 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
1820 CHECK_CALLED(BeginningTransaction);
1821 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1822 ok(wstr == NULL, "wstr = %p\n", wstr);
1824 IHttpNegotiate_Release(http_negotiate_serv);
1826 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1827 (void**)&http_negotiate_serv);
1828 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1829 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1830 IHttpNegotiate_Release(http_negotiate_serv);
1832 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
1833 if(SUCCEEDED(hres)) {
1834 have_IHttpNegotiate2 = TRUE;
1835 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1836 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x\n", hres);
1838 SET_EXPECT(QueryInterface_IHttpNegotiate2);
1839 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
1840 (void**)&http_negotiate2_serv);
1841 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
1842 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
1843 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
1845 SET_EXPECT(GetRootSecurityId);
1846 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1847 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
1848 CHECK_CALLED(GetRootSecurityId);
1850 IHttpNegotiate_Release(http_negotiate2_serv);
1851 IHttpNegotiate_Release(http_negotiate2);
1853 skip("Could not get IHttpNegotiate2\n");
1857 SET_EXPECT(OnProgress_FINDINGRESOURCE);
1858 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
1859 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
1860 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
1862 SET_EXPECT(OnResponse);
1863 wstr = (void*)0xdeadbeef;
1864 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
1865 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
1866 CHECK_CALLED(OnResponse);
1868 IHttpNegotiate_Release(http_negotiate);
1870 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
1871 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
1873 SET_EXPECT(QueryInterface_IAuthenticate);
1874 SET_EXPECT(QueryService_IAuthenticate);
1875 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1876 (void**)&authenticate_serv);
1877 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1878 CHECK_CALLED(QueryInterface_IAuthenticate);
1879 CHECK_CALLED(QueryService_IAuthenticate);
1880 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1881 IAuthenticate_Release(authenticate_serv);
1883 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1884 (void**)&authenticate_serv);
1885 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1886 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1888 IAuthenticate_Release(authenticate);
1889 IAuthenticate_Release(authenticate_serv);
1891 SET_EXPECT(OnStopBinding);
1892 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
1893 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1894 CHECK_CALLED(OnStopBinding);
1896 SET_EXPECT(QueryInterface_IInternetProtocol);
1897 SET_EXPECT(QueryService_IInternetProtocol);
1898 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
1900 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
1901 CHECK_CALLED(QueryInterface_IInternetProtocol);
1902 CHECK_CALLED(QueryService_IInternetProtocol);
1904 IServiceProvider_Release(serv_prov);
1908 static BOOL test_RegisterBindStatusCallback(void)
1910 IBindStatusCallback *prevbsc, *clb;
1916 hres = CreateBindCtx(0, &bindctx);
1917 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
1919 SET_EXPECT(QueryInterface_IServiceProvider);
1921 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
1922 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1924 SET_EXPECT(QueryInterface_IBindStatusCallback);
1925 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
1926 prevbsc = (void*)0xdeadbeef;
1927 hres = RegisterBindStatusCallback(bindctx, &bsc, &prevbsc, 0);
1928 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1929 ok(prevbsc == &bsc, "prevbsc=%p\n", prevbsc);
1930 CHECK_CALLED(QueryInterface_IBindStatusCallback);
1931 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
1933 CHECK_CALLED(QueryInterface_IServiceProvider);
1935 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1936 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1938 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
1939 IUnknown_Release(unk);
1940 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
1941 ok(clb != &bsc, "bsc == clb\n");
1943 if(!test_bscholder(clb))
1946 IBindStatusCallback_Release(clb);
1948 hres = RevokeBindStatusCallback(bindctx, &bsc);
1949 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1951 unk = (void*)0xdeadbeef;
1952 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1953 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
1954 ok(unk == NULL, "unk != NULL\n");
1957 IUnknown_Release(unk);
1959 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
1960 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1962 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
1963 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1965 hres = RevokeBindStatusCallback(bindctx, NULL);
1966 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1968 IBindCtx_Release(bindctx);
1972 #define BINDTEST_EMULATE 1
1973 #define BINDTEST_TOOBJECT 2
1974 #define BINDTEST_FILEDWLAPI 4
1976 static void init_bind_test(int protocol, DWORD flags, DWORD t)
1978 test_protocol = protocol;
1979 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
1980 download_state = BEFORE_DOWNLOAD;
1981 stopped_binding = FALSE;
1982 stopped_obj_binding = FALSE;
1983 data_available = FALSE;
1985 binding_hres = S_OK;
1986 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
1988 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
1991 static void test_BindToStorage(int protocol, BOOL emul, DWORD t)
1995 LPOLESTR display_name;
1998 IBindStatusCallback *previousclb;
1999 IUnknown *unk = (IUnknown*)0x00ff00ff;
2002 init_bind_test(protocol, emul ? BINDTEST_EMULATE : 0, t);
2004 SET_EXPECT(QueryInterface_IServiceProvider);
2005 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
2006 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2007 CHECK_CALLED(QueryInterface_IServiceProvider);
2011 SET_EXPECT(QueryInterface_IServiceProvider);
2012 hres = RegisterBindStatusCallback(bctx, &bsc, &previousclb, 0);
2013 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2014 ok(previousclb == &bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2015 CHECK_CALLED(QueryInterface_IServiceProvider);
2017 IBindStatusCallback_Release(previousclb);
2019 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2020 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2022 IBindCtx_Release(bctx);
2026 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2027 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2029 IBinding_Release(bind);
2031 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2032 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2033 ok(!lstrcmpW(display_name, urls[test_protocol]),
2034 "GetDisplayName got wrong name %s\n", debugstr_w(display_name));
2035 CoTaskMemFree(display_name);
2037 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2038 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2040 SET_EXPECT(GetBindInfo);
2041 SET_EXPECT(QueryInterface_IInternetProtocol);
2042 if(!emulate_protocol)
2043 SET_EXPECT(QueryService_IInternetProtocol);
2044 SET_EXPECT(OnStartBinding);
2045 if(emulate_protocol) {
2047 if(test_protocol == HTTP_TEST)
2048 SET_EXPECT(Terminate);
2049 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2050 SET_EXPECT(UnlockRequest);
2052 if(test_protocol == HTTP_TEST) {
2053 SET_EXPECT(QueryInterface_IInternetBindInfo);
2054 SET_EXPECT(QueryService_IInternetBindInfo);
2055 SET_EXPECT(QueryInterface_IHttpNegotiate);
2056 SET_EXPECT(BeginningTransaction);
2057 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2058 SET_EXPECT(GetRootSecurityId);
2059 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2060 SET_EXPECT(OnProgress_CONNECTING);
2062 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2063 SET_EXPECT(OnProgress_SENDINGREQUEST);
2064 if(test_protocol == HTTP_TEST)
2065 SET_EXPECT(OnResponse);
2066 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2067 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2068 if(test_protocol == FILE_TEST)
2069 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2070 if(test_protocol == HTTP_TEST)
2071 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2072 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2073 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2074 SET_EXPECT(OnDataAvailable);
2075 SET_EXPECT(OnStopBinding);
2078 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2079 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2081 skip("Network unreachable, skipping tests\n");
2085 if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2086 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2087 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2088 ok(unk == NULL, "istr should be NULL\n");
2089 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2090 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2091 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2092 ok(unk == NULL, "istr should be NULL\n");
2094 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2095 ok(unk != NULL, "unk == NULL\n");
2098 IUnknown_Release(unk);
2103 while((bindf & BINDF_ASYNCHRONOUS) &&
2104 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
2105 TranslateMessage(&msg);
2106 DispatchMessage(&msg);
2109 CHECK_CALLED(GetBindInfo);
2110 CHECK_CALLED(QueryInterface_IInternetProtocol);
2111 if(!emulate_protocol)
2112 CHECK_CALLED(QueryService_IInternetProtocol);
2113 CHECK_CALLED(OnStartBinding);
2114 if(emulate_protocol) {
2115 CHECK_CALLED(Start);
2116 if(test_protocol == HTTP_TEST) {
2117 if(tymed == TYMED_FILE)
2119 CHECK_CALLED(Terminate);
2121 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2122 CHECK_CALLED(UnlockRequest);
2124 if(test_protocol == HTTP_TEST) {
2125 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2126 CLEAR_CALLED(QueryService_IInternetBindInfo);
2127 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2128 CHECK_CALLED(BeginningTransaction);
2129 if (have_IHttpNegotiate2)
2131 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2132 CHECK_CALLED(GetRootSecurityId);
2135 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2136 CHECK_CALLED(OnProgress_CONNECTING);
2138 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2139 /* IE7 does call this */
2140 CLEAR_CALLED(OnProgress_CONNECTING);
2143 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2144 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2145 if(test_protocol == HTTP_TEST)
2146 CHECK_CALLED(OnResponse);
2147 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2148 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2149 if(test_protocol == FILE_TEST)
2150 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2151 if(test_protocol == HTTP_TEST)
2152 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2153 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2154 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2155 CHECK_CALLED(OnDataAvailable);
2156 CHECK_CALLED(OnStopBinding);
2159 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2160 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2162 if(test_protocol == HTTP_TEST)
2163 http_is_first = FALSE;
2166 static void test_BindToObject(int protocol, BOOL emul)
2170 LPOLESTR display_name;
2174 IUnknown *unk = (IUnknown*)0x00ff00ff;
2177 init_bind_test(protocol, BINDTEST_TOOBJECT | (emul ? BINDTEST_EMULATE : 0), TYMED_ISTREAM);
2180 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
2181 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
2183 SET_EXPECT(QueryInterface_IServiceProvider);
2184 hres = CreateAsyncBindCtx(0, &objbsc, NULL, &bctx);
2185 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
2186 CHECK_CALLED(QueryInterface_IServiceProvider);
2190 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2191 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2193 IBindCtx_Release(bctx);
2197 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2198 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2200 IBinding_Release(bind);
2202 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2203 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2204 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
2206 SET_EXPECT(Obj_GetBindInfo);
2207 SET_EXPECT(QueryInterface_IInternetProtocol);
2208 if(!emulate_protocol)
2209 SET_EXPECT(QueryService_IInternetProtocol);
2210 SET_EXPECT(Obj_OnStartBinding);
2211 if(emulate_protocol) {
2213 if(test_protocol == HTTP_TEST)
2214 SET_EXPECT(Terminate);
2215 if(test_protocol == FILE_TEST)
2216 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2217 SET_EXPECT(UnlockRequest);
2219 if(test_protocol == HTTP_TEST) {
2220 SET_EXPECT(QueryInterface_IHttpNegotiate);
2221 SET_EXPECT(BeginningTransaction);
2222 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2223 SET_EXPECT(GetRootSecurityId);
2224 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
2225 SET_EXPECT(Obj_OnProgress_CONNECTING);
2227 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2228 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
2229 if(test_protocol == HTTP_TEST)
2230 SET_EXPECT(OnResponse);
2231 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
2232 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
2233 if(test_protocol == FILE_TEST)
2234 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2235 if(test_protocol == HTTP_TEST)
2236 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2237 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
2238 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
2239 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
2240 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
2241 SET_EXPECT(OnObjectAvailable);
2242 SET_EXPECT(Obj_OnStopBinding);
2245 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
2247 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2249 skip( "Network unreachable, skipping tests\n" );
2253 /* no point testing the calls if binding didn't even work */
2254 if (FAILED(hres)) return;
2256 if(bindf & BINDF_ASYNCHRONOUS) {
2257 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
2258 ok(unk == NULL, "istr should be NULL\n");
2260 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2261 ok(unk != NULL, "unk == NULL\n");
2263 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
2266 IUnknown_Release(unk);
2268 while((bindf & BINDF_ASYNCHRONOUS) &&
2269 !((!emul || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
2270 TranslateMessage(&msg);
2271 DispatchMessage(&msg);
2274 CHECK_CALLED(Obj_GetBindInfo);
2275 CHECK_CALLED(QueryInterface_IInternetProtocol);
2276 if(!emulate_protocol)
2277 CHECK_CALLED(QueryService_IInternetProtocol);
2278 CHECK_CALLED(Obj_OnStartBinding);
2279 if(emulate_protocol) {
2280 CHECK_CALLED(Start);
2281 if(test_protocol == HTTP_TEST)
2282 CHECK_CALLED(Terminate);
2283 if(test_protocol == FILE_TEST)
2284 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
2285 CHECK_CALLED(UnlockRequest);
2287 if(test_protocol == HTTP_TEST) {
2288 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2289 CHECK_CALLED(BeginningTransaction);
2290 if (have_IHttpNegotiate2)
2292 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2293 CHECK_CALLED(GetRootSecurityId);
2296 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2297 CHECK_CALLED(Obj_OnProgress_CONNECTING);
2299 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2300 /* IE7 does call this */
2301 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
2304 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST) {
2305 if(urls[test_protocol] == SHORT_RESPONSE_URL)
2306 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
2308 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
2310 if(test_protocol == HTTP_TEST)
2311 CHECK_CALLED(OnResponse);
2312 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
2313 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
2314 if(test_protocol == FILE_TEST)
2315 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2316 if(test_protocol == HTTP_TEST)
2317 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2318 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
2319 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
2320 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
2321 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
2322 CHECK_CALLED(OnObjectAvailable);
2323 CHECK_CALLED(Obj_OnStopBinding);
2326 if(test_protocol != HTTP_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL) {
2327 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2328 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2330 todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2332 if(bindf & BINDF_ASYNCHRONOUS)
2333 IBindCtx_Release(bctx);
2335 todo_wine ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2339 CoRevokeClassObject(regid);
2341 if(test_protocol == HTTP_TEST)
2342 http_is_first = FALSE;
2345 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
2350 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
2352 SET_EXPECT(GetBindInfo);
2353 SET_EXPECT(QueryInterface_IInternetProtocol);
2354 if(!emulate_protocol) {
2355 SET_EXPECT(QueryInterface_IServiceProvider);
2356 SET_EXPECT(QueryService_IInternetProtocol);
2358 SET_EXPECT(OnStartBinding);
2359 if(emulate_protocol) {
2361 SET_EXPECT(UnlockRequest);
2363 if(test_protocol == HTTP_TEST) {
2364 SET_EXPECT(QueryInterface_IHttpNegotiate);
2365 SET_EXPECT(BeginningTransaction);
2366 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2367 SET_EXPECT(GetRootSecurityId);
2369 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2370 SET_EXPECT(OnProgress_SENDINGREQUEST);
2371 if(test_protocol == HTTP_TEST)
2372 SET_EXPECT(OnResponse);
2373 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2374 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2375 if(test_protocol == FILE_TEST)
2376 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2377 if(test_protocol == HTTP_TEST)
2378 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2379 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2380 SET_EXPECT(OnStopBinding);
2383 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], dwl_htmlW, 0, &bsc);
2384 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2386 CHECK_CALLED(GetBindInfo);
2387 CHECK_CALLED(QueryInterface_IInternetProtocol);
2388 if(!emulate_protocol) {
2389 CHECK_CALLED(QueryInterface_IServiceProvider);
2390 CHECK_CALLED(QueryService_IInternetProtocol);
2392 CHECK_CALLED(OnStartBinding);
2393 if(emulate_protocol) {
2394 CHECK_CALLED(Start);
2395 CHECK_CALLED(UnlockRequest);
2397 if(test_protocol == HTTP_TEST) {
2398 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2399 CHECK_CALLED(BeginningTransaction);
2400 if (have_IHttpNegotiate2)
2402 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2403 CHECK_CALLED(GetRootSecurityId);
2406 if(test_protocol == FILE_TEST)
2407 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2408 else if(test_protocol == HTTP_TEST)
2409 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
2410 if(test_protocol == HTTP_TEST)
2411 CHECK_CALLED(OnResponse);
2412 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2413 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2414 if(test_protocol == FILE_TEST)
2415 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2416 if(test_protocol == HTTP_TEST)
2417 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2418 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2419 CHECK_CALLED(OnStopBinding);
2422 res = DeleteFileA(dwl_htmlA);
2423 ok(res, "DeleteFile failed: %u\n", GetLastError());
2425 if(prot != FILE_TEST || emul)
2428 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
2429 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2431 res = DeleteFileA(dwl_htmlA);
2432 ok(res, "DeleteFile failed: %u\n", GetLastError());
2435 static void set_file_url(char *path)
2437 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
2438 CHAR INDEX_HTMLA[MAX_PATH];
2440 lstrcpyA(file_urlA, "file:///");
2441 lstrcatA(file_urlA, path);
2442 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
2444 lstrcpyA(INDEX_HTMLA, "file://");
2445 lstrcatA(INDEX_HTMLA, path);
2446 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
2449 static void create_file(void)
2453 CHAR path[MAX_PATH];
2455 static const char html_doc[] = "<HTML></HTML>";
2457 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2458 FILE_ATTRIBUTE_NORMAL, NULL);
2459 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2460 if(file == INVALID_HANDLE_VALUE)
2463 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2466 GetCurrentDirectoryA(MAX_PATH, path);
2467 lstrcatA(path, "\\");
2468 lstrcatA(path, wszIndexHtmlA);
2472 static void test_ReportResult(HRESULT exhres)
2474 IMoniker *mon = NULL;
2475 IBindCtx *bctx = NULL;
2476 IUnknown *unk = (void*)0xdeadbeef;
2479 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2480 binding_hres = exhres;
2482 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2483 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2485 SET_EXPECT(QueryInterface_IServiceProvider);
2486 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
2487 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2488 CHECK_CALLED(QueryInterface_IServiceProvider);
2490 SET_EXPECT(GetBindInfo);
2491 SET_EXPECT(QueryInterface_IInternetProtocol);
2492 SET_EXPECT(OnStartBinding);
2495 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2496 if(SUCCEEDED(exhres))
2497 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
2499 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
2500 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
2502 CHECK_CALLED(GetBindInfo);
2503 CHECK_CALLED(QueryInterface_IInternetProtocol);
2504 CHECK_CALLED(OnStartBinding);
2505 CHECK_CALLED(Start);
2507 ok(unk == NULL, "unk=%p\n", unk);
2509 IBindCtx_Release(bctx);
2510 IMoniker_Release(mon);
2513 static void test_BindToStorage_fail(void)
2515 IMoniker *mon = NULL;
2516 IBindCtx *bctx = NULL;
2520 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2521 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2525 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2526 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2528 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2529 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
2530 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
2532 IBindCtx_Release(bctx);
2534 IMoniker_Release(mon);
2536 test_ReportResult(E_NOTIMPL);
2537 test_ReportResult(S_FALSE);
2540 static void gecko_installer_workaround(BOOL disable)
2545 static BOOL has_url = FALSE;
2546 static char url[2048];
2548 if(!disable && !has_url)
2551 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
2552 if(res != ERROR_SUCCESS)
2556 DWORD type, size = sizeof(url);
2558 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
2559 if(res == ERROR_SUCCESS && type == REG_SZ)
2562 RegDeleteValue(hkey, "GeckoUrl");
2564 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
2572 gecko_installer_workaround(TRUE);
2574 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2575 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2576 thread_id = GetCurrentThreadId();
2580 test_CreateAsyncBindCtx();
2581 test_CreateAsyncBindCtxEx();
2583 if(!test_RegisterBindStatusCallback()) {
2584 test_BindToStorage_fail();
2586 trace("synchronous http test (COM not initialised)...\n");
2587 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2591 trace("synchronous http test...\n");
2592 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2594 trace("synchronous http test (to object)...\n");
2595 test_BindToObject(HTTP_TEST, FALSE);
2597 trace("synchronous file test...\n");
2598 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2600 trace("synchronous file test (to object)...\n");
2601 test_BindToObject(FILE_TEST, FALSE);
2603 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2605 trace("http test...\n");
2606 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2608 trace("http test (to file)...\n");
2609 test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE);
2611 trace("http test (to object)...\n");
2612 test_BindToObject(HTTP_TEST, FALSE);
2614 trace("http test (short response)...\n");
2615 http_is_first = TRUE;
2616 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
2617 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2619 trace("http test (short response, to object)...\n");
2620 test_BindToObject(HTTP_TEST, FALSE);
2622 trace("emulated http test...\n");
2623 test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM);
2625 trace("emulated http test (to object)...\n");
2626 test_BindToObject(HTTP_TEST, TRUE);
2628 trace("emulated http test (to file)...\n");
2629 test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE);
2631 trace("about test...\n");
2632 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM);
2634 trace("about test (to file)...\n");
2635 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE);
2637 trace("about test (to object)...\n");
2638 test_BindToObject(ABOUT_TEST, FALSE);
2640 trace("emulated about test...\n");
2641 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM);
2643 trace("emulated about test (to file)...\n");
2644 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE);
2646 trace("emulated about test (to object)...\n");
2647 test_BindToObject(ABOUT_TEST, TRUE);
2649 trace("file test...\n");
2650 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2652 trace("file test (to file)...\n");
2653 test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE);
2655 trace("file test (to object)...\n");
2656 test_BindToObject(FILE_TEST, FALSE);
2658 trace("emulated file test...\n");
2659 test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM);
2661 trace("emulated file test (to file)...\n");
2662 test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE);
2664 trace("emulated file test (to object)...\n");
2665 test_BindToObject(FILE_TEST, TRUE);
2667 trace("emulated its test...\n");
2668 test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM);
2670 trace("emulated its test (to file)...\n");
2671 test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE);
2673 trace("emulated mk test...\n");
2674 test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM);
2676 trace("test URLDownloadToFile for file protocol...\n");
2677 test_URLDownloadToFile(FILE_TEST, FALSE);
2679 trace("test URLDownloadToFile for emulated file protocol...\n");
2680 test_URLDownloadToFile(FILE_TEST, TRUE);
2682 trace("test URLDownloadToFile for http protocol...\n");
2683 test_URLDownloadToFile(HTTP_TEST, FALSE);
2685 trace("test failures...\n");
2686 test_BindToStorage_fail();
2689 DeleteFileA(wszIndexHtmlA);
2690 CloseHandle(complete_event);
2691 CloseHandle(complete_event2);
2694 gecko_installer_workaround(FALSE);