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");
1252 ok(0, "unexpected code %d\n", ulStatusCode);
1257 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
1259 if(iface == &objbsc) {
1260 CHECK_EXPECT(Obj_OnStopBinding);
1261 stopped_obj_binding = TRUE;
1263 CHECK_EXPECT(OnStopBinding);
1264 stopped_binding = TRUE;
1267 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1269 /* ignore DNS failure */
1270 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1274 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1276 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1277 ok(szError == NULL, "szError should be NULL\n");
1279 if(test_protocol == HTTP_TEST && emulate_protocol) {
1280 SetEvent(complete_event);
1281 if(iface != &objbsc)
1282 WaitForSingleObject(complete_event2, INFINITE);
1288 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1292 if(iface == &objbsc)
1293 CHECK_EXPECT(Obj_GetBindInfo);
1295 CHECK_EXPECT(GetBindInfo);
1297 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1300 cbSize = pbindinfo->cbSize;
1301 memset(pbindinfo, 0, cbSize);
1302 pbindinfo->cbSize = cbSize;
1307 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
1308 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1315 if(iface == &objbsc)
1316 ok(0, "unexpected call\n");
1318 CHECK_EXPECT2(OnDataAvailable);
1320 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1322 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1323 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1325 data_available = TRUE;
1327 ok(pformatetc != NULL, "pformatetx == NULL\n");
1331 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1332 "GetClipboardFormatName failed, error %d\n", GetLastError());
1333 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1334 pformatetc->cfFormat, clipfmt, mime_type);
1336 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1338 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1339 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1340 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1341 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1344 ok(pstgmed != NULL, "stgmeg == NULL\n");
1345 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1346 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1348 switch(pstgmed->tymed) {
1350 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1351 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1352 ok(hres == STG_E_ACCESSDENIED,
1353 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1355 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1356 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1358 hres = IStream_Revert(U(*pstgmed).pstm);
1359 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1362 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1363 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1364 while(hres == S_OK);
1365 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1369 if(test_protocol == FILE_TEST)
1370 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1371 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1372 else if(emulate_protocol)
1373 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1374 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1376 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1379 if(test_protocol == HTTP_TEST && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1380 SetEvent(complete_event);
1385 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
1387 CHECK_EXPECT(OnObjectAvailable);
1389 if(iface != &objbsc)
1390 ok(0, "unexpected call\n");
1392 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1393 ok(punk != NULL, "punk == NULL\n");
1398 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
1399 statusclb_QueryInterface,
1402 statusclb_OnStartBinding,
1403 statusclb_GetPriority,
1404 statusclb_OnLowResource,
1405 statusclb_OnProgress,
1406 statusclb_OnStopBinding,
1407 statusclb_GetBindInfo,
1408 statusclb_OnDataAvailable,
1409 statusclb_OnObjectAvailable
1412 static IBindStatusCallback bsc = { &BindStatusCallbackVtbl };
1413 static IBindStatusCallback objbsc = { &BindStatusCallbackVtbl };
1415 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1418 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1419 return E_NOINTERFACE;
1422 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
1427 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
1432 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
1436 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
1437 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", debugstr_w(val));
1440 CHECK_EXPECT(PutProperty_CLASSIDPROP);
1449 static const IMonikerPropVtbl MonikerPropVtbl = {
1450 MonikerProp_QueryInterface,
1452 MonikerProp_Release,
1453 MonikerProp_PutProperty
1456 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
1458 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
1462 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
1464 else if(IsEqualGUID(&IID_IMonikerProp, riid))
1465 *ppv = &MonikerProp;
1470 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1471 return E_NOINTERFACE;
1474 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
1479 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
1484 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
1486 ok(0, "unexpected call\n");
1490 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
1492 ok(0, "unexpected call\n");
1496 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
1497 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
1502 static WCHAR cbinding_contextW[] =
1503 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1506 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1508 if(test_protocol == HTTP_TEST)
1509 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1511 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1512 ok(pimkName != NULL, "pimkName == NULL\n");
1513 ok(pibc != NULL, "pibc == NULL\n");
1514 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
1516 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
1517 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
1518 if(SUCCEEDED(hres)) {
1521 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
1522 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
1524 IBinding_Release(binding);
1525 IUnknown_Release(unk);
1528 SET_EXPECT(QueryInterface_IServiceProvider);
1529 hres = RegisterBindStatusCallback(pibc, &bsc, NULL, 0);
1530 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1531 CHECK_CALLED(QueryInterface_IServiceProvider);
1533 SET_EXPECT(GetBindInfo);
1534 SET_EXPECT(OnStartBinding);
1535 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1536 if(test_protocol == FILE_TEST)
1537 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1538 if(test_protocol != HTTP_TEST)
1539 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1540 SET_EXPECT(LockRequest);
1541 SET_EXPECT(OnDataAvailable);
1542 if(test_protocol != HTTP_TEST)
1543 SET_EXPECT(OnStopBinding);
1545 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
1546 ok(hres == S_OK, "Load failed: %08x\n", hres);
1548 CHECK_CALLED(GetBindInfo);
1549 CHECK_CALLED(OnStartBinding);
1550 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1551 if(test_protocol == FILE_TEST)
1552 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1553 if(test_protocol != HTTP_TEST)
1554 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1555 CHECK_CALLED(LockRequest);
1556 CHECK_CALLED(OnDataAvailable);
1557 if(test_protocol != HTTP_TEST)
1558 CHECK_CALLED(OnStopBinding);
1561 IUnknown_Release(unk);
1566 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
1568 ok(0, "unexpected call\n");
1572 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
1574 ok(0, "unexpected call\n");
1578 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
1580 ok(0, "unexpected call\n");
1584 static const IPersistMonikerVtbl PersistMonikerVtbl = {
1585 PersistMoniker_QueryInterface,
1586 PersistMoniker_AddRef,
1587 PersistMoniker_Release,
1588 PersistMoniker_GetClassID,
1589 PersistMoniker_IsDirty,
1590 PersistMoniker_Load,
1591 PersistMoniker_Save,
1592 PersistMoniker_SaveCompleted,
1593 PersistMoniker_GetCurMoniker
1596 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
1598 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1602 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1607 if(IsEqualGUID(&IID_IMarshal, riid))
1608 return E_NOINTERFACE;
1609 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1610 return E_NOINTERFACE;
1612 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1616 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1621 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1626 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1628 CHECK_EXPECT(CreateInstance);
1629 ok(!outer, "outer = %p\n", outer);
1630 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1631 *ppv = &PersistMoniker;
1635 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1637 ok(0, "unexpected call\n");
1641 static const IClassFactoryVtbl ClassFactoryVtbl = {
1642 ClassFactory_QueryInterface,
1643 ClassFactory_AddRef,
1644 ClassFactory_Release,
1645 ClassFactory_CreateInstance,
1646 ClassFactory_LockServer
1649 static IClassFactory mime_cf = { &ClassFactoryVtbl };
1651 static void test_CreateAsyncBindCtx(void)
1653 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1659 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1660 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1661 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1663 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1664 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1666 SET_EXPECT(QueryInterface_IServiceProvider);
1667 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1668 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1669 CHECK_CALLED(QueryInterface_IServiceProvider);
1671 bindopts.cbStruct = sizeof(bindopts);
1672 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1673 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1674 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1675 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1676 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1677 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1679 ok(bindopts.dwTickCountDeadline == 0,
1680 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1682 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1683 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1685 IUnknown_Release(unk);
1687 ref = IBindCtx_Release(bctx);
1688 ok(ref == 0, "bctx should be destroyed here\n");
1691 static void test_CreateAsyncBindCtxEx(void)
1693 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1698 static WCHAR testW[] = {'t','e','s','t',0};
1700 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1701 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1703 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1704 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1706 if(SUCCEEDED(hres)) {
1707 bindopts.cbStruct = sizeof(bindopts);
1708 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1709 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1710 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1711 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1712 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1713 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1715 ok(bindopts.dwTickCountDeadline == 0,
1716 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1718 IBindCtx_Release(bctx);
1721 CreateBindCtx(0, &bctx_arg);
1722 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1723 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1725 if(SUCCEEDED(hres)) {
1726 bindopts.cbStruct = sizeof(bindopts);
1727 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1728 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1729 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1730 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1731 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1732 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1734 ok(bindopts.dwTickCountDeadline == 0,
1735 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1737 IBindCtx_Release(bctx);
1740 IBindCtx_Release(bctx_arg);
1742 SET_EXPECT(QueryInterface_IServiceProvider);
1743 hres = CreateAsyncBindCtxEx(NULL, 0, &bsc, NULL, &bctx, 0);
1744 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1745 CHECK_CALLED(QueryInterface_IServiceProvider);
1747 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1748 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1750 IUnknown_Release(unk);
1752 IBindCtx_Release(bctx);
1754 hres = CreateBindCtx(0, &bctx2);
1755 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1757 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1758 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1760 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1761 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1763 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1764 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1765 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1767 IBindCtx_Release(bctx);
1768 IBindCtx_Release(bctx2);
1771 static void test_bscholder(IBindStatusCallback *holder)
1773 IServiceProvider *serv_prov;
1774 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1775 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1776 IAuthenticate *authenticate, *authenticate_serv;
1777 IInternetProtocol *protocol;
1778 BINDINFO bindinfo = {sizeof(bindinfo)};
1783 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
1784 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
1787 SET_EXPECT(GetBindInfo);
1788 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
1789 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1790 CHECK_CALLED(GetBindInfo);
1792 SET_EXPECT(OnStartBinding);
1793 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
1794 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1795 CHECK_CALLED(OnStartBinding);
1797 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
1798 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
1800 wstr = (void*)0xdeadbeef;
1801 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol], (void*)0xdeadbeef, 0xff, &wstr);
1802 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1803 ok(wstr == NULL, "wstr = %p\n", wstr);
1805 SET_EXPECT(QueryInterface_IHttpNegotiate);
1806 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1807 (void**)&http_negotiate_serv);
1808 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1809 CHECK_CALLED(QueryInterface_IHttpNegotiate);
1811 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1813 wstr = (void*)0xdeadbeef;
1814 SET_EXPECT(BeginningTransaction);
1815 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
1816 CHECK_CALLED(BeginningTransaction);
1817 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1818 ok(wstr == NULL, "wstr = %p\n", wstr);
1820 IHttpNegotiate_Release(http_negotiate_serv);
1822 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1823 (void**)&http_negotiate_serv);
1824 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1825 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1826 IHttpNegotiate_Release(http_negotiate_serv);
1828 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
1829 if(SUCCEEDED(hres)) {
1830 have_IHttpNegotiate2 = TRUE;
1831 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1832 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x\n", hres);
1834 SET_EXPECT(QueryInterface_IHttpNegotiate2);
1835 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
1836 (void**)&http_negotiate2_serv);
1837 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
1838 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
1839 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
1841 SET_EXPECT(GetRootSecurityId);
1842 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1843 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
1844 CHECK_CALLED(GetRootSecurityId);
1846 IHttpNegotiate_Release(http_negotiate2_serv);
1847 IHttpNegotiate_Release(http_negotiate2);
1849 skip("Could not get IHttpNegotiate2\n");
1852 SET_EXPECT(OnProgress_FINDINGRESOURCE);
1853 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
1854 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
1855 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
1857 SET_EXPECT(OnResponse);
1858 wstr = (void*)0xdeadbeef;
1859 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
1860 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
1861 CHECK_CALLED(OnResponse);
1863 IHttpNegotiate_Release(http_negotiate);
1865 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
1866 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
1868 SET_EXPECT(QueryInterface_IAuthenticate);
1869 SET_EXPECT(QueryService_IAuthenticate);
1870 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1871 (void**)&authenticate_serv);
1872 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1873 CHECK_CALLED(QueryInterface_IAuthenticate);
1874 CHECK_CALLED(QueryService_IAuthenticate);
1875 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1876 IAuthenticate_Release(authenticate_serv);
1878 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1879 (void**)&authenticate_serv);
1880 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1881 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1883 IAuthenticate_Release(authenticate);
1884 IAuthenticate_Release(authenticate_serv);
1886 SET_EXPECT(OnStopBinding);
1887 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
1888 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1889 CHECK_CALLED(OnStopBinding);
1891 SET_EXPECT(QueryInterface_IInternetProtocol);
1892 SET_EXPECT(QueryService_IInternetProtocol);
1893 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
1895 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
1896 CHECK_CALLED(QueryInterface_IInternetProtocol);
1897 CHECK_CALLED(QueryService_IInternetProtocol);
1899 IServiceProvider_Release(serv_prov);
1902 static void test_RegisterBindStatusCallback(void)
1904 IBindStatusCallback *prevbsc, *clb;
1909 hres = CreateBindCtx(0, &bindctx);
1910 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
1912 SET_EXPECT(QueryInterface_IServiceProvider);
1914 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
1915 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1917 SET_EXPECT(QueryInterface_IBindStatusCallback);
1918 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
1919 prevbsc = (void*)0xdeadbeef;
1920 hres = RegisterBindStatusCallback(bindctx, &bsc, &prevbsc, 0);
1921 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1922 ok(prevbsc == &bsc, "prevbsc=%p\n", prevbsc);
1923 CHECK_CALLED(QueryInterface_IBindStatusCallback);
1924 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
1926 CHECK_CALLED(QueryInterface_IServiceProvider);
1928 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1929 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1931 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
1932 IUnknown_Release(unk);
1933 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
1934 ok(clb != &bsc, "bsc == clb\n");
1936 test_bscholder(clb);
1938 IBindStatusCallback_Release(clb);
1940 hres = RevokeBindStatusCallback(bindctx, &bsc);
1941 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1943 unk = (void*)0xdeadbeef;
1944 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1945 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
1946 ok(unk == NULL, "unk != NULL\n");
1949 IUnknown_Release(unk);
1951 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
1952 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1954 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
1955 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1957 hres = RevokeBindStatusCallback(bindctx, NULL);
1958 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1960 IBindCtx_Release(bindctx);
1963 #define BINDTEST_EMULATE 1
1964 #define BINDTEST_TOOBJECT 2
1965 #define BINDTEST_FILEDWLAPI 4
1967 static void init_bind_test(int protocol, DWORD flags, DWORD t)
1969 test_protocol = protocol;
1970 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
1971 download_state = BEFORE_DOWNLOAD;
1972 stopped_binding = FALSE;
1973 stopped_obj_binding = FALSE;
1974 data_available = FALSE;
1976 binding_hres = S_OK;
1977 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
1979 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
1982 static void test_BindToStorage(int protocol, BOOL emul, DWORD t)
1986 LPOLESTR display_name;
1989 IBindStatusCallback *previousclb;
1990 IUnknown *unk = (IUnknown*)0x00ff00ff;
1993 init_bind_test(protocol, emul ? BINDTEST_EMULATE : 0, t);
1995 SET_EXPECT(QueryInterface_IServiceProvider);
1996 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1997 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
1998 CHECK_CALLED(QueryInterface_IServiceProvider);
2002 SET_EXPECT(QueryInterface_IServiceProvider);
2003 hres = RegisterBindStatusCallback(bctx, &bsc, &previousclb, 0);
2004 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2005 ok(previousclb == &bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2006 CHECK_CALLED(QueryInterface_IServiceProvider);
2008 IBindStatusCallback_Release(previousclb);
2010 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2011 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2013 IBindCtx_Release(bctx);
2017 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2018 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2020 IBinding_Release(bind);
2022 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2023 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2024 ok(!lstrcmpW(display_name, urls[test_protocol]),
2025 "GetDisplayName got wrong name %s\n", debugstr_w(display_name));
2026 CoTaskMemFree(display_name);
2028 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2029 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2031 SET_EXPECT(GetBindInfo);
2032 SET_EXPECT(QueryInterface_IInternetProtocol);
2033 if(!emulate_protocol)
2034 SET_EXPECT(QueryService_IInternetProtocol);
2035 SET_EXPECT(OnStartBinding);
2036 if(emulate_protocol) {
2038 if(test_protocol == HTTP_TEST)
2039 SET_EXPECT(Terminate);
2040 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2041 SET_EXPECT(UnlockRequest);
2043 if(test_protocol == HTTP_TEST) {
2044 SET_EXPECT(QueryInterface_IInternetBindInfo);
2045 SET_EXPECT(QueryService_IInternetBindInfo);
2046 SET_EXPECT(QueryInterface_IHttpNegotiate);
2047 SET_EXPECT(BeginningTransaction);
2048 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2049 SET_EXPECT(GetRootSecurityId);
2050 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2051 SET_EXPECT(OnProgress_CONNECTING);
2053 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2054 SET_EXPECT(OnProgress_SENDINGREQUEST);
2055 if(test_protocol == HTTP_TEST)
2056 SET_EXPECT(OnResponse);
2057 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2058 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2059 if(test_protocol == FILE_TEST)
2060 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2061 if(test_protocol == HTTP_TEST)
2062 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2063 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2064 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2065 SET_EXPECT(OnDataAvailable);
2066 SET_EXPECT(OnStopBinding);
2069 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2070 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2072 skip("Network unreachable, skipping tests\n");
2076 if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2077 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2078 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2079 ok(unk == NULL, "istr should be NULL\n");
2080 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2081 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2082 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2083 ok(unk == NULL, "istr should be NULL\n");
2085 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2086 ok(unk != NULL, "unk == NULL\n");
2089 IUnknown_Release(unk);
2094 while((bindf & BINDF_ASYNCHRONOUS) &&
2095 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
2096 TranslateMessage(&msg);
2097 DispatchMessage(&msg);
2100 CHECK_CALLED(GetBindInfo);
2101 CHECK_CALLED(QueryInterface_IInternetProtocol);
2102 if(!emulate_protocol)
2103 CHECK_CALLED(QueryService_IInternetProtocol);
2104 CHECK_CALLED(OnStartBinding);
2105 if(emulate_protocol) {
2106 CHECK_CALLED(Start);
2107 if(test_protocol == HTTP_TEST) {
2108 if(tymed == TYMED_FILE)
2110 CHECK_CALLED(Terminate);
2112 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2113 CHECK_CALLED(UnlockRequest);
2115 if(test_protocol == HTTP_TEST) {
2116 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2117 CLEAR_CALLED(QueryService_IInternetBindInfo);
2118 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2119 CHECK_CALLED(BeginningTransaction);
2120 if (have_IHttpNegotiate2)
2122 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2123 CHECK_CALLED(GetRootSecurityId);
2126 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2127 CHECK_CALLED(OnProgress_CONNECTING);
2129 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2130 /* IE7 does call this */
2131 CLEAR_CALLED(OnProgress_CONNECTING);
2134 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2135 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2136 if(test_protocol == HTTP_TEST)
2137 CHECK_CALLED(OnResponse);
2138 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2139 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2140 if(test_protocol == FILE_TEST)
2141 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2142 if(test_protocol == HTTP_TEST)
2143 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2144 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2145 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2146 CHECK_CALLED(OnDataAvailable);
2147 CHECK_CALLED(OnStopBinding);
2150 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2151 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2153 if(test_protocol == HTTP_TEST)
2154 http_is_first = FALSE;
2157 static void test_BindToObject(int protocol, BOOL emul)
2161 LPOLESTR display_name;
2165 IUnknown *unk = (IUnknown*)0x00ff00ff;
2168 init_bind_test(protocol, BINDTEST_TOOBJECT | (emul ? BINDTEST_EMULATE : 0), TYMED_ISTREAM);
2171 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
2172 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
2174 SET_EXPECT(QueryInterface_IServiceProvider);
2175 hres = CreateAsyncBindCtx(0, &objbsc, NULL, &bctx);
2176 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
2177 CHECK_CALLED(QueryInterface_IServiceProvider);
2181 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2182 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2184 IBindCtx_Release(bctx);
2188 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2189 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2191 IBinding_Release(bind);
2193 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2194 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2195 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
2197 SET_EXPECT(Obj_GetBindInfo);
2198 SET_EXPECT(QueryInterface_IInternetProtocol);
2199 if(!emulate_protocol)
2200 SET_EXPECT(QueryService_IInternetProtocol);
2201 SET_EXPECT(Obj_OnStartBinding);
2202 if(emulate_protocol) {
2204 if(test_protocol == HTTP_TEST)
2205 SET_EXPECT(Terminate);
2206 if(test_protocol == FILE_TEST)
2207 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2208 SET_EXPECT(UnlockRequest);
2210 if(test_protocol == HTTP_TEST) {
2211 SET_EXPECT(QueryInterface_IHttpNegotiate);
2212 SET_EXPECT(BeginningTransaction);
2213 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2214 SET_EXPECT(GetRootSecurityId);
2215 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
2216 SET_EXPECT(Obj_OnProgress_CONNECTING);
2218 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2219 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
2220 if(test_protocol == HTTP_TEST)
2221 SET_EXPECT(OnResponse);
2222 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
2223 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
2224 if(test_protocol == FILE_TEST)
2225 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2226 if(test_protocol == HTTP_TEST)
2227 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2228 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
2229 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
2230 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
2231 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
2232 SET_EXPECT(OnObjectAvailable);
2233 SET_EXPECT(Obj_OnStopBinding);
2236 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
2238 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2240 skip( "Network unreachable, skipping tests\n" );
2244 /* no point testing the calls if binding didn't even work */
2245 if (FAILED(hres)) return;
2247 if(bindf & BINDF_ASYNCHRONOUS) {
2248 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
2249 ok(unk == NULL, "istr should be NULL\n");
2251 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2252 ok(unk != NULL, "unk == NULL\n");
2254 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
2257 IUnknown_Release(unk);
2259 while((bindf & BINDF_ASYNCHRONOUS) &&
2260 !((!emul || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
2261 TranslateMessage(&msg);
2262 DispatchMessage(&msg);
2265 CHECK_CALLED(Obj_GetBindInfo);
2266 CHECK_CALLED(QueryInterface_IInternetProtocol);
2267 if(!emulate_protocol)
2268 CHECK_CALLED(QueryService_IInternetProtocol);
2269 CHECK_CALLED(Obj_OnStartBinding);
2270 if(emulate_protocol) {
2271 CHECK_CALLED(Start);
2272 if(test_protocol == HTTP_TEST)
2273 CHECK_CALLED(Terminate);
2274 if(test_protocol == FILE_TEST)
2275 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
2276 CHECK_CALLED(UnlockRequest);
2278 if(test_protocol == HTTP_TEST) {
2279 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2280 CHECK_CALLED(BeginningTransaction);
2281 if (have_IHttpNegotiate2)
2283 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2284 CHECK_CALLED(GetRootSecurityId);
2287 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2288 CHECK_CALLED(Obj_OnProgress_CONNECTING);
2290 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2291 /* IE7 does call this */
2292 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
2295 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST) {
2296 if(urls[test_protocol] == SHORT_RESPONSE_URL)
2297 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
2299 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
2301 if(test_protocol == HTTP_TEST)
2302 CHECK_CALLED(OnResponse);
2303 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
2304 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
2305 if(test_protocol == FILE_TEST)
2306 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2307 if(test_protocol == HTTP_TEST)
2308 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2309 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
2310 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
2311 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
2312 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
2313 CHECK_CALLED(OnObjectAvailable);
2314 CHECK_CALLED(Obj_OnStopBinding);
2317 if(test_protocol != HTTP_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL) {
2318 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2319 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2321 todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2323 if(bindf & BINDF_ASYNCHRONOUS)
2324 ok(IBindCtx_Release(bctx) != 0, "bctx should not be destroyed here\n");
2326 todo_wine ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2330 CoRevokeClassObject(regid);
2332 if(test_protocol == HTTP_TEST)
2333 http_is_first = FALSE;
2336 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
2341 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
2343 SET_EXPECT(GetBindInfo);
2344 SET_EXPECT(QueryInterface_IInternetProtocol);
2345 if(!emulate_protocol) {
2346 SET_EXPECT(QueryInterface_IServiceProvider);
2347 SET_EXPECT(QueryService_IInternetProtocol);
2349 SET_EXPECT(OnStartBinding);
2350 if(emulate_protocol) {
2352 SET_EXPECT(UnlockRequest);
2354 if(test_protocol == HTTP_TEST) {
2355 SET_EXPECT(QueryInterface_IHttpNegotiate);
2356 SET_EXPECT(BeginningTransaction);
2357 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2358 SET_EXPECT(GetRootSecurityId);
2360 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2361 SET_EXPECT(OnProgress_SENDINGREQUEST);
2362 if(test_protocol == HTTP_TEST)
2363 SET_EXPECT(OnResponse);
2364 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2365 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2366 if(test_protocol == FILE_TEST)
2367 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2368 if(test_protocol == HTTP_TEST)
2369 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2370 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2371 SET_EXPECT(OnStopBinding);
2374 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], dwl_htmlW, 0, &bsc);
2375 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2377 CHECK_CALLED(GetBindInfo);
2378 CHECK_CALLED(QueryInterface_IInternetProtocol);
2379 if(!emulate_protocol) {
2380 CHECK_CALLED(QueryInterface_IServiceProvider);
2381 CHECK_CALLED(QueryService_IInternetProtocol);
2383 CHECK_CALLED(OnStartBinding);
2384 if(emulate_protocol) {
2385 CHECK_CALLED(Start);
2386 CHECK_CALLED(UnlockRequest);
2388 if(test_protocol == HTTP_TEST) {
2389 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2390 CHECK_CALLED(BeginningTransaction);
2391 if (have_IHttpNegotiate2)
2393 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2394 CHECK_CALLED(GetRootSecurityId);
2397 if(test_protocol == FILE_TEST)
2398 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2399 else if(test_protocol == HTTP_TEST)
2400 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
2401 if(test_protocol == HTTP_TEST)
2402 CHECK_CALLED(OnResponse);
2403 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2404 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2405 if(test_protocol == FILE_TEST)
2406 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2407 if(test_protocol == HTTP_TEST)
2408 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2409 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2410 CHECK_CALLED(OnStopBinding);
2413 res = DeleteFileA(dwl_htmlA);
2414 ok(res, "DeleteFile failed: %u\n", GetLastError());
2416 if(prot != FILE_TEST || emul)
2419 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
2420 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2422 res = DeleteFileA(dwl_htmlA);
2423 ok(res, "DeleteFile failed: %u\n", GetLastError());
2426 static void set_file_url(char *path)
2428 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
2429 CHAR INDEX_HTMLA[MAX_PATH];
2431 lstrcpyA(file_urlA, "file:///");
2432 lstrcatA(file_urlA, path);
2433 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
2435 lstrcpyA(INDEX_HTMLA, "file://");
2436 lstrcatA(INDEX_HTMLA, path);
2437 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
2440 static void create_file(void)
2444 CHAR path[MAX_PATH];
2446 static const char html_doc[] = "<HTML></HTML>";
2448 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2449 FILE_ATTRIBUTE_NORMAL, NULL);
2450 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2451 if(file == INVALID_HANDLE_VALUE)
2454 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2457 GetCurrentDirectoryA(MAX_PATH, path);
2458 lstrcatA(path, "\\");
2459 lstrcatA(path, wszIndexHtmlA);
2463 static void test_ReportResult(HRESULT exhres)
2465 IMoniker *mon = NULL;
2466 IBindCtx *bctx = NULL;
2467 IUnknown *unk = (void*)0xdeadbeef;
2470 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2471 binding_hres = exhres;
2473 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2474 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2476 SET_EXPECT(QueryInterface_IServiceProvider);
2477 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
2478 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2479 CHECK_CALLED(QueryInterface_IServiceProvider);
2481 SET_EXPECT(GetBindInfo);
2482 SET_EXPECT(QueryInterface_IInternetProtocol);
2483 SET_EXPECT(OnStartBinding);
2486 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2487 if(SUCCEEDED(exhres))
2488 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
2490 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
2491 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
2493 CHECK_CALLED(GetBindInfo);
2494 CHECK_CALLED(QueryInterface_IInternetProtocol);
2495 CHECK_CALLED(OnStartBinding);
2496 CHECK_CALLED(Start);
2498 ok(unk == NULL, "unk=%p\n", unk);
2500 IBindCtx_Release(bctx);
2501 IMoniker_Release(mon);
2504 static void test_BindToStorage_fail(void)
2506 IMoniker *mon = NULL;
2507 IBindCtx *bctx = NULL;
2511 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2512 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2516 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2517 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2519 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2520 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
2521 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
2523 IBindCtx_Release(bctx);
2525 IMoniker_Release(mon);
2527 test_ReportResult(E_NOTIMPL);
2528 test_ReportResult(S_FALSE);
2531 static void gecko_installer_workaround(BOOL disable)
2536 static BOOL has_url = FALSE;
2537 static char url[2048];
2539 if(!disable && !has_url)
2542 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
2543 if(res != ERROR_SUCCESS)
2547 DWORD type, size = sizeof(url);
2549 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
2550 if(res == ERROR_SUCCESS && type == REG_SZ)
2553 RegDeleteValue(hkey, "GeckoUrl");
2555 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
2563 gecko_installer_workaround(TRUE);
2565 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2566 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2567 thread_id = GetCurrentThreadId();
2571 test_CreateAsyncBindCtx();
2572 test_CreateAsyncBindCtxEx();
2573 test_RegisterBindStatusCallback();
2574 test_BindToStorage_fail();
2576 trace("synchronous http test (COM not initialised)...\n");
2577 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2581 trace("synchronous http test...\n");
2582 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2584 trace("synchronous http test (to object)...\n");
2585 test_BindToObject(HTTP_TEST, FALSE);
2587 trace("synchronous file test...\n");
2588 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2590 trace("synchronous file test (to object)...\n");
2591 test_BindToObject(FILE_TEST, FALSE);
2593 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2595 trace("http test...\n");
2596 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2598 trace("http test (to file)...\n");
2599 test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE);
2601 trace("http test (to object)...\n");
2602 test_BindToObject(HTTP_TEST, FALSE);
2604 trace("http test (short response)...\n");
2605 http_is_first = TRUE;
2606 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
2607 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2609 trace("http test (short response, to object)...\n");
2610 test_BindToObject(HTTP_TEST, FALSE);
2612 trace("emulated http test...\n");
2613 test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM);
2615 trace("emulated http test (to object)...\n");
2616 test_BindToObject(HTTP_TEST, TRUE);
2618 trace("emulated http test (to file)...\n");
2619 test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE);
2621 trace("about test...\n");
2622 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM);
2624 trace("about test (to file)...\n");
2625 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE);
2627 trace("about test (to object)...\n");
2628 test_BindToObject(ABOUT_TEST, FALSE);
2630 trace("emulated about test...\n");
2631 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM);
2633 trace("emulated about test (to file)...\n");
2634 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE);
2636 trace("emulated about test (to object)...\n");
2637 test_BindToObject(ABOUT_TEST, TRUE);
2639 trace("file test...\n");
2640 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2642 trace("file test (to file)...\n");
2643 test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE);
2645 trace("file test (to object)...\n");
2646 test_BindToObject(FILE_TEST, FALSE);
2648 trace("emulated file test...\n");
2649 test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM);
2651 trace("emulated file test (to file)...\n");
2652 test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE);
2654 trace("emulated file test (to object)...\n");
2655 test_BindToObject(FILE_TEST, TRUE);
2657 trace("emulated its test...\n");
2658 test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM);
2660 trace("emulated its test (to file)...\n");
2661 test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE);
2663 trace("emulated mk test...\n");
2664 test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM);
2666 trace("test URLDownloadToFile for file protocol...\n");
2667 test_URLDownloadToFile(FILE_TEST, FALSE);
2669 trace("test URLDownloadToFile for emulated file protocol...\n");
2670 test_URLDownloadToFile(FILE_TEST, TRUE);
2672 trace("test URLDownloadToFile for http protocol...\n");
2673 test_URLDownloadToFile(HTTP_TEST, FALSE);
2675 trace("test failures...\n");
2676 test_BindToStorage_fail();
2678 DeleteFileA(wszIndexHtmlA);
2679 CloseHandle(complete_event);
2680 CloseHandle(complete_event2);
2683 gecko_installer_workaround(FALSE);