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;
165 static LPCWSTR urls[] = {
173 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
189 static const char *debugstr_w(LPCWSTR str)
191 static char buf[1024];
192 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
196 static const char *debugstr_guid(REFIID riid)
200 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
201 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
202 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
203 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
208 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
211 IMoniker *mon1 = NULL;
212 IMoniker *mon2 = NULL;
214 hr = CreateURLMoniker(NULL, url1, &mon1);
215 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
217 hr = CreateURLMoniker(mon1, url2, &mon2);
218 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
220 if(mon1) IMoniker_Release(mon1);
221 if(mon2) IMoniker_Release(mon2);
224 static void test_create(void)
226 test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
229 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
231 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
237 return E_NOINTERFACE;
240 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
245 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
250 static DWORD WINAPI thread_proc(PVOID arg)
252 PROTOCOLDATA protocoldata;
256 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
258 SET_EXPECT(OnProgress_FINDINGRESOURCE);
259 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
260 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
261 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
262 WaitForSingleObject(complete_event, INFINITE);
264 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
266 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
269 SET_EXPECT(Obj_OnProgress_CONNECTING);
271 SET_EXPECT(OnProgress_CONNECTING);
272 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
273 BINDSTATUS_CONNECTING, wszWineHQIP);
274 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
275 WaitForSingleObject(complete_event, INFINITE);
277 CHECK_CALLED(Obj_OnProgress_CONNECTING);
279 CHECK_CALLED(OnProgress_CONNECTING);
282 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
284 SET_EXPECT(OnProgress_SENDINGREQUEST);
285 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
286 BINDSTATUS_SENDINGREQUEST, NULL);
287 ok(hres == S_OK, "ReportProxgress failed: %08x\n", hres);
288 WaitForSingleObject(complete_event, INFINITE);
290 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
292 CHECK_CALLED(OnProgress_SENDINGREQUEST);
294 SET_EXPECT(Continue);
296 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
297 ok(hres == S_OK, "Switch failed: %08x\n", hres);
298 WaitForSingleObject(complete_event, INFINITE);
300 CHECK_CALLED(Continue);
303 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
304 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
305 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
306 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
307 CHECK_CALLED(CreateInstance);
308 CHECK_CALLED(PutProperty_MIMETYPEPROP);
309 CLEAR_CALLED(PutProperty_CLASSIDPROP);
311 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
312 CHECK_CALLED(OnObjectAvailable);
313 CHECK_CALLED(Obj_OnStopBinding);
315 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
316 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
317 CHECK_CALLED(LockRequest);
318 CHECK_CALLED(OnDataAvailable);
321 SET_EXPECT(Continue);
323 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
324 ok(hres == S_OK, "Switch failed: %08x\n", hres);
325 WaitForSingleObject(complete_event, INFINITE);
326 CHECK_CALLED(Continue);
328 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
329 CHECK_CALLED(OnDataAvailable);
331 SET_EXPECT(Continue);
333 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
334 ok(hres == S_OK, "Switch failed: %08x\n", hres);
335 WaitForSingleObject(complete_event, INFINITE);
336 CHECK_CALLED(Continue);
338 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
339 CHECK_CALLED(OnDataAvailable);
341 SET_EXPECT(Continue);
343 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
344 ok(hres == S_OK, "Switch failed: %08x\n", hres);
345 WaitForSingleObject(complete_event, INFINITE);
346 CHECK_CALLED(Continue);
348 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
349 CHECK_CALLED(OnDataAvailable);
350 CHECK_CALLED(OnStopBinding);
354 SetEvent(complete_event2);
358 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
359 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
360 DWORD grfPI, DWORD dwReserved)
363 DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
366 static const STGMEDIUM stgmed_zero = {0};
367 static const SECURITY_ATTRIBUTES sa_zero = {0};
373 if(!filedwl_api) /* FIXME */
374 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", debugstr_w(szUrl));
375 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
376 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
377 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
378 ok(dwReserved == 0, "dwReserved=%d, expected 0\n", dwReserved);
380 if(!filedwl_api && binding_hres != S_OK) {
381 SET_EXPECT(OnStopBinding);
382 SET_EXPECT(Terminate);
383 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
384 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
385 CHECK_CALLED(OnStopBinding);
386 CHECK_CALLED(Terminate);
391 memset(&bindinfo, 0, sizeof(bindinfo));
392 bindinfo.cbSize = sizeof(bindinfo);
393 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
394 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
397 ok(bindf == (BINDF_PULLDATA|BINDF_FROMURLMON|BINDF_NEEDFILE), "bindf=%08x\n", bindf);
398 }else if(tymed == TYMED_ISTREAM
399 && (test_protocol == FILE_TEST || test_protocol == MK_TEST || test_protocol == HTTP_TEST)) {
400 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
402 "bindf=%08x\n", bindf);
404 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
405 |BINDF_FROMURLMON|BINDF_NEEDFILE),
406 "bindf=%08x\n", bindf);
409 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
410 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
411 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
412 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
413 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
414 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
415 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
416 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
417 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
418 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
419 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
420 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
421 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
422 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
424 switch(test_protocol) {
426 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
427 BINDSTATUS_DIRECTBIND, NULL);
429 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
434 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
436 SET_EXPECT(OnProgress_SENDINGREQUEST);
437 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
438 BINDSTATUS_SENDINGREQUEST, emptyW);
440 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
442 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
444 CHECK_CALLED(OnProgress_SENDINGREQUEST);
449 if(test_protocol == HTTP_TEST) {
450 IServiceProvider *service_provider;
451 IHttpNegotiate *http_negotiate;
452 IHttpNegotiate2 *http_negotiate2;
453 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
454 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
456 DWORD fetched = 256, size = 100;
459 static const WCHAR wszMimes[] = {'*','/','*',0};
461 SET_EXPECT(QueryInterface_IInternetBindInfo);
462 SET_EXPECT(QueryService_IInternetBindInfo);
463 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
466 CHECK_CALLED(QueryInterface_IInternetBindInfo);
467 CHECK_CALLED(QueryService_IInternetBindInfo);
469 ok(hres == E_NOINTERFACE,
470 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
471 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
472 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
474 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
475 accept_mimes, 256, &fetched);
477 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
478 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
479 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
481 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
482 NULL, 256, &fetched);
483 ok(hres == E_INVALIDARG,
484 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
486 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
487 accept_mimes, 256, NULL);
488 ok(hres == E_INVALIDARG,
489 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
491 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
492 (void**)&service_provider);
493 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
495 SET_EXPECT(QueryInterface_IHttpNegotiate);
496 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
497 &IID_IHttpNegotiate, (void**)&http_negotiate);
498 CHECK_CALLED(QueryInterface_IHttpNegotiate);
499 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
501 SET_EXPECT(BeginningTransaction);
502 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
503 NULL, 0, &additional_headers);
504 CHECK_CALLED(BeginningTransaction);
505 IHttpNegotiate_Release(http_negotiate);
506 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
507 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
509 SET_EXPECT(QueryInterface_IHttpNegotiate2);
510 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
511 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
512 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
513 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
516 SET_EXPECT(GetRootSecurityId);
517 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
518 CHECK_CALLED(GetRootSecurityId);
519 IHttpNegotiate2_Release(http_negotiate2);
520 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
521 ok(size == 13, "size=%d\n", size);
523 IServiceProvider_Release(service_provider);
525 IInternetProtocolSink_AddRef(pOIProtSink);
526 protocol_sink = pOIProtSink;
527 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
532 if(test_protocol == FILE_TEST) {
533 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
534 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
536 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
539 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
541 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
542 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
543 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
545 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
547 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
549 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
551 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
552 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
554 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
557 if(test_protocol == ABOUT_TEST)
558 bscf |= BSCF_DATAFULLYAVAILABLE;
559 if(test_protocol == ITS_TEST)
560 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
564 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
565 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
566 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
567 if(test_protocol == FILE_TEST)
568 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
569 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
570 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
571 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
572 SET_EXPECT(CreateInstance);
573 SET_EXPECT(PutProperty_MIMETYPEPROP);
574 SET_EXPECT(PutProperty_CLASSIDPROP);
576 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
577 SET_EXPECT(OnObjectAvailable);
578 SET_EXPECT(Obj_OnStopBinding);
580 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
581 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
582 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
583 if(test_protocol == FILE_TEST)
584 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
585 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
586 SET_EXPECT(LockRequest);
588 SET_EXPECT(OnDataAvailable);
589 SET_EXPECT(OnStopBinding);
592 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
593 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
597 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
598 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
599 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
600 if(test_protocol == FILE_TEST)
601 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
602 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
603 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
604 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
605 CHECK_CALLED(CreateInstance);
606 CHECK_CALLED(PutProperty_MIMETYPEPROP);
607 CLEAR_CALLED(PutProperty_CLASSIDPROP);
609 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
610 CHECK_CALLED(OnObjectAvailable);
611 CHECK_CALLED(Obj_OnStopBinding);
613 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
614 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
615 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
616 if(test_protocol == FILE_TEST)
617 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
618 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
619 CHECK_CALLED(LockRequest);
621 CHECK_CALLED(OnDataAvailable);
622 CHECK_CALLED(OnStopBinding);
625 if(test_protocol == ITS_TEST) {
627 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
628 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
632 SET_EXPECT(Terminate);
633 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
634 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
635 CHECK_CALLED(Terminate);
640 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
641 PROTOCOLDATA *pProtocolData)
646 CHECK_EXPECT(Continue);
648 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
650 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
656 IServiceProvider *service_provider;
657 IHttpNegotiate *http_negotiate;
658 static WCHAR header[] = {'?',0};
660 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
661 (void**)&service_provider);
662 ok(hres == S_OK, "Could not get IServiceProvicder\n");
664 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
665 &IID_IHttpNegotiate, (void**)&http_negotiate);
666 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
668 SET_EXPECT(OnResponse);
669 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
670 CHECK_CALLED(OnResponse);
671 IHttpNegotiate_Release(http_negotiate);
672 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
674 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
675 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
677 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
679 if(tymed == TYMED_FILE) {
680 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
681 BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_fileW);
683 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
686 bscf |= BSCF_FIRSTDATANOTIFICATION;
691 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
695 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
696 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
702 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
703 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
704 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
705 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
706 SET_EXPECT(CreateInstance);
707 SET_EXPECT(PutProperty_MIMETYPEPROP);
708 SET_EXPECT(PutProperty_CLASSIDPROP);
710 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
711 SET_EXPECT(OnObjectAvailable);
712 SET_EXPECT(Obj_OnStopBinding);
714 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
715 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
716 SET_EXPECT(LockRequest);
720 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
723 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
724 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
726 if(!bind_to_object || prot_state >= 2)
727 SET_EXPECT(OnDataAvailable);
729 SET_EXPECT(OnStopBinding);
734 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
737 ok(0, "unexpected call\n");
741 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
743 CHECK_EXPECT(Terminate);
745 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
748 IInternetProtocolSink_Release(protocol_sink);
749 protocol_sink = NULL;
755 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
757 ok(0, "unexpected call\n");
761 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
763 ok(0, "unexpected call\n");
767 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
768 ULONG cb, ULONG *pcbRead)
770 static const char data[] = "<HTML></HTML>";
774 if(test_protocol == HTTP_TEST) {
777 static BOOL pending = TRUE;
799 hres = IInternetProtocolSink_ReportData(protocol_sink,
800 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
801 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
803 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
804 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
818 ok(pv != NULL, "pv == NULL\n");
819 ok(cb != 0, "cb == 0\n");
820 ok(pcbRead != NULL, "pcbRead == NULL\n");
822 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
823 read += *pcbRead = sizeof(data)-1;
826 memcpy(pv, data, sizeof(data));
831 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
832 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
834 ok(0, "unexpected call\n");
838 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
840 CHECK_EXPECT(LockRequest);
844 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
846 CHECK_EXPECT(UnlockRequest);
850 static const IInternetProtocolVtbl ProtocolVtbl = {
851 Protocol_QueryInterface,
862 Protocol_LockRequest,
863 Protocol_UnlockRequest
866 static IInternetProtocol Protocol = { &ProtocolVtbl };
868 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
870 if(IsEqualGUID(&IID_IUnknown, riid)
871 || IsEqualGUID(&IID_IHttpNegotiate, riid)
872 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
877 ok(0, "unexpected call\n");
878 return E_NOINTERFACE;
881 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
886 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
891 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
892 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
894 CHECK_EXPECT(BeginningTransaction);
896 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
898 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
899 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
900 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
901 if(pszAdditionalHeaders)
902 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
907 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
908 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
910 CHECK_EXPECT(OnResponse);
912 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
914 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
915 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
916 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
917 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
918 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
919 if(pszAdditionalRequestHeaders)
920 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
925 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
926 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
928 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
930 CHECK_EXPECT(GetRootSecurityId);
932 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
934 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
935 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
936 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
938 if(pbSecurityId == (void*)0xdeadbeef)
942 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
943 *pcbSecurityId = sizeof(sec_id);
947 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
952 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
953 HttpNegotiate_QueryInterface,
954 HttpNegotiate_AddRef,
955 HttpNegotiate_Release,
956 HttpNegotiate_BeginningTransaction,
957 HttpNegotiate_OnResponse,
958 HttpNegotiate_GetRootSecurityId
961 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
963 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
965 ok(0, "unexpected call\n");
966 return E_NOINTERFACE;
969 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
974 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
979 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
980 REFGUID guidService, REFIID riid, void **ppv)
982 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
983 CHECK_EXPECT(QueryService_IAuthenticate);
987 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
988 CHECK_EXPECT2(QueryService_IInternetProtocol);
992 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
993 CHECK_EXPECT(QueryService_IInternetBindInfo);
997 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
998 return E_NOINTERFACE;
1001 static IServiceProviderVtbl ServiceProviderVtbl = {
1002 ServiceProvider_QueryInterface,
1003 ServiceProvider_AddRef,
1004 ServiceProvider_Release,
1005 ServiceProvider_QueryService
1008 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1010 static IBindStatusCallback objbsc;
1012 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
1014 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1016 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1017 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1018 if(emulate_protocol) {
1022 return E_NOINTERFACE;
1025 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1027 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1028 *ppv = &ServiceProvider;
1031 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1033 CHECK_EXPECT(QueryInterface_IHttpNegotiate);
1034 *ppv = &HttpNegotiate;
1037 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1039 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1040 *ppv = &HttpNegotiate;
1043 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1045 CHECK_EXPECT(QueryInterface_IAuthenticate);
1046 return E_NOINTERFACE;
1048 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1050 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1054 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1056 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1057 return E_NOINTERFACE;
1059 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1062 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1066 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1069 return E_NOINTERFACE;
1072 static ULONG WINAPI statusclb_AddRef(IBindStatusCallback *iface)
1077 static ULONG WINAPI statusclb_Release(IBindStatusCallback *iface)
1082 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved,
1085 IWinInetHttpInfo *http_info;
1089 if(iface == &objbsc)
1090 CHECK_EXPECT(Obj_OnStartBinding);
1092 CHECK_EXPECT(OnStartBinding);
1094 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1096 ok(pib != NULL, "pib should not be NULL\n");
1097 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1099 if(pib == (void*)0xdeadbeef)
1102 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1103 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1105 IMoniker_Release(mon);
1107 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1108 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1113 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
1115 ok(0, "unexpected call\n");
1119 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
1121 ok(0, "unexpected call\n");
1125 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
1126 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1128 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1130 switch(ulStatusCode) {
1131 case BINDSTATUS_FINDINGRESOURCE:
1132 if(iface == &objbsc)
1133 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1135 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1136 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1137 SetEvent(complete_event);
1139 case BINDSTATUS_CONNECTING:
1140 if(iface == &objbsc)
1141 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1143 CHECK_EXPECT(OnProgress_CONNECTING);
1144 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1145 SetEvent(complete_event);
1147 case BINDSTATUS_SENDINGREQUEST:
1148 if(iface == &objbsc)
1149 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1151 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1152 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1153 SetEvent(complete_event);
1155 case BINDSTATUS_MIMETYPEAVAILABLE:
1156 if(iface == &objbsc)
1157 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1159 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1161 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1163 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1165 case BINDSTATUS_BEGINDOWNLOADDATA:
1166 if(iface == &objbsc)
1167 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1169 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1170 ok(szStatusText != NULL, "szStatusText == NULL\n");
1175 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1179 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1181 download_state = DOWNLOADING;
1183 case BINDSTATUS_DOWNLOADINGDATA:
1184 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1185 if(iface == &objbsc)
1186 todo_wine ok(0, "unexpected call\n");
1187 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1190 case BINDSTATUS_ENDDOWNLOADDATA:
1191 if(iface == &objbsc)
1192 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1194 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1195 ok(szStatusText != NULL, "szStatusText == NULL\n");
1200 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1203 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1205 download_state = END_DOWNLOAD;
1207 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1208 if(test_protocol != HTTP_TEST) {
1209 if(iface == &objbsc)
1210 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1212 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1214 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1215 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1218 ok(szStatusText != NULL, "szStatusText == NULL\n");
1219 if(szStatusText && test_protocol == FILE_TEST)
1220 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1222 case BINDSTATUS_CLASSIDAVAILABLE:
1226 if(iface != &objbsc)
1227 ok(0, "unexpected call\n");
1228 else if(1||emulate_protocol)
1229 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1231 todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1232 hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
1233 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1234 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1235 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1238 case BINDSTATUS_BEGINSYNCOPERATION:
1239 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1240 if(iface != &objbsc)
1241 ok(0, "unexpected call\n");
1242 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1244 case BINDSTATUS_ENDSYNCOPERATION:
1245 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1246 if(iface != &objbsc)
1247 ok(0, "unexpected call\n");
1248 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1251 ok(0, "unexpected code %d\n", ulStatusCode);
1256 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
1258 if(iface == &objbsc) {
1259 CHECK_EXPECT(Obj_OnStopBinding);
1260 stopped_obj_binding = TRUE;
1262 CHECK_EXPECT(OnStopBinding);
1263 stopped_binding = TRUE;
1266 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1268 /* ignore DNS failure */
1269 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1273 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1275 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1276 ok(szError == NULL, "szError should be NULL\n");
1278 if(test_protocol == HTTP_TEST && emulate_protocol) {
1279 SetEvent(complete_event);
1280 if(iface != &objbsc)
1281 WaitForSingleObject(complete_event2, INFINITE);
1287 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1291 if(iface == &objbsc)
1292 CHECK_EXPECT(Obj_GetBindInfo);
1294 CHECK_EXPECT(GetBindInfo);
1296 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1299 cbSize = pbindinfo->cbSize;
1300 memset(pbindinfo, 0, cbSize);
1301 pbindinfo->cbSize = cbSize;
1306 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
1307 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1314 if(iface == &objbsc)
1315 ok(0, "unexpected call\n");
1317 CHECK_EXPECT2(OnDataAvailable);
1319 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1321 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1322 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1324 data_available = TRUE;
1326 ok(pformatetc != NULL, "pformatetx == NULL\n");
1330 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1331 "GetClipboardFormatName failed, error %d\n", GetLastError());
1332 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1333 pformatetc->cfFormat, clipfmt, mime_type);
1335 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1337 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1338 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1339 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1340 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1343 ok(pstgmed != NULL, "stgmeg == NULL\n");
1344 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1345 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1347 switch(pstgmed->tymed) {
1349 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1350 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1351 ok(hres == STG_E_ACCESSDENIED,
1352 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1354 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1355 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1357 hres = IStream_Revert(U(*pstgmed).pstm);
1358 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1361 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1362 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1363 while(hres == S_OK);
1364 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1368 if(test_protocol == FILE_TEST)
1369 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1370 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1371 else if(emulate_protocol)
1372 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1373 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1375 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1378 if(test_protocol == HTTP_TEST && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1379 SetEvent(complete_event);
1384 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
1386 CHECK_EXPECT(OnObjectAvailable);
1388 if(iface != &objbsc)
1389 ok(0, "unexpected call\n");
1391 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1392 ok(punk != NULL, "punk == NULL\n");
1397 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
1398 statusclb_QueryInterface,
1401 statusclb_OnStartBinding,
1402 statusclb_GetPriority,
1403 statusclb_OnLowResource,
1404 statusclb_OnProgress,
1405 statusclb_OnStopBinding,
1406 statusclb_GetBindInfo,
1407 statusclb_OnDataAvailable,
1408 statusclb_OnObjectAvailable
1411 static IBindStatusCallback bsc = { &BindStatusCallbackVtbl };
1412 static IBindStatusCallback objbsc = { &BindStatusCallbackVtbl };
1414 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1417 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1418 return E_NOINTERFACE;
1421 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
1426 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
1431 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
1435 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
1436 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", debugstr_w(val));
1439 CHECK_EXPECT(PutProperty_CLASSIDPROP);
1448 static const IMonikerPropVtbl MonikerPropVtbl = {
1449 MonikerProp_QueryInterface,
1451 MonikerProp_Release,
1452 MonikerProp_PutProperty
1455 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
1457 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
1461 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
1463 else if(IsEqualGUID(&IID_IMonikerProp, riid))
1464 *ppv = &MonikerProp;
1469 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1470 return E_NOINTERFACE;
1473 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
1478 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
1483 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
1485 ok(0, "unexpected call\n");
1489 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
1491 ok(0, "unexpected call\n");
1495 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
1496 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
1501 static WCHAR cbinding_contextW[] =
1502 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1505 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1507 if(test_protocol == HTTP_TEST)
1508 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1510 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1511 ok(pimkName != NULL, "pimkName == NULL\n");
1512 ok(pibc != NULL, "pibc == NULL\n");
1513 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
1515 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
1516 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
1517 if(SUCCEEDED(hres)) {
1520 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
1521 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
1523 IBinding_Release(binding);
1524 IUnknown_Release(unk);
1527 SET_EXPECT(QueryInterface_IServiceProvider);
1528 hres = RegisterBindStatusCallback(pibc, &bsc, NULL, 0);
1529 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1530 CHECK_CALLED(QueryInterface_IServiceProvider);
1532 SET_EXPECT(GetBindInfo);
1533 SET_EXPECT(OnStartBinding);
1534 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1535 if(test_protocol == FILE_TEST)
1536 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1537 if(test_protocol != HTTP_TEST)
1538 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1539 SET_EXPECT(LockRequest);
1540 SET_EXPECT(OnDataAvailable);
1541 if(test_protocol != HTTP_TEST)
1542 SET_EXPECT(OnStopBinding);
1544 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
1545 ok(hres == S_OK, "Load failed: %08x\n", hres);
1547 CHECK_CALLED(GetBindInfo);
1548 CHECK_CALLED(OnStartBinding);
1549 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1550 if(test_protocol == FILE_TEST)
1551 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1552 if(test_protocol != HTTP_TEST)
1553 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1554 CHECK_CALLED(LockRequest);
1555 CHECK_CALLED(OnDataAvailable);
1556 if(test_protocol != HTTP_TEST)
1557 CHECK_CALLED(OnStopBinding);
1560 IUnknown_Release(unk);
1565 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
1567 ok(0, "unexpected call\n");
1571 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
1573 ok(0, "unexpected call\n");
1577 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
1579 ok(0, "unexpected call\n");
1583 static const IPersistMonikerVtbl PersistMonikerVtbl = {
1584 PersistMoniker_QueryInterface,
1585 PersistMoniker_AddRef,
1586 PersistMoniker_Release,
1587 PersistMoniker_GetClassID,
1588 PersistMoniker_IsDirty,
1589 PersistMoniker_Load,
1590 PersistMoniker_Save,
1591 PersistMoniker_SaveCompleted,
1592 PersistMoniker_GetCurMoniker
1595 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
1597 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1601 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1606 if(IsEqualGUID(&IID_IMarshal, riid))
1607 return E_NOINTERFACE;
1608 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1609 return E_NOINTERFACE;
1611 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1615 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1620 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1625 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1627 CHECK_EXPECT(CreateInstance);
1628 ok(!outer, "outer = %p\n", outer);
1629 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1630 *ppv = &PersistMoniker;
1634 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1636 ok(0, "unexpected call\n");
1640 static const IClassFactoryVtbl ClassFactoryVtbl = {
1641 ClassFactory_QueryInterface,
1642 ClassFactory_AddRef,
1643 ClassFactory_Release,
1644 ClassFactory_CreateInstance,
1645 ClassFactory_LockServer
1648 static IClassFactory mime_cf = { &ClassFactoryVtbl };
1650 static void test_CreateAsyncBindCtx(void)
1652 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1658 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1659 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1660 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1662 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1663 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1665 SET_EXPECT(QueryInterface_IServiceProvider);
1666 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1667 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1668 CHECK_CALLED(QueryInterface_IServiceProvider);
1670 bindopts.cbStruct = sizeof(bindopts);
1671 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1672 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1673 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1674 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1675 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1676 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1678 ok(bindopts.dwTickCountDeadline == 0,
1679 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1681 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1682 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1684 IUnknown_Release(unk);
1686 ref = IBindCtx_Release(bctx);
1687 ok(ref == 0, "bctx should be destroyed here\n");
1690 static void test_CreateAsyncBindCtxEx(void)
1692 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1697 static WCHAR testW[] = {'t','e','s','t',0};
1699 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1700 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1702 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1703 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1705 if(SUCCEEDED(hres)) {
1706 bindopts.cbStruct = sizeof(bindopts);
1707 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1708 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1709 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1710 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1711 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1712 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1714 ok(bindopts.dwTickCountDeadline == 0,
1715 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1717 IBindCtx_Release(bctx);
1720 CreateBindCtx(0, &bctx_arg);
1721 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1722 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1724 if(SUCCEEDED(hres)) {
1725 bindopts.cbStruct = sizeof(bindopts);
1726 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1727 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1728 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1729 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1730 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1731 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1733 ok(bindopts.dwTickCountDeadline == 0,
1734 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1736 IBindCtx_Release(bctx);
1739 IBindCtx_Release(bctx_arg);
1741 SET_EXPECT(QueryInterface_IServiceProvider);
1742 hres = CreateAsyncBindCtxEx(NULL, 0, &bsc, NULL, &bctx, 0);
1743 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1744 CHECK_CALLED(QueryInterface_IServiceProvider);
1746 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1747 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1749 IUnknown_Release(unk);
1751 IBindCtx_Release(bctx);
1753 hres = CreateBindCtx(0, &bctx2);
1754 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1756 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1757 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1759 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1760 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1762 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1763 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1764 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1766 IBindCtx_Release(bctx);
1767 IBindCtx_Release(bctx2);
1770 static void test_bscholder(IBindStatusCallback *holder)
1772 IServiceProvider *serv_prov;
1773 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1774 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1775 IAuthenticate *authenticate, *authenticate_serv;
1776 IInternetProtocol *protocol;
1777 BINDINFO bindinfo = {sizeof(bindinfo)};
1782 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
1783 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
1786 SET_EXPECT(GetBindInfo);
1787 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
1788 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1789 CHECK_CALLED(GetBindInfo);
1791 SET_EXPECT(OnStartBinding);
1792 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
1793 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1794 CHECK_CALLED(OnStartBinding);
1796 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
1797 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
1799 wstr = (void*)0xdeadbeef;
1800 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol], (void*)0xdeadbeef, 0xff, &wstr);
1801 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1802 ok(wstr == NULL, "wstr = %p\n", wstr);
1804 SET_EXPECT(QueryInterface_IHttpNegotiate);
1805 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1806 (void**)&http_negotiate_serv);
1807 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1808 CHECK_CALLED(QueryInterface_IHttpNegotiate);
1810 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1812 wstr = (void*)0xdeadbeef;
1813 SET_EXPECT(BeginningTransaction);
1814 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
1815 CHECK_CALLED(BeginningTransaction);
1816 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1817 ok(wstr == NULL, "wstr = %p\n", wstr);
1819 IHttpNegotiate_Release(http_negotiate_serv);
1821 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1822 (void**)&http_negotiate_serv);
1823 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1824 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1825 IHttpNegotiate_Release(http_negotiate_serv);
1827 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
1828 if(SUCCEEDED(hres)) {
1829 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1830 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x\n", hres);
1832 SET_EXPECT(QueryInterface_IHttpNegotiate2);
1833 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
1834 (void**)&http_negotiate2_serv);
1835 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
1836 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
1837 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
1839 SET_EXPECT(GetRootSecurityId);
1840 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1841 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
1842 CHECK_CALLED(GetRootSecurityId);
1844 IHttpNegotiate_Release(http_negotiate2_serv);
1845 IHttpNegotiate_Release(http_negotiate2);
1847 skip("Could not get IHttpNegotiate2\n");
1850 SET_EXPECT(OnProgress_FINDINGRESOURCE);
1851 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
1852 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
1853 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
1855 SET_EXPECT(OnResponse);
1856 wstr = (void*)0xdeadbeef;
1857 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
1858 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
1859 CHECK_CALLED(OnResponse);
1861 IHttpNegotiate_Release(http_negotiate);
1863 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
1864 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
1866 SET_EXPECT(QueryInterface_IAuthenticate);
1867 SET_EXPECT(QueryService_IAuthenticate);
1868 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1869 (void**)&authenticate_serv);
1870 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1871 CHECK_CALLED(QueryInterface_IAuthenticate);
1872 CHECK_CALLED(QueryService_IAuthenticate);
1873 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1874 IAuthenticate_Release(authenticate_serv);
1876 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1877 (void**)&authenticate_serv);
1878 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1879 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1881 IAuthenticate_Release(authenticate);
1882 IAuthenticate_Release(authenticate_serv);
1884 SET_EXPECT(OnStopBinding);
1885 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
1886 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1887 CHECK_CALLED(OnStopBinding);
1889 SET_EXPECT(QueryInterface_IInternetProtocol);
1890 SET_EXPECT(QueryService_IInternetProtocol);
1891 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
1893 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
1894 CHECK_CALLED(QueryInterface_IInternetProtocol);
1895 CHECK_CALLED(QueryService_IInternetProtocol);
1897 IServiceProvider_Release(serv_prov);
1900 static void test_RegisterBindStatusCallback(void)
1902 IBindStatusCallback *prevbsc, *clb;
1907 hres = CreateBindCtx(0, &bindctx);
1908 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
1910 SET_EXPECT(QueryInterface_IServiceProvider);
1912 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
1913 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1915 SET_EXPECT(QueryInterface_IBindStatusCallback);
1916 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
1917 prevbsc = (void*)0xdeadbeef;
1918 hres = RegisterBindStatusCallback(bindctx, &bsc, &prevbsc, 0);
1919 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1920 ok(prevbsc == &bsc, "prevbsc=%p\n", prevbsc);
1921 CHECK_CALLED(QueryInterface_IBindStatusCallback);
1922 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
1924 CHECK_CALLED(QueryInterface_IServiceProvider);
1926 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1927 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1929 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
1930 IUnknown_Release(unk);
1931 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
1932 ok(clb != &bsc, "bsc == clb\n");
1934 test_bscholder(clb);
1936 IBindStatusCallback_Release(clb);
1938 hres = RevokeBindStatusCallback(bindctx, &bsc);
1939 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1941 unk = (void*)0xdeadbeef;
1942 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1943 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
1944 ok(unk == NULL, "unk != NULL\n");
1947 IUnknown_Release(unk);
1949 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
1950 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1952 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
1953 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1955 hres = RevokeBindStatusCallback(bindctx, NULL);
1956 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1958 IBindCtx_Release(bindctx);
1961 #define BINDTEST_EMULATE 1
1962 #define BINDTEST_TOOBJECT 2
1963 #define BINDTEST_FILEDWLAPI 4
1965 static void init_bind_test(int protocol, DWORD flags, DWORD t)
1967 test_protocol = protocol;
1968 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
1969 download_state = BEFORE_DOWNLOAD;
1970 stopped_binding = FALSE;
1971 stopped_obj_binding = FALSE;
1972 data_available = FALSE;
1974 binding_hres = S_OK;
1975 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
1977 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
1980 static void test_BindToStorage(int protocol, BOOL emul, DWORD t)
1984 LPOLESTR display_name;
1987 IBindStatusCallback *previousclb;
1988 IUnknown *unk = (IUnknown*)0x00ff00ff;
1991 init_bind_test(protocol, emul ? BINDTEST_EMULATE : 0, t);
1993 SET_EXPECT(QueryInterface_IServiceProvider);
1994 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1995 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
1996 CHECK_CALLED(QueryInterface_IServiceProvider);
2000 SET_EXPECT(QueryInterface_IServiceProvider);
2001 hres = RegisterBindStatusCallback(bctx, &bsc, &previousclb, 0);
2002 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2003 ok(previousclb == &bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2004 CHECK_CALLED(QueryInterface_IServiceProvider);
2006 IBindStatusCallback_Release(previousclb);
2008 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2009 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2011 IBindCtx_Release(bctx);
2015 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2016 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2018 IBinding_Release(bind);
2020 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2021 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2022 ok(!lstrcmpW(display_name, urls[test_protocol]),
2023 "GetDisplayName got wrong name %s\n", debugstr_w(display_name));
2024 CoTaskMemFree(display_name);
2026 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2027 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2029 SET_EXPECT(GetBindInfo);
2030 SET_EXPECT(QueryInterface_IInternetProtocol);
2031 if(!emulate_protocol)
2032 SET_EXPECT(QueryService_IInternetProtocol);
2033 SET_EXPECT(OnStartBinding);
2034 if(emulate_protocol) {
2036 if(test_protocol == HTTP_TEST)
2037 SET_EXPECT(Terminate);
2038 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2039 SET_EXPECT(UnlockRequest);
2041 if(test_protocol == HTTP_TEST) {
2042 SET_EXPECT(QueryInterface_IInternetBindInfo);
2043 SET_EXPECT(QueryService_IInternetBindInfo);
2044 SET_EXPECT(QueryInterface_IHttpNegotiate);
2045 SET_EXPECT(BeginningTransaction);
2046 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2047 SET_EXPECT(GetRootSecurityId);
2048 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2049 SET_EXPECT(OnProgress_CONNECTING);
2051 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2052 SET_EXPECT(OnProgress_SENDINGREQUEST);
2053 if(test_protocol == HTTP_TEST)
2054 SET_EXPECT(OnResponse);
2055 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2056 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2057 if(test_protocol == FILE_TEST)
2058 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2059 if(test_protocol == HTTP_TEST)
2060 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2061 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2062 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2063 SET_EXPECT(OnDataAvailable);
2064 SET_EXPECT(OnStopBinding);
2067 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2068 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2070 skip("Network unreachable, skipping tests\n");
2074 if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2075 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2076 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2077 ok(unk == NULL, "istr should be NULL\n");
2078 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2079 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2080 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2081 ok(unk == NULL, "istr should be NULL\n");
2083 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2084 ok(unk != NULL, "unk == NULL\n");
2087 IUnknown_Release(unk);
2092 while((bindf & BINDF_ASYNCHRONOUS) &&
2093 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
2094 TranslateMessage(&msg);
2095 DispatchMessage(&msg);
2098 CHECK_CALLED(GetBindInfo);
2099 CHECK_CALLED(QueryInterface_IInternetProtocol);
2100 if(!emulate_protocol)
2101 CHECK_CALLED(QueryService_IInternetProtocol);
2102 CHECK_CALLED(OnStartBinding);
2103 if(emulate_protocol) {
2104 CHECK_CALLED(Start);
2105 if(test_protocol == HTTP_TEST) {
2106 if(tymed == TYMED_FILE)
2108 CHECK_CALLED(Terminate);
2110 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2111 CHECK_CALLED(UnlockRequest);
2113 if(test_protocol == HTTP_TEST) {
2114 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2115 CLEAR_CALLED(QueryService_IInternetBindInfo);
2116 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2117 CHECK_CALLED(BeginningTransaction);
2118 /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
2119 * called on WinXP but not on Win98 */
2120 CLEAR_CALLED(QueryInterface_IHttpNegotiate2);
2121 CLEAR_CALLED(GetRootSecurityId);
2123 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2124 CHECK_CALLED(OnProgress_CONNECTING);
2126 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2127 /* IE7 does call this */
2128 CLEAR_CALLED(OnProgress_CONNECTING);
2131 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2132 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2133 if(test_protocol == HTTP_TEST)
2134 CHECK_CALLED(OnResponse);
2135 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2136 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2137 if(test_protocol == FILE_TEST)
2138 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2139 if(test_protocol == HTTP_TEST)
2140 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2141 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2142 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2143 CHECK_CALLED(OnDataAvailable);
2144 CHECK_CALLED(OnStopBinding);
2147 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2148 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2150 if(test_protocol == HTTP_TEST)
2151 http_is_first = FALSE;
2154 static void test_BindToObject(int protocol, BOOL emul)
2158 LPOLESTR display_name;
2162 IUnknown *unk = (IUnknown*)0x00ff00ff;
2165 init_bind_test(protocol, BINDTEST_TOOBJECT | (emul ? BINDTEST_EMULATE : 0), TYMED_ISTREAM);
2168 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
2169 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
2171 SET_EXPECT(QueryInterface_IServiceProvider);
2172 hres = CreateAsyncBindCtx(0, &objbsc, NULL, &bctx);
2173 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
2174 CHECK_CALLED(QueryInterface_IServiceProvider);
2178 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2179 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2181 IBindCtx_Release(bctx);
2185 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2186 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2188 IBinding_Release(bind);
2190 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2191 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2192 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
2194 SET_EXPECT(Obj_GetBindInfo);
2195 SET_EXPECT(QueryInterface_IInternetProtocol);
2196 if(!emulate_protocol)
2197 SET_EXPECT(QueryService_IInternetProtocol);
2198 SET_EXPECT(Obj_OnStartBinding);
2199 if(emulate_protocol) {
2201 if(test_protocol == HTTP_TEST)
2202 SET_EXPECT(Terminate);
2203 if(test_protocol == FILE_TEST)
2204 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2205 SET_EXPECT(UnlockRequest);
2207 if(test_protocol == HTTP_TEST) {
2208 SET_EXPECT(QueryInterface_IHttpNegotiate);
2209 SET_EXPECT(BeginningTransaction);
2210 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2211 SET_EXPECT(GetRootSecurityId);
2212 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
2213 SET_EXPECT(Obj_OnProgress_CONNECTING);
2215 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2216 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
2217 if(test_protocol == HTTP_TEST)
2218 SET_EXPECT(OnResponse);
2219 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
2220 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
2221 if(test_protocol == FILE_TEST)
2222 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2223 if(test_protocol == HTTP_TEST)
2224 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2225 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
2226 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
2227 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
2228 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
2229 SET_EXPECT(OnObjectAvailable);
2230 SET_EXPECT(Obj_OnStopBinding);
2233 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
2235 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2237 skip( "Network unreachable, skipping tests\n" );
2241 /* no point testing the calls if binding didn't even work */
2242 if (FAILED(hres)) return;
2244 if(bindf & BINDF_ASYNCHRONOUS) {
2245 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
2246 ok(unk == NULL, "istr should be NULL\n");
2248 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2249 ok(unk != NULL, "unk == NULL\n");
2251 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
2254 IUnknown_Release(unk);
2256 while((bindf & BINDF_ASYNCHRONOUS) &&
2257 !((!emul || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
2258 TranslateMessage(&msg);
2259 DispatchMessage(&msg);
2262 CHECK_CALLED(Obj_GetBindInfo);
2263 CHECK_CALLED(QueryInterface_IInternetProtocol);
2264 if(!emulate_protocol)
2265 CHECK_CALLED(QueryService_IInternetProtocol);
2266 CHECK_CALLED(Obj_OnStartBinding);
2267 if(emulate_protocol) {
2268 CHECK_CALLED(Start);
2269 if(test_protocol == HTTP_TEST)
2270 CHECK_CALLED(Terminate);
2271 if(test_protocol == FILE_TEST)
2272 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
2273 CHECK_CALLED(UnlockRequest);
2275 if(test_protocol == HTTP_TEST) {
2276 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2277 CHECK_CALLED(BeginningTransaction);
2278 /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
2279 * called on WinXP but not on Win98 */
2280 CLEAR_CALLED(QueryInterface_IHttpNegotiate2);
2281 CLEAR_CALLED(GetRootSecurityId);
2283 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2284 CHECK_CALLED(Obj_OnProgress_CONNECTING);
2286 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2287 /* IE7 does call this */
2288 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
2291 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST) {
2292 if(urls[test_protocol] == SHORT_RESPONSE_URL)
2293 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
2295 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
2297 if(test_protocol == HTTP_TEST)
2298 CHECK_CALLED(OnResponse);
2299 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
2300 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
2301 if(test_protocol == FILE_TEST)
2302 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2303 if(test_protocol == HTTP_TEST)
2304 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2305 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
2306 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
2307 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
2308 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
2309 CHECK_CALLED(OnObjectAvailable);
2310 CHECK_CALLED(Obj_OnStopBinding);
2313 if(test_protocol != HTTP_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL) {
2314 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2315 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2317 todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2319 if(bindf & BINDF_ASYNCHRONOUS)
2320 ok(IBindCtx_Release(bctx) != 0, "bctx should not be destroyed here\n");
2322 todo_wine ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2326 CoRevokeClassObject(regid);
2328 if(test_protocol == HTTP_TEST)
2329 http_is_first = FALSE;
2332 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
2337 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
2339 SET_EXPECT(GetBindInfo);
2340 SET_EXPECT(QueryInterface_IInternetProtocol);
2341 if(!emulate_protocol) {
2342 SET_EXPECT(QueryInterface_IServiceProvider);
2343 SET_EXPECT(QueryService_IInternetProtocol);
2345 SET_EXPECT(OnStartBinding);
2346 if(emulate_protocol) {
2348 SET_EXPECT(UnlockRequest);
2350 if(test_protocol == HTTP_TEST) {
2351 SET_EXPECT(QueryInterface_IHttpNegotiate);
2352 SET_EXPECT(BeginningTransaction);
2353 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2354 SET_EXPECT(GetRootSecurityId);
2356 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2357 SET_EXPECT(OnProgress_SENDINGREQUEST);
2358 if(test_protocol == HTTP_TEST)
2359 SET_EXPECT(OnResponse);
2360 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2361 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2362 if(test_protocol == FILE_TEST)
2363 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2364 if(test_protocol == HTTP_TEST)
2365 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2366 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2367 SET_EXPECT(OnStopBinding);
2370 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], dwl_htmlW, 0, &bsc);
2371 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2373 CHECK_CALLED(GetBindInfo);
2374 CHECK_CALLED(QueryInterface_IInternetProtocol);
2375 if(!emulate_protocol) {
2376 CHECK_CALLED(QueryInterface_IServiceProvider);
2377 CHECK_CALLED(QueryService_IInternetProtocol);
2379 CHECK_CALLED(OnStartBinding);
2380 if(emulate_protocol) {
2381 CHECK_CALLED(Start);
2382 CHECK_CALLED(UnlockRequest);
2384 if(test_protocol == HTTP_TEST) {
2385 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2386 CHECK_CALLED(BeginningTransaction);
2387 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2388 CHECK_CALLED(GetRootSecurityId);
2390 if(test_protocol == FILE_TEST)
2391 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2392 else if(test_protocol == HTTP_TEST)
2393 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
2394 if(test_protocol == HTTP_TEST)
2395 CHECK_CALLED(OnResponse);
2396 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2397 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2398 if(test_protocol == FILE_TEST)
2399 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2400 if(test_protocol == HTTP_TEST)
2401 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2402 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2403 CHECK_CALLED(OnStopBinding);
2406 res = DeleteFileA(dwl_htmlA);
2407 ok(res, "DeleteFile failed: %u\n", GetLastError());
2409 if(prot != FILE_TEST || emul)
2412 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
2413 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2415 res = DeleteFileA(dwl_htmlA);
2416 ok(res, "DeleteFile failed: %u\n", GetLastError());
2419 static void set_file_url(char *path)
2421 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
2422 CHAR INDEX_HTMLA[MAX_PATH];
2424 lstrcpyA(file_urlA, "file:///");
2425 lstrcatA(file_urlA, path);
2426 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
2428 lstrcpyA(INDEX_HTMLA, "file://");
2429 lstrcatA(INDEX_HTMLA, path);
2430 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
2433 static void create_file(void)
2437 CHAR path[MAX_PATH];
2439 static const char html_doc[] = "<HTML></HTML>";
2441 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2442 FILE_ATTRIBUTE_NORMAL, NULL);
2443 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2444 if(file == INVALID_HANDLE_VALUE)
2447 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2450 GetCurrentDirectoryA(MAX_PATH, path);
2451 lstrcatA(path, "\\");
2452 lstrcatA(path, wszIndexHtmlA);
2456 static void test_ReportResult(HRESULT exhres)
2458 IMoniker *mon = NULL;
2459 IBindCtx *bctx = NULL;
2460 IUnknown *unk = (void*)0xdeadbeef;
2463 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2464 binding_hres = exhres;
2466 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2467 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2469 SET_EXPECT(QueryInterface_IServiceProvider);
2470 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
2471 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2472 CHECK_CALLED(QueryInterface_IServiceProvider);
2474 SET_EXPECT(GetBindInfo);
2475 SET_EXPECT(QueryInterface_IInternetProtocol);
2476 SET_EXPECT(OnStartBinding);
2479 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2480 if(SUCCEEDED(exhres))
2481 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
2483 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
2484 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
2486 CHECK_CALLED(GetBindInfo);
2487 CHECK_CALLED(QueryInterface_IInternetProtocol);
2488 CHECK_CALLED(OnStartBinding);
2489 CHECK_CALLED(Start);
2491 ok(unk == NULL, "unk=%p\n", unk);
2493 IBindCtx_Release(bctx);
2494 IMoniker_Release(mon);
2497 static void test_BindToStorage_fail(void)
2499 IMoniker *mon = NULL;
2500 IBindCtx *bctx = NULL;
2504 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2505 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2509 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2510 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2512 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2513 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
2514 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
2516 IBindCtx_Release(bctx);
2518 IMoniker_Release(mon);
2520 test_ReportResult(E_NOTIMPL);
2521 test_ReportResult(S_FALSE);
2524 static void gecko_installer_workaround(BOOL disable)
2529 static BOOL has_url = FALSE;
2530 static char url[2048];
2532 if(!disable && !has_url)
2535 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
2536 if(res != ERROR_SUCCESS)
2540 DWORD type, size = sizeof(url);
2542 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
2543 if(res == ERROR_SUCCESS && type == REG_SZ)
2546 RegDeleteValue(hkey, "GeckoUrl");
2548 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
2556 gecko_installer_workaround(TRUE);
2558 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2559 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2560 thread_id = GetCurrentThreadId();
2564 test_CreateAsyncBindCtx();
2565 test_CreateAsyncBindCtxEx();
2566 test_RegisterBindStatusCallback();
2567 test_BindToStorage_fail();
2569 trace("synchronous http test (COM not initialised)...\n");
2570 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2574 trace("synchronous http test...\n");
2575 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2577 trace("synchronous http test (to object)...\n");
2578 test_BindToObject(HTTP_TEST, FALSE);
2580 trace("synchronous file test...\n");
2581 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2583 trace("synchronous file test (to object)...\n");
2584 test_BindToObject(FILE_TEST, FALSE);
2586 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2588 trace("http test...\n");
2589 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2591 trace("http test (to file)...\n");
2592 test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE);
2594 trace("http test (to object)...\n");
2595 test_BindToObject(HTTP_TEST, FALSE);
2597 trace("http test (short response)...\n");
2598 http_is_first = TRUE;
2599 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
2600 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2602 trace("http test (short response, to object)...\n");
2603 test_BindToObject(HTTP_TEST, FALSE);
2605 trace("emulated http test...\n");
2606 test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM);
2608 trace("emulated http test (to object)...\n");
2609 test_BindToObject(HTTP_TEST, TRUE);
2611 trace("emulated http test (to file)...\n");
2612 test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE);
2614 trace("about test...\n");
2615 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM);
2617 trace("about test (to file)...\n");
2618 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE);
2620 trace("about test (to object)...\n");
2621 test_BindToObject(ABOUT_TEST, FALSE);
2623 trace("emulated about test...\n");
2624 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM);
2626 trace("emulated about test (to file)...\n");
2627 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE);
2629 trace("emulated about test (to object)...\n");
2630 test_BindToObject(ABOUT_TEST, TRUE);
2632 trace("file test...\n");
2633 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2635 trace("file test (to file)...\n");
2636 test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE);
2638 trace("file test (to object)...\n");
2639 test_BindToObject(FILE_TEST, FALSE);
2641 trace("emulated file test...\n");
2642 test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM);
2644 trace("emulated file test (to file)...\n");
2645 test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE);
2647 trace("emulated file test (to object)...\n");
2648 test_BindToObject(FILE_TEST, TRUE);
2650 trace("emulated its test...\n");
2651 test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM);
2653 trace("emulated its test (to file)...\n");
2654 test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE);
2656 trace("emulated mk test...\n");
2657 test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM);
2659 trace("test URLDownloadToFile for file protocol...\n");
2660 test_URLDownloadToFile(FILE_TEST, FALSE);
2662 trace("test URLDownloadToFile for emulated file protocol...\n");
2663 test_URLDownloadToFile(FILE_TEST, TRUE);
2665 trace("test URLDownloadToFile for http protocol...\n");
2666 test_URLDownloadToFile(HTTP_TEST, FALSE);
2668 trace("test failures...\n");
2669 test_BindToStorage_fail();
2671 DeleteFileA(wszIndexHtmlA);
2672 CloseHandle(complete_event);
2673 CloseHandle(complete_event2);
2676 gecko_installer_workaround(FALSE);