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
22 #include <wine/test.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) \
40 ok(expect_ ##func, "unexpected call " #func "\n"); \
41 called_ ## func = TRUE; \
44 #define CHECK_EXPECT(func) \
46 CHECK_EXPECT2(func); \
47 expect_ ## func = FALSE; \
50 #define CHECK_CALLED(func) \
52 ok(called_ ## func, "expected " #func "\n"); \
53 expect_ ## func = called_ ## func = FALSE; \
56 #define CHECK_NOT_CALLED(func) \
58 ok(!called_ ## func, "unexpected " #func "\n"); \
59 expect_ ## func = called_ ## func = FALSE; \
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(QueryService_HttpSecurity
);
88 DEFINE_EXPECT(BeginningTransaction
);
89 DEFINE_EXPECT(GetRootSecurityId
);
90 DEFINE_EXPECT(OnResponse
);
91 DEFINE_EXPECT(Switch
);
92 DEFINE_EXPECT(Continue
);
93 DEFINE_EXPECT(CreateInstance
);
95 DEFINE_EXPECT(Terminate
);
97 DEFINE_EXPECT(SetPriority
);
98 DEFINE_EXPECT(LockRequest
);
99 DEFINE_EXPECT(UnlockRequest
);
101 static const WCHAR wszIndexHtml
[] = {'i','n','d','e','x','.','h','t','m','l',0};
102 static const WCHAR index_url
[] =
103 {'f','i','l','e',':','i','n','d','e','x','.','h','t','m','l',0};
105 static const WCHAR acc_mimeW
[] = {'*','/','*',0};
106 static const WCHAR user_agentW
[] = {'W','i','n','e',0};
107 static const WCHAR text_htmlW
[] = {'t','e','x','t','/','h','t','m','l',0};
108 static const WCHAR hostW
[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
109 static const WCHAR winehq_ipW
[] = {'2','0','9','.','4','6','.','2','5','.','1','3','4',0};
110 static const WCHAR emptyW
[] = {0};
112 static HRESULT expect_hrResult
;
113 static LPCWSTR file_name
, http_url
, expect_wsz
;
114 static IInternetProtocol
*async_protocol
= NULL
;
115 static BOOL first_data_notif
= FALSE
, http_is_first
= FALSE
,
116 http_post_test
= FALSE
;
117 static int state
= 0, prot_state
;
118 static DWORD bindf
= 0, ex_priority
= 0;
119 static IInternetProtocol
*binding_protocol
;
120 static IInternetBindInfo
*prot_bind_info
;
121 static IInternetProtocolSink
*binding_sink
;
122 static void *expect_pv
;
123 static HANDLE event_complete
, event_complete2
;
124 static BOOL binding_test
;
125 static PROTOCOLDATA protocoldata
, *pdata
;
126 static DWORD prot_read
;
127 static BOOL security_problem
= FALSE
;
138 static const WCHAR protocol_names
[][10] = {
141 {'h','t','t','p','s',0},
147 static const WCHAR binding_urls
[][130] = {
148 {'f','i','l','e',':','t','e','s','t','.','h','t','m','l',0},
149 {'h','t','t','p',':','/','/','t','e','s','t','/','t','e','s','t','.','h','t','m','l',0},
150 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
151 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0},
152 {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
153 '/','p','u','b','/','o','t','h','e','r',
154 '/','w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0},
155 {'m','k',':','t','e','s','t',0},
156 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0}
159 static const char *debugstr_w(LPCWSTR str
)
161 static char buf
[512];
164 WideCharToMultiByte(CP_ACP
, 0, str
, -1, buf
, sizeof(buf
), NULL
, NULL
);
168 static const char *debugstr_guid(REFIID riid
)
172 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
173 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
174 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
175 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
180 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
183 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
184 return lstrcmpW(strw
, buf
);
187 static HRESULT WINAPI
HttpSecurity_QueryInterface(IHttpSecurity
*iface
, REFIID riid
, void **ppv
)
189 if(IsEqualGUID(&IID_IUnknown
, riid
)
190 || IsEqualGUID(&IID_IHttpSecurity
, riid
)) {
195 ok(0, "unexpected call\n");
196 return E_NOINTERFACE
;
199 static ULONG WINAPI
HttpSecurity_AddRef(IHttpSecurity
*iface
)
204 static ULONG WINAPI
HttpSecurity_Release(IHttpSecurity
*iface
)
209 static HRESULT WINAPI
HttpSecurity_GetWindow(IHttpSecurity
* iface
, REFGUID rguidReason
, HWND
*phwnd
)
211 trace("HttpSecurity_GetWindow\n");
216 static HRESULT WINAPI
HttpSecurity_OnSecurityProblem(IHttpSecurity
*iface
, DWORD dwProblem
)
218 trace("Security problem: %u\n", dwProblem
);
219 ok(dwProblem
== ERROR_INTERNET_SEC_CERT_REV_FAILED
, "Expected ERROR_INTERNET_SEC_CERT_REV_FAILED got %u\n", dwProblem
);
221 /* Only retry once */
222 if (security_problem
)
225 security_problem
= TRUE
;
226 SET_EXPECT(BeginningTransaction
);
231 static IHttpSecurityVtbl HttpSecurityVtbl
= {
232 HttpSecurity_QueryInterface
,
234 HttpSecurity_Release
,
235 HttpSecurity_GetWindow
,
236 HttpSecurity_OnSecurityProblem
239 static IHttpSecurity http_security
= { &HttpSecurityVtbl
};
241 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate2
*iface
, REFIID riid
, void **ppv
)
243 if(IsEqualGUID(&IID_IUnknown
, riid
)
244 || IsEqualGUID(&IID_IHttpNegotiate
, riid
)
245 || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
250 ok(0, "unexpected call\n");
251 return E_NOINTERFACE
;
254 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate2
*iface
)
259 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate2
*iface
)
264 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate2
*iface
, LPCWSTR szURL
,
265 LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
269 static const WCHAR wszHeaders
[] =
270 {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ','a','p','p','l','i','c','a','t',
271 'i','o','n','/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o',
272 'd','e','d','\r','\n',0};
274 CHECK_EXPECT(BeginningTransaction
);
277 ok(!lstrcmpW(szURL
, binding_urls
[tested_protocol
]), "szURL != http_url\n");
279 ok(!lstrcmpW(szURL
, http_url
), "szURL != http_url\n");
280 ok(!dwReserved
, "dwReserved=%d, expected 0\n", dwReserved
);
281 ok(pszAdditionalHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
282 if(pszAdditionalHeaders
)
284 ok(*pszAdditionalHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
287 addl_headers
= CoTaskMemAlloc(sizeof(wszHeaders
));
290 http_post_test
= FALSE
;
291 skip("Out of memory\n");
292 return E_OUTOFMEMORY
;
294 lstrcpyW(addl_headers
, wszHeaders
);
295 *pszAdditionalHeaders
= addl_headers
;
302 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate2
*iface
, DWORD dwResponseCode
,
303 LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
, LPWSTR
*pszAdditionalRequestHeaders
)
305 CHECK_EXPECT(OnResponse
);
307 ok(dwResponseCode
== 200, "dwResponseCode=%d, expected 200\n", dwResponseCode
);
308 ok(szResponseHeaders
!= NULL
, "szResponseHeaders == NULL\n");
309 ok(szRequestHeaders
== NULL
, "szRequestHeaders != NULL\n");
310 ok(pszAdditionalRequestHeaders
== NULL
, "pszAdditionalHeaders != NULL\n");
315 static HRESULT WINAPI
HttpNegotiate_GetRootSecurityId(IHttpNegotiate2
*iface
,
316 BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
318 static const BYTE sec_id
[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
320 CHECK_EXPECT(GetRootSecurityId
);
322 ok(!dwReserved
, "dwReserved=%ld, expected 0\n", dwReserved
);
323 ok(pbSecurityId
!= NULL
, "pbSecurityId == NULL\n");
324 ok(pcbSecurityId
!= NULL
, "pcbSecurityId == NULL\n");
327 ok(*pcbSecurityId
== 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId
);
328 *pcbSecurityId
= sizeof(sec_id
);
332 memcpy(pbSecurityId
, sec_id
, sizeof(sec_id
));
337 static IHttpNegotiate2Vtbl HttpNegotiateVtbl
= {
338 HttpNegotiate_QueryInterface
,
339 HttpNegotiate_AddRef
,
340 HttpNegotiate_Release
,
341 HttpNegotiate_BeginningTransaction
,
342 HttpNegotiate_OnResponse
,
343 HttpNegotiate_GetRootSecurityId
346 static IHttpNegotiate2 http_negotiate
= { &HttpNegotiateVtbl
};
348 static HRESULT
QueryInterface(REFIID
,void**);
350 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
352 return QueryInterface(riid
, ppv
);
355 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
360 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
365 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
366 REFIID riid
, void **ppv
)
368 if(IsEqualGUID(&IID_IHttpNegotiate
, guidService
) || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
369 CHECK_EXPECT2(QueryService_HttpNegotiate
);
370 return IHttpNegotiate2_QueryInterface(&http_negotiate
, riid
, ppv
);
373 if(IsEqualGUID(&IID_IInternetProtocol
, guidService
)) {
374 ok(IsEqualGUID(&IID_IInternetProtocol
, riid
), "unexpected riid\n");
375 CHECK_EXPECT(QueryService_InternetProtocol
);
376 return E_NOINTERFACE
;
379 if(IsEqualGUID(&IID_IHttpSecurity
, guidService
)) {
380 ok(IsEqualGUID(&IID_IHttpSecurity
, riid
), "unexpected riid\n");
381 CHECK_EXPECT(QueryService_HttpSecurity
);
382 return IHttpSecurity_QueryInterface(&http_security
, riid
, ppv
);
385 ok(0, "unexpected service %s\n", debugstr_guid(guidService
));
389 static const IServiceProviderVtbl ServiceProviderVtbl
= {
390 ServiceProvider_QueryInterface
,
391 ServiceProvider_AddRef
,
392 ServiceProvider_Release
,
393 ServiceProvider_QueryService
396 static IServiceProvider service_provider
= { &ServiceProviderVtbl
};
398 static HRESULT WINAPI
ProtocolSink_QueryInterface(IInternetProtocolSink
*iface
, REFIID riid
, void **ppv
)
400 return QueryInterface(riid
, ppv
);
403 static ULONG WINAPI
ProtocolSink_AddRef(IInternetProtocolSink
*iface
)
408 static ULONG WINAPI
ProtocolSink_Release(IInternetProtocolSink
*iface
)
413 static HRESULT WINAPI
ProtocolSink_Switch(IInternetProtocolSink
*iface
, PROTOCOLDATA
*pProtocolData
)
417 if(tested_protocol
== FTP_TEST
)
418 CHECK_EXPECT2(Switch
);
420 CHECK_EXPECT(Switch
);
421 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
423 pdata
= pProtocolData
;
426 SetEvent(event_complete
);
427 WaitForSingleObject(event_complete2
, INFINITE
);
432 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
|| tested_protocol
== FTP_TEST
) {
434 CLEAR_CALLED(ReportProgress_FINDINGRESOURCE
);
435 CLEAR_CALLED(ReportProgress_CONNECTING
);
436 CLEAR_CALLED(ReportProgress_PROXYDETECTING
);
438 CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE
);
439 /* IE7 does call this */
440 CLEAR_CALLED(ReportProgress_CONNECTING
);
443 if(tested_protocol
== FTP_TEST
)
444 todo_wine
CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
445 else if (tested_protocol
!= HTTPS_TEST
)
446 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
447 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
448 SET_EXPECT(OnResponse
);
449 if(tested_protocol
== HTTPS_TEST
)
450 SET_EXPECT(ReportProgress_ACCEPTRANGES
);
451 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
452 if(bindf
& BINDF_NEEDFILE
)
453 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
457 SET_EXPECT(ReportData
);
458 hres
= IInternetProtocol_Continue(async_protocol
, pProtocolData
);
459 ok(hres
== S_OK
, "Continue failed: %08x\n", hres
);
460 if(tested_protocol
== FTP_TEST
)
461 CLEAR_CALLED(ReportData
);
462 else if (! security_problem
)
463 CHECK_CALLED(ReportData
);
466 if (! security_problem
)
469 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
470 CHECK_CALLED(OnResponse
);
471 if(tested_protocol
== HTTPS_TEST
)
472 CHECK_CALLED(ReportProgress_ACCEPTRANGES
);
473 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
474 if(bindf
& BINDF_NEEDFILE
)
475 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
480 security_problem
= FALSE
;
481 SET_EXPECT(ReportProgress_CONNECTING
);
485 SetEvent(event_complete
);
490 static HRESULT WINAPI
ProtocolSink_ReportProgress(IInternetProtocolSink
*iface
, ULONG ulStatusCode
,
491 LPCWSTR szStatusText
)
493 static const WCHAR null_guid
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-',
494 '0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}',0};
495 static const WCHAR text_plain
[] = {'t','e','x','t','/','p','l','a','i','n',0};
497 switch(ulStatusCode
) {
498 case BINDSTATUS_MIMETYPEAVAILABLE
:
499 CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
500 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
502 if(tested_protocol
== BIND_TEST
)
503 ok(szStatusText
== expect_wsz
, "unexpected szStatusText\n");
504 else if (http_post_test
)
505 ok(lstrlenW(text_plain
) <= lstrlenW(szStatusText
) &&
506 !memcmp(szStatusText
, text_plain
, lstrlenW(text_plain
)*sizeof(WCHAR
)),
507 "szStatusText != text/plain\n");
509 ok(lstrlenW(text_htmlW
) <= lstrlenW(szStatusText
) &&
510 !memcmp(szStatusText
, text_htmlW
, lstrlenW(text_htmlW
)*sizeof(WCHAR
)),
511 "szStatusText != text/html\n");
514 case BINDSTATUS_DIRECTBIND
:
515 CHECK_EXPECT2(ReportProgress_DIRECTBIND
);
516 ok(szStatusText
== NULL
, "szStatusText != NULL\n");
518 case BINDSTATUS_RAWMIMETYPE
:
519 CHECK_EXPECT2(ReportProgress_RAWMIMETYPE
);
520 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
522 ok(lstrlenW(szStatusText
) < lstrlenW(text_htmlW
) ||
523 !memcmp(szStatusText
, text_htmlW
, lstrlenW(text_htmlW
)*sizeof(WCHAR
)),
524 "szStatusText != text/html\n");
526 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
527 CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
528 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
531 ok(!lstrcmpW(szStatusText
, expect_wsz
), "unexpected szStatusText\n");
532 else if(tested_protocol
== FILE_TEST
)
533 ok(!lstrcmpW(szStatusText
, file_name
), "szStatusText = \"%s\"\n", debugstr_w(szStatusText
));
535 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
538 case BINDSTATUS_FINDINGRESOURCE
:
539 CHECK_EXPECT2(ReportProgress_FINDINGRESOURCE
);
540 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
542 case BINDSTATUS_CONNECTING
:
543 CHECK_EXPECT2(ReportProgress_CONNECTING
);
544 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
546 case BINDSTATUS_SENDINGREQUEST
:
547 CHECK_EXPECT2(ReportProgress_SENDINGREQUEST
);
548 if(tested_protocol
== FILE_TEST
) {
549 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
551 ok(!*szStatusText
, "wrong szStatusText\n");
554 case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
:
555 CHECK_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
556 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
558 ok(!lstrcmpW(szStatusText
, text_htmlW
), "szStatusText != text/html\n");
560 case BINDSTATUS_PROTOCOLCLASSID
:
561 CHECK_EXPECT(ReportProgress_PROTOCOLCLASSID
);
562 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
563 ok(!lstrcmpW(szStatusText
, null_guid
), "unexpected szStatusText\n");
565 case BINDSTATUS_COOKIE_SENT
:
566 CHECK_EXPECT(ReportProgress_COOKIE_SENT
);
567 ok(szStatusText
== NULL
, "szStatusText != NULL\n");
569 case BINDSTATUS_REDIRECTING
:
570 CHECK_EXPECT(ReportProgress_REDIRECTING
);
571 ok(szStatusText
== NULL
, "szStatusText = %s\n", debugstr_w(szStatusText
));
573 case BINDSTATUS_ENCODING
:
574 CHECK_EXPECT(ReportProgress_ENCODING
);
575 ok(!strcmp_wa(szStatusText
, "gzip"), "szStatusText = %s\n", debugstr_w(szStatusText
));
577 case BINDSTATUS_ACCEPTRANGES
:
578 CHECK_EXPECT(ReportProgress_ACCEPTRANGES
);
579 ok(!szStatusText
, "szStatusText = %s\n", debugstr_w(szStatusText
));
581 case BINDSTATUS_PROXYDETECTING
:
582 CHECK_EXPECT(ReportProgress_PROXYDETECTING
);
583 SET_EXPECT(ReportProgress_CONNECTING
);
584 ok(!szStatusText
, "szStatusText = %s\n", debugstr_w(szStatusText
));
587 ok(0, "Unexpected status %d\n", ulStatusCode
);
593 static HRESULT WINAPI
ProtocolSink_ReportData(IInternetProtocolSink
*iface
, DWORD grfBSCF
,
594 ULONG ulProgress
, ULONG ulProgressMax
)
596 if(tested_protocol
== FILE_TEST
) {
597 CHECK_EXPECT2(ReportData
);
599 ok(ulProgress
== ulProgressMax
, "ulProgress (%d) != ulProgressMax (%d)\n",
600 ulProgress
, ulProgressMax
);
601 ok(ulProgressMax
== 13, "ulProgressMax=%d, expected 13\n", ulProgressMax
);
602 ok(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
),
603 "grcfBSCF = %08x\n", grfBSCF
);
604 }else if(!binding_test
&& (tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
|| tested_protocol
== FTP_TEST
)) {
605 if(!(grfBSCF
& BSCF_LASTDATANOTIFICATION
) || (grfBSCF
& BSCF_DATAFULLYAVAILABLE
))
606 CHECK_EXPECT(ReportData
);
607 else if (http_post_test
)
608 ok(ulProgress
== 13, "Read %u bytes instead of 13\n", ulProgress
);
610 ok(ulProgress
, "ulProgress == 0\n");
612 if(first_data_notif
) {
613 ok(grfBSCF
== BSCF_FIRSTDATANOTIFICATION
614 || grfBSCF
== (BSCF_LASTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
),
615 "grcfBSCF = %08x\n", grfBSCF
);
616 first_data_notif
= FALSE
;
618 ok(grfBSCF
== BSCF_INTERMEDIATEDATANOTIFICATION
619 || grfBSCF
== (BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
)
620 || broken(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
|BSCF_LASTDATANOTIFICATION
)),
621 "grcfBSCF = %08x\n", grfBSCF
);
624 if(!(bindf
& BINDF_FROMURLMON
) &&
625 !(grfBSCF
& BSCF_LASTDATANOTIFICATION
)) {
629 CHECK_CALLED(ReportProgress_FINDINGRESOURCE
);
630 CHECK_CALLED(ReportProgress_CONNECTING
);
632 CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE
);
633 CHECK_NOT_CALLED(ReportProgress_CONNECTING
);
635 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
636 CHECK_CALLED(OnResponse
);
637 CHECK_CALLED(ReportProgress_RAWMIMETYPE
);
639 SetEvent(event_complete
);
646 CHECK_EXPECT(ReportData
);
648 if(tested_protocol
== BIND_TEST
)
653 hres
= IInternetProtocol_Read(binding_protocol
, expect_pv
=buf
, sizeof(buf
), &read
);
655 }while(hres
== S_OK
);
661 static HRESULT WINAPI
ProtocolSink_ReportResult(IInternetProtocolSink
*iface
, HRESULT hrResult
,
662 DWORD dwError
, LPCWSTR szResult
)
664 CHECK_EXPECT(ReportResult
);
666 if(tested_protocol
== FTP_TEST
)
667 ok(hrResult
== E_PENDING
|| hrResult
== S_OK
, "hrResult = %08x, expected E_PENDING or S_OK\n", hrResult
);
669 ok(hrResult
== expect_hrResult
, "hrResult = %08x, expected: %08x\n",
670 hrResult
, expect_hrResult
);
671 if(SUCCEEDED(hrResult
) || tested_protocol
== FTP_TEST
)
672 ok(dwError
== ERROR_SUCCESS
, "dwError = %d, expected ERROR_SUCCESS\n", dwError
);
674 ok(dwError
!= ERROR_SUCCESS
||
675 broken(tested_protocol
== MK_TEST
), /* Win9x, WinME and NT4 */
676 "dwError == ERROR_SUCCESS\n");
677 ok(!szResult
, "szResult != NULL\n");
682 static IInternetProtocolSinkVtbl protocol_sink_vtbl
= {
683 ProtocolSink_QueryInterface
,
685 ProtocolSink_Release
,
687 ProtocolSink_ReportProgress
,
688 ProtocolSink_ReportData
,
689 ProtocolSink_ReportResult
692 static IInternetProtocolSink protocol_sink
= { &protocol_sink_vtbl
};
694 static HRESULT
QueryInterface(REFIID riid
, void **ppv
)
698 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocolSink
, riid
))
699 *ppv
= &protocol_sink
;
700 if(IsEqualGUID(&IID_IServiceProvider
, riid
))
701 *ppv
= &service_provider
;
706 return E_NOINTERFACE
;
709 static HRESULT WINAPI
BindInfo_QueryInterface(IInternetBindInfo
*iface
, REFIID riid
, void **ppv
)
711 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
715 return E_NOINTERFACE
;
718 static ULONG WINAPI
BindInfo_AddRef(IInternetBindInfo
*iface
)
723 static ULONG WINAPI
BindInfo_Release(IInternetBindInfo
*iface
)
728 static HRESULT WINAPI
BindInfo_GetBindInfo(IInternetBindInfo
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
732 static const CHAR szPostData
[] = "mode=Test";
734 CHECK_EXPECT(GetBindInfo
);
736 ok(grfBINDF
!= NULL
, "grfBINDF == NULL\n");
737 ok(pbindinfo
!= NULL
, "pbindinfo == NULL\n");
738 ok(pbindinfo
->cbSize
== sizeof(BINDINFO
), "wrong size of pbindinfo: %d\n", pbindinfo
->cbSize
);
742 *grfBINDF
|= BINDF_FROMURLMON
;
743 cbSize
= pbindinfo
->cbSize
;
744 memset(pbindinfo
, 0, cbSize
);
745 pbindinfo
->cbSize
= cbSize
;
749 /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly
750 * with urlmon on native (Win98 and WinXP) */
751 U(pbindinfo
->stgmedData
).hGlobal
= GlobalAlloc(GPTR
, sizeof(szPostData
));
752 if (!U(pbindinfo
->stgmedData
).hGlobal
)
754 http_post_test
= FALSE
;
755 skip("Out of memory\n");
756 return E_OUTOFMEMORY
;
758 lstrcpy((LPSTR
)U(pbindinfo
->stgmedData
).hGlobal
, szPostData
);
759 pbindinfo
->cbstgmedData
= sizeof(szPostData
)-1;
760 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
761 pbindinfo
->stgmedData
.tymed
= TYMED_HGLOBAL
;
767 static HRESULT WINAPI
BindInfo_GetBindString(IInternetBindInfo
*iface
, ULONG ulStringType
,
768 LPOLESTR
*ppwzStr
, ULONG cEl
, ULONG
*pcElFetched
)
770 ok(ppwzStr
!= NULL
, "ppwzStr == NULL\n");
771 ok(pcElFetched
!= NULL
, "pcElFetched == NULL\n");
773 switch(ulStringType
) {
774 case BINDSTRING_ACCEPT_MIMES
:
775 CHECK_EXPECT(GetBindString_ACCEPT_MIMES
);
776 ok(cEl
== 256, "cEl=%d, expected 256\n", cEl
);
778 ok(*pcElFetched
== 256, "*pcElFetched=%d, expected 256\n", *pcElFetched
);
782 *ppwzStr
= CoTaskMemAlloc(sizeof(acc_mimeW
));
783 memcpy(*ppwzStr
, acc_mimeW
, sizeof(acc_mimeW
));
786 case BINDSTRING_USER_AGENT
:
787 CHECK_EXPECT(GetBindString_USER_AGENT
);
788 ok(cEl
== 1, "cEl=%d, expected 1\n", cEl
);
790 ok(*pcElFetched
== 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched
);
794 *ppwzStr
= CoTaskMemAlloc(sizeof(user_agentW
));
795 memcpy(*ppwzStr
, user_agentW
, sizeof(user_agentW
));
798 case BINDSTRING_POST_COOKIE
:
799 CHECK_EXPECT(GetBindString_POST_COOKIE
);
800 ok(cEl
== 1, "cEl=%d, expected 1\n", cEl
);
802 ok(*pcElFetched
== 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched
);
805 ok(0, "unexpected call\n");
811 static IInternetBindInfoVtbl bind_info_vtbl
= {
812 BindInfo_QueryInterface
,
815 BindInfo_GetBindInfo
,
816 BindInfo_GetBindString
819 static IInternetBindInfo bind_info
= { &bind_info_vtbl
};
821 static HRESULT WINAPI
InternetPriority_QueryInterface(IInternetPriority
*iface
,
822 REFIID riid
, void **ppv
)
824 ok(0, "unexpected call\n");
825 return E_NOINTERFACE
;
828 static ULONG WINAPI
InternetPriority_AddRef(IInternetPriority
*iface
)
833 static ULONG WINAPI
InternetPriority_Release(IInternetPriority
*iface
)
838 static HRESULT WINAPI
InternetPriority_SetPriority(IInternetPriority
*iface
, LONG nPriority
)
840 CHECK_EXPECT(SetPriority
);
841 ok(nPriority
== ex_priority
, "nPriority=%d\n", nPriority
);
845 static HRESULT WINAPI
InternetPriority_GetPriority(IInternetPriority
*iface
, LONG
*pnPriority
)
847 ok(0, "unexpected call\n");
852 static const IInternetPriorityVtbl InternetPriorityVtbl
= {
853 InternetPriority_QueryInterface
,
854 InternetPriority_AddRef
,
855 InternetPriority_Release
,
856 InternetPriority_SetPriority
,
857 InternetPriority_GetPriority
860 static IInternetPriority InternetPriority
= { &InternetPriorityVtbl
};
862 static HRESULT WINAPI
Protocol_QueryInterface(IInternetProtocol
*iface
, REFIID riid
, void **ppv
)
864 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
869 if(IsEqualGUID(&IID_IInternetProtocolEx
, riid
)) {
870 trace("IID_IInternetProtocolEx not supported\n");
872 return E_NOINTERFACE
;
875 if(IsEqualGUID(&IID_IInternetPriority
, riid
)) {
876 *ppv
= &InternetPriority
;
880 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
882 return E_NOINTERFACE
;
885 static ULONG WINAPI
Protocol_AddRef(IInternetProtocol
*iface
)
890 static ULONG WINAPI
Protocol_Release(IInternetProtocol
*iface
)
895 static DWORD WINAPI
thread_proc(PVOID arg
)
899 memset(&protocoldata
, -1, sizeof(protocoldata
));
903 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
904 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
905 BINDSTATUS_FINDINGRESOURCE
, hostW
);
906 CHECK_CALLED(ReportProgress_FINDINGRESOURCE
);
907 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
909 SET_EXPECT(ReportProgress_CONNECTING
);
910 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
911 BINDSTATUS_CONNECTING
, winehq_ipW
);
912 CHECK_CALLED(ReportProgress_CONNECTING
);
913 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
915 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
916 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
917 BINDSTATUS_SENDINGREQUEST
, NULL
);
918 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
919 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
923 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
924 CHECK_CALLED(Switch
);
925 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
929 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
930 CHECK_CALLED(Switch
);
931 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
935 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
936 CHECK_CALLED(Switch
);
937 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
941 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
942 CHECK_CALLED(Switch
);
943 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
945 SetEvent(event_complete
);
950 static HRESULT WINAPI
Protocol_Start(IInternetProtocol
*iface
, LPCWSTR szUrl
,
951 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
952 DWORD grfPI
, HANDLE_PTR dwReserved
)
954 BINDINFO bindinfo
, exp_bindinfo
;
960 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
961 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
962 ok(pOIProtSink
!= &protocol_sink
, "unexpected pOIProtSink\n");
963 ok(pOIBindInfo
!= &bind_info
, "unexpected pOIBindInfo\n");
964 ok(!grfPI
, "grfPI = %x\n", grfPI
);
965 ok(!dwReserved
, "dwReserved = %lx\n", dwReserved
);
967 memset(&bindinfo
, 0, sizeof(bindinfo
));
968 bindinfo
.cbSize
= sizeof(bindinfo
);
969 memcpy(&exp_bindinfo
, &bindinfo
, sizeof(bindinfo
));
970 SET_EXPECT(GetBindInfo
);
971 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &cbindf
, &bindinfo
);
972 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
973 CHECK_CALLED(GetBindInfo
);
974 ok(cbindf
== (bindf
|BINDF_FROMURLMON
), "bindf = %x, expected %x\n",
975 cbindf
, (bindf
|BINDF_FROMURLMON
));
976 ok(!memcmp(&exp_bindinfo
, &bindinfo
, sizeof(bindinfo
)), "unexpected bindinfo\n");
977 ReleaseBindInfo(&bindinfo
);
979 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
980 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_SENDINGREQUEST
, emptyW
);
981 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
982 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
984 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
985 IServiceProvider
*service_provider
;
986 IHttpNegotiate
*http_negotiate
;
987 IHttpNegotiate2
*http_negotiate2
;
988 LPWSTR ua
= (LPWSTR
)0xdeadbeef, accept_mimes
[256];
989 LPWSTR additional_headers
= NULL
;
991 DWORD fetched
= 0, size
= 100;
994 SET_EXPECT(GetBindString_USER_AGENT
);
995 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_USER_AGENT
,
997 CHECK_CALLED(GetBindString_USER_AGENT
);
998 ok(hres
== S_OK
, "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres
);
999 ok(fetched
== 1, "fetched = %d, expected 254\n", fetched
);
1000 ok(ua
!= NULL
, "ua = %p\n", ua
);
1001 ok(!lstrcmpW(ua
, user_agentW
), "unexpected user agent %s\n", debugstr_w(ua
));
1005 SET_EXPECT(GetBindString_ACCEPT_MIMES
);
1006 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
1007 accept_mimes
, 256, &fetched
);
1008 CHECK_CALLED(GetBindString_ACCEPT_MIMES
);
1011 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
1012 ok(fetched
== 1, "fetched = %d, expected 1\n", fetched
);
1013 ok(!lstrcmpW(acc_mimeW
, accept_mimes
[0]), "unexpected mimes %s\n", debugstr_w(accept_mimes
[0]));
1015 hres
= IInternetBindInfo_QueryInterface(pOIBindInfo
, &IID_IServiceProvider
,
1016 (void**)&service_provider
);
1017 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
1019 SET_EXPECT(QueryService_HttpNegotiate
);
1020 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
1021 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
1022 CHECK_CALLED(QueryService_HttpNegotiate
);
1023 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1025 SET_EXPECT(BeginningTransaction
);
1026 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, binding_urls
[tested_protocol
],
1027 NULL
, 0, &additional_headers
);
1028 CHECK_CALLED(BeginningTransaction
);
1029 IHttpNegotiate_Release(http_negotiate
);
1030 ok(hres
== S_OK
, "BeginningTransction failed: %08x\n", hres
);
1031 ok(additional_headers
== NULL
, "additional_headers=%p\n", additional_headers
);
1033 SET_EXPECT(QueryService_HttpNegotiate
);
1034 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate2
,
1035 &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
1036 CHECK_CALLED(QueryService_HttpNegotiate
);
1037 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1040 SET_EXPECT(GetRootSecurityId
);
1041 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, sec_id
, &size
, 0);
1042 CHECK_CALLED(GetRootSecurityId
);
1043 IHttpNegotiate2_Release(http_negotiate2
);
1044 ok(hres
== E_FAIL
, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres
);
1045 ok(size
== 13, "size=%d\n", size
);
1047 IServiceProvider_Release(service_provider
);
1049 CreateThread(NULL
, 0, thread_proc
, NULL
, 0, &tid
);
1054 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
1055 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
1056 BINDSTATUS_CACHEFILENAMEAVAILABLE
, expect_wsz
= emptyW
);
1057 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
1058 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
1060 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1061 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
,
1062 expect_wsz
= text_htmlW
);
1064 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres
);
1065 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1067 SET_EXPECT(ReportData
);
1068 hres
= IInternetProtocolSink_ReportData(pOIProtSink
,
1069 BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
, 13, 13);
1070 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1071 CHECK_CALLED(ReportData
);
1073 if(tested_protocol
== BIND_TEST
) {
1074 hres
= IInternetProtocol_Terminate(binding_protocol
, 0);
1075 ok(hres
== E_FAIL
, "Termiante failed: %08x\n", hres
);
1078 SET_EXPECT(ReportResult
);
1079 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, S_OK
, 0, NULL
);
1080 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1081 CHECK_CALLED(ReportResult
);
1086 static HRESULT WINAPI
Protocol_Continue(IInternetProtocol
*iface
,
1087 PROTOCOLDATA
*pProtocolData
)
1092 CHECK_EXPECT(Continue
);
1094 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
1095 if(!pProtocolData
|| tested_protocol
== BIND_TEST
)
1098 switch(prot_state
) {
1100 IServiceProvider
*service_provider
;
1101 IHttpNegotiate
*http_negotiate
;
1102 static WCHAR header
[] = {'?',0};
1104 hres
= IInternetProtocolSink_QueryInterface(binding_sink
, &IID_IServiceProvider
,
1105 (void**)&service_provider
);
1106 ok(hres
== S_OK
, "Could not get IServiceProvicder\n");
1108 SET_EXPECT(QueryService_HttpNegotiate
);
1109 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
1110 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
1111 IServiceProvider_Release(service_provider
);
1112 CHECK_CALLED(QueryService_HttpNegotiate
);
1113 ok(hres
== S_OK
, "Could not get IHttpNegotiate\n");
1115 SET_EXPECT(OnResponse
);
1116 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, header
, NULL
, NULL
);
1117 IHttpNegotiate_Release(http_negotiate
);
1118 CHECK_CALLED(OnResponse
);
1119 IHttpNegotiate_Release(http_negotiate
);
1120 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
1122 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1123 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1124 BINDSTATUS_MIMETYPEAVAILABLE
, text_htmlW
);
1125 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1127 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
1129 bscf
|= BSCF_FIRSTDATANOTIFICATION
;
1134 bscf
= BSCF_INTERMEDIATEDATANOTIFICATION
;
1138 SET_EXPECT(ReportData
);
1139 hres
= IInternetProtocolSink_ReportData(binding_sink
, bscf
, 100, 400);
1140 CHECK_CALLED(ReportData
);
1141 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1149 static HRESULT WINAPI
Protocol_Abort(IInternetProtocol
*iface
, HRESULT hrReason
,
1152 ok(0, "unexpected call\n");
1156 static HRESULT WINAPI
Protocol_Terminate(IInternetProtocol
*iface
, DWORD dwOptions
)
1158 CHECK_EXPECT(Terminate
);
1159 ok(!dwOptions
, "dwOptions=%d\n", dwOptions
);
1163 static HRESULT WINAPI
Protocol_Suspend(IInternetProtocol
*iface
)
1165 ok(0, "unexpected call\n");
1169 static HRESULT WINAPI
Protocol_Resume(IInternetProtocol
*iface
)
1171 ok(0, "unexpected call\n");
1175 static HRESULT WINAPI
Protocol_Read(IInternetProtocol
*iface
, void *pv
,
1176 ULONG cb
, ULONG
*pcbRead
)
1178 static BOOL b
= TRUE
;
1182 ok(pv
== expect_pv
, "pv != expect_pv\n");
1183 ok(cb
== 1000, "cb=%d\n", cb
);
1184 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
1185 ok(!*pcbRead
, "*pcbRead = %d\n", *pcbRead
);
1187 if(prot_state
== 3) {
1190 SET_EXPECT(ReportResult
);
1191 hres
= IInternetProtocolSink_ReportResult(binding_sink
, S_OK
, ERROR_SUCCESS
, NULL
);
1192 CHECK_CALLED(ReportResult
);
1198 return tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
? E_PENDING
: S_FALSE
;
1200 memset(pv
, 'x', 100);
1201 prot_read
+= *pcbRead
= 100;
1205 static HRESULT WINAPI
Protocol_Seek(IInternetProtocol
*iface
,
1206 LARGE_INTEGER dlibMove
, DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
1208 ok(0, "unexpected call\n");
1212 static HRESULT WINAPI
Protocol_LockRequest(IInternetProtocol
*iface
, DWORD dwOptions
)
1214 CHECK_EXPECT(LockRequest
);
1215 ok(dwOptions
== 0, "dwOptions=%x\n", dwOptions
);
1219 static HRESULT WINAPI
Protocol_UnlockRequest(IInternetProtocol
*iface
)
1221 CHECK_EXPECT(UnlockRequest
);
1225 static const IInternetProtocolVtbl ProtocolVtbl
= {
1226 Protocol_QueryInterface
,
1237 Protocol_LockRequest
,
1238 Protocol_UnlockRequest
1241 static IInternetProtocol Protocol
= { &ProtocolVtbl
};
1243 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1245 ok(0, "unexpected call\n");
1246 return E_NOINTERFACE
;
1249 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1254 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1259 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
1260 REFIID riid
, void **ppv
)
1262 CHECK_EXPECT(CreateInstance
);
1264 ok(pOuter
== (IUnknown
*)prot_bind_info
, "pOuter != protocol_unk\n");
1265 ok(IsEqualGUID(&IID_IUnknown
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
1266 ok(ppv
!= NULL
, "ppv == NULL\n");
1272 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
1274 ok(0, "unexpected call\n");
1278 static const IClassFactoryVtbl ClassFactoryVtbl
= {
1279 ClassFactory_QueryInterface
,
1280 ClassFactory_AddRef
,
1281 ClassFactory_Release
,
1282 ClassFactory_CreateInstance
,
1283 ClassFactory_LockServer
1286 static IClassFactory ClassFactory
= { &ClassFactoryVtbl
};
1288 static void test_priority(IInternetProtocol
*protocol
)
1290 IInternetPriority
*priority
;
1294 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetPriority
,
1296 ok(hres
== S_OK
, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres
);
1300 hres
= IInternetPriority_GetPriority(priority
, &pr
);
1301 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
1302 ok(pr
== 0, "pr=%d, expected 0\n", pr
);
1304 hres
= IInternetPriority_SetPriority(priority
, 1);
1305 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
1307 hres
= IInternetPriority_GetPriority(priority
, &pr
);
1308 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
1309 ok(pr
== 1, "pr=%d, expected 1\n", pr
);
1311 IInternetPriority_Release(priority
);
1314 static BOOL
file_protocol_start(IInternetProtocol
*protocol
, LPCWSTR url
, BOOL is_first
)
1318 SET_EXPECT(GetBindInfo
);
1319 if(!(bindf
& BINDF_FROMURLMON
))
1320 SET_EXPECT(ReportProgress_DIRECTBIND
);
1322 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1323 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
1324 if(bindf
& BINDF_FROMURLMON
)
1325 SET_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
1327 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1329 SET_EXPECT(ReportData
);
1331 SET_EXPECT(ReportResult
);
1333 expect_hrResult
= S_OK
;
1335 hres
= IInternetProtocol_Start(protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
1336 if(hres
== INET_E_RESOURCE_NOT_FOUND
) {
1337 win_skip("Start failed\n");
1340 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
1342 CHECK_CALLED(GetBindInfo
);
1343 if(!(bindf
& BINDF_FROMURLMON
))
1344 CHECK_CALLED(ReportProgress_DIRECTBIND
);
1346 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
1347 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
1348 if(bindf
& BINDF_FROMURLMON
)
1349 CHECK_CALLED(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
1351 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1353 CHECK_CALLED(ReportData
);
1355 CHECK_CALLED(ReportResult
);
1360 static void test_file_protocol_url(LPCWSTR url
)
1362 IInternetProtocolInfo
*protocol_info
;
1364 IClassFactory
*factory
;
1367 hres
= CoGetClassObject(&CLSID_FileProtocol
, CLSCTX_INPROC_SERVER
, NULL
,
1368 &IID_IUnknown
, (void**)&unk
);
1369 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
1373 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
1374 ok(hres
== E_NOINTERFACE
,
1375 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
1377 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
1378 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
1379 if(SUCCEEDED(hres
)) {
1380 IInternetProtocol
*protocol
;
1383 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
1384 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
1386 if(SUCCEEDED(hres
)) {
1387 if(file_protocol_start(protocol
, url
, TRUE
)) {
1388 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
1389 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
1390 ok(cb
== 2, "cb=%u expected 2\n", cb
);
1391 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
1392 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
1393 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
1394 ok(hres
== S_FALSE
, "Read failed: %08x expected S_FALSE\n", hres
);
1395 ok(cb
== 0, "cb=%u expected 0\n", cb
);
1396 hres
= IInternetProtocol_UnlockRequest(protocol
);
1397 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
1400 if(file_protocol_start(protocol
, url
, FALSE
)) {
1401 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
1402 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
1403 hres
= IInternetProtocol_LockRequest(protocol
, 0);
1404 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
1405 hres
= IInternetProtocol_UnlockRequest(protocol
);
1406 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
1409 IInternetProtocol_Release(protocol
);
1412 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
1413 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
1415 if(SUCCEEDED(hres
)) {
1416 if(file_protocol_start(protocol
, url
, TRUE
)) {
1417 hres
= IInternetProtocol_LockRequest(protocol
, 0);
1418 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
1419 hres
= IInternetProtocol_Terminate(protocol
, 0);
1420 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
1421 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
1422 ok(hres
== S_OK
, "Read failed: %08x\n\n", hres
);
1423 hres
= IInternetProtocol_UnlockRequest(protocol
);
1424 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
1425 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
1426 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
1427 hres
= IInternetProtocol_Terminate(protocol
, 0);
1428 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
1431 IInternetProtocol_Release(protocol
);
1434 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
1435 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
1437 if(SUCCEEDED(hres
)) {
1438 if(file_protocol_start(protocol
, url
, TRUE
)) {
1439 hres
= IInternetProtocol_Terminate(protocol
, 0);
1440 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
1441 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
1442 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
1443 ok(cb
== 2, "cb=%u expected 2\n", cb
);
1446 IInternetProtocol_Release(protocol
);
1449 IClassFactory_Release(factory
);
1452 IUnknown_Release(unk
);
1455 static void test_file_protocol_fail(void)
1457 IInternetProtocol
*protocol
;
1460 static const WCHAR index_url2
[] =
1461 {'f','i','l','e',':','/','/','i','n','d','e','x','.','h','t','m','l',0};
1463 hres
= CoCreateInstance(&CLSID_FileProtocol
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
1464 &IID_IInternetProtocol
, (void**)&protocol
);
1465 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
1469 SET_EXPECT(GetBindInfo
);
1470 expect_hrResult
= MK_E_SYNTAX
;
1471 hres
= IInternetProtocol_Start(protocol
, wszIndexHtml
, &protocol_sink
, &bind_info
, 0, 0);
1472 ok(hres
== MK_E_SYNTAX
||
1473 hres
== E_INVALIDARG
,
1474 "Start failed: %08x, expected MK_E_SYNTAX or E_INVALIDARG\n", hres
);
1475 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
1477 SET_EXPECT(GetBindInfo
);
1478 if(!(bindf
& BINDF_FROMURLMON
))
1479 SET_EXPECT(ReportProgress_DIRECTBIND
);
1480 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1481 SET_EXPECT(ReportResult
);
1482 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
1483 hres
= IInternetProtocol_Start(protocol
, index_url
, &protocol_sink
, &bind_info
, 0, 0);
1484 ok(hres
== INET_E_RESOURCE_NOT_FOUND
,
1485 "Start failed: %08x expected INET_E_RESOURCE_NOT_FOUND\n", hres
);
1486 CHECK_CALLED(GetBindInfo
);
1487 if(!(bindf
& BINDF_FROMURLMON
))
1488 CHECK_CALLED(ReportProgress_DIRECTBIND
);
1489 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
1490 CHECK_CALLED(ReportResult
);
1492 IInternetProtocol_Release(protocol
);
1494 hres
= CoCreateInstance(&CLSID_FileProtocol
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
1495 &IID_IInternetProtocol
, (void**)&protocol
);
1496 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
1500 SET_EXPECT(GetBindInfo
);
1501 if(!(bindf
& BINDF_FROMURLMON
))
1502 SET_EXPECT(ReportProgress_DIRECTBIND
);
1503 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1504 SET_EXPECT(ReportResult
);
1505 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
1507 hres
= IInternetProtocol_Start(protocol
, index_url2
, &protocol_sink
, &bind_info
, 0, 0);
1508 ok(hres
== INET_E_RESOURCE_NOT_FOUND
,
1509 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND\n", hres
);
1510 CHECK_CALLED(GetBindInfo
);
1511 if(!(bindf
& BINDF_FROMURLMON
))
1512 CHECK_CALLED(ReportProgress_DIRECTBIND
);
1513 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
1514 CHECK_CALLED(ReportResult
);
1516 SET_EXPECT(GetBindInfo
);
1517 hres
= IInternetProtocol_Start(protocol
, NULL
, &protocol_sink
, &bind_info
, 0, 0);
1518 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
1519 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
1521 SET_EXPECT(GetBindInfo
);
1522 hres
= IInternetProtocol_Start(protocol
, emptyW
, &protocol_sink
, &bind_info
, 0, 0);
1523 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
1524 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
1526 IInternetProtocol_Release(protocol
);
1529 static void test_file_protocol(void) {
1530 WCHAR buf
[INTERNET_MAX_URL_LENGTH
], file_name_buf
[MAX_PATH
];
1535 static const WCHAR wszFile
[] = {'f','i','l','e',':',0};
1536 static const WCHAR wszFile2
[] = {'f','i','l','e',':','/','/',0};
1537 static const WCHAR wszFile3
[] = {'f','i','l','e',':','/','/','/',0};
1538 static const char html_doc
[] = "<HTML></HTML>";
1540 trace("Testing file protocol...\n");
1541 tested_protocol
= FILE_TEST
;
1543 SetLastError(0xdeadbeef);
1544 file
= CreateFileW(wszIndexHtml
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
1545 FILE_ATTRIBUTE_NORMAL
, NULL
);
1546 if(!file
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1548 win_skip("Detected Win9x or WinMe\n");
1551 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed\n");
1552 if(file
== INVALID_HANDLE_VALUE
)
1554 WriteFile(file
, html_doc
, sizeof(html_doc
)-1, &size
, NULL
);
1557 file_name
= wszIndexHtml
;
1559 test_file_protocol_url(index_url
);
1560 bindf
= BINDF_FROMURLMON
;
1561 test_file_protocol_url(index_url
);
1562 bindf
= BINDF_FROMURLMON
| BINDF_NEEDFILE
;
1563 test_file_protocol_url(index_url
);
1565 memcpy(buf
, wszFile
, sizeof(wszFile
));
1566 len
= sizeof(wszFile
)/sizeof(WCHAR
)-1;
1567 len
+= GetCurrentDirectoryW(sizeof(buf
)/sizeof(WCHAR
)-len
, buf
+len
);
1569 memcpy(buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
1571 file_name
= buf
+ sizeof(wszFile
)/sizeof(WCHAR
)-1;
1573 test_file_protocol_url(buf
);
1574 bindf
= BINDF_FROMURLMON
;
1575 test_file_protocol_url(buf
);
1577 memcpy(buf
, wszFile2
, sizeof(wszFile2
));
1578 len
= GetCurrentDirectoryW(sizeof(file_name_buf
)/sizeof(WCHAR
), file_name_buf
);
1579 file_name_buf
[len
++] = '\\';
1580 memcpy(file_name_buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
1581 lstrcpyW(buf
+sizeof(wszFile2
)/sizeof(WCHAR
)-1, file_name_buf
);
1582 file_name
= file_name_buf
;
1584 test_file_protocol_url(buf
);
1585 bindf
= BINDF_FROMURLMON
;
1586 test_file_protocol_url(buf
);
1588 buf
[sizeof(wszFile2
)/sizeof(WCHAR
)] = '|';
1589 test_file_protocol_url(buf
);
1591 memcpy(buf
, wszFile3
, sizeof(wszFile3
));
1592 len
= sizeof(wszFile3
)/sizeof(WCHAR
)-1;
1593 len
+= GetCurrentDirectoryW(sizeof(buf
)/sizeof(WCHAR
)-len
, buf
+len
);
1595 memcpy(buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
1597 file_name
= buf
+ sizeof(wszFile3
)/sizeof(WCHAR
)-1;
1599 test_file_protocol_url(buf
);
1600 bindf
= BINDF_FROMURLMON
;
1601 test_file_protocol_url(buf
);
1603 DeleteFileW(wszIndexHtml
);
1606 test_file_protocol_fail();
1607 bindf
= BINDF_FROMURLMON
;
1608 test_file_protocol_fail();
1611 static BOOL
http_protocol_start(LPCWSTR url
, BOOL is_first
)
1613 static BOOL got_user_agent
= FALSE
;
1616 first_data_notif
= TRUE
;
1619 SET_EXPECT(GetBindInfo
);
1620 if (!(bindf
& BINDF_FROMURLMON
))
1621 SET_EXPECT(ReportProgress_DIRECTBIND
);
1622 SET_EXPECT(GetBindString_USER_AGENT
);
1623 SET_EXPECT(GetBindString_ACCEPT_MIMES
);
1624 SET_EXPECT(QueryService_HttpNegotiate
);
1625 SET_EXPECT(BeginningTransaction
);
1626 SET_EXPECT(GetRootSecurityId
);
1628 SET_EXPECT(GetBindString_POST_COOKIE
);
1630 hres
= IInternetProtocol_Start(async_protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
1631 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
1635 CHECK_CALLED(GetBindInfo
);
1636 if (!(bindf
& BINDF_FROMURLMON
))
1637 CHECK_CALLED(ReportProgress_DIRECTBIND
);
1638 if (!got_user_agent
)
1640 CHECK_CALLED(GetBindString_USER_AGENT
);
1641 got_user_agent
= TRUE
;
1645 /* user agent only retrieved once, even with different URLs */
1646 CHECK_NOT_CALLED(GetBindString_USER_AGENT
);
1648 CHECK_CALLED(GetBindString_ACCEPT_MIMES
);
1649 CHECK_CALLED(QueryService_HttpNegotiate
);
1650 CHECK_CALLED(BeginningTransaction
);
1651 /* GetRootSecurityId called on WinXP but not on Win98 */
1652 CLEAR_CALLED(GetRootSecurityId
);
1654 CHECK_CALLED(GetBindString_POST_COOKIE
);
1659 static void test_protocol_terminate(IInternetProtocol
*protocol
)
1665 hres
= IInternetProtocol_LockRequest(protocol
, 0);
1666 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
1668 hres
= IInternetProtocol_Read(protocol
, buf
, 1, &cb
);
1669 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
1671 hres
= IInternetProtocol_Terminate(protocol
, 0);
1672 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
1674 /* This wait is to give the internet handles being freed in Terminate
1675 * enough time to actually terminate in all cases. Internet handles
1676 * terminate asynchronously and native reuses the main InternetOpen
1677 * handle. The only case in which this seems to be necessary is on
1678 * wine with native wininet and urlmon, resulting in the next time
1679 * test_http_protocol_url being called the first data notification actually
1680 * being an extra last data notification from the previous connection
1681 * about once out of every ten times. */
1684 hres
= IInternetProtocol_UnlockRequest(protocol
);
1685 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
1688 static void test_http_info(IInternetProtocol
*protocol
)
1690 IWinInetHttpInfo
*info
;
1693 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetHttpInfo
, (void**)&info
);
1694 ok(hres
== S_OK
, "Could not get IWinInterHttpInfo iface: %08x\n", hres
);
1698 IWinInetHttpInfo_Release(info
);
1701 /* is_first refers to whether this is the first call to this function
1703 static void test_http_protocol_url(LPCWSTR url
, BOOL is_https
, BOOL is_first
)
1705 IInternetProtocolInfo
*protocol_info
;
1706 IClassFactory
*factory
;
1711 http_is_first
= is_first
;
1713 hres
= CoGetClassObject(is_https
? &CLSID_HttpSProtocol
: &CLSID_HttpProtocol
,
1714 CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
1715 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
1719 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
1720 ok(hres
== E_NOINTERFACE
,
1721 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
1724 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
1725 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
1726 IUnknown_Release(unk
);
1730 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
1731 (void**)&async_protocol
);
1732 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
1733 if(SUCCEEDED(hres
)) {
1738 test_priority(async_protocol
);
1739 test_http_info(async_protocol
);
1741 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
1742 SET_EXPECT(ReportProgress_CONNECTING
);
1743 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1744 SET_EXPECT(ReportProgress_PROXYDETECTING
);
1746 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
1748 SET_EXPECT(QueryService_HttpSecurity
);
1749 if(!(bindf
& BINDF_FROMURLMON
)) {
1750 SET_EXPECT(OnResponse
);
1751 SET_EXPECT(ReportProgress_RAWMIMETYPE
);
1752 SET_EXPECT(ReportData
);
1757 if(!http_protocol_start(url
, is_first
))
1760 SET_EXPECT(ReportResult
);
1761 expect_hrResult
= S_OK
;
1763 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
1764 ok((hres
== E_PENDING
&& cb
==0) ||
1765 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
1767 WaitForSingleObject(event_complete
, INFINITE
);
1768 if(bindf
& BINDF_FROMURLMON
)
1769 CHECK_CALLED(Switch
);
1771 CHECK_CALLED(ReportData
);
1773 CLEAR_CALLED(QueryService_HttpSecurity
);
1776 if(bindf
& BINDF_FROMURLMON
)
1779 SET_EXPECT(ReportData
);
1780 hres
= IInternetProtocol_Read(async_protocol
, buf
, sizeof(buf
), &cb
);
1781 if(hres
== E_PENDING
) {
1782 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
1783 ok((hres
== E_PENDING
&& cb
==0) ||
1784 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
1785 WaitForSingleObject(event_complete
, INFINITE
);
1786 if(bindf
& BINDF_FROMURLMON
)
1787 CHECK_CALLED(Switch
);
1789 CHECK_CALLED(ReportData
);
1791 if(bindf
& BINDF_FROMURLMON
)
1792 CHECK_NOT_CALLED(Switch
);
1794 CHECK_NOT_CALLED(ReportData
);
1798 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
1799 CHECK_CALLED(ReportResult
);
1801 CLEAR_CALLED(ReportProgress_SENDINGREQUEST
);
1803 test_protocol_terminate(async_protocol
);
1804 ref
= IInternetProtocol_Release(async_protocol
);
1805 ok(!ref
, "ref=%x\n", hres
);
1808 IClassFactory_Release(factory
);
1811 static void test_http_protocol(void)
1813 static const WCHAR winehq_url
[] =
1814 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
1815 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
1816 static const WCHAR posttest_url
[] =
1817 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
1818 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
1819 'p','o','s','t','t','e','s','t','.','p','h','p',0};
1821 trace("Testing http protocol (not from urlmon)...\n");
1822 tested_protocol
= HTTP_TEST
;
1823 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
;
1824 test_http_protocol_url(winehq_url
, FALSE
, TRUE
);
1826 trace("Testing http protocol (from urlmon)...\n");
1827 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
;
1828 test_http_protocol_url(winehq_url
, FALSE
, FALSE
);
1830 trace("Testing http protocol (to file)...\n");
1831 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NEEDFILE
;
1832 test_http_protocol_url(winehq_url
, FALSE
, FALSE
);
1834 trace("Testing http protocol (post data)...\n");
1835 http_post_test
= TRUE
;
1836 /* Without this flag we get a ReportProgress_CACHEFILENAMEAVAILABLE
1837 * notification with BINDVERB_POST */
1838 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
1839 test_http_protocol_url(posttest_url
, FALSE
, TRUE
);
1840 http_post_test
= FALSE
;
1843 static void test_https_protocol(void)
1845 static const WCHAR codeweavers_url
[] =
1846 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
1847 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0};
1849 trace("Testing https protocol (from urlmon)...\n");
1850 tested_protocol
= HTTPS_TEST
;
1851 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
1852 test_http_protocol_url(codeweavers_url
, TRUE
, TRUE
);
1856 static void test_ftp_protocol(void)
1858 IInternetProtocolInfo
*protocol_info
;
1859 IClassFactory
*factory
;
1866 static const WCHAR ftp_urlW
[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
1867 '/','p','u','b','/','o','t','h','e','r','/',
1868 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
1870 trace("Testing ftp protocol...\n");
1872 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
1874 tested_protocol
= FTP_TEST
;
1875 first_data_notif
= TRUE
;
1876 expect_hrResult
= E_PENDING
;
1878 hres
= CoGetClassObject(&CLSID_FtpProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
1879 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
1883 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
1884 ok(hres
== E_NOINTERFACE
, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
1886 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
1887 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
1888 IUnknown_Release(unk
);
1892 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
1893 (void**)&async_protocol
);
1894 IClassFactory_Release(factory
);
1895 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
1897 test_priority(async_protocol
);
1898 test_http_info(async_protocol
);
1900 SET_EXPECT(GetBindInfo
);
1901 SET_EXPECT(GetBindString_USER_AGENT
);
1902 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
1903 SET_EXPECT(ReportProgress_CONNECTING
);
1904 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1907 hres
= IInternetProtocol_Start(async_protocol
, ftp_urlW
, &protocol_sink
, &bind_info
, 0, 0);
1908 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
1909 CHECK_CALLED(GetBindInfo
);
1910 todo_wine
CHECK_NOT_CALLED(GetBindString_USER_AGENT
);
1912 SET_EXPECT(ReportResult
);
1914 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
1915 ok((hres
== E_PENDING
&& cb
==0) ||
1916 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
1918 WaitForSingleObject(event_complete
, INFINITE
);
1922 hres
= IInternetProtocol_Read(async_protocol
, buf
, sizeof(buf
), &cb
);
1923 if(hres
== E_PENDING
)
1924 WaitForSingleObject(event_complete
, INFINITE
);
1929 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
1930 CHECK_CALLED(ReportResult
);
1931 CHECK_CALLED(Switch
);
1933 test_protocol_terminate(async_protocol
);
1935 ref
= IInternetProtocol_Release(async_protocol
);
1936 ok(!ref
, "ref=%d\n", ref
);
1939 static void test_gopher_protocol(void)
1941 IInternetProtocolInfo
*protocol_info
;
1942 IClassFactory
*factory
;
1946 trace("Testing gopher protocol...\n");
1948 hres
= CoGetClassObject(&CLSID_GopherProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
1950 hres
== REGDB_E_CLASSNOTREG
, /* Gopher protocol has been removed as of Vista */
1951 "CoGetClassObject failed: %08x\n", hres
);
1955 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
1956 ok(hres
== E_NOINTERFACE
, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
1958 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
1959 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
1960 IUnknown_Release(unk
);
1964 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
1965 (void**)&async_protocol
);
1966 IClassFactory_Release(factory
);
1967 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
1969 test_priority(async_protocol
);
1971 IInternetProtocol_Release(async_protocol
);
1974 static void test_mk_protocol(void)
1976 IInternetProtocolInfo
*protocol_info
;
1977 IInternetProtocol
*protocol
;
1978 IClassFactory
*factory
;
1982 static const WCHAR wrong_url1
[] = {'t','e','s','t',':','@','M','S','I','T','S','t','o','r','e',
1983 ':',':','/','t','e','s','t','.','h','t','m','l',0};
1984 static const WCHAR wrong_url2
[] = {'m','k',':','/','t','e','s','t','.','h','t','m','l',0};
1986 trace("Testing mk protocol...\n");
1987 tested_protocol
= MK_TEST
;
1989 hres
= CoGetClassObject(&CLSID_MkProtocol
, CLSCTX_INPROC_SERVER
, NULL
,
1990 &IID_IUnknown
, (void**)&unk
);
1991 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
1993 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
1994 ok(hres
== E_NOINTERFACE
,
1995 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
1998 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
1999 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
2000 IUnknown_Release(unk
);
2004 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
2006 IClassFactory_Release(factory
);
2007 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2009 SET_EXPECT(GetBindInfo
);
2010 hres
= IInternetProtocol_Start(protocol
, wrong_url1
, &protocol_sink
, &bind_info
, 0, 0);
2011 ok(hres
== MK_E_SYNTAX
|| hres
== INET_E_INVALID_URL
,
2012 "Start failed: %08x, expected MK_E_SYNTAX or INET_E_INVALID_URL\n", hres
);
2013 CLEAR_CALLED(GetBindInfo
);
2015 SET_EXPECT(GetBindInfo
);
2016 SET_EXPECT(ReportProgress_DIRECTBIND
);
2017 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2018 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
2019 SET_EXPECT(ReportResult
);
2020 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
2022 hres
= IInternetProtocol_Start(protocol
, wrong_url2
, &protocol_sink
, &bind_info
, 0, 0);
2023 ok(hres
== INET_E_RESOURCE_NOT_FOUND
||
2024 hres
== INET_E_INVALID_URL
, /* win2k3 */
2025 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND or INET_E_INVALID_URL\n", hres
);
2027 if (hres
== INET_E_RESOURCE_NOT_FOUND
) {
2028 CHECK_CALLED(GetBindInfo
);
2029 CLEAR_CALLED(ReportProgress_DIRECTBIND
);
2030 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
2031 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
2032 CHECK_CALLED(ReportResult
);
2034 CLEAR_CALLED(GetBindInfo
);
2035 CLEAR_CALLED(ReportProgress_DIRECTBIND
);
2036 CLEAR_CALLED(ReportProgress_SENDINGREQUEST
);
2037 CLEAR_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
2038 CLEAR_CALLED(ReportResult
);
2041 IInternetProtocol_Release(protocol
);
2044 static void test_CreateBinding(void)
2046 IInternetProtocolSink
*sink
;
2047 IInternetProtocol
*protocol
;
2048 IInternetPriority
*priority
;
2049 IInternetSession
*session
;
2055 static const WCHAR test_url
[] =
2056 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0};
2057 static const WCHAR wsz_test
[] = {'t','e','s','t',0};
2059 trace("Testing CreateBinding...\n");
2060 tested_protocol
= BIND_TEST
;
2061 binding_test
= TRUE
;
2063 hres
= CoInternetGetSession(0, &session
, 0);
2064 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
2066 hres
= IInternetSession_RegisterNameSpace(session
, &ClassFactory
, &IID_NULL
, wsz_test
, 0, NULL
, 0);
2067 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
2069 hres
= IInternetSession_CreateBinding(session
, NULL
, test_url
, NULL
, NULL
, &protocol
, 0);
2070 binding_protocol
= protocol
;
2071 ok(hres
== S_OK
, "CreateBinding failed: %08x\n", hres
);
2072 ok(protocol
!= NULL
, "protocol == NULL\n");
2074 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetBindInfo
, (void**)&prot_bind_info
);
2075 ok(hres
== S_OK
, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres
);
2077 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetProtocolSink
, (void**)&sink
);
2078 ok(hres
== S_OK
, "Could not get IInternetProtocolSink: %08x\n", hres
);
2080 hres
= IInternetProtocol_Start(protocol
, test_url
, NULL
, &bind_info
, 0, 0);
2081 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2082 hres
= IInternetProtocol_Start(protocol
, test_url
, &protocol_sink
, NULL
, 0, 0);
2083 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2084 hres
= IInternetProtocol_Start(protocol
, NULL
, &protocol_sink
, &bind_info
, 0, 0);
2085 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2087 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetPriority
, (void**)&priority
);
2088 ok(hres
== S_OK
, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres
);
2091 hres
= IInternetPriority_GetPriority(priority
, &p
);
2092 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2093 ok(!p
, "p=%d\n", p
);
2096 hres
= IInternetPriority_SetPriority(priority
, 100);
2097 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
2100 hres
= IInternetPriority_GetPriority(priority
, &p
);
2101 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2102 ok(p
== 100, "p=%d\n", p
);
2104 SET_EXPECT(QueryService_InternetProtocol
);
2105 SET_EXPECT(CreateInstance
);
2106 SET_EXPECT(ReportProgress_PROTOCOLCLASSID
);
2107 SET_EXPECT(SetPriority
);
2110 expect_hrResult
= S_OK
;
2111 hres
= IInternetProtocol_Start(protocol
, test_url
, &protocol_sink
, &bind_info
, 0, 0);
2112 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2114 CHECK_CALLED(QueryService_InternetProtocol
);
2115 CHECK_CALLED(CreateInstance
);
2116 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID
);
2117 CHECK_CALLED(SetPriority
);
2118 CHECK_CALLED(Start
);
2122 hres
= IInternetProtocol_Read(protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
2123 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2124 ok(read
== 100, "read = %d\n", read
);
2129 hres
= IInternetProtocol_Read(protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
2130 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2131 ok(!read
, "read = %d\n", read
);
2135 hres
= IInternetPriority_GetPriority(priority
, &p
);
2136 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2137 ok(p
== 100, "p=%d\n", p
);
2139 hres
= IInternetPriority_SetPriority(priority
, 101);
2140 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
2142 SET_EXPECT(Terminate
);
2143 hres
= IInternetProtocol_Terminate(protocol
, 0xdeadbeef);
2144 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2145 CHECK_CALLED(Terminate
);
2147 SET_EXPECT(Continue
);
2148 hres
= IInternetProtocolSink_Switch(sink
, &protocoldata
);
2149 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
2150 CHECK_CALLED(Continue
);
2152 hres
= IInternetProtocolSink_ReportProgress(sink
,
2153 BINDSTATUS_CACHEFILENAMEAVAILABLE
, expect_wsz
= emptyW
);
2154 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
2156 hres
= IInternetProtocolSink_ReportResult(sink
, S_OK
, ERROR_SUCCESS
, NULL
);
2157 ok(hres
== E_FAIL
, "ReportResult failed: %08x, expected E_FAIL\n", hres
);
2159 hres
= IInternetProtocolSink_ReportData(sink
, 0, 0, 0);
2160 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
2162 IInternetProtocolSink_Release(sink
);
2163 IInternetPriority_Release(priority
);
2164 IInternetBindInfo_Release(prot_bind_info
);
2165 IInternetProtocol_Release(protocol
);
2166 IInternetSession_Release(session
);
2169 static void test_binding(int prot
)
2171 IInternetProtocol
*protocol
;
2172 IInternetSession
*session
;
2176 trace("Testing %s binding...\n", debugstr_w(protocol_names
[prot
]));
2178 tested_protocol
= prot
;
2179 binding_test
= TRUE
;
2180 first_data_notif
= TRUE
;
2183 hres
= CoInternetGetSession(0, &session
, 0);
2184 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
2186 hres
= IInternetSession_RegisterNameSpace(session
, &ClassFactory
, &IID_NULL
, protocol_names
[prot
], 0, NULL
, 0);
2187 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
2189 hres
= IInternetSession_CreateBinding(session
, NULL
, binding_urls
[prot
], NULL
, NULL
, &protocol
, 0);
2190 binding_protocol
= protocol
;
2191 IInternetSession_Release(session
);
2192 ok(hres
== S_OK
, "CreateBinding failed: %08x\n", hres
);
2193 ok(protocol
!= NULL
, "protocol == NULL\n");
2195 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetBindInfo
, (void**)&prot_bind_info
);
2196 ok(hres
== S_OK
, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres
);
2198 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetProtocolSink
, (void**)&binding_sink
);
2199 ok(hres
== S_OK
, "QueryInterface(IID_IInternetProtocolSink) failed: %08x\n", hres
);
2202 SET_EXPECT(QueryService_InternetProtocol
);
2203 SET_EXPECT(CreateInstance
);
2204 SET_EXPECT(ReportProgress_PROTOCOLCLASSID
);
2205 SET_EXPECT(SetPriority
);
2208 expect_hrResult
= S_OK
;
2209 hres
= IInternetProtocol_Start(protocol
, binding_urls
[prot
], &protocol_sink
, &bind_info
, 0, 0);
2210 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2212 CHECK_CALLED(QueryService_InternetProtocol
);
2213 CHECK_CALLED(CreateInstance
);
2214 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID
);
2215 CHECK_CALLED(SetPriority
);
2216 CHECK_CALLED(Start
);
2218 if(prot
== HTTP_TEST
|| prot
== HTTPS_TEST
) {
2219 while(prot_state
< 4) {
2220 WaitForSingleObject(event_complete
, INFINITE
);
2221 SET_EXPECT(Continue
);
2222 IInternetProtocol_Continue(protocol
, pdata
);
2223 CHECK_CALLED(Continue
);
2224 SetEvent(event_complete2
);
2227 WaitForSingleObject(event_complete
, INFINITE
);
2229 SET_EXPECT(LockRequest
);
2230 hres
= IInternetProtocol_LockRequest(protocol
, 0);
2231 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2232 CHECK_CALLED(LockRequest
);
2234 SET_EXPECT(UnlockRequest
);
2235 hres
= IInternetProtocol_UnlockRequest(protocol
);
2236 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2237 CHECK_CALLED(UnlockRequest
);
2240 SET_EXPECT(Terminate
);
2241 hres
= IInternetProtocol_Terminate(protocol
, 0);
2242 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2243 CHECK_CALLED(Terminate
);
2245 IInternetBindInfo_Release(prot_bind_info
);
2246 IInternetProtocolSink_Release(binding_sink
);
2247 ref
= IInternetProtocol_Release(protocol
);
2248 ok(!ref
, "ref=%u, expected 0\n", ref
);
2251 START_TEST(protocol
)
2253 OleInitialize(NULL
);
2255 event_complete
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2256 event_complete2
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2258 test_file_protocol();
2259 test_http_protocol();
2260 test_https_protocol();
2261 test_ftp_protocol();
2262 test_gopher_protocol();
2264 test_CreateBinding();
2265 test_binding(FILE_TEST
);
2266 test_binding(HTTP_TEST
);
2268 CloseHandle(event_complete
);
2269 CloseHandle(event_complete2
);