push eb25bf65c4616aa55a810ed5c29198b1a080b208
[wine/hacks.git] / dlls / urlmon / tests / protocol.c
blobc9c42e8d673b42084042cb0075a69daaa1c6e9e8
1 /*
2 * Copyright 2005-2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "urlmon.h"
30 #include "wininet.h"
32 #define DEFINE_EXPECT(func) \
33 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
35 #define SET_EXPECT(func) \
36 expect_ ## func = TRUE
38 #define CHECK_EXPECT2(func) \
39 do { \
40 ok(expect_ ##func, "unexpected call " #func "\n"); \
41 called_ ## func = TRUE; \
42 }while(0)
44 #define CHECK_EXPECT(func) \
45 do { \
46 CHECK_EXPECT2(func); \
47 expect_ ## func = FALSE; \
48 }while(0)
50 #define CHECK_CALLED(func) \
51 do { \
52 ok(called_ ## func, "expected " #func "\n"); \
53 expect_ ## func = called_ ## func = FALSE; \
54 }while(0)
56 #define CHECK_NOT_CALLED(func) \
57 do { \
58 ok(!called_ ## func, "unexpected " #func "\n"); \
59 expect_ ## func = called_ ## func = FALSE; \
60 }while(0)
62 #define CLEAR_CALLED(func) \
63 expect_ ## func = called_ ## func = FALSE
65 DEFINE_EXPECT(GetBindInfo);
66 DEFINE_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
67 DEFINE_EXPECT(ReportProgress_DIRECTBIND);
68 DEFINE_EXPECT(ReportProgress_RAWMIMETYPE);
69 DEFINE_EXPECT(ReportProgress_FINDINGRESOURCE);
70 DEFINE_EXPECT(ReportProgress_CONNECTING);
71 DEFINE_EXPECT(ReportProgress_SENDINGREQUEST);
72 DEFINE_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
73 DEFINE_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
74 DEFINE_EXPECT(ReportProgress_PROTOCOLCLASSID);
75 DEFINE_EXPECT(ReportProgress_COOKIE_SENT);
76 DEFINE_EXPECT(ReportProgress_REDIRECTING);
77 DEFINE_EXPECT(ReportProgress_ENCODING);
78 DEFINE_EXPECT(ReportProgress_ACCEPTRANGES);
79 DEFINE_EXPECT(ReportProgress_PROXYDETECTING);
80 DEFINE_EXPECT(ReportData);
81 DEFINE_EXPECT(ReportResult);
82 DEFINE_EXPECT(GetBindString_ACCEPT_MIMES);
83 DEFINE_EXPECT(GetBindString_USER_AGENT);
84 DEFINE_EXPECT(GetBindString_POST_COOKIE);
85 DEFINE_EXPECT(QueryService_HttpNegotiate);
86 DEFINE_EXPECT(QueryService_InternetProtocol);
87 DEFINE_EXPECT(BeginningTransaction);
88 DEFINE_EXPECT(GetRootSecurityId);
89 DEFINE_EXPECT(OnResponse);
90 DEFINE_EXPECT(Switch);
91 DEFINE_EXPECT(Continue);
92 DEFINE_EXPECT(CreateInstance);
93 DEFINE_EXPECT(Start);
94 DEFINE_EXPECT(Terminate);
95 DEFINE_EXPECT(Read);
96 DEFINE_EXPECT(SetPriority);
97 DEFINE_EXPECT(LockRequest);
98 DEFINE_EXPECT(UnlockRequest);
100 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
101 static const WCHAR index_url[] =
102 {'f','i','l','e',':','i','n','d','e','x','.','h','t','m','l',0};
104 static const WCHAR acc_mimeW[] = {'*','/','*',0};
105 static const WCHAR user_agentW[] = {'W','i','n','e',0};
106 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
107 static const WCHAR hostW[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
108 static const WCHAR winehq_ipW[] = {'2','0','9','.','4','6','.','2','5','.','1','3','4',0};
109 static const WCHAR emptyW[] = {0};
111 static HRESULT expect_hrResult;
112 static LPCWSTR file_name, http_url, expect_wsz;
113 static IInternetProtocol *async_protocol = NULL;
114 static BOOL first_data_notif = FALSE, http_is_first = FALSE,
115 http_post_test = FALSE;
116 static int state = 0, prot_state;
117 static DWORD bindf = 0, ex_priority = 0;
118 static IInternetProtocol *binding_protocol;
119 static IInternetBindInfo *prot_bind_info;
120 static IInternetProtocolSink *binding_sink;
121 static void *expect_pv;
122 static HANDLE event_complete, event_complete2;
123 static BOOL binding_test;
124 static PROTOCOLDATA protocoldata, *pdata;
125 static DWORD prot_read;
127 static enum {
128 FILE_TEST,
129 HTTP_TEST,
130 HTTPS_TEST,
131 FTP_TEST,
132 MK_TEST,
133 BIND_TEST
134 } tested_protocol;
136 static const WCHAR protocol_names[][10] = {
137 {'f','i','l','e',0},
138 {'h','t','t','p',0},
139 {'h','t','t','p','s',0},
140 {'f','t','p',0},
141 {'m','k',0},
142 {'t','e','s','t',0}
145 static const WCHAR binding_urls[][130] = {
146 {'f','i','l','e',':','t','e','s','t','.','h','t','m','l',0},
147 {'h','t','t','p',':','/','/','t','e','s','t','/','t','e','s','t','.','h','t','m','l',0},
148 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
149 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0},
150 {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
151 '/','p','u','b','/','o','t','h','e','r',
152 '/','w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0},
153 {'m','k',':','t','e','s','t',0},
154 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0}
157 static const char *debugstr_w(LPCWSTR str)
159 static char buf[512];
160 if(!str)
161 return "(null)";
162 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
163 return buf;
166 static const char *debugstr_guid(REFIID riid)
168 static char buf[50];
170 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
171 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
172 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
173 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
175 return buf;
178 static int strcmp_wa(LPCWSTR strw, const char *stra)
180 WCHAR buf[512];
181 MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
182 return lstrcmpW(strw, buf);
185 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
187 if(IsEqualGUID(&IID_IUnknown, riid)
188 || IsEqualGUID(&IID_IHttpNegotiate, riid)
189 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
190 *ppv = iface;
191 return S_OK;
194 ok(0, "unexpected call\n");
195 return E_NOINTERFACE;
198 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
200 return 2;
203 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
205 return 1;
208 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
209 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
211 LPWSTR addl_headers;
213 static const WCHAR wszHeaders[] =
214 {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ','a','p','p','l','i','c','a','t',
215 'i','o','n','/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o',
216 'd','e','d','\r','\n',0};
218 CHECK_EXPECT(BeginningTransaction);
220 if(binding_test)
221 ok(!lstrcmpW(szURL, binding_urls[tested_protocol]), "szURL != http_url\n");
222 else
223 ok(!lstrcmpW(szURL, http_url), "szURL != http_url\n");
224 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
225 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
226 if(pszAdditionalHeaders)
228 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
229 if (http_post_test)
231 addl_headers = CoTaskMemAlloc(sizeof(wszHeaders));
232 if (!addl_headers)
234 http_post_test = FALSE;
235 skip("Out of memory\n");
236 return E_OUTOFMEMORY;
238 lstrcpyW(addl_headers, wszHeaders);
239 *pszAdditionalHeaders = addl_headers;
243 return S_OK;
246 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
247 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
249 CHECK_EXPECT(OnResponse);
251 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
252 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
253 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
254 ok(pszAdditionalRequestHeaders == NULL, "pszAdditionalHeaders != NULL\n");
256 return S_OK;
259 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
260 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
262 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
264 CHECK_EXPECT(GetRootSecurityId);
266 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
267 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
268 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
270 if(pcbSecurityId) {
271 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
272 *pcbSecurityId = sizeof(sec_id);
275 if(pbSecurityId)
276 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
278 return E_FAIL;
281 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
282 HttpNegotiate_QueryInterface,
283 HttpNegotiate_AddRef,
284 HttpNegotiate_Release,
285 HttpNegotiate_BeginningTransaction,
286 HttpNegotiate_OnResponse,
287 HttpNegotiate_GetRootSecurityId
290 static IHttpNegotiate2 http_negotiate = { &HttpNegotiateVtbl };
292 static HRESULT QueryInterface(REFIID,void**);
294 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
296 return QueryInterface(riid, ppv);
299 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
301 return 2;
304 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
306 return 1;
309 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
310 REFIID riid, void **ppv)
312 if(IsEqualGUID(&IID_IHttpNegotiate, guidService) || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
313 CHECK_EXPECT2(QueryService_HttpNegotiate);
314 return IHttpNegotiate2_QueryInterface(&http_negotiate, riid, ppv);
317 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
318 ok(IsEqualGUID(&IID_IInternetProtocol, riid), "unexpected riid\n");
319 CHECK_EXPECT(QueryService_InternetProtocol);
320 return E_NOINTERFACE;
323 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
324 return E_FAIL;
327 static const IServiceProviderVtbl ServiceProviderVtbl = {
328 ServiceProvider_QueryInterface,
329 ServiceProvider_AddRef,
330 ServiceProvider_Release,
331 ServiceProvider_QueryService
334 static IServiceProvider service_provider = { &ServiceProviderVtbl };
336 static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
338 return QueryInterface(riid, ppv);
341 static ULONG WINAPI ProtocolSink_AddRef(IInternetProtocolSink *iface)
343 return 2;
346 static ULONG WINAPI ProtocolSink_Release(IInternetProtocolSink *iface)
348 return 1;
351 static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
353 HRESULT hres;
355 CHECK_EXPECT(Switch);
356 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
358 pdata = pProtocolData;
360 if(binding_test) {
361 SetEvent(event_complete);
362 WaitForSingleObject(event_complete2, INFINITE);
363 return S_OK;
366 if (!state) {
367 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST || tested_protocol == FTP_TEST) {
368 if (http_is_first) {
369 CLEAR_CALLED(ReportProgress_FINDINGRESOURCE);
370 CLEAR_CALLED(ReportProgress_CONNECTING);
371 CLEAR_CALLED(ReportProgress_PROXYDETECTING);
372 } else todo_wine {
373 CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE);
374 /* IE7 does call this */
375 CLEAR_CALLED(ReportProgress_CONNECTING);
378 if(tested_protocol == FTP_TEST)
379 todo_wine CHECK_CALLED(ReportProgress_SENDINGREQUEST);
380 else
381 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
382 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
383 SET_EXPECT(OnResponse);
384 if(tested_protocol == HTTPS_TEST)
385 SET_EXPECT(ReportProgress_ACCEPTRANGES);
386 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
387 if(bindf & BINDF_NEEDFILE)
388 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
392 SET_EXPECT(ReportData);
393 hres = IInternetProtocol_Continue(async_protocol, pProtocolData);
394 ok(hres == S_OK, "Continue failed: %08x\n", hres);
395 if(tested_protocol == FTP_TEST)
396 CLEAR_CALLED(ReportData);
397 else
398 CHECK_CALLED(ReportData);
400 if (!state) {
401 state = 1;
402 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
403 CHECK_CALLED(OnResponse);
404 if(tested_protocol == HTTPS_TEST)
405 CHECK_CALLED(ReportProgress_ACCEPTRANGES);
406 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
407 if(bindf & BINDF_NEEDFILE)
408 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
412 SetEvent(event_complete);
414 return S_OK;
417 static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
418 LPCWSTR szStatusText)
420 static const WCHAR null_guid[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-',
421 '0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}',0};
422 static const WCHAR text_plain[] = {'t','e','x','t','/','p','l','a','i','n',0};
424 switch(ulStatusCode) {
425 case BINDSTATUS_MIMETYPEAVAILABLE:
426 CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
427 ok(szStatusText != NULL, "szStatusText == NULL\n");
428 if(szStatusText) {
429 if(tested_protocol == BIND_TEST)
430 ok(szStatusText == expect_wsz, "unexpected szStatusText\n");
431 else if (http_post_test)
432 ok(lstrlenW(text_plain) <= lstrlenW(szStatusText) &&
433 !memcmp(szStatusText, text_plain, lstrlenW(text_plain)*sizeof(WCHAR)),
434 "szStatusText != text/plain\n");
435 else
436 ok(lstrlenW(text_htmlW) <= lstrlenW(szStatusText) &&
437 !memcmp(szStatusText, text_htmlW, lstrlenW(text_htmlW)*sizeof(WCHAR)),
438 "szStatusText != text/html\n");
440 break;
441 case BINDSTATUS_DIRECTBIND:
442 CHECK_EXPECT2(ReportProgress_DIRECTBIND);
443 ok(szStatusText == NULL, "szStatusText != NULL\n");
444 break;
445 case BINDSTATUS_RAWMIMETYPE:
446 CHECK_EXPECT2(ReportProgress_RAWMIMETYPE);
447 ok(szStatusText != NULL, "szStatusText == NULL\n");
448 if(szStatusText)
449 ok(lstrlenW(szStatusText) < lstrlenW(text_htmlW) ||
450 !memcmp(szStatusText, text_htmlW, lstrlenW(text_htmlW)*sizeof(WCHAR)),
451 "szStatusText != text/html\n");
452 break;
453 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
454 CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
455 ok(szStatusText != NULL, "szStatusText == NULL\n");
456 if(szStatusText) {
457 if(binding_test)
458 ok(!lstrcmpW(szStatusText, expect_wsz), "unexpected szStatusText\n");
459 else if(tested_protocol == FILE_TEST)
460 ok(!lstrcmpW(szStatusText, file_name), "szStatusText = \"%s\"\n", debugstr_w(szStatusText));
461 else
462 ok(szStatusText != NULL, "szStatusText == NULL\n");
464 break;
465 case BINDSTATUS_FINDINGRESOURCE:
466 CHECK_EXPECT(ReportProgress_FINDINGRESOURCE);
467 ok(szStatusText != NULL, "szStatusText == NULL\n");
468 break;
469 case BINDSTATUS_CONNECTING:
470 CHECK_EXPECT(ReportProgress_CONNECTING);
471 ok(szStatusText != NULL, "szStatusText == NULL\n");
472 break;
473 case BINDSTATUS_SENDINGREQUEST:
474 CHECK_EXPECT2(ReportProgress_SENDINGREQUEST);
475 if(tested_protocol == FILE_TEST) {
476 ok(szStatusText != NULL, "szStatusText == NULL\n");
477 if(szStatusText)
478 ok(!*szStatusText, "wrong szStatusText\n");
480 break;
481 case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
482 CHECK_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
483 ok(szStatusText != NULL, "szStatusText == NULL\n");
484 if(szStatusText)
485 ok(!lstrcmpW(szStatusText, text_htmlW), "szStatusText != text/html\n");
486 break;
487 case BINDSTATUS_PROTOCOLCLASSID:
488 CHECK_EXPECT(ReportProgress_PROTOCOLCLASSID);
489 ok(szStatusText != NULL, "szStatusText == NULL\n");
490 ok(!lstrcmpW(szStatusText, null_guid), "unexpected szStatusText\n");
491 break;
492 case BINDSTATUS_COOKIE_SENT:
493 CHECK_EXPECT(ReportProgress_COOKIE_SENT);
494 ok(szStatusText == NULL, "szStatusText != NULL\n");
495 break;
496 case BINDSTATUS_REDIRECTING:
497 CHECK_EXPECT(ReportProgress_REDIRECTING);
498 ok(szStatusText == NULL, "szStatusText = %s\n", debugstr_w(szStatusText));
499 break;
500 case BINDSTATUS_ENCODING:
501 CHECK_EXPECT(ReportProgress_ENCODING);
502 ok(!strcmp_wa(szStatusText, "gzip"), "szStatusText = %s\n", debugstr_w(szStatusText));
503 break;
504 case BINDSTATUS_ACCEPTRANGES:
505 CHECK_EXPECT(ReportProgress_ACCEPTRANGES);
506 ok(!szStatusText, "szStatusText = %s\n", debugstr_w(szStatusText));
507 break;
508 case BINDSTATUS_PROXYDETECTING:
509 CHECK_EXPECT(ReportProgress_PROXYDETECTING);
510 SET_EXPECT(ReportProgress_CONNECTING);
511 ok(!szStatusText, "szStatusText = %s\n", debugstr_w(szStatusText));
512 break;
513 default:
514 ok(0, "Unexpected status %d\n", ulStatusCode);
517 return S_OK;
520 static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF,
521 ULONG ulProgress, ULONG ulProgressMax)
523 if(tested_protocol == FILE_TEST) {
524 CHECK_EXPECT2(ReportData);
526 ok(ulProgress == ulProgressMax, "ulProgress (%d) != ulProgressMax (%d)\n",
527 ulProgress, ulProgressMax);
528 ok(ulProgressMax == 13, "ulProgressMax=%d, expected 13\n", ulProgressMax);
529 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION),
530 "grcfBSCF = %08x\n", grfBSCF);
531 }else if(!binding_test && (tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST || tested_protocol == FTP_TEST)) {
532 if(!(grfBSCF & BSCF_LASTDATANOTIFICATION) || (grfBSCF & BSCF_DATAFULLYAVAILABLE))
533 CHECK_EXPECT(ReportData);
534 else if (http_post_test)
535 ok(ulProgress == 13, "Read %u bytes instead of 13\n", ulProgress);
537 ok(ulProgress, "ulProgress == 0\n");
539 if(first_data_notif) {
540 ok(grfBSCF == BSCF_FIRSTDATANOTIFICATION
541 || grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE),
542 "grcfBSCF = %08x\n", grfBSCF);
543 first_data_notif = FALSE;
544 } else {
545 ok(grfBSCF == BSCF_INTERMEDIATEDATANOTIFICATION
546 || grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION)
547 || broken(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION)),
548 "grcfBSCF = %08x\n", grfBSCF);
551 if(!(bindf & BINDF_FROMURLMON) &&
552 !(grfBSCF & BSCF_LASTDATANOTIFICATION)) {
553 if(!state) {
554 state = 1;
555 if(http_is_first) {
556 CHECK_CALLED(ReportProgress_FINDINGRESOURCE);
557 CHECK_CALLED(ReportProgress_CONNECTING);
558 } else todo_wine {
559 CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE);
560 CHECK_NOT_CALLED(ReportProgress_CONNECTING);
562 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
563 CHECK_CALLED(OnResponse);
564 CHECK_CALLED(ReportProgress_RAWMIMETYPE);
566 SetEvent(event_complete);
568 }else {
569 BYTE buf[1000];
570 ULONG read;
571 HRESULT hres;
573 CHECK_EXPECT(ReportData);
575 if(tested_protocol == BIND_TEST)
576 return S_OK;
578 do {
579 SET_EXPECT(Read);
580 hres = IInternetProtocol_Read(binding_protocol, expect_pv=buf, sizeof(buf), &read);
581 CHECK_CALLED(Read);
582 }while(hres == S_OK);
585 return S_OK;
588 static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult,
589 DWORD dwError, LPCWSTR szResult)
591 CHECK_EXPECT(ReportResult);
593 if(tested_protocol == FTP_TEST)
594 ok(hrResult == E_PENDING || hrResult == S_OK, "hrResult = %08x, expected E_PENDING or S_OK\n", hrResult);
595 else
596 ok(hrResult == expect_hrResult, "hrResult = %08x, expected: %08x\n",
597 hrResult, expect_hrResult);
598 if(SUCCEEDED(hrResult) || tested_protocol == FTP_TEST)
599 ok(dwError == ERROR_SUCCESS, "dwError = %d, expected ERROR_SUCCESS\n", dwError);
600 else
601 ok(dwError != ERROR_SUCCESS, "dwError == ERROR_SUCCESS\n");
602 ok(!szResult, "szResult != NULL\n");
604 return S_OK;
607 static IInternetProtocolSinkVtbl protocol_sink_vtbl = {
608 ProtocolSink_QueryInterface,
609 ProtocolSink_AddRef,
610 ProtocolSink_Release,
611 ProtocolSink_Switch,
612 ProtocolSink_ReportProgress,
613 ProtocolSink_ReportData,
614 ProtocolSink_ReportResult
617 static IInternetProtocolSink protocol_sink = { &protocol_sink_vtbl };
619 static HRESULT QueryInterface(REFIID riid, void **ppv)
621 *ppv = NULL;
623 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid))
624 *ppv = &protocol_sink;
625 if(IsEqualGUID(&IID_IServiceProvider, riid))
626 *ppv = &service_provider;
628 if(*ppv)
629 return S_OK;
631 return E_NOINTERFACE;
634 static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
636 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) {
637 *ppv = iface;
638 return S_OK;
640 return E_NOINTERFACE;
643 static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
645 return 2;
648 static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
650 return 1;
653 static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
655 DWORD cbSize;
657 static const CHAR szPostData[] = "mode=Test";
659 CHECK_EXPECT(GetBindInfo);
661 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
662 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
663 ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %d\n", pbindinfo->cbSize);
665 *grfBINDF = bindf;
666 if(binding_test)
667 *grfBINDF |= BINDF_FROMURLMON;
668 cbSize = pbindinfo->cbSize;
669 memset(pbindinfo, 0, cbSize);
670 pbindinfo->cbSize = cbSize;
672 if (http_post_test)
674 /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly
675 * with urlmon on native (Win98 and WinXP) */
676 U(pbindinfo->stgmedData).hGlobal = GlobalAlloc(GPTR, sizeof(szPostData));
677 if (!U(pbindinfo->stgmedData).hGlobal)
679 http_post_test = FALSE;
680 skip("Out of memory\n");
681 return E_OUTOFMEMORY;
683 lstrcpy((LPSTR)U(pbindinfo->stgmedData).hGlobal, szPostData);
684 pbindinfo->cbstgmedData = sizeof(szPostData)-1;
685 pbindinfo->dwBindVerb = BINDVERB_POST;
686 pbindinfo->stgmedData.tymed = TYMED_HGLOBAL;
689 return S_OK;
692 static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType,
693 LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
695 ok(ppwzStr != NULL, "ppwzStr == NULL\n");
696 ok(pcElFetched != NULL, "pcElFetched == NULL\n");
698 switch(ulStringType) {
699 case BINDSTRING_ACCEPT_MIMES:
700 CHECK_EXPECT(GetBindString_ACCEPT_MIMES);
701 ok(cEl == 256, "cEl=%d, expected 256\n", cEl);
702 if(pcElFetched) {
703 ok(*pcElFetched == 256, "*pcElFetched=%d, expected 256\n", *pcElFetched);
704 *pcElFetched = 1;
706 if(ppwzStr) {
707 *ppwzStr = CoTaskMemAlloc(sizeof(acc_mimeW));
708 memcpy(*ppwzStr, acc_mimeW, sizeof(acc_mimeW));
710 return S_OK;
711 case BINDSTRING_USER_AGENT:
712 CHECK_EXPECT(GetBindString_USER_AGENT);
713 ok(cEl == 1, "cEl=%d, expected 1\n", cEl);
714 if(pcElFetched) {
715 ok(*pcElFetched == 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched);
716 *pcElFetched = 1;
718 if(ppwzStr) {
719 *ppwzStr = CoTaskMemAlloc(sizeof(user_agentW));
720 memcpy(*ppwzStr, user_agentW, sizeof(user_agentW));
722 return S_OK;
723 case BINDSTRING_POST_COOKIE:
724 CHECK_EXPECT(GetBindString_POST_COOKIE);
725 ok(cEl == 1, "cEl=%d, expected 1\n", cEl);
726 if(pcElFetched)
727 ok(*pcElFetched == 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched);
728 return S_OK;
729 default:
730 ok(0, "unexpected call\n");
733 return E_NOTIMPL;
736 static IInternetBindInfoVtbl bind_info_vtbl = {
737 BindInfo_QueryInterface,
738 BindInfo_AddRef,
739 BindInfo_Release,
740 BindInfo_GetBindInfo,
741 BindInfo_GetBindString
744 static IInternetBindInfo bind_info = { &bind_info_vtbl };
746 static HRESULT WINAPI InternetPriority_QueryInterface(IInternetPriority *iface,
747 REFIID riid, void **ppv)
749 ok(0, "unexpected call\n");
750 return E_NOINTERFACE;
753 static ULONG WINAPI InternetPriority_AddRef(IInternetPriority *iface)
755 return 2;
758 static ULONG WINAPI InternetPriority_Release(IInternetPriority *iface)
760 return 1;
763 static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
765 CHECK_EXPECT(SetPriority);
766 ok(nPriority == ex_priority, "nPriority=%d\n", nPriority);
767 return S_OK;
770 static HRESULT WINAPI InternetPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
772 ok(0, "unexpected call\n");
773 return E_NOTIMPL;
777 static const IInternetPriorityVtbl InternetPriorityVtbl = {
778 InternetPriority_QueryInterface,
779 InternetPriority_AddRef,
780 InternetPriority_Release,
781 InternetPriority_SetPriority,
782 InternetPriority_GetPriority
785 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
787 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
789 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
790 *ppv = iface;
791 return S_OK;
794 if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) {
795 trace("IID_IInternetProtocolEx not supported\n");
796 *ppv = NULL;
797 return E_NOINTERFACE;
800 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
801 *ppv = &InternetPriority;
802 return S_OK;
805 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
806 *ppv = NULL;
807 return E_NOINTERFACE;
810 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
812 return 2;
815 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
817 return 1;
820 static DWORD WINAPI thread_proc(PVOID arg)
822 HRESULT hres;
824 memset(&protocoldata, -1, sizeof(protocoldata));
826 prot_state = 0;
828 SET_EXPECT(ReportProgress_FINDINGRESOURCE);
829 hres = IInternetProtocolSink_ReportProgress(binding_sink,
830 BINDSTATUS_FINDINGRESOURCE, hostW);
831 CHECK_CALLED(ReportProgress_FINDINGRESOURCE);
832 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
834 SET_EXPECT(ReportProgress_CONNECTING);
835 hres = IInternetProtocolSink_ReportProgress(binding_sink,
836 BINDSTATUS_CONNECTING, winehq_ipW);
837 CHECK_CALLED(ReportProgress_CONNECTING);
838 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
840 SET_EXPECT(ReportProgress_SENDINGREQUEST);
841 hres = IInternetProtocolSink_ReportProgress(binding_sink,
842 BINDSTATUS_SENDINGREQUEST, NULL);
843 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
844 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
846 prot_state = 1;
847 SET_EXPECT(Switch);
848 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
849 CHECK_CALLED(Switch);
850 ok(hres == S_OK, "Switch failed: %08x\n", hres);
852 prot_state = 2;
853 SET_EXPECT(Switch);
854 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
855 CHECK_CALLED(Switch);
856 ok(hres == S_OK, "Switch failed: %08x\n", hres);
858 prot_state = 2;
859 SET_EXPECT(Switch);
860 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
861 CHECK_CALLED(Switch);
862 ok(hres == S_OK, "Switch failed: %08x\n", hres);
864 prot_state = 3;
865 SET_EXPECT(Switch);
866 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
867 CHECK_CALLED(Switch);
868 ok(hres == S_OK, "Switch failed: %08x\n", hres);
870 SetEvent(event_complete);
872 return 0;
875 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
876 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
877 DWORD grfPI, DWORD dwReserved)
879 BINDINFO bindinfo, exp_bindinfo;
880 DWORD cbindf = 0;
881 HRESULT hres;
883 CHECK_EXPECT(Start);
885 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
886 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
887 ok(pOIProtSink != &protocol_sink, "unexpected pOIProtSink\n");
888 ok(pOIBindInfo != &bind_info, "unexpected pOIBindInfo\n");
889 ok(!grfPI, "grfPI = %x\n", grfPI);
890 ok(!dwReserved, "dwReserved = %d\n", dwReserved);
892 memset(&bindinfo, 0, sizeof(bindinfo));
893 bindinfo.cbSize = sizeof(bindinfo);
894 memcpy(&exp_bindinfo, &bindinfo, sizeof(bindinfo));
895 SET_EXPECT(GetBindInfo);
896 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &cbindf, &bindinfo);
897 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
898 CHECK_CALLED(GetBindInfo);
899 ok(cbindf == (bindf|BINDF_FROMURLMON), "bindf = %x, expected %x\n",
900 cbindf, (bindf|BINDF_FROMURLMON));
901 ok(!memcmp(&exp_bindinfo, &bindinfo, sizeof(bindinfo)), "unexpected bindinfo\n");
902 ReleaseBindInfo(&bindinfo);
904 SET_EXPECT(ReportProgress_SENDINGREQUEST);
905 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, emptyW);
906 ok(hres == S_OK, "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
907 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
909 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
910 IServiceProvider *service_provider;
911 IHttpNegotiate *http_negotiate;
912 IHttpNegotiate2 *http_negotiate2;
913 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
914 LPWSTR additional_headers = NULL;
915 BYTE sec_id[100];
916 DWORD fetched = 0, size = 100;
917 DWORD tid;
919 SET_EXPECT(GetBindString_USER_AGENT);
920 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
921 &ua, 1, &fetched);
922 CHECK_CALLED(GetBindString_USER_AGENT);
923 ok(hres == S_OK, "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
924 ok(fetched == 1, "fetched = %d, expected 254\n", fetched);
925 ok(ua != NULL, "ua = %p\n", ua);
926 ok(!lstrcmpW(ua, user_agentW), "unexpected user agent %s\n", debugstr_w(ua));
927 CoTaskMemFree(ua);
929 fetched = 256;
930 SET_EXPECT(GetBindString_ACCEPT_MIMES);
931 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
932 accept_mimes, 256, &fetched);
933 CHECK_CALLED(GetBindString_ACCEPT_MIMES);
935 ok(hres == S_OK,
936 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
937 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
938 ok(!lstrcmpW(acc_mimeW, accept_mimes[0]), "unexpected mimes %s\n", debugstr_w(accept_mimes[0]));
940 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
941 (void**)&service_provider);
942 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
944 SET_EXPECT(QueryService_HttpNegotiate);
945 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
946 &IID_IHttpNegotiate, (void**)&http_negotiate);
947 CHECK_CALLED(QueryService_HttpNegotiate);
948 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
950 SET_EXPECT(BeginningTransaction);
951 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, binding_urls[tested_protocol],
952 NULL, 0, &additional_headers);
953 CHECK_CALLED(BeginningTransaction);
954 IHttpNegotiate_Release(http_negotiate);
955 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
956 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
958 SET_EXPECT(QueryService_HttpNegotiate);
959 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
960 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
961 CHECK_CALLED(QueryService_HttpNegotiate);
962 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
964 size = 512;
965 SET_EXPECT(GetRootSecurityId);
966 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
967 CHECK_CALLED(GetRootSecurityId);
968 IHttpNegotiate2_Release(http_negotiate2);
969 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
970 ok(size == 13, "size=%d\n", size);
972 IServiceProvider_Release(service_provider);
974 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
976 return S_OK;
979 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
980 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
981 BINDSTATUS_CACHEFILENAMEAVAILABLE, expect_wsz = emptyW);
982 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
983 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
985 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
986 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE,
987 expect_wsz = text_htmlW);
988 ok(hres == S_OK,
989 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
990 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
992 SET_EXPECT(ReportData);
993 hres = IInternetProtocolSink_ReportData(pOIProtSink,
994 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
995 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
996 CHECK_CALLED(ReportData);
998 if(tested_protocol == BIND_TEST) {
999 hres = IInternetProtocol_Terminate(binding_protocol, 0);
1000 ok(hres == E_FAIL, "Termiante failed: %08x\n", hres);
1003 SET_EXPECT(ReportResult);
1004 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
1005 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1006 CHECK_CALLED(ReportResult);
1008 return S_OK;
1011 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
1012 PROTOCOLDATA *pProtocolData)
1014 DWORD bscf = 0;
1015 HRESULT hres;
1017 CHECK_EXPECT(Continue);
1019 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
1020 if(!pProtocolData || tested_protocol == BIND_TEST)
1021 return S_OK;
1023 switch(prot_state) {
1024 case 1: {
1025 IServiceProvider *service_provider;
1026 IHttpNegotiate *http_negotiate;
1027 static WCHAR header[] = {'?',0};
1029 hres = IInternetProtocolSink_QueryInterface(binding_sink, &IID_IServiceProvider,
1030 (void**)&service_provider);
1031 ok(hres == S_OK, "Could not get IServiceProvicder\n");
1033 SET_EXPECT(QueryService_HttpNegotiate);
1034 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
1035 &IID_IHttpNegotiate, (void**)&http_negotiate);
1036 IServiceProvider_Release(service_provider);
1037 CHECK_CALLED(QueryService_HttpNegotiate);
1038 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
1040 SET_EXPECT(OnResponse);
1041 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
1042 IHttpNegotiate_Release(http_negotiate);
1043 CHECK_CALLED(OnResponse);
1044 IHttpNegotiate_Release(http_negotiate);
1045 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
1047 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
1048 hres = IInternetProtocolSink_ReportProgress(binding_sink,
1049 BINDSTATUS_MIMETYPEAVAILABLE, text_htmlW);
1050 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1051 ok(hres == S_OK,
1052 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1054 bscf |= BSCF_FIRSTDATANOTIFICATION;
1055 break;
1057 case 2:
1058 case 3:
1059 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
1060 break;
1063 SET_EXPECT(ReportData);
1064 hres = IInternetProtocolSink_ReportData(binding_sink, bscf, 100, 400);
1065 CHECK_CALLED(ReportData);
1066 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1068 if(prot_state == 3)
1069 prot_state = 4;
1071 return S_OK;
1074 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
1075 DWORD dwOptions)
1077 ok(0, "unexpected call\n");
1078 return E_NOTIMPL;
1081 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
1083 CHECK_EXPECT(Terminate);
1084 ok(!dwOptions, "dwOptions=%d\n", dwOptions);
1085 return S_OK;
1088 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
1090 ok(0, "unexpected call\n");
1091 return E_NOTIMPL;
1094 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
1096 ok(0, "unexpected call\n");
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
1101 ULONG cb, ULONG *pcbRead)
1103 static BOOL b = TRUE;
1105 CHECK_EXPECT(Read);
1107 ok(pv == expect_pv, "pv != expect_pv\n");
1108 ok(cb == 1000, "cb=%d\n", cb);
1109 ok(pcbRead != NULL, "pcbRead == NULL\n");
1110 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
1112 if(prot_state == 3) {
1113 HRESULT hres;
1115 SET_EXPECT(ReportResult);
1116 hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL);
1117 CHECK_CALLED(ReportResult);
1119 return S_FALSE;
1122 if((b = !b))
1123 return tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST ? E_PENDING : S_FALSE;
1125 memset(pv, 'x', 100);
1126 prot_read += *pcbRead = 100;
1127 return S_OK;
1130 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
1131 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
1133 ok(0, "unexpected call\n");
1134 return E_NOTIMPL;
1137 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
1139 CHECK_EXPECT(LockRequest);
1140 ok(dwOptions == 0, "dwOptions=%x\n", dwOptions);
1141 return S_OK;
1144 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
1146 CHECK_EXPECT(UnlockRequest);
1147 return S_OK;
1150 static const IInternetProtocolVtbl ProtocolVtbl = {
1151 Protocol_QueryInterface,
1152 Protocol_AddRef,
1153 Protocol_Release,
1154 Protocol_Start,
1155 Protocol_Continue,
1156 Protocol_Abort,
1157 Protocol_Terminate,
1158 Protocol_Suspend,
1159 Protocol_Resume,
1160 Protocol_Read,
1161 Protocol_Seek,
1162 Protocol_LockRequest,
1163 Protocol_UnlockRequest
1166 static IInternetProtocol Protocol = { &ProtocolVtbl };
1168 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1170 ok(0, "unexpected call\n");
1171 return E_NOINTERFACE;
1174 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1176 return 2;
1179 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1181 return 1;
1184 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
1185 REFIID riid, void **ppv)
1187 CHECK_EXPECT(CreateInstance);
1189 ok(pOuter == (IUnknown*)prot_bind_info, "pOuter != protocol_unk\n");
1190 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1191 ok(ppv != NULL, "ppv == NULL\n");
1193 *ppv = &Protocol;
1194 return S_OK;
1197 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1199 ok(0, "unexpected call\n");
1200 return S_OK;
1203 static const IClassFactoryVtbl ClassFactoryVtbl = {
1204 ClassFactory_QueryInterface,
1205 ClassFactory_AddRef,
1206 ClassFactory_Release,
1207 ClassFactory_CreateInstance,
1208 ClassFactory_LockServer
1211 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
1213 static void test_priority(IInternetProtocol *protocol)
1215 IInternetPriority *priority;
1216 LONG pr;
1217 HRESULT hres;
1219 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority,
1220 (void**)&priority);
1221 ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres);
1222 if(FAILED(hres))
1223 return;
1225 hres = IInternetPriority_GetPriority(priority, &pr);
1226 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
1227 ok(pr == 0, "pr=%d, expected 0\n", pr);
1229 hres = IInternetPriority_SetPriority(priority, 1);
1230 ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
1232 hres = IInternetPriority_GetPriority(priority, &pr);
1233 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
1234 ok(pr == 1, "pr=%d, expected 1\n", pr);
1236 IInternetPriority_Release(priority);
1239 static BOOL file_protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL is_first)
1241 HRESULT hres;
1243 SET_EXPECT(GetBindInfo);
1244 if(!(bindf & BINDF_FROMURLMON))
1245 SET_EXPECT(ReportProgress_DIRECTBIND);
1246 if(is_first) {
1247 SET_EXPECT(ReportProgress_SENDINGREQUEST);
1248 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
1249 if(bindf & BINDF_FROMURLMON)
1250 SET_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
1251 else
1252 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
1254 SET_EXPECT(ReportData);
1255 if(is_first)
1256 SET_EXPECT(ReportResult);
1258 expect_hrResult = S_OK;
1260 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
1261 if(hres == INET_E_RESOURCE_NOT_FOUND) {
1262 win_skip("Start failed\n");
1263 return FALSE;
1265 ok(hres == S_OK, "Start failed: %08x\n", hres);
1267 CHECK_CALLED(GetBindInfo);
1268 if(!(bindf & BINDF_FROMURLMON))
1269 CHECK_CALLED(ReportProgress_DIRECTBIND);
1270 if(is_first) {
1271 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
1272 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
1273 if(bindf & BINDF_FROMURLMON)
1274 CHECK_CALLED(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
1275 else
1276 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1278 CHECK_CALLED(ReportData);
1279 if(is_first)
1280 CHECK_CALLED(ReportResult);
1282 return TRUE;
1285 static void test_file_protocol_url(LPCWSTR url)
1287 IInternetProtocolInfo *protocol_info;
1288 IUnknown *unk;
1289 IClassFactory *factory;
1290 HRESULT hres;
1292 hres = CoGetClassObject(&CLSID_FileProtocol, CLSCTX_INPROC_SERVER, NULL,
1293 &IID_IUnknown, (void**)&unk);
1294 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
1295 if(FAILED(hres))
1296 return;
1298 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
1299 ok(hres == E_NOINTERFACE,
1300 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
1302 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
1303 ok(hres == S_OK, "Could not get IClassFactory interface\n");
1304 if(SUCCEEDED(hres)) {
1305 IInternetProtocol *protocol;
1306 BYTE buf[512];
1307 ULONG cb;
1308 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
1309 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
1311 if(SUCCEEDED(hres)) {
1312 if(file_protocol_start(protocol, url, TRUE)) {
1313 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
1314 ok(hres == S_OK, "Read failed: %08x\n", hres);
1315 ok(cb == 2, "cb=%u expected 2\n", cb);
1316 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
1317 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
1318 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
1319 ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres);
1320 ok(cb == 0, "cb=%u expected 0\n", cb);
1321 hres = IInternetProtocol_UnlockRequest(protocol);
1322 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
1325 if(file_protocol_start(protocol, url, FALSE)) {
1326 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
1327 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
1328 hres = IInternetProtocol_LockRequest(protocol, 0);
1329 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
1330 hres = IInternetProtocol_UnlockRequest(protocol);
1331 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
1334 IInternetProtocol_Release(protocol);
1337 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
1338 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
1340 if(SUCCEEDED(hres)) {
1341 if(file_protocol_start(protocol, url, TRUE)) {
1342 hres = IInternetProtocol_LockRequest(protocol, 0);
1343 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
1344 hres = IInternetProtocol_Terminate(protocol, 0);
1345 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
1346 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
1347 ok(hres == S_OK, "Read failed: %08x\n\n", hres);
1348 hres = IInternetProtocol_UnlockRequest(protocol);
1349 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
1350 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
1351 ok(hres == S_OK, "Read failed: %08x\n", hres);
1352 hres = IInternetProtocol_Terminate(protocol, 0);
1353 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
1356 IInternetProtocol_Release(protocol);
1359 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
1360 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
1362 if(SUCCEEDED(hres)) {
1363 if(file_protocol_start(protocol, url, TRUE)) {
1364 hres = IInternetProtocol_Terminate(protocol, 0);
1365 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
1366 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
1367 ok(hres == S_OK, "Read failed: %08x\n", hres);
1368 ok(cb == 2, "cb=%u expected 2\n", cb);
1371 IInternetProtocol_Release(protocol);
1374 IClassFactory_Release(factory);
1377 IUnknown_Release(unk);
1380 static void test_file_protocol_fail(void)
1382 IInternetProtocol *protocol;
1383 HRESULT hres;
1385 static const WCHAR index_url2[] =
1386 {'f','i','l','e',':','/','/','i','n','d','e','x','.','h','t','m','l',0};
1388 hres = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1389 &IID_IInternetProtocol, (void**)&protocol);
1390 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
1391 if(FAILED(hres))
1392 return;
1394 SET_EXPECT(GetBindInfo);
1395 expect_hrResult = MK_E_SYNTAX;
1396 hres = IInternetProtocol_Start(protocol, wszIndexHtml, &protocol_sink, &bind_info, 0, 0);
1397 ok(hres == MK_E_SYNTAX ||
1398 hres == E_INVALIDARG,
1399 "Start failed: %08x, expected MK_E_SYNTAX or E_INVALIDARG\n", hres);
1400 CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
1402 SET_EXPECT(GetBindInfo);
1403 if(!(bindf & BINDF_FROMURLMON))
1404 SET_EXPECT(ReportProgress_DIRECTBIND);
1405 SET_EXPECT(ReportProgress_SENDINGREQUEST);
1406 SET_EXPECT(ReportResult);
1407 expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
1408 hres = IInternetProtocol_Start(protocol, index_url, &protocol_sink, &bind_info, 0, 0);
1409 ok(hres == INET_E_RESOURCE_NOT_FOUND,
1410 "Start failed: %08x expected INET_E_RESOURCE_NOT_FOUND\n", hres);
1411 CHECK_CALLED(GetBindInfo);
1412 if(!(bindf & BINDF_FROMURLMON))
1413 CHECK_CALLED(ReportProgress_DIRECTBIND);
1414 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
1415 CHECK_CALLED(ReportResult);
1417 IInternetProtocol_Release(protocol);
1419 hres = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1420 &IID_IInternetProtocol, (void**)&protocol);
1421 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
1422 if(FAILED(hres))
1423 return;
1425 SET_EXPECT(GetBindInfo);
1426 if(!(bindf & BINDF_FROMURLMON))
1427 SET_EXPECT(ReportProgress_DIRECTBIND);
1428 SET_EXPECT(ReportProgress_SENDINGREQUEST);
1429 SET_EXPECT(ReportResult);
1430 expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
1432 hres = IInternetProtocol_Start(protocol, index_url2, &protocol_sink, &bind_info, 0, 0);
1433 ok(hres == INET_E_RESOURCE_NOT_FOUND,
1434 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND\n", hres);
1435 CHECK_CALLED(GetBindInfo);
1436 if(!(bindf & BINDF_FROMURLMON))
1437 CHECK_CALLED(ReportProgress_DIRECTBIND);
1438 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
1439 CHECK_CALLED(ReportResult);
1441 SET_EXPECT(GetBindInfo);
1442 hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0);
1443 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
1444 CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
1446 SET_EXPECT(GetBindInfo);
1447 hres = IInternetProtocol_Start(protocol, emptyW, &protocol_sink, &bind_info, 0, 0);
1448 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
1449 CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
1451 IInternetProtocol_Release(protocol);
1454 static void test_file_protocol(void) {
1455 WCHAR buf[INTERNET_MAX_URL_LENGTH], file_name_buf[MAX_PATH];
1456 DWORD size;
1457 ULONG len;
1458 HANDLE file;
1460 static const WCHAR wszFile[] = {'f','i','l','e',':',0};
1461 static const WCHAR wszFile2[] = {'f','i','l','e',':','/','/',0};
1462 static const WCHAR wszFile3[] = {'f','i','l','e',':','/','/','/',0};
1463 static const char html_doc[] = "<HTML></HTML>";
1465 trace("Testing file protocol...\n");
1466 tested_protocol = FILE_TEST;
1468 SetLastError(0xdeadbeef);
1469 file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
1470 FILE_ATTRIBUTE_NORMAL, NULL);
1471 if(!file && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
1473 win_skip("Detected Win9x or WinMe\n");
1474 return;
1476 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
1477 if(file == INVALID_HANDLE_VALUE)
1478 return;
1479 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
1480 CloseHandle(file);
1482 file_name = wszIndexHtml;
1483 bindf = 0;
1484 test_file_protocol_url(index_url);
1485 bindf = BINDF_FROMURLMON;
1486 test_file_protocol_url(index_url);
1487 bindf = BINDF_FROMURLMON | BINDF_NEEDFILE;
1488 test_file_protocol_url(index_url);
1490 memcpy(buf, wszFile, sizeof(wszFile));
1491 len = sizeof(wszFile)/sizeof(WCHAR)-1;
1492 len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
1493 buf[len++] = '\\';
1494 memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
1496 file_name = buf + sizeof(wszFile)/sizeof(WCHAR)-1;
1497 bindf = 0;
1498 test_file_protocol_url(buf);
1499 bindf = BINDF_FROMURLMON;
1500 test_file_protocol_url(buf);
1502 memcpy(buf, wszFile2, sizeof(wszFile2));
1503 len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
1504 file_name_buf[len++] = '\\';
1505 memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
1506 lstrcpyW(buf+sizeof(wszFile2)/sizeof(WCHAR)-1, file_name_buf);
1507 file_name = file_name_buf;
1508 bindf = 0;
1509 test_file_protocol_url(buf);
1510 bindf = BINDF_FROMURLMON;
1511 test_file_protocol_url(buf);
1513 buf[sizeof(wszFile2)/sizeof(WCHAR)] = '|';
1514 test_file_protocol_url(buf);
1516 memcpy(buf, wszFile3, sizeof(wszFile3));
1517 len = sizeof(wszFile3)/sizeof(WCHAR)-1;
1518 len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
1519 buf[len++] = '\\';
1520 memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
1522 file_name = buf + sizeof(wszFile3)/sizeof(WCHAR)-1;
1523 bindf = 0;
1524 test_file_protocol_url(buf);
1525 bindf = BINDF_FROMURLMON;
1526 test_file_protocol_url(buf);
1528 DeleteFileW(wszIndexHtml);
1530 bindf = 0;
1531 test_file_protocol_fail();
1532 bindf = BINDF_FROMURLMON;
1533 test_file_protocol_fail();
1536 static BOOL http_protocol_start(LPCWSTR url, BOOL is_first)
1538 static BOOL got_user_agent = FALSE;
1539 HRESULT hres;
1541 first_data_notif = TRUE;
1542 state = 0;
1544 SET_EXPECT(GetBindInfo);
1545 if (!(bindf & BINDF_FROMURLMON))
1546 SET_EXPECT(ReportProgress_DIRECTBIND);
1547 SET_EXPECT(GetBindString_USER_AGENT);
1548 SET_EXPECT(GetBindString_ACCEPT_MIMES);
1549 SET_EXPECT(QueryService_HttpNegotiate);
1550 SET_EXPECT(BeginningTransaction);
1551 SET_EXPECT(GetRootSecurityId);
1552 if (http_post_test)
1553 SET_EXPECT(GetBindString_POST_COOKIE);
1555 hres = IInternetProtocol_Start(async_protocol, url, &protocol_sink, &bind_info, 0, 0);
1556 ok(hres == S_OK, "Start failed: %08x\n", hres);
1557 if(FAILED(hres))
1558 return FALSE;
1560 CHECK_CALLED(GetBindInfo);
1561 if (!(bindf & BINDF_FROMURLMON))
1562 CHECK_CALLED(ReportProgress_DIRECTBIND);
1563 if (!got_user_agent)
1565 CHECK_CALLED(GetBindString_USER_AGENT);
1566 got_user_agent = TRUE;
1568 else todo_wine
1570 /* user agent only retrieved once, even with different URLs */
1571 CHECK_NOT_CALLED(GetBindString_USER_AGENT);
1573 CHECK_CALLED(GetBindString_ACCEPT_MIMES);
1574 CHECK_CALLED(QueryService_HttpNegotiate);
1575 CHECK_CALLED(BeginningTransaction);
1576 /* GetRootSecurityId called on WinXP but not on Win98 */
1577 CLEAR_CALLED(GetRootSecurityId);
1578 if (http_post_test)
1579 CHECK_CALLED(GetBindString_POST_COOKIE);
1581 return TRUE;
1584 static void test_protocol_terminate(IInternetProtocol *protocol)
1586 BYTE buf[3600];
1587 DWORD cb;
1588 HRESULT hres;
1590 hres = IInternetProtocol_LockRequest(protocol, 0);
1591 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
1593 hres = IInternetProtocol_Read(protocol, buf, 1, &cb);
1594 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
1596 hres = IInternetProtocol_Terminate(protocol, 0);
1597 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
1599 /* This wait is to give the internet handles being freed in Terminate
1600 * enough time to actually terminate in all cases. Internet handles
1601 * terminate asynchronously and native reuses the main InternetOpen
1602 * handle. The only case in which this seems to be necessary is on
1603 * wine with native wininet and urlmon, resulting in the next time
1604 * test_http_protocol_url being called the first data notification actually
1605 * being an extra last data notification from the previous connection
1606 * about once out of every ten times. */
1607 Sleep(100);
1609 hres = IInternetProtocol_UnlockRequest(protocol);
1610 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
1613 /* is_first refers to whether this is the first call to this function
1614 * _for this url_ */
1615 static void test_http_protocol_url(LPCWSTR url, BOOL is_https, BOOL is_first)
1617 IInternetProtocolInfo *protocol_info;
1618 IClassFactory *factory;
1619 IUnknown *unk;
1620 HRESULT hres;
1622 http_url = url;
1623 http_is_first = is_first;
1625 hres = CoGetClassObject(is_https ? &CLSID_HttpSProtocol : &CLSID_HttpProtocol,
1626 CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
1627 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
1628 if(FAILED(hres))
1629 return;
1631 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
1632 ok(hres == E_NOINTERFACE,
1633 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
1634 hres);
1636 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
1637 ok(hres == S_OK, "Could not get IClassFactory interface\n");
1638 IUnknown_Release(unk);
1639 if(FAILED(hres))
1640 return;
1642 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
1643 (void**)&async_protocol);
1644 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
1645 if(SUCCEEDED(hres)) {
1646 BYTE buf[3600];
1647 DWORD cb;
1648 ULONG ref;
1650 test_priority(async_protocol);
1652 SET_EXPECT(ReportProgress_FINDINGRESOURCE);
1653 SET_EXPECT(ReportProgress_CONNECTING);
1654 SET_EXPECT(ReportProgress_SENDINGREQUEST);
1655 SET_EXPECT(ReportProgress_PROXYDETECTING);
1656 if(! is_https)
1657 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
1658 if(!(bindf & BINDF_FROMURLMON)) {
1659 SET_EXPECT(OnResponse);
1660 SET_EXPECT(ReportProgress_RAWMIMETYPE);
1661 SET_EXPECT(ReportData);
1662 } else {
1663 SET_EXPECT(Switch);
1666 if(!http_protocol_start(url, is_first))
1667 return;
1669 SET_EXPECT(ReportResult);
1670 expect_hrResult = S_OK;
1672 hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
1673 ok((hres == E_PENDING && cb==0) ||
1674 (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
1676 WaitForSingleObject(event_complete, INFINITE);
1677 if(bindf & BINDF_FROMURLMON)
1678 CHECK_CALLED(Switch);
1679 else
1680 CHECK_CALLED(ReportData);
1682 while(1) {
1683 if(bindf & BINDF_FROMURLMON)
1684 SET_EXPECT(Switch);
1685 else
1686 SET_EXPECT(ReportData);
1687 hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb);
1688 if(hres == E_PENDING) {
1689 hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
1690 ok((hres == E_PENDING && cb==0) ||
1691 (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
1692 WaitForSingleObject(event_complete, INFINITE);
1693 if(bindf & BINDF_FROMURLMON)
1694 CHECK_CALLED(Switch);
1695 else
1696 CHECK_CALLED(ReportData);
1697 }else {
1698 if(bindf & BINDF_FROMURLMON)
1699 CHECK_NOT_CALLED(Switch);
1700 else
1701 CHECK_NOT_CALLED(ReportData);
1702 if(cb == 0) break;
1705 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
1706 CHECK_CALLED(ReportResult);
1708 test_protocol_terminate(async_protocol);
1709 ref = IInternetProtocol_Release(async_protocol);
1710 ok(!ref, "ref=%x\n", hres);
1713 IClassFactory_Release(factory);
1716 static void test_http_protocol(void)
1718 static const WCHAR winehq_url[] =
1719 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
1720 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
1721 static const WCHAR posttest_url[] =
1722 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
1723 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
1724 'p','o','s','t','t','e','s','t','.','p','h','p',0};
1726 trace("Testing http protocol (not from urlmon)...\n");
1727 tested_protocol = HTTP_TEST;
1728 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
1729 test_http_protocol_url(winehq_url, FALSE, TRUE);
1731 trace("Testing http protocol (from urlmon)...\n");
1732 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON;
1733 test_http_protocol_url(winehq_url, FALSE, FALSE);
1735 trace("Testing http protocol (to file)...\n");
1736 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NEEDFILE;
1737 test_http_protocol_url(winehq_url, FALSE, FALSE);
1739 trace("Testing http protocol (post data)...\n");
1740 http_post_test = TRUE;
1741 /* Without this flag we get a ReportProgress_CACHEFILENAMEAVAILABLE
1742 * notification with BINDVERB_POST */
1743 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
1744 test_http_protocol_url(posttest_url, FALSE, TRUE);
1745 http_post_test = FALSE;
1748 static void test_https_protocol(void)
1750 static const WCHAR codeweavers_url[] =
1751 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
1752 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0};
1754 trace("Testing https protocol (from urlmon)...\n");
1755 tested_protocol = HTTPS_TEST;
1756 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
1757 test_http_protocol_url(codeweavers_url, TRUE, TRUE);
1761 static void test_ftp_protocol(void)
1763 IInternetProtocolInfo *protocol_info;
1764 IClassFactory *factory;
1765 IUnknown *unk;
1766 BYTE buf[4096];
1767 ULONG ref;
1768 DWORD cb;
1769 HRESULT hres;
1771 static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
1772 '/','p','u','b','/','o','t','h','e','r','/',
1773 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
1775 trace("Testing ftp protocol...\n");
1777 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
1778 state = 0;
1779 tested_protocol = FTP_TEST;
1780 first_data_notif = TRUE;
1781 expect_hrResult = E_PENDING;
1783 hres = CoGetClassObject(&CLSID_FtpProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
1784 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
1785 if(FAILED(hres))
1786 return;
1788 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
1789 ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
1791 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
1792 ok(hres == S_OK, "Could not get IClassFactory interface\n");
1793 IUnknown_Release(unk);
1794 if(FAILED(hres))
1795 return;
1797 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
1798 (void**)&async_protocol);
1799 IClassFactory_Release(factory);
1800 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
1802 test_priority(async_protocol);
1804 SET_EXPECT(GetBindInfo);
1805 SET_EXPECT(GetBindString_USER_AGENT);
1806 SET_EXPECT(ReportProgress_FINDINGRESOURCE);
1807 SET_EXPECT(ReportProgress_CONNECTING);
1808 SET_EXPECT(ReportProgress_SENDINGREQUEST);
1809 SET_EXPECT(Switch);
1811 hres = IInternetProtocol_Start(async_protocol, ftp_urlW, &protocol_sink, &bind_info, 0, 0);
1812 ok(hres == S_OK, "Start failed: %08x\n", hres);
1813 CHECK_CALLED(GetBindInfo);
1814 todo_wine CHECK_NOT_CALLED(GetBindString_USER_AGENT);
1816 SET_EXPECT(ReportResult);
1818 hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
1819 ok((hres == E_PENDING && cb==0) ||
1820 (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
1822 WaitForSingleObject(event_complete, INFINITE);
1823 CHECK_CALLED(Switch);
1825 while(1) {
1826 SET_EXPECT(Switch);
1828 hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb);
1829 if(hres == E_PENDING) {
1830 WaitForSingleObject(event_complete, INFINITE);
1831 CHECK_CALLED(Switch);
1832 }else {
1833 CHECK_NOT_CALLED(Switch);
1834 if(cb == 0) break;
1838 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
1839 CHECK_CALLED(ReportResult);
1841 test_protocol_terminate(async_protocol);
1843 ref = IInternetProtocol_Release(async_protocol);
1844 ok(!ref, "ref=%d\n", ref);
1847 static void test_gopher_protocol(void)
1849 IInternetProtocolInfo *protocol_info;
1850 IClassFactory *factory;
1851 IUnknown *unk;
1852 HRESULT hres;
1854 trace("Testing gopher protocol...\n");
1856 hres = CoGetClassObject(&CLSID_GopherProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
1857 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
1858 if(FAILED(hres))
1859 return;
1861 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
1862 ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
1864 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
1865 ok(hres == S_OK, "Could not get IClassFactory interface\n");
1866 IUnknown_Release(unk);
1867 if(FAILED(hres))
1868 return;
1870 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
1871 (void**)&async_protocol);
1872 IClassFactory_Release(factory);
1873 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
1875 test_priority(async_protocol);
1877 IInternetProtocol_Release(async_protocol);
1880 static void test_mk_protocol(void)
1882 IInternetProtocolInfo *protocol_info;
1883 IInternetProtocol *protocol;
1884 IClassFactory *factory;
1885 IUnknown *unk;
1886 HRESULT hres;
1888 static const WCHAR wrong_url1[] = {'t','e','s','t',':','@','M','S','I','T','S','t','o','r','e',
1889 ':',':','/','t','e','s','t','.','h','t','m','l',0};
1890 static const WCHAR wrong_url2[] = {'m','k',':','/','t','e','s','t','.','h','t','m','l',0};
1892 trace("Testing mk protocol...\n");
1893 tested_protocol = MK_TEST;
1895 hres = CoGetClassObject(&CLSID_MkProtocol, CLSCTX_INPROC_SERVER, NULL,
1896 &IID_IUnknown, (void**)&unk);
1897 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
1899 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
1900 ok(hres == E_NOINTERFACE,
1901 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
1902 hres);
1904 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
1905 ok(hres == S_OK, "Could not get IClassFactory interface\n");
1906 IUnknown_Release(unk);
1907 if(FAILED(hres))
1908 return;
1910 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
1911 (void**)&protocol);
1912 IClassFactory_Release(factory);
1913 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
1915 SET_EXPECT(GetBindInfo);
1916 hres = IInternetProtocol_Start(protocol, wrong_url1, &protocol_sink, &bind_info, 0, 0);
1917 ok(hres == MK_E_SYNTAX || hres == INET_E_INVALID_URL,
1918 "Start failed: %08x, expected MK_E_SYNTAX or INET_E_INVALID_URL\n", hres);
1919 CLEAR_CALLED(GetBindInfo);
1921 SET_EXPECT(GetBindInfo);
1922 SET_EXPECT(ReportProgress_DIRECTBIND);
1923 SET_EXPECT(ReportProgress_SENDINGREQUEST);
1924 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
1925 SET_EXPECT(ReportResult);
1926 expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
1928 hres = IInternetProtocol_Start(protocol, wrong_url2, &protocol_sink, &bind_info, 0, 0);
1929 ok(hres == INET_E_RESOURCE_NOT_FOUND ||
1930 hres == INET_E_INVALID_URL, /* win2k3 */
1931 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND or INET_E_INVALID_URL\n", hres);
1933 if (hres == INET_E_RESOURCE_NOT_FOUND) {
1934 CHECK_CALLED(GetBindInfo);
1935 CLEAR_CALLED(ReportProgress_DIRECTBIND);
1936 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
1937 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1938 CHECK_CALLED(ReportResult);
1939 }else {
1940 CLEAR_CALLED(GetBindInfo);
1941 CLEAR_CALLED(ReportProgress_DIRECTBIND);
1942 CLEAR_CALLED(ReportProgress_SENDINGREQUEST);
1943 CLEAR_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1944 CLEAR_CALLED(ReportResult);
1947 IInternetProtocol_Release(protocol);
1950 static void test_CreateBinding(void)
1952 IInternetProtocolSink *sink;
1953 IInternetProtocol *protocol;
1954 IInternetPriority *priority;
1955 IInternetSession *session;
1956 LONG p;
1957 BYTE buf[1000];
1958 DWORD read;
1959 HRESULT hres;
1961 static const WCHAR test_url[] =
1962 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0};
1963 static const WCHAR wsz_test[] = {'t','e','s','t',0};
1965 trace("Testing CreateBinding...\n");
1966 tested_protocol = BIND_TEST;
1967 binding_test = TRUE;
1969 hres = CoInternetGetSession(0, &session, 0);
1970 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
1972 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL, wsz_test, 0, NULL, 0);
1973 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
1975 hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0);
1976 binding_protocol = protocol;
1977 ok(hres == S_OK, "CreateBinding failed: %08x\n", hres);
1978 ok(protocol != NULL, "protocol == NULL\n");
1980 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetBindInfo, (void**)&prot_bind_info);
1981 ok(hres == S_OK, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres);
1983 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolSink, (void**)&sink);
1984 ok(hres == S_OK, "Could not get IInternetProtocolSink: %08x\n", hres);
1986 hres = IInternetProtocol_Start(protocol, test_url, NULL, &bind_info, 0, 0);
1987 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
1988 hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, NULL, 0, 0);
1989 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
1990 hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0);
1991 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
1993 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
1994 ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres);
1996 p = 0xdeadbeef;
1997 hres = IInternetPriority_GetPriority(priority, &p);
1998 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
1999 ok(!p, "p=%d\n", p);
2001 ex_priority = 100;
2002 hres = IInternetPriority_SetPriority(priority, 100);
2003 ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
2005 p = 0xdeadbeef;
2006 hres = IInternetPriority_GetPriority(priority, &p);
2007 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
2008 ok(p == 100, "p=%d\n", p);
2010 SET_EXPECT(QueryService_InternetProtocol);
2011 SET_EXPECT(CreateInstance);
2012 SET_EXPECT(ReportProgress_PROTOCOLCLASSID);
2013 SET_EXPECT(SetPriority);
2014 SET_EXPECT(Start);
2016 expect_hrResult = S_OK;
2017 hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, &bind_info, 0, 0);
2018 ok(hres == S_OK, "Start failed: %08x\n", hres);
2020 CHECK_CALLED(QueryService_InternetProtocol);
2021 CHECK_CALLED(CreateInstance);
2022 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID);
2023 CHECK_CALLED(SetPriority);
2024 CHECK_CALLED(Start);
2026 SET_EXPECT(Read);
2027 read = 0xdeadbeef;
2028 hres = IInternetProtocol_Read(protocol, expect_pv = buf, sizeof(buf), &read);
2029 ok(hres == S_OK, "Read failed: %08x\n", hres);
2030 ok(read == 100, "read = %d\n", read);
2031 CHECK_CALLED(Read);
2033 SET_EXPECT(Read);
2034 read = 0xdeadbeef;
2035 hres = IInternetProtocol_Read(protocol, expect_pv = buf, sizeof(buf), &read);
2036 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
2037 ok(!read, "read = %d\n", read);
2038 CHECK_CALLED(Read);
2040 p = 0xdeadbeef;
2041 hres = IInternetPriority_GetPriority(priority, &p);
2042 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
2043 ok(p == 100, "p=%d\n", p);
2045 hres = IInternetPriority_SetPriority(priority, 101);
2046 ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
2048 SET_EXPECT(Terminate);
2049 hres = IInternetProtocol_Terminate(protocol, 0xdeadbeef);
2050 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
2051 CHECK_CALLED(Terminate);
2053 SET_EXPECT(Continue);
2054 hres = IInternetProtocolSink_Switch(sink, &protocoldata);
2055 ok(hres == S_OK, "Switch failed: %08x\n", hres);
2056 CHECK_CALLED(Continue);
2058 hres = IInternetProtocolSink_ReportProgress(sink,
2059 BINDSTATUS_CACHEFILENAMEAVAILABLE, expect_wsz = emptyW);
2060 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
2062 hres = IInternetProtocolSink_ReportResult(sink, S_OK, ERROR_SUCCESS, NULL);
2063 ok(hres == E_FAIL, "ReportResult failed: %08x, expected E_FAIL\n", hres);
2065 hres = IInternetProtocolSink_ReportData(sink, 0, 0, 0);
2066 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
2068 IInternetProtocolSink_Release(sink);
2069 IInternetPriority_Release(priority);
2070 IInternetBindInfo_Release(prot_bind_info);
2071 IInternetProtocol_Release(protocol);
2072 IInternetSession_Release(session);
2075 static void test_binding(int prot)
2077 IInternetProtocol *protocol;
2078 IInternetSession *session;
2079 ULONG ref;
2080 HRESULT hres;
2082 trace("Testing %s binding...\n", debugstr_w(protocol_names[prot]));
2084 tested_protocol = prot;
2085 binding_test = TRUE;
2086 first_data_notif = TRUE;
2087 prot_read = 0;
2089 hres = CoInternetGetSession(0, &session, 0);
2090 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
2092 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL, protocol_names[prot], 0, NULL, 0);
2093 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
2095 hres = IInternetSession_CreateBinding(session, NULL, binding_urls[prot], NULL, NULL, &protocol, 0);
2096 binding_protocol = protocol;
2097 IInternetSession_Release(session);
2098 ok(hres == S_OK, "CreateBinding failed: %08x\n", hres);
2099 ok(protocol != NULL, "protocol == NULL\n");
2101 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetBindInfo, (void**)&prot_bind_info);
2102 ok(hres == S_OK, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres);
2104 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolSink, (void**)&binding_sink);
2105 ok(hres == S_OK, "QueryInterface(IID_IInternetProtocolSink) failed: %08x\n", hres);
2107 ex_priority = 0;
2108 SET_EXPECT(QueryService_InternetProtocol);
2109 SET_EXPECT(CreateInstance);
2110 SET_EXPECT(ReportProgress_PROTOCOLCLASSID);
2111 SET_EXPECT(SetPriority);
2112 SET_EXPECT(Start);
2114 expect_hrResult = S_OK;
2115 hres = IInternetProtocol_Start(protocol, binding_urls[prot], &protocol_sink, &bind_info, 0, 0);
2116 ok(hres == S_OK, "Start failed: %08x\n", hres);
2118 CHECK_CALLED(QueryService_InternetProtocol);
2119 CHECK_CALLED(CreateInstance);
2120 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID);
2121 CHECK_CALLED(SetPriority);
2122 CHECK_CALLED(Start);
2124 if(prot == HTTP_TEST || prot == HTTPS_TEST) {
2125 while(prot_state < 4) {
2126 WaitForSingleObject(event_complete, INFINITE);
2127 SET_EXPECT(Continue);
2128 IInternetProtocol_Continue(protocol, pdata);
2129 CHECK_CALLED(Continue);
2130 SetEvent(event_complete2);
2133 WaitForSingleObject(event_complete, INFINITE);
2134 }else {
2135 SET_EXPECT(LockRequest);
2136 hres = IInternetProtocol_LockRequest(protocol, 0);
2137 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
2138 CHECK_CALLED(LockRequest);
2140 SET_EXPECT(UnlockRequest);
2141 hres = IInternetProtocol_UnlockRequest(protocol);
2142 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
2143 CHECK_CALLED(UnlockRequest);
2146 SET_EXPECT(Terminate);
2147 hres = IInternetProtocol_Terminate(protocol, 0);
2148 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
2149 CHECK_CALLED(Terminate);
2151 IInternetBindInfo_Release(prot_bind_info);
2152 IInternetProtocolSink_Release(binding_sink);
2153 ref = IInternetProtocol_Release(protocol);
2154 ok(!ref, "ref=%u, expected 0\n", ref);
2157 START_TEST(protocol)
2159 OleInitialize(NULL);
2161 event_complete = CreateEvent(NULL, FALSE, FALSE, NULL);
2162 event_complete2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2164 test_file_protocol();
2165 test_http_protocol();
2166 test_https_protocol();
2167 test_ftp_protocol();
2168 test_gopher_protocol();
2169 test_mk_protocol();
2170 test_CreateBinding();
2171 test_binding(FILE_TEST);
2172 test_binding(HTTP_TEST);
2174 CloseHandle(event_complete);
2175 CloseHandle(event_complete2);
2177 OleUninitialize();