2 * Copyright 2005-2009 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 static HRESULT (WINAPI
*pCoInternetGetSession
)(DWORD
, IInternetSession
**, DWORD
);
33 static HRESULT (WINAPI
*pReleaseBindInfo
)(BINDINFO
*);
35 #define DEFINE_EXPECT(func) \
36 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
38 #define SET_EXPECT(func) \
39 expect_ ## func = TRUE
41 #define CHECK_EXPECT2(func) \
43 ok(expect_ ##func, "unexpected call " #func "\n"); \
44 called_ ## func = TRUE; \
47 #define CHECK_EXPECT(func) \
49 CHECK_EXPECT2(func); \
50 expect_ ## func = FALSE; \
53 #define CHECK_CALLED(func) \
55 ok(called_ ## func, "expected " #func "\n"); \
56 expect_ ## func = called_ ## func = FALSE; \
59 #define CHECK_NOT_CALLED(func) \
61 ok(!called_ ## func, "unexpected " #func "\n"); \
62 expect_ ## func = called_ ## func = FALSE; \
65 #define CLEAR_CALLED(func) \
66 expect_ ## func = called_ ## func = FALSE
68 DEFINE_EXPECT(GetBindInfo
);
69 DEFINE_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
70 DEFINE_EXPECT(ReportProgress_DIRECTBIND
);
71 DEFINE_EXPECT(ReportProgress_RAWMIMETYPE
);
72 DEFINE_EXPECT(ReportProgress_FINDINGRESOURCE
);
73 DEFINE_EXPECT(ReportProgress_CONNECTING
);
74 DEFINE_EXPECT(ReportProgress_SENDINGREQUEST
);
75 DEFINE_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
76 DEFINE_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
77 DEFINE_EXPECT(ReportProgress_PROTOCOLCLASSID
);
78 DEFINE_EXPECT(ReportProgress_COOKIE_SENT
);
79 DEFINE_EXPECT(ReportProgress_REDIRECTING
);
80 DEFINE_EXPECT(ReportProgress_ENCODING
);
81 DEFINE_EXPECT(ReportProgress_ACCEPTRANGES
);
82 DEFINE_EXPECT(ReportProgress_PROXYDETECTING
);
83 DEFINE_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
84 DEFINE_EXPECT(ReportProgress_DECODING
);
85 DEFINE_EXPECT(ReportData
);
86 DEFINE_EXPECT(ReportData2
);
87 DEFINE_EXPECT(ReportResult
);
88 DEFINE_EXPECT(GetBindString_ACCEPT_MIMES
);
89 DEFINE_EXPECT(GetBindString_USER_AGENT
);
90 DEFINE_EXPECT(GetBindString_POST_COOKIE
);
91 DEFINE_EXPECT(GetBindString_URL
);
92 DEFINE_EXPECT(QueryService_HttpNegotiate
);
93 DEFINE_EXPECT(QueryService_InternetProtocol
);
94 DEFINE_EXPECT(QueryService_HttpSecurity
);
95 DEFINE_EXPECT(QueryInterface_IWinInetInfo
);
96 DEFINE_EXPECT(QueryInterface_IWinInetHttpInfo
);
97 DEFINE_EXPECT(BeginningTransaction
);
98 DEFINE_EXPECT(GetRootSecurityId
);
99 DEFINE_EXPECT(OnResponse
);
100 DEFINE_EXPECT(Switch
);
101 DEFINE_EXPECT(Continue
);
102 DEFINE_EXPECT(CreateInstance
);
103 DEFINE_EXPECT(Start
);
104 DEFINE_EXPECT(Terminate
);
106 DEFINE_EXPECT(Read2
);
107 DEFINE_EXPECT(SetPriority
);
108 DEFINE_EXPECT(LockRequest
);
109 DEFINE_EXPECT(UnlockRequest
);
110 DEFINE_EXPECT(MimeFilter_CreateInstance
);
111 DEFINE_EXPECT(MimeFilter_Start
);
112 DEFINE_EXPECT(MimeFilter_ReportProgress
);
113 DEFINE_EXPECT(MimeFilter_ReportData
);
114 DEFINE_EXPECT(MimeFilter_ReportResult
);
115 DEFINE_EXPECT(MimeFilter_Terminate
);
116 DEFINE_EXPECT(MimeFilter_LockRequest
);
117 DEFINE_EXPECT(MimeFilter_UnlockRequest
);
118 DEFINE_EXPECT(MimeFilter_Read
);
119 DEFINE_EXPECT(MimeFilter_Switch
);
120 DEFINE_EXPECT(MimeFilter_Continue
);
122 static const WCHAR wszIndexHtml
[] = {'i','n','d','e','x','.','h','t','m','l',0};
123 static const WCHAR index_url
[] =
124 {'f','i','l','e',':','i','n','d','e','x','.','h','t','m','l',0};
126 static const WCHAR acc_mimeW
[] = {'*','/','*',0};
127 static const WCHAR user_agentW
[] = {'W','i','n','e',0};
128 static const WCHAR text_htmlW
[] = {'t','e','x','t','/','h','t','m','l',0};
129 static const WCHAR hostW
[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
130 static const WCHAR winehq_ipW
[] = {'2','0','9','.','4','6','.','2','5','.','1','3','4',0};
131 static const WCHAR emptyW
[] = {0};
132 static const WCHAR gzipW
[] = {'g','z','i','p',0};
134 static HRESULT expect_hrResult
;
135 static LPCWSTR file_name
, http_url
, expect_wsz
;
136 static IInternetProtocol
*async_protocol
= NULL
;
137 static BOOL first_data_notif
, http_is_first
, http_post_test
, test_redirect
;
138 static int state
= 0, prot_state
, read_report_data
;
139 static DWORD bindf
, ex_priority
, pi
;
140 static IInternetProtocol
*binding_protocol
, *filtered_protocol
;
141 static IInternetBindInfo
*prot_bind_info
;
142 static IInternetProtocolSink
*binding_sink
, *filtered_sink
;
143 static void *expect_pv
;
144 static HANDLE event_complete
, event_complete2
, event_continue
, event_continue_done
;
145 static BOOL binding_test
;
146 static PROTOCOLDATA protocoldata
, *pdata
, continue_protdata
;
147 static DWORD prot_read
, pi
, filter_state
;
148 static BOOL security_problem
;
149 static BOOL async_read_pending
, mimefilter_test
, direct_read
, wait_for_switch
, emulate_prot
, short_read
;
160 static const WCHAR protocol_names
[][10] = {
163 {'h','t','t','p','s',0},
169 static const WCHAR binding_urls
[][130] = {
170 {'f','i','l','e',':','t','e','s','t','.','h','t','m','l',0},
171 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
172 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0},
173 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
174 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0},
175 {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
176 '/','p','u','b','/','o','t','h','e','r',
177 '/','w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0},
178 {'m','k',':','t','e','s','t',0},
179 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0}
182 static const char *debugstr_guid(REFIID riid
)
186 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
187 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
188 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
189 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
194 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
197 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
198 return lstrcmpA(stra
, buf
);
201 /* lstrcmpW is not implemented on Win9x */
202 static int strcmp_ww(LPCWSTR strw1
, LPCWSTR strw2
)
204 CHAR stra1
[512], stra2
[512];
205 WideCharToMultiByte(CP_ACP
, 0, strw1
, -1, stra1
, MAX_PATH
, NULL
, NULL
);
206 WideCharToMultiByte(CP_ACP
, 0, strw2
, -1, stra2
, MAX_PATH
, NULL
, NULL
);
207 return lstrcmpA(stra1
, stra2
);
210 static HRESULT WINAPI
HttpSecurity_QueryInterface(IHttpSecurity
*iface
, REFIID riid
, void **ppv
)
212 if(IsEqualGUID(&IID_IUnknown
, riid
)
213 || IsEqualGUID(&IID_IHttpSecurity
, riid
)) {
218 ok(0, "unexpected call\n");
219 return E_NOINTERFACE
;
222 static ULONG WINAPI
HttpSecurity_AddRef(IHttpSecurity
*iface
)
227 static ULONG WINAPI
HttpSecurity_Release(IHttpSecurity
*iface
)
232 static HRESULT WINAPI
HttpSecurity_GetWindow(IHttpSecurity
* iface
, REFGUID rguidReason
, HWND
*phwnd
)
234 trace("HttpSecurity_GetWindow\n");
239 static HRESULT WINAPI
HttpSecurity_OnSecurityProblem(IHttpSecurity
*iface
, DWORD dwProblem
)
241 trace("Security problem: %u\n", dwProblem
);
242 ok(dwProblem
== ERROR_INTERNET_SEC_CERT_REV_FAILED
, "Expected ERROR_INTERNET_SEC_CERT_REV_FAILED got %u\n", dwProblem
);
244 /* Only retry once */
245 if (security_problem
)
248 security_problem
= TRUE
;
249 SET_EXPECT(BeginningTransaction
);
254 static IHttpSecurityVtbl HttpSecurityVtbl
= {
255 HttpSecurity_QueryInterface
,
257 HttpSecurity_Release
,
258 HttpSecurity_GetWindow
,
259 HttpSecurity_OnSecurityProblem
262 static IHttpSecurity http_security
= { &HttpSecurityVtbl
};
264 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate2
*iface
, REFIID riid
, void **ppv
)
266 if(IsEqualGUID(&IID_IUnknown
, riid
)
267 || IsEqualGUID(&IID_IHttpNegotiate
, riid
)
268 || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
273 ok(0, "unexpected call\n");
274 return E_NOINTERFACE
;
277 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate2
*iface
)
282 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate2
*iface
)
287 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate2
*iface
, LPCWSTR szURL
,
288 LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
292 static const WCHAR wszHeaders
[] =
293 {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ','a','p','p','l','i','c','a','t',
294 'i','o','n','/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o',
295 'd','e','d','\r','\n',0};
297 CHECK_EXPECT(BeginningTransaction
);
300 ok(!strcmp_ww(szURL
, binding_urls
[tested_protocol
]), "szURL != http_url\n");
302 ok(!strcmp_ww(szURL
, http_url
), "szURL != http_url\n");
303 ok(!dwReserved
, "dwReserved=%d, expected 0\n", dwReserved
);
304 ok(pszAdditionalHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
305 if(pszAdditionalHeaders
)
307 ok(*pszAdditionalHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
310 addl_headers
= CoTaskMemAlloc(sizeof(wszHeaders
));
313 http_post_test
= FALSE
;
314 skip("Out of memory\n");
315 return E_OUTOFMEMORY
;
317 memcpy(addl_headers
, wszHeaders
, sizeof(wszHeaders
));
318 *pszAdditionalHeaders
= addl_headers
;
325 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate2
*iface
, DWORD dwResponseCode
,
326 LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
, LPWSTR
*pszAdditionalRequestHeaders
)
328 CHECK_EXPECT(OnResponse
);
330 ok(dwResponseCode
== 200, "dwResponseCode=%d, expected 200\n", dwResponseCode
);
331 ok(szResponseHeaders
!= NULL
, "szResponseHeaders == NULL\n");
332 ok(szRequestHeaders
== NULL
, "szRequestHeaders != NULL\n");
333 ok(pszAdditionalRequestHeaders
== NULL
, "pszAdditionalHeaders != NULL\n");
338 static HRESULT WINAPI
HttpNegotiate_GetRootSecurityId(IHttpNegotiate2
*iface
,
339 BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
341 static const BYTE sec_id
[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
343 CHECK_EXPECT(GetRootSecurityId
);
345 ok(!dwReserved
, "dwReserved=%ld, expected 0\n", dwReserved
);
346 ok(pbSecurityId
!= NULL
, "pbSecurityId == NULL\n");
347 ok(pcbSecurityId
!= NULL
, "pcbSecurityId == NULL\n");
350 ok(*pcbSecurityId
== 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId
);
351 *pcbSecurityId
= sizeof(sec_id
);
355 memcpy(pbSecurityId
, sec_id
, sizeof(sec_id
));
360 static IHttpNegotiate2Vtbl HttpNegotiateVtbl
= {
361 HttpNegotiate_QueryInterface
,
362 HttpNegotiate_AddRef
,
363 HttpNegotiate_Release
,
364 HttpNegotiate_BeginningTransaction
,
365 HttpNegotiate_OnResponse
,
366 HttpNegotiate_GetRootSecurityId
369 static IHttpNegotiate2 http_negotiate
= { &HttpNegotiateVtbl
};
371 static HRESULT
QueryInterface(REFIID
,void**);
373 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
375 return QueryInterface(riid
, ppv
);
378 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
383 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
388 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
389 REFIID riid
, void **ppv
)
391 if(IsEqualGUID(&IID_IHttpNegotiate
, guidService
) || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
392 CHECK_EXPECT2(QueryService_HttpNegotiate
);
393 return IHttpNegotiate2_QueryInterface(&http_negotiate
, riid
, ppv
);
396 if(IsEqualGUID(&IID_IInternetProtocol
, guidService
)) {
397 ok(IsEqualGUID(&IID_IInternetProtocol
, riid
), "unexpected riid\n");
398 CHECK_EXPECT(QueryService_InternetProtocol
);
399 return E_NOINTERFACE
;
402 if(IsEqualGUID(&IID_IHttpSecurity
, guidService
)) {
403 ok(IsEqualGUID(&IID_IHttpSecurity
, riid
), "unexpected riid\n");
404 CHECK_EXPECT(QueryService_HttpSecurity
);
405 return IHttpSecurity_QueryInterface(&http_security
, riid
, ppv
);
408 ok(0, "unexpected service %s\n", debugstr_guid(guidService
));
412 static const IServiceProviderVtbl ServiceProviderVtbl
= {
413 ServiceProvider_QueryInterface
,
414 ServiceProvider_AddRef
,
415 ServiceProvider_Release
,
416 ServiceProvider_QueryService
419 static IServiceProvider service_provider
= { &ServiceProviderVtbl
};
421 static HRESULT WINAPI
ProtocolSink_QueryInterface(IInternetProtocolSink
*iface
, REFIID riid
, void **ppv
)
423 return QueryInterface(riid
, ppv
);
426 static ULONG WINAPI
ProtocolSink_AddRef(IInternetProtocolSink
*iface
)
431 static ULONG WINAPI
ProtocolSink_Release(IInternetProtocolSink
*iface
)
436 static void call_continue(PROTOCOLDATA
*protocol_data
)
441 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
)
442 CLEAR_CALLED(ReportProgress_COOKIE_SENT
);
443 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
|| tested_protocol
== FTP_TEST
) {
445 CLEAR_CALLED(ReportProgress_FINDINGRESOURCE
);
446 CLEAR_CALLED(ReportProgress_CONNECTING
);
447 CLEAR_CALLED(ReportProgress_PROXYDETECTING
);
448 }else if(test_redirect
) {
449 CHECK_CALLED(ReportProgress_FINDINGRESOURCE
);
451 CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE
);
452 /* IE7 does call this */
453 CLEAR_CALLED(ReportProgress_CONNECTING
);
456 if(tested_protocol
== FTP_TEST
)
457 todo_wine
CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
458 else if (tested_protocol
!= HTTPS_TEST
)
459 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
461 CHECK_CALLED(ReportProgress_REDIRECTING
);
462 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
463 SET_EXPECT(OnResponse
);
464 if(tested_protocol
== HTTPS_TEST
|| test_redirect
)
465 SET_EXPECT(ReportProgress_ACCEPTRANGES
);
466 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
467 if(bindf
& BINDF_NEEDFILE
)
468 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
472 SET_EXPECT(ReportData
);
473 hres
= IInternetProtocol_Continue(async_protocol
, protocol_data
);
474 ok(hres
== S_OK
, "Continue failed: %08x\n", hres
);
475 if(tested_protocol
== FTP_TEST
)
476 CLEAR_CALLED(ReportData
);
477 else if (! security_problem
)
478 CHECK_CALLED(ReportData
);
481 if (! security_problem
)
484 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
485 CHECK_CALLED(OnResponse
);
486 if(tested_protocol
== HTTPS_TEST
)
487 CHECK_CALLED(ReportProgress_ACCEPTRANGES
);
488 else if(test_redirect
)
489 CLEAR_CALLED(ReportProgress_ACCEPTRANGES
);
490 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
491 if(bindf
& BINDF_NEEDFILE
)
492 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
497 security_problem
= FALSE
;
498 SET_EXPECT(ReportProgress_CONNECTING
);
503 static HRESULT WINAPI
ProtocolSink_Switch(IInternetProtocolSink
*iface
, PROTOCOLDATA
*pProtocolData
)
505 if(tested_protocol
== FTP_TEST
)
506 CHECK_EXPECT2(Switch
);
508 CHECK_EXPECT(Switch
);
510 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
512 ok(pProtocolData
!= &protocoldata
, "pProtocolData == &protocoldata\n");
513 ok(pProtocolData
->grfFlags
== protocoldata
.grfFlags
, "grfFlags wrong %x/%x\n",
514 pProtocolData
->grfFlags
, protocoldata
.grfFlags
);
515 ok(pProtocolData
->dwState
== protocoldata
.dwState
, "dwState wrong %x/%x\n",
516 pProtocolData
->dwState
, protocoldata
.dwState
);
517 ok(pProtocolData
->pData
== protocoldata
.pData
, "pData wrong %p/%p\n",
518 pProtocolData
->pData
, protocoldata
.pData
);
519 ok(pProtocolData
->cbData
== protocoldata
.cbData
, "cbData wrong %x/%x\n",
520 pProtocolData
->cbData
, protocoldata
.cbData
);
523 pdata
= pProtocolData
;
526 SetEvent(event_complete
);
527 WaitForSingleObject(event_complete2
, INFINITE
);
530 continue_protdata
= *pProtocolData
;
531 SetEvent(event_continue
);
532 WaitForSingleObject(event_continue_done
, INFINITE
);
534 call_continue(pProtocolData
);
535 SetEvent(event_complete
);
541 static HRESULT WINAPI
ProtocolSink_ReportProgress(IInternetProtocolSink
*iface
, ULONG ulStatusCode
,
542 LPCWSTR szStatusText
)
544 static const WCHAR null_guid
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-',
545 '0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}',0};
546 static const WCHAR text_plain
[] = {'t','e','x','t','/','p','l','a','i','n',0};
548 switch(ulStatusCode
) {
549 case BINDSTATUS_MIMETYPEAVAILABLE
:
550 CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
551 if(tested_protocol
!= FILE_TEST
&& !mimefilter_test
&& (pi
& PI_MIMEVERIFICATION
)) {
552 if(!short_read
|| !direct_read
)
553 CHECK_CALLED(Read
); /* set in Continue */
555 CHECK_CALLED(Read2
); /* set in Read */
557 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
559 if(tested_protocol
== BIND_TEST
)
560 ok(szStatusText
== expect_wsz
, "unexpected szStatusText\n");
561 else if (http_post_test
)
562 ok(lstrlenW(text_plain
) <= lstrlenW(szStatusText
) &&
563 !memcmp(szStatusText
, text_plain
, lstrlenW(text_plain
)*sizeof(WCHAR
)),
564 "szStatusText != text/plain\n");
565 else if(!mimefilter_test
)
566 ok(lstrlenW(text_htmlW
) <= lstrlenW(szStatusText
) &&
567 !memcmp(szStatusText
, text_htmlW
, lstrlenW(text_htmlW
)*sizeof(WCHAR
)),
568 "szStatusText != text/html\n");
571 case BINDSTATUS_DIRECTBIND
:
572 CHECK_EXPECT2(ReportProgress_DIRECTBIND
);
573 ok(szStatusText
== NULL
, "szStatusText != NULL\n");
575 case BINDSTATUS_RAWMIMETYPE
:
576 CHECK_EXPECT2(ReportProgress_RAWMIMETYPE
);
577 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
579 ok(lstrlenW(szStatusText
) < lstrlenW(text_htmlW
) ||
580 !memcmp(szStatusText
, text_htmlW
, lstrlenW(text_htmlW
)*sizeof(WCHAR
)),
581 "szStatusText != text/html\n");
583 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
584 CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
585 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
588 ok(!strcmp_ww(szStatusText
, expect_wsz
), "unexpected szStatusText\n");
589 else if(tested_protocol
== FILE_TEST
)
590 ok(!strcmp_ww(szStatusText
, file_name
), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
592 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
595 case BINDSTATUS_FINDINGRESOURCE
:
596 CHECK_EXPECT2(ReportProgress_FINDINGRESOURCE
);
597 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
599 case BINDSTATUS_CONNECTING
:
600 CHECK_EXPECT2(ReportProgress_CONNECTING
);
601 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
603 case BINDSTATUS_SENDINGREQUEST
:
604 CHECK_EXPECT2(ReportProgress_SENDINGREQUEST
);
605 if(tested_protocol
== FILE_TEST
) {
606 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
608 ok(!*szStatusText
, "wrong szStatusText\n");
611 case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
:
612 CHECK_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
613 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
615 ok(!strcmp_ww(szStatusText
, text_htmlW
), "szStatusText != text/html\n");
617 case BINDSTATUS_PROTOCOLCLASSID
:
618 CHECK_EXPECT(ReportProgress_PROTOCOLCLASSID
);
619 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
620 ok(!strcmp_ww(szStatusText
, null_guid
), "unexpected classid %s\n", wine_dbgstr_w(szStatusText
));
622 case BINDSTATUS_COOKIE_SENT
:
623 CHECK_EXPECT(ReportProgress_COOKIE_SENT
);
624 ok(szStatusText
== NULL
, "szStatusText != NULL\n");
626 case BINDSTATUS_REDIRECTING
:
627 CHECK_EXPECT(ReportProgress_REDIRECTING
);
629 ok(!strcmp_wa(szStatusText
, "http://test.winehq.org/hello.html"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
631 ok(szStatusText
== NULL
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
633 case BINDSTATUS_ENCODING
:
634 CHECK_EXPECT(ReportProgress_ENCODING
);
635 ok(!strcmp_wa(szStatusText
, "gzip"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
637 case BINDSTATUS_ACCEPTRANGES
:
638 CHECK_EXPECT(ReportProgress_ACCEPTRANGES
);
639 ok(!szStatusText
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
641 case BINDSTATUS_PROXYDETECTING
:
642 CHECK_EXPECT(ReportProgress_PROXYDETECTING
);
643 SET_EXPECT(ReportProgress_CONNECTING
);
644 ok(!szStatusText
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
646 case BINDSTATUS_LOADINGMIMEHANDLER
:
647 CHECK_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
648 ok(!szStatusText
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
650 case BINDSTATUS_DECODING
:
651 CHECK_EXPECT(ReportProgress_DECODING
);
652 ok(!strcmp_ww(szStatusText
, gzipW
), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
655 ok(0, "Unexpected status %d\n", ulStatusCode
);
661 static HRESULT WINAPI
ProtocolSink_ReportData(IInternetProtocolSink
*iface
, DWORD grfBSCF
,
662 ULONG ulProgress
, ULONG ulProgressMax
)
666 static int rec_depth
;
669 if(!mimefilter_test
&& tested_protocol
== FILE_TEST
) {
670 CHECK_EXPECT2(ReportData
);
672 ok(ulProgress
== ulProgressMax
, "ulProgress (%d) != ulProgressMax (%d)\n",
673 ulProgress
, ulProgressMax
);
674 ok(ulProgressMax
== 13, "ulProgressMax=%d, expected 13\n", ulProgressMax
);
675 /* BSCF_SKIPDRAINDATAFORFILEURLS added in IE8 */
676 ok((grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
)) ||
677 (grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
| BSCF_SKIPDRAINDATAFORFILEURLS
)),
678 "grcfBSCF = %08x\n", grfBSCF
);
679 }else if(direct_read
) {
683 if(!read_report_data
&& rec_depth
== 1) {
684 BOOL reported_all_data
= called_ReportData2
;
686 CHECK_EXPECT2(ReportData
);
689 ok(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
|BSCF_LASTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
)
690 || grfBSCF
== BSCF_FIRSTDATANOTIFICATION
, /* < IE8 */
691 "grcfBSCF = %08x\n", grfBSCF
);
692 CHECK_CALLED(Read
); /* Set in Continue */
693 first_data_notif
= FALSE
;
694 }else if(first_data_notif
) {
695 ok(grfBSCF
== BSCF_FIRSTDATANOTIFICATION
, "grcfBSCF = %08x\n", grfBSCF
);
696 first_data_notif
= FALSE
;
697 }else if(reported_all_data
) {
698 ok(grfBSCF
== (BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
),
699 "grcfBSCF = %08x\n", grfBSCF
);
700 }else if(!direct_read
) {
701 ok(grfBSCF
== BSCF_INTERMEDIATEDATANOTIFICATION
, "grcfBSCF = %08x\n", grfBSCF
);
709 SET_EXPECT(ReportData2
);
710 SET_EXPECT(ReportResult
);
711 hres
= IInternetProtocol_Read(binding_test
? binding_protocol
: async_protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
713 ok(read
, "read == 0\n");
714 if(reported_all_data
) {
715 ok(hres
== S_FALSE
, "Read failed: %08x, expected S_FALSE\n", hres
);
719 if(!reported_all_data
&& called_ReportData2
) {
721 CHECK_CALLED(ReportData2
);
722 CHECK_CALLED(ReportResult
);
723 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
724 reported_all_data
= TRUE
;
727 CHECK_NOT_CALLED(ReportData2
);
728 CHECK_NOT_CALLED(ReportResult
);
730 }while(hres
== S_OK
);
732 wait_for_switch
= FALSE
;
734 CHECK_EXPECT(ReportData2
);
736 ok(grfBSCF
& BSCF_LASTDATANOTIFICATION
, "grfBSCF = %08x\n", grfBSCF
);
741 hres
= IInternetProtocol_Read(binding_test
? binding_protocol
: async_protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
744 ok(hres
== S_FALSE
, "Read returned: %08x, expected E_FALSE\n", hres
);
745 ok(!read
, "read = %d\n", read
);
747 }else if(!binding_test
&& (tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
748 || tested_protocol
== FTP_TEST
)) {
749 if(!(grfBSCF
& BSCF_LASTDATANOTIFICATION
) || (grfBSCF
& BSCF_DATAFULLYAVAILABLE
))
750 CHECK_EXPECT(ReportData
);
751 else if (http_post_test
)
752 ok(ulProgress
== 13, "Read %u bytes instead of 13\n", ulProgress
);
754 ok(ulProgress
, "ulProgress == 0\n");
756 if(first_data_notif
) {
757 ok(grfBSCF
== BSCF_FIRSTDATANOTIFICATION
758 || grfBSCF
== (BSCF_LASTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
),
759 "grcfBSCF = %08x\n", grfBSCF
);
760 first_data_notif
= FALSE
;
762 ok(grfBSCF
== BSCF_INTERMEDIATEDATANOTIFICATION
763 || grfBSCF
== (BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
)
764 || broken(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
|BSCF_LASTDATANOTIFICATION
)),
765 "grcfBSCF = %08x\n", grfBSCF
);
768 if(!(bindf
& BINDF_FROMURLMON
) &&
769 !(grfBSCF
& BSCF_LASTDATANOTIFICATION
)) {
773 CHECK_CALLED(ReportProgress_FINDINGRESOURCE
);
774 CHECK_CALLED(ReportProgress_CONNECTING
);
776 CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE
);
777 CHECK_NOT_CALLED(ReportProgress_CONNECTING
);
779 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
780 CHECK_CALLED(OnResponse
);
781 CHECK_CALLED(ReportProgress_RAWMIMETYPE
);
783 SetEvent(event_complete
);
785 }else if(!read_report_data
) {
790 CHECK_EXPECT(ReportData
);
792 if(tested_protocol
!= BIND_TEST
) {
795 SET_EXPECT(MimeFilter_Read
);
796 else if(rec_depth
> 1)
800 hres
= IInternetProtocol_Read(binding_protocol
, expect_pv
=buf
, sizeof(buf
), &read
);
802 CHECK_CALLED(MimeFilter_Read
);
803 else if(rec_depth
> 1)
807 }while(hres
== S_OK
);
815 static HRESULT WINAPI
ProtocolSink_ReportResult(IInternetProtocolSink
*iface
, HRESULT hrResult
,
816 DWORD dwError
, LPCWSTR szResult
)
818 CHECK_EXPECT(ReportResult
);
820 if(tested_protocol
== FTP_TEST
)
821 ok(hrResult
== E_PENDING
|| hrResult
== S_OK
, "hrResult = %08x, expected E_PENDING or S_OK\n", hrResult
);
823 ok(hrResult
== expect_hrResult
, "hrResult = %08x, expected: %08x\n",
824 hrResult
, expect_hrResult
);
825 if(SUCCEEDED(hrResult
) || tested_protocol
== FTP_TEST
)
826 ok(dwError
== ERROR_SUCCESS
, "dwError = %d, expected ERROR_SUCCESS\n", dwError
);
828 ok(dwError
!= ERROR_SUCCESS
||
829 broken(tested_protocol
== MK_TEST
), /* Win9x, WinME and NT4 */
830 "dwError == ERROR_SUCCESS\n");
831 ok(!szResult
, "szResult != NULL\n");
834 SET_EXPECT(ReportData
); /* checked after main loop */
839 static IInternetProtocolSinkVtbl protocol_sink_vtbl
= {
840 ProtocolSink_QueryInterface
,
842 ProtocolSink_Release
,
844 ProtocolSink_ReportProgress
,
845 ProtocolSink_ReportData
,
846 ProtocolSink_ReportResult
849 static IInternetProtocolSink protocol_sink
= { &protocol_sink_vtbl
};
851 static HRESULT WINAPI
MimeProtocolSink_QueryInterface(IInternetProtocolSink
*iface
, REFIID riid
, void **ppv
)
853 ok(0, "unexpected call\n");
857 static ULONG WINAPI
MimeProtocolSink_AddRef(IInternetProtocolSink
*iface
)
862 static ULONG WINAPI
MimeProtocolSink_Release(IInternetProtocolSink
*iface
)
867 static HRESULT WINAPI
MimeProtocolSink_Switch(IInternetProtocolSink
*iface
, PROTOCOLDATA
*pProtocolData
)
871 CHECK_EXPECT(MimeFilter_Switch
);
874 hres
= IInternetProtocolSink_Switch(filtered_sink
, pProtocolData
);
875 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
876 CHECK_CALLED(Switch
);
881 static HRESULT WINAPI
MimeProtocolSink_ReportProgress(IInternetProtocolSink
*iface
, ULONG ulStatusCode
,
882 LPCWSTR szStatusText
)
884 CHECK_EXPECT(MimeFilter_ReportProgress
);
888 static HRESULT WINAPI
MimeProtocolSink_ReportData(IInternetProtocolSink
*iface
, DWORD grfBSCF
,
889 ULONG ulProgress
, ULONG ulProgressMax
)
895 CHECK_EXPECT(MimeFilter_ReportData
);
899 hres
= IInternetProtocol_Read(filtered_protocol
, buf
, sizeof(buf
), &read
);
900 if(tested_protocol
== HTTP_TEST
)
901 ok(hres
== S_OK
|| hres
== E_PENDING
|| hres
== S_FALSE
, "Read failed: %08x\n", hres
);
903 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
906 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
907 hres
= IInternetProtocolSink_ReportProgress(filtered_sink
, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
, text_htmlW
);
908 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
909 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
911 /* FIXME: test BINDSTATUS_CACHEFILENAMEAVAILABLE */
914 if(!read_report_data
)
915 SET_EXPECT(ReportData
);
916 hres
= IInternetProtocolSink_ReportData(filtered_sink
, grfBSCF
, ulProgress
, ulProgressMax
);
917 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
918 if(!read_report_data
)
919 CHECK_CALLED(ReportData
);
927 static HRESULT WINAPI
MimeProtocolSink_ReportResult(IInternetProtocolSink
*iface
, HRESULT hrResult
,
928 DWORD dwError
, LPCWSTR szResult
)
932 CHECK_EXPECT(MimeFilter_ReportResult
);
934 ok(hrResult
== S_OK
, "hrResult = %08x\n", hrResult
);
935 ok(dwError
== ERROR_SUCCESS
, "dwError = %u\n", dwError
);
936 ok(!szResult
, "szResult = %s\n", wine_dbgstr_w(szResult
));
938 SET_EXPECT(ReportResult
);
939 hres
= IInternetProtocolSink_ReportResult(filtered_sink
, hrResult
, dwError
, szResult
);
940 ok(SUCCEEDED(hres
), "ReportResult failed: %08x\n", hres
);
941 CHECK_CALLED(ReportResult
);
946 static IInternetProtocolSinkVtbl mime_protocol_sink_vtbl
= {
947 MimeProtocolSink_QueryInterface
,
948 MimeProtocolSink_AddRef
,
949 MimeProtocolSink_Release
,
950 MimeProtocolSink_Switch
,
951 MimeProtocolSink_ReportProgress
,
952 MimeProtocolSink_ReportData
,
953 MimeProtocolSink_ReportResult
956 static IInternetProtocolSink mime_protocol_sink
= { &mime_protocol_sink_vtbl
};
958 static HRESULT
QueryInterface(REFIID riid
, void **ppv
)
960 static const IID IID_undocumented
= {0x58DFC7D0,0x5381,0x43E5,{0x9D,0x72,0x4C,0xDD,0xE4,0xCB,0x0F,0x1A}};
964 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocolSink
, riid
))
965 *ppv
= &protocol_sink
;
966 if(IsEqualGUID(&IID_IServiceProvider
, riid
))
967 *ppv
= &service_provider
;
968 if(IsEqualGUID(&IID_IUriContainer
, riid
))
969 return E_NOINTERFACE
; /* TODO */
971 /* NOTE: IE8 queries for undocumented {58DFC7D0-5381-43E5-9D72-4CDDE4CB0F1A} interface. */
972 if(IsEqualGUID(&IID_undocumented
, riid
))
973 return E_NOINTERFACE
;
978 ok(0, "unexpected call %s\n", debugstr_guid(riid
));
979 return E_NOINTERFACE
;
982 static HRESULT WINAPI
BindInfo_QueryInterface(IInternetBindInfo
*iface
, REFIID riid
, void **ppv
)
984 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
988 return E_NOINTERFACE
;
991 static ULONG WINAPI
BindInfo_AddRef(IInternetBindInfo
*iface
)
996 static ULONG WINAPI
BindInfo_Release(IInternetBindInfo
*iface
)
1001 static HRESULT WINAPI
BindInfo_GetBindInfo(IInternetBindInfo
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
1005 static const CHAR szPostData
[] = "mode=Test";
1007 CHECK_EXPECT(GetBindInfo
);
1009 ok(grfBINDF
!= NULL
, "grfBINDF == NULL\n");
1010 ok(pbindinfo
!= NULL
, "pbindinfo == NULL\n");
1011 ok(pbindinfo
->cbSize
== sizeof(BINDINFO
), "wrong size of pbindinfo: %d\n", pbindinfo
->cbSize
);
1015 *grfBINDF
|= BINDF_FROMURLMON
;
1016 cbSize
= pbindinfo
->cbSize
;
1017 memset(pbindinfo
, 0, cbSize
);
1018 pbindinfo
->cbSize
= cbSize
;
1022 /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly
1023 * with urlmon on native (Win98 and WinXP) */
1024 U(pbindinfo
->stgmedData
).hGlobal
= GlobalAlloc(GPTR
, sizeof(szPostData
));
1025 if (!U(pbindinfo
->stgmedData
).hGlobal
)
1027 http_post_test
= FALSE
;
1028 skip("Out of memory\n");
1029 return E_OUTOFMEMORY
;
1031 lstrcpy((LPSTR
)U(pbindinfo
->stgmedData
).hGlobal
, szPostData
);
1032 pbindinfo
->cbstgmedData
= sizeof(szPostData
)-1;
1033 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
1034 pbindinfo
->stgmedData
.tymed
= TYMED_HGLOBAL
;
1040 static HRESULT WINAPI
BindInfo_GetBindString(IInternetBindInfo
*iface
, ULONG ulStringType
,
1041 LPOLESTR
*ppwzStr
, ULONG cEl
, ULONG
*pcElFetched
)
1043 ok(ppwzStr
!= NULL
, "ppwzStr == NULL\n");
1044 ok(pcElFetched
!= NULL
, "pcElFetched == NULL\n");
1046 switch(ulStringType
) {
1047 case BINDSTRING_ACCEPT_MIMES
:
1048 CHECK_EXPECT(GetBindString_ACCEPT_MIMES
);
1049 ok(cEl
== 256, "cEl=%d, expected 256\n", cEl
);
1051 ok(*pcElFetched
== 256, "*pcElFetched=%d, expected 256\n", *pcElFetched
);
1055 *ppwzStr
= CoTaskMemAlloc(sizeof(acc_mimeW
));
1056 memcpy(*ppwzStr
, acc_mimeW
, sizeof(acc_mimeW
));
1059 case BINDSTRING_USER_AGENT
:
1060 CHECK_EXPECT(GetBindString_USER_AGENT
);
1061 ok(cEl
== 1, "cEl=%d, expected 1\n", cEl
);
1063 ok(*pcElFetched
== 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched
);
1067 *ppwzStr
= CoTaskMemAlloc(sizeof(user_agentW
));
1068 memcpy(*ppwzStr
, user_agentW
, sizeof(user_agentW
));
1071 case BINDSTRING_POST_COOKIE
:
1072 CHECK_EXPECT(GetBindString_POST_COOKIE
);
1073 ok(cEl
== 1, "cEl=%d, expected 1\n", cEl
);
1075 ok(*pcElFetched
== 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched
);
1077 case BINDSTRING_URL
: {
1080 CHECK_EXPECT(GetBindString_URL
);
1081 ok(cEl
== 1, "cEl=%d, expected 1\n", cEl
);
1082 ok(*pcElFetched
== 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched
);
1085 size
= (lstrlenW(binding_urls
[tested_protocol
])+1)*sizeof(WCHAR
);
1086 *ppwzStr
= CoTaskMemAlloc(size
);
1087 memcpy(*ppwzStr
, binding_urls
[tested_protocol
], size
);
1091 ok(0, "unexpected call\n");
1097 static IInternetBindInfoVtbl bind_info_vtbl
= {
1098 BindInfo_QueryInterface
,
1101 BindInfo_GetBindInfo
,
1102 BindInfo_GetBindString
1105 static IInternetBindInfo bind_info
= { &bind_info_vtbl
};
1107 static HRESULT WINAPI
InternetPriority_QueryInterface(IInternetPriority
*iface
,
1108 REFIID riid
, void **ppv
)
1110 ok(0, "unexpected call\n");
1111 return E_NOINTERFACE
;
1114 static ULONG WINAPI
InternetPriority_AddRef(IInternetPriority
*iface
)
1119 static ULONG WINAPI
InternetPriority_Release(IInternetPriority
*iface
)
1124 static HRESULT WINAPI
InternetPriority_SetPriority(IInternetPriority
*iface
, LONG nPriority
)
1126 CHECK_EXPECT(SetPriority
);
1127 ok(nPriority
== ex_priority
, "nPriority=%d\n", nPriority
);
1131 static HRESULT WINAPI
InternetPriority_GetPriority(IInternetPriority
*iface
, LONG
*pnPriority
)
1133 ok(0, "unexpected call\n");
1138 static const IInternetPriorityVtbl InternetPriorityVtbl
= {
1139 InternetPriority_QueryInterface
,
1140 InternetPriority_AddRef
,
1141 InternetPriority_Release
,
1142 InternetPriority_SetPriority
,
1143 InternetPriority_GetPriority
1146 static IInternetPriority InternetPriority
= { &InternetPriorityVtbl
};
1148 static ULONG WINAPI
Protocol_AddRef(IInternetProtocol
*iface
)
1153 static ULONG WINAPI
Protocol_Release(IInternetProtocol
*iface
)
1158 static HRESULT WINAPI
Protocol_Abort(IInternetProtocol
*iface
, HRESULT hrReason
,
1161 ok(0, "unexpected call\n");
1165 static HRESULT WINAPI
Protocol_Suspend(IInternetProtocol
*iface
)
1167 ok(0, "unexpected call\n");
1171 static HRESULT WINAPI
Protocol_Resume(IInternetProtocol
*iface
)
1173 ok(0, "unexpected call\n");
1177 static HRESULT WINAPI
Protocol_Seek(IInternetProtocol
*iface
,
1178 LARGE_INTEGER dlibMove
, DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
1180 ok(0, "unexpected call\n");
1184 static HRESULT WINAPI
ProtocolEmul_QueryInterface(IInternetProtocol
*iface
, REFIID riid
, void **ppv
)
1186 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
1191 if(IsEqualGUID(&IID_IInternetProtocolEx
, riid
)) {
1192 trace("IID_IInternetProtocolEx not supported\n");
1194 return E_NOINTERFACE
;
1197 if(IsEqualGUID(&IID_IInternetPriority
, riid
)) {
1198 *ppv
= &InternetPriority
;
1202 if(IsEqualGUID(&IID_IWinInetInfo
, riid
)) {
1203 CHECK_EXPECT(QueryInterface_IWinInetInfo
);
1205 return E_NOINTERFACE
;
1208 if(IsEqualGUID(&IID_IWinInetHttpInfo
, riid
)) {
1209 CHECK_EXPECT(QueryInterface_IWinInetHttpInfo
);
1211 return E_NOINTERFACE
;
1214 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1216 return E_NOINTERFACE
;
1219 static DWORD WINAPI
thread_proc(PVOID arg
)
1223 memset(&protocoldata
, -1, sizeof(protocoldata
));
1227 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
1228 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1229 BINDSTATUS_FINDINGRESOURCE
, hostW
);
1230 CHECK_CALLED(ReportProgress_FINDINGRESOURCE
);
1231 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
1233 SET_EXPECT(ReportProgress_CONNECTING
);
1234 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1235 BINDSTATUS_CONNECTING
, winehq_ipW
);
1236 CHECK_CALLED(ReportProgress_CONNECTING
);
1237 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
1239 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1240 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1241 BINDSTATUS_SENDINGREQUEST
, NULL
);
1242 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
1243 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
1247 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
1248 CHECK_CALLED(Switch
);
1249 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1254 SET_EXPECT(MimeFilter_Switch
);
1257 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
1258 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1260 CHECK_CALLED(MimeFilter_Switch
);
1262 CHECK_CALLED(Switch
);
1266 SET_EXPECT(MimeFilter_Switch
);
1269 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
1270 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1272 CHECK_CALLED(MimeFilter_Switch
);
1274 CHECK_CALLED(Switch
);
1278 SET_EXPECT(MimeFilter_Switch
);
1281 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
1282 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1284 CHECK_CALLED(MimeFilter_Switch
);
1286 CHECK_CALLED(Switch
);
1289 SetEvent(event_complete
);
1294 static HRESULT WINAPI
ProtocolEmul_Start(IInternetProtocol
*iface
, LPCWSTR szUrl
,
1295 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
1296 DWORD grfPI
, HANDLE_PTR dwReserved
)
1298 BINDINFO bindinfo
, exp_bindinfo
;
1302 CHECK_EXPECT(Start
);
1304 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
1305 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
1306 ok(pOIProtSink
!= &protocol_sink
, "unexpected pOIProtSink\n");
1307 ok(pOIBindInfo
!= &bind_info
, "unexpected pOIBindInfo\n");
1308 ok(!grfPI
, "grfPI = %x\n", grfPI
);
1309 ok(!dwReserved
, "dwReserved = %lx\n", dwReserved
);
1312 ok(pOIProtSink
== binding_sink
, "pOIProtSink != binding_sink\n");
1314 memset(&bindinfo
, 0, sizeof(bindinfo
));
1315 bindinfo
.cbSize
= sizeof(bindinfo
);
1316 memcpy(&exp_bindinfo
, &bindinfo
, sizeof(bindinfo
));
1317 SET_EXPECT(GetBindInfo
);
1318 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &cbindf
, &bindinfo
);
1319 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
1320 CHECK_CALLED(GetBindInfo
);
1321 ok(cbindf
== (bindf
|BINDF_FROMURLMON
), "bindf = %x, expected %x\n",
1322 cbindf
, (bindf
|BINDF_FROMURLMON
));
1323 ok(!memcmp(&exp_bindinfo
, &bindinfo
, sizeof(bindinfo
)), "unexpected bindinfo\n");
1324 pReleaseBindInfo(&bindinfo
);
1326 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1327 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_SENDINGREQUEST
, emptyW
);
1328 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
1329 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
1331 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
1332 IServiceProvider
*service_provider
;
1333 IHttpNegotiate
*http_negotiate
;
1334 IHttpNegotiate2
*http_negotiate2
;
1335 LPWSTR ua
= (LPWSTR
)0xdeadbeef, accept_mimes
[256];
1336 LPWSTR additional_headers
= NULL
;
1338 DWORD fetched
= 0, size
= 100;
1341 SET_EXPECT(GetBindString_USER_AGENT
);
1342 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_USER_AGENT
,
1344 CHECK_CALLED(GetBindString_USER_AGENT
);
1345 ok(hres
== S_OK
, "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres
);
1346 ok(fetched
== 1, "fetched = %d, expected 254\n", fetched
);
1347 ok(ua
!= NULL
, "ua = %p\n", ua
);
1348 ok(!strcmp_ww(ua
, user_agentW
), "unexpected user agent %s\n", wine_dbgstr_w(ua
));
1352 SET_EXPECT(GetBindString_ACCEPT_MIMES
);
1353 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
1354 accept_mimes
, 256, &fetched
);
1355 CHECK_CALLED(GetBindString_ACCEPT_MIMES
);
1358 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
1359 ok(fetched
== 1, "fetched = %d, expected 1\n", fetched
);
1360 ok(!strcmp_ww(acc_mimeW
, accept_mimes
[0]), "unexpected mimes %s\n", wine_dbgstr_w(accept_mimes
[0]));
1361 CoTaskMemFree(accept_mimes
[0]);
1363 hres
= IInternetBindInfo_QueryInterface(pOIBindInfo
, &IID_IServiceProvider
,
1364 (void**)&service_provider
);
1365 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
1367 SET_EXPECT(QueryService_HttpNegotiate
);
1368 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
1369 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
1370 CHECK_CALLED(QueryService_HttpNegotiate
);
1371 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1373 SET_EXPECT(BeginningTransaction
);
1374 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, binding_urls
[tested_protocol
],
1375 NULL
, 0, &additional_headers
);
1376 CHECK_CALLED(BeginningTransaction
);
1377 IHttpNegotiate_Release(http_negotiate
);
1378 ok(hres
== S_OK
, "BeginningTransction failed: %08x\n", hres
);
1379 ok(additional_headers
== NULL
, "additional_headers=%p\n", additional_headers
);
1381 SET_EXPECT(QueryService_HttpNegotiate
);
1382 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate2
,
1383 &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
1384 CHECK_CALLED(QueryService_HttpNegotiate
);
1385 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1388 SET_EXPECT(GetRootSecurityId
);
1389 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, sec_id
, &size
, 0);
1390 CHECK_CALLED(GetRootSecurityId
);
1391 IHttpNegotiate2_Release(http_negotiate2
);
1392 ok(hres
== E_FAIL
, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres
);
1393 ok(size
== 13, "size=%d\n", size
);
1395 IServiceProvider_Release(service_provider
);
1397 CreateThread(NULL
, 0, thread_proc
, NULL
, 0, &tid
);
1402 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
1403 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
1404 BINDSTATUS_CACHEFILENAMEAVAILABLE
, expect_wsz
= emptyW
);
1405 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
1406 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
1408 if(mimefilter_test
) {
1409 SET_EXPECT(MimeFilter_CreateInstance
);
1410 SET_EXPECT(MimeFilter_Start
);
1411 SET_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
1413 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1414 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
,
1415 mimefilter_test
? gzipW
: (expect_wsz
= text_htmlW
));
1417 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres
);
1418 if(mimefilter_test
) {
1419 CHECK_CALLED(MimeFilter_CreateInstance
);
1420 CHECK_CALLED(MimeFilter_Start
);
1421 CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER
);
1422 todo_wine
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1424 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1428 SET_EXPECT(MimeFilter_ReportData
);
1430 SET_EXPECT(ReportData
);
1431 hres
= IInternetProtocolSink_ReportData(pOIProtSink
,
1432 BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
, 13, 13);
1433 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1435 CHECK_CALLED(MimeFilter_ReportData
);
1437 CHECK_CALLED(ReportData
);
1439 if(tested_protocol
== BIND_TEST
) {
1440 hres
= IInternetProtocol_Terminate(binding_protocol
, 0);
1441 ok(hres
== E_FAIL
, "Termiante failed: %08x\n", hres
);
1445 SET_EXPECT(MimeFilter_ReportResult
);
1447 SET_EXPECT(ReportResult
);
1448 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, S_OK
, 0, NULL
);
1449 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1451 CHECK_CALLED(MimeFilter_ReportResult
);
1453 CHECK_CALLED(ReportResult
);
1458 static HRESULT WINAPI
ProtocolEmul_Continue(IInternetProtocol
*iface
,
1459 PROTOCOLDATA
*pProtocolData
)
1464 CHECK_EXPECT(Continue
);
1466 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
1467 if(!pProtocolData
|| tested_protocol
== BIND_TEST
)
1470 ok(pProtocolData
!= &protocoldata
, "pProtocolData == &protocoldata\n");
1471 ok(pProtocolData
->grfFlags
== protocoldata
.grfFlags
, "grfFlags wrong %x/%x\n",
1472 pProtocolData
->grfFlags
, protocoldata
.grfFlags
);
1473 ok(pProtocolData
->dwState
== protocoldata
.dwState
, "dwState wrong %x/%x\n",
1474 pProtocolData
->dwState
, protocoldata
.dwState
);
1475 ok(pProtocolData
->pData
== protocoldata
.pData
, "pData wrong %p/%p\n",
1476 pProtocolData
->pData
, protocoldata
.pData
);
1477 ok(pProtocolData
->cbData
== protocoldata
.cbData
, "cbData wrong %x/%x\n",
1478 pProtocolData
->cbData
, protocoldata
.cbData
);
1481 switch(prot_state
) {
1483 IServiceProvider
*service_provider
;
1484 IHttpNegotiate
*http_negotiate
;
1485 static WCHAR header
[] = {'?',0};
1487 hres
= IInternetProtocolSink_QueryInterface(binding_sink
, &IID_IServiceProvider
,
1488 (void**)&service_provider
);
1489 ok(hres
== S_OK
, "Could not get IServiceProvicder\n");
1491 SET_EXPECT(QueryService_HttpNegotiate
);
1492 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
1493 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
1494 IServiceProvider_Release(service_provider
);
1495 CHECK_CALLED(QueryService_HttpNegotiate
);
1496 ok(hres
== S_OK
, "Could not get IHttpNegotiate\n");
1498 SET_EXPECT(OnResponse
);
1499 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, header
, NULL
, NULL
);
1500 IHttpNegotiate_Release(http_negotiate
);
1501 CHECK_CALLED(OnResponse
);
1502 IHttpNegotiate_Release(http_negotiate
);
1503 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
1505 if(mimefilter_test
) {
1506 SET_EXPECT(MimeFilter_CreateInstance
);
1507 SET_EXPECT(MimeFilter_Start
);
1508 SET_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
1509 }else if(!(pi
& PI_MIMEVERIFICATION
)) {
1510 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1512 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1513 BINDSTATUS_MIMETYPEAVAILABLE
, mimefilter_test
? gzipW
: text_htmlW
);
1514 if(mimefilter_test
) {
1515 CHECK_CALLED(MimeFilter_CreateInstance
);
1516 CHECK_CALLED(MimeFilter_Start
);
1517 CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER
);
1518 }else if(!(pi
& PI_MIMEVERIFICATION
)) {
1519 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1522 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
1524 bscf
|= BSCF_FIRSTDATANOTIFICATION
;
1529 bscf
= BSCF_INTERMEDIATEDATANOTIFICATION
;
1534 if(mimefilter_test
) {
1535 SET_EXPECT(MimeFilter_ReportData
);
1536 }else if(pi
& PI_MIMEVERIFICATION
) {
1538 SET_EXPECT(Read
); /* checked in ReportData for short_read */
1540 if(!mimefilter_test
)
1541 SET_EXPECT(Read
); /* checked in BINDSTATUS_MIMETYPEAVAILABLE or ReportData */
1542 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1545 SET_EXPECT(ReportData
);
1547 SET_EXPECT(ReportData
);
1550 hres
= IInternetProtocolSink_ReportData(binding_sink
, bscf
, pr
, 400);
1551 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1553 if(mimefilter_test
) {
1554 SET_EXPECT(MimeFilter_ReportData
);
1555 }else if(pi
& PI_MIMEVERIFICATION
) {
1556 if(!short_read
&& pr
< 200)
1559 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1562 CHECK_CALLED(ReportData
);
1571 static HRESULT WINAPI
ProtocolEmul_Terminate(IInternetProtocol
*iface
, DWORD dwOptions
)
1573 CHECK_EXPECT(Terminate
);
1574 ok(!dwOptions
, "dwOptions=%d\n", dwOptions
);
1578 static HRESULT WINAPI
ProtocolEmul_Read(IInternetProtocol
*iface
, void *pv
,
1579 ULONG cb
, ULONG
*pcbRead
)
1581 if(read_report_data
)
1582 CHECK_EXPECT2(Read2
);
1584 if(mimefilter_test
|| short_read
) {
1585 if(!read_report_data
)
1586 CHECK_EXPECT2(Read
);
1587 }else if((pi
& PI_MIMEVERIFICATION
)) {
1588 if(!read_report_data
)
1589 CHECK_EXPECT2(Read
);
1591 if(prot_read
< 300) {
1592 ok(pv
!= expect_pv
, "pv == expect_pv\n");
1594 ok(cb
== 2048-prot_read
, "cb=%d\n", cb
);
1596 ok(cb
== 700, "cb=%d\n", cb
);
1598 ok(expect_pv
<= pv
&& (BYTE
*)pv
< (BYTE
*)expect_pv
+ cb
, "pv != expect_pv\n");
1601 if(!read_report_data
)
1604 ok(pv
== expect_pv
, "pv != expect_pv\n");
1605 ok(cb
== 1000, "cb=%d\n", cb
);
1606 ok(!*pcbRead
, "*pcbRead = %d\n", *pcbRead
);
1608 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
1610 if(prot_state
== 3 || (short_read
&& prot_state
!= 4)) {
1615 SET_EXPECT(Read2
); /* checked in BINDSTATUS_MIMETYPEAVAILABLE */
1616 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1619 SET_EXPECT(MimeFilter_ReportData
);
1620 else if(direct_read
)
1621 SET_EXPECT(ReportData2
);
1623 hres
= IInternetProtocolSink_ReportData(binding_sink
,
1624 BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
, 0, 0);
1626 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1628 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1630 CHECK_CALLED(MimeFilter_ReportData
);
1631 else if(direct_read
)
1632 CHECK_CALLED(ReportData2
);
1635 SET_EXPECT(MimeFilter_ReportResult
);
1637 SET_EXPECT(ReportResult
);
1638 hres
= IInternetProtocolSink_ReportResult(binding_sink
, S_OK
, ERROR_SUCCESS
, NULL
);
1639 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1641 CHECK_CALLED(MimeFilter_ReportResult
);
1643 CHECK_CALLED(ReportResult
);
1645 memset(pv
, 'x', 100);
1646 prot_read
+= *pcbRead
= 100;
1648 }if(prot_state
== 4) {
1653 if((async_read_pending
= !async_read_pending
)) {
1655 return tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
? E_PENDING
: S_FALSE
;
1658 memset(pv
, 'x', 100);
1659 prot_read
+= *pcbRead
= 100;
1663 static HRESULT WINAPI
ProtocolEmul_LockRequest(IInternetProtocol
*iface
, DWORD dwOptions
)
1665 CHECK_EXPECT(LockRequest
);
1666 ok(dwOptions
== 0, "dwOptions=%x\n", dwOptions
);
1670 static HRESULT WINAPI
ProtocolEmul_UnlockRequest(IInternetProtocol
*iface
)
1672 CHECK_EXPECT(UnlockRequest
);
1676 static const IInternetProtocolVtbl ProtocolVtbl
= {
1677 ProtocolEmul_QueryInterface
,
1681 ProtocolEmul_Continue
,
1683 ProtocolEmul_Terminate
,
1688 ProtocolEmul_LockRequest
,
1689 ProtocolEmul_UnlockRequest
1692 static IInternetProtocol Protocol
= { &ProtocolVtbl
};
1694 static HRESULT WINAPI
MimeProtocol_QueryInterface(IInternetProtocol
*iface
, REFIID riid
, void **ppv
)
1696 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
1701 if(IsEqualGUID(&IID_IInternetProtocolSink
, riid
)) {
1702 *ppv
= &mime_protocol_sink
;
1706 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1708 return E_NOINTERFACE
;
1711 static HRESULT WINAPI
MimeProtocol_Start(IInternetProtocol
*iface
, LPCWSTR szUrl
,
1712 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
1713 DWORD grfPI
, HANDLE_PTR dwReserved
)
1715 PROTOCOLFILTERDATA
*data
;
1716 LPOLESTR url_str
= NULL
;
1722 CHECK_EXPECT(MimeFilter_Start
);
1724 ok(!strcmp_ww(szUrl
, gzipW
), "wrong url %s\n", wine_dbgstr_w(szUrl
));
1725 ok(grfPI
== (PI_FILTER_MODE
|PI_FORCE_ASYNC
), "grfPI=%x, expected PI_FILTER_MODE|PI_FORCE_ASYNC\n", grfPI
);
1726 ok(dwReserved
, "dwReserved == 0\n");
1727 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
1728 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
1731 ok(pOIProtSink
!= binding_sink
, "pOIProtSink == protocol_sink\n");
1732 ok(pOIBindInfo
== prot_bind_info
, "pOIBindInfo != bind_info\n");
1734 ok(pOIProtSink
== &protocol_sink
, "pOIProtSink != protocol_sink\n");
1735 ok(pOIBindInfo
== &bind_info
, "pOIBindInfo != bind_info\n");
1738 data
= (void*)dwReserved
;
1739 ok(data
->cbSize
== sizeof(*data
), "data->cbSize = %d\n", data
->cbSize
);
1740 ok(!data
->pProtocolSink
, "data->pProtocolSink != NULL\n");
1741 ok(data
->pProtocol
!= NULL
, "data->pProtocol == NULL\n");
1742 ok(!data
->pUnk
, "data->pUnk != NULL\n");
1743 ok(!data
->dwFilterFlags
, "data->dwProtocolFlags = %x\n", data
->dwFilterFlags
);
1745 IInternetProtocolSink
*prot_sink
;
1747 IInternetProtocol_QueryInterface(data
->pProtocol
, &IID_IInternetProtocolSink
, (void**)&prot_sink
);
1748 ok(prot_sink
== pOIProtSink
, "QI(data->pProtocol, IID_IInternetProtocolSink) != pOIProtSink\n");
1749 IInternetProtocolSink_Release(prot_sink
);
1751 ok(data
->pProtocol
!= binding_protocol
, "data->pProtocol == binding_protocol\n");
1753 filtered_protocol
= data
->pProtocol
;
1754 IInternetProtocol_AddRef(filtered_protocol
);
1756 IInternetProtocol
*prot
;
1758 IInternetProtocol_QueryInterface(data
->pProtocol
, &IID_IInternetProtocol
, (void**)&prot
);
1759 ok(prot
== async_protocol
, "QI(data->pProtocol, IID_IInternetProtocol) != async_protocol\n");
1760 IInternetProtocol_Release(prot
);
1762 ok(data
->pProtocol
!= async_protocol
, "data->pProtocol == async_protocol\n");
1765 filtered_sink
= pOIProtSink
;
1767 SET_EXPECT(ReportProgress_DECODING
);
1768 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_DECODING
, gzipW
);
1769 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_DECODING) failed: %08x\n", hres
);
1770 CHECK_CALLED(ReportProgress_DECODING
);
1772 SET_EXPECT(GetBindInfo
);
1773 memset(&bindinfo
, 0, sizeof(bindinfo
));
1774 bindinfo
.cbSize
= sizeof(bindinfo
);
1775 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &cbindf
, &bindinfo
);
1776 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
1777 ok(cbindf
== (bindf
|BINDF_FROMURLMON
), "cbindf = %x, expected %x\n", cbindf
, bindf
);
1778 CHECK_CALLED(GetBindInfo
);
1780 SET_EXPECT(GetBindString_URL
);
1781 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_URL
, &url_str
, 1, &fetched
);
1782 ok(hres
== S_OK
, "GetBindString(BINDSTRING_URL) failed: %08x\n", hres
);
1783 ok(fetched
== 1, "fetched = %d\n", fetched
);
1784 ok(!strcmp_ww(url_str
, binding_urls
[tested_protocol
]), "wrong url_str %s\n", wine_dbgstr_w(url_str
));
1785 CoTaskMemFree(url_str
);
1786 CHECK_CALLED(GetBindString_URL
);
1791 static HRESULT WINAPI
Protocol_Continue(IInternetProtocol
*iface
,
1792 PROTOCOLDATA
*pProtocolData
)
1794 CHECK_EXPECT(MimeFilter_Continue
);
1798 static HRESULT WINAPI
MimeProtocol_Terminate(IInternetProtocol
*iface
, DWORD dwOptions
)
1802 CHECK_EXPECT(MimeFilter_Terminate
);
1804 ok(!dwOptions
, "dwOptions = %x\n", dwOptions
);
1806 SET_EXPECT(Terminate
);
1807 hres
= IInternetProtocol_Terminate(filtered_protocol
, dwOptions
);
1808 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
1809 CHECK_CALLED(Terminate
);
1814 static HRESULT WINAPI
MimeProtocol_Read(IInternetProtocol
*iface
, void *pv
,
1815 ULONG cb
, ULONG
*pcbRead
)
1821 CHECK_EXPECT(MimeFilter_Read
);
1823 ok(pv
!= NULL
, "pv == NULL\n");
1824 ok(cb
!= 0, "cb == 0\n");
1825 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
1827 if(read_report_data
)
1831 hres
= IInternetProtocol_Read(filtered_protocol
, buf
, sizeof(buf
), &read
);
1832 ok(hres
== S_OK
|| hres
== S_FALSE
|| hres
== E_PENDING
, "Read failed: %08x\n", hres
);
1833 if(read_report_data
)
1834 CHECK_CALLED(Read2
);
1839 ok(*pcbRead
== 0, "*pcbRead=%d, expected 0\n", *pcbRead
);
1843 memset(pv
, 'x', read
);
1847 static HRESULT WINAPI
MimeProtocol_LockRequest(IInternetProtocol
*iface
, DWORD dwOptions
)
1851 CHECK_EXPECT(MimeFilter_LockRequest
);
1853 ok(!dwOptions
, "dwOptions = %x\n", dwOptions
);
1855 SET_EXPECT(LockRequest
);
1856 hres
= IInternetProtocol_LockRequest(filtered_protocol
, dwOptions
);
1857 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
1858 CHECK_CALLED(LockRequest
);
1863 static HRESULT WINAPI
MimeProtocol_UnlockRequest(IInternetProtocol
*iface
)
1867 CHECK_EXPECT(MimeFilter_UnlockRequest
);
1869 SET_EXPECT(UnlockRequest
);
1870 hres
= IInternetProtocol_UnlockRequest(filtered_protocol
);
1871 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
1872 CHECK_CALLED(UnlockRequest
);
1877 static const IInternetProtocolVtbl MimeProtocolVtbl
= {
1878 MimeProtocol_QueryInterface
,
1884 MimeProtocol_Terminate
,
1889 MimeProtocol_LockRequest
,
1890 MimeProtocol_UnlockRequest
1893 static IInternetProtocol MimeProtocol
= { &MimeProtocolVtbl
};
1895 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1897 ok(0, "unexpected call\n");
1898 return E_NOINTERFACE
;
1901 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1906 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1911 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
1912 REFIID riid
, void **ppv
)
1914 CHECK_EXPECT(CreateInstance
);
1916 ok(pOuter
== (IUnknown
*)prot_bind_info
, "pOuter != protocol_unk\n");
1917 ok(IsEqualGUID(&IID_IUnknown
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
1918 ok(ppv
!= NULL
, "ppv == NULL\n");
1924 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
1926 ok(0, "unexpected call\n");
1930 static const IClassFactoryVtbl ClassFactoryVtbl
= {
1931 ClassFactory_QueryInterface
,
1932 ClassFactory_AddRef
,
1933 ClassFactory_Release
,
1934 ClassFactory_CreateInstance
,
1935 ClassFactory_LockServer
1938 static IClassFactory ClassFactory
= { &ClassFactoryVtbl
};
1940 static HRESULT WINAPI
MimeFilter_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
1942 CHECK_EXPECT(MimeFilter_CreateInstance
);
1944 ok(!outer
, "outer = %p\n", outer
);
1945 ok(IsEqualGUID(&IID_IInternetProtocol
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
1947 *ppv
= &MimeProtocol
;
1951 static const IClassFactoryVtbl MimeFilterCFVtbl
= {
1952 ClassFactory_QueryInterface
,
1953 ClassFactory_AddRef
,
1954 ClassFactory_Release
,
1955 MimeFilter_CreateInstance
,
1956 ClassFactory_LockServer
1959 static IClassFactory mimefilter_cf
= { &MimeFilterCFVtbl
};
1961 #define TEST_BINDING 0x01
1962 #define TEST_FILTER 0x02
1963 #define TEST_FIRST_HTTP 0x04
1964 #define TEST_DIRECT_READ 0x08
1965 #define TEST_POST 0x10
1966 #define TEST_EMULATEPROT 0x20
1967 #define TEST_SHORT_READ 0x40
1968 #define TEST_REDIRECT 0x80
1970 static void init_test(int prot
, DWORD flags
)
1972 tested_protocol
= prot
;
1973 binding_test
= (flags
& TEST_BINDING
) != 0;
1974 first_data_notif
= TRUE
;
1977 async_read_pending
= TRUE
;
1978 mimefilter_test
= (flags
& TEST_FILTER
) != 0;
1980 ResetEvent(event_complete
);
1981 ResetEvent(event_complete2
);
1982 ResetEvent(event_continue
);
1983 ResetEvent(event_continue_done
);
1984 async_protocol
= binding_protocol
= filtered_protocol
= NULL
;
1985 filtered_sink
= NULL
;
1986 http_is_first
= (flags
& TEST_FIRST_HTTP
) != 0;
1987 first_data_notif
= TRUE
;
1989 direct_read
= (flags
& TEST_DIRECT_READ
) != 0;
1990 http_post_test
= (flags
& TEST_POST
) != 0;
1991 emulate_prot
= (flags
& TEST_EMULATEPROT
) != 0;
1992 wait_for_switch
= TRUE
;
1993 short_read
= (flags
& TEST_SHORT_READ
) != 0;
1994 test_redirect
= (flags
& TEST_REDIRECT
) != 0;
1997 static void test_priority(IInternetProtocol
*protocol
)
1999 IInternetPriority
*priority
;
2003 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetPriority
,
2005 ok(hres
== S_OK
, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres
);
2009 hres
= IInternetPriority_GetPriority(priority
, &pr
);
2010 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2011 ok(pr
== 0, "pr=%d, expected 0\n", pr
);
2013 hres
= IInternetPriority_SetPriority(priority
, 1);
2014 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
2016 hres
= IInternetPriority_GetPriority(priority
, &pr
);
2017 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2018 ok(pr
== 1, "pr=%d, expected 1\n", pr
);
2020 IInternetPriority_Release(priority
);
2023 static BOOL
file_protocol_start(IInternetProtocol
*protocol
, LPCWSTR url
, BOOL is_first
)
2027 SET_EXPECT(GetBindInfo
);
2028 if(!(bindf
& BINDF_FROMURLMON
))
2029 SET_EXPECT(ReportProgress_DIRECTBIND
);
2031 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2032 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
2033 if(bindf
& BINDF_FROMURLMON
)
2034 SET_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
2036 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
2038 SET_EXPECT(ReportData
);
2040 SET_EXPECT(ReportResult
);
2042 expect_hrResult
= S_OK
;
2044 hres
= IInternetProtocol_Start(protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
2045 if(hres
== INET_E_RESOURCE_NOT_FOUND
) {
2046 win_skip("Start failed\n");
2049 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2051 CHECK_CALLED(GetBindInfo
);
2052 if(!(bindf
& BINDF_FROMURLMON
))
2053 CHECK_CALLED(ReportProgress_DIRECTBIND
);
2055 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
2056 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
2057 if(bindf
& BINDF_FROMURLMON
)
2058 CHECK_CALLED(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
2060 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
2062 CHECK_CALLED(ReportData
);
2064 CHECK_CALLED(ReportResult
);
2069 static void test_file_protocol_url(LPCWSTR url
)
2071 IInternetProtocolInfo
*protocol_info
;
2073 IClassFactory
*factory
;
2076 hres
= CoGetClassObject(&CLSID_FileProtocol
, CLSCTX_INPROC_SERVER
, NULL
,
2077 &IID_IUnknown
, (void**)&unk
);
2078 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
2082 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
2083 ok(hres
== E_NOINTERFACE
,
2084 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
2086 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
2087 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
2088 if(SUCCEEDED(hres
)) {
2089 IInternetProtocol
*protocol
;
2092 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
2093 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2095 if(SUCCEEDED(hres
)) {
2096 if(file_protocol_start(protocol
, url
, TRUE
)) {
2097 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2098 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2099 ok(cb
== 2, "cb=%u expected 2\n", cb
);
2100 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
2101 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2102 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
2103 ok(hres
== S_FALSE
, "Read failed: %08x expected S_FALSE\n", hres
);
2104 ok(cb
== 0, "cb=%u expected 0\n", cb
);
2105 hres
= IInternetProtocol_UnlockRequest(protocol
);
2106 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2109 if(file_protocol_start(protocol
, url
, FALSE
)) {
2110 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2111 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2112 hres
= IInternetProtocol_LockRequest(protocol
, 0);
2113 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2114 hres
= IInternetProtocol_UnlockRequest(protocol
);
2115 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2118 IInternetProtocol_Release(protocol
);
2121 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
2122 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2124 if(SUCCEEDED(hres
)) {
2125 if(file_protocol_start(protocol
, url
, TRUE
)) {
2126 hres
= IInternetProtocol_LockRequest(protocol
, 0);
2127 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2128 hres
= IInternetProtocol_Terminate(protocol
, 0);
2129 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2130 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2131 ok(hres
== S_OK
, "Read failed: %08x\n\n", hres
);
2132 hres
= IInternetProtocol_UnlockRequest(protocol
);
2133 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2134 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2135 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2136 hres
= IInternetProtocol_Terminate(protocol
, 0);
2137 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2140 IInternetProtocol_Release(protocol
);
2143 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
2144 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2146 if(SUCCEEDED(hres
)) {
2147 if(file_protocol_start(protocol
, url
, TRUE
)) {
2148 hres
= IInternetProtocol_Terminate(protocol
, 0);
2149 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2150 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2151 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2152 ok(cb
== 2, "cb=%u expected 2\n", cb
);
2155 IInternetProtocol_Release(protocol
);
2158 IClassFactory_Release(factory
);
2161 IUnknown_Release(unk
);
2164 static void test_file_protocol_fail(void)
2166 IInternetProtocol
*protocol
;
2169 static const WCHAR index_url2
[] =
2170 {'f','i','l','e',':','/','/','i','n','d','e','x','.','h','t','m','l',0};
2172 hres
= CoCreateInstance(&CLSID_FileProtocol
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
2173 &IID_IInternetProtocol
, (void**)&protocol
);
2174 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
2178 SET_EXPECT(GetBindInfo
);
2179 expect_hrResult
= MK_E_SYNTAX
;
2180 hres
= IInternetProtocol_Start(protocol
, wszIndexHtml
, &protocol_sink
, &bind_info
, 0, 0);
2181 ok(hres
== MK_E_SYNTAX
||
2182 hres
== E_INVALIDARG
,
2183 "Start failed: %08x, expected MK_E_SYNTAX or E_INVALIDARG\n", hres
);
2184 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
2186 SET_EXPECT(GetBindInfo
);
2187 if(!(bindf
& BINDF_FROMURLMON
))
2188 SET_EXPECT(ReportProgress_DIRECTBIND
);
2189 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2190 SET_EXPECT(ReportResult
);
2191 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
2192 hres
= IInternetProtocol_Start(protocol
, index_url
, &protocol_sink
, &bind_info
, 0, 0);
2193 ok(hres
== INET_E_RESOURCE_NOT_FOUND
,
2194 "Start failed: %08x expected INET_E_RESOURCE_NOT_FOUND\n", hres
);
2195 CHECK_CALLED(GetBindInfo
);
2196 if(!(bindf
& BINDF_FROMURLMON
))
2197 CHECK_CALLED(ReportProgress_DIRECTBIND
);
2198 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
2199 CHECK_CALLED(ReportResult
);
2201 IInternetProtocol_Release(protocol
);
2203 hres
= CoCreateInstance(&CLSID_FileProtocol
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
2204 &IID_IInternetProtocol
, (void**)&protocol
);
2205 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
2209 SET_EXPECT(GetBindInfo
);
2210 if(!(bindf
& BINDF_FROMURLMON
))
2211 SET_EXPECT(ReportProgress_DIRECTBIND
);
2212 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2213 SET_EXPECT(ReportResult
);
2214 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
2216 hres
= IInternetProtocol_Start(protocol
, index_url2
, &protocol_sink
, &bind_info
, 0, 0);
2217 ok(hres
== INET_E_RESOURCE_NOT_FOUND
,
2218 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND\n", hres
);
2219 CHECK_CALLED(GetBindInfo
);
2220 if(!(bindf
& BINDF_FROMURLMON
))
2221 CHECK_CALLED(ReportProgress_DIRECTBIND
);
2222 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
2223 CHECK_CALLED(ReportResult
);
2225 SET_EXPECT(GetBindInfo
);
2226 hres
= IInternetProtocol_Start(protocol
, NULL
, &protocol_sink
, &bind_info
, 0, 0);
2227 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2228 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
2230 SET_EXPECT(GetBindInfo
);
2231 hres
= IInternetProtocol_Start(protocol
, emptyW
, &protocol_sink
, &bind_info
, 0, 0);
2232 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2233 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
2235 IInternetProtocol_Release(protocol
);
2238 static void test_file_protocol(void) {
2239 WCHAR buf
[INTERNET_MAX_URL_LENGTH
], file_name_buf
[MAX_PATH
];
2244 static const WCHAR wszFile
[] = {'f','i','l','e',':',0};
2245 static const WCHAR wszFile2
[] = {'f','i','l','e',':','/','/',0};
2246 static const WCHAR wszFile3
[] = {'f','i','l','e',':','/','/','/',0};
2247 static const WCHAR wszFile4
[] = {'f','i','l','e',':','\\','\\',0};
2248 static const char html_doc
[] = "<HTML></HTML>";
2250 trace("Testing file protocol...\n");
2251 init_test(FILE_TEST
, 0);
2253 SetLastError(0xdeadbeef);
2254 file
= CreateFileW(wszIndexHtml
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
2255 FILE_ATTRIBUTE_NORMAL
, NULL
);
2256 if(!file
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
2258 win_skip("Detected Win9x or WinMe\n");
2261 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed\n");
2262 if(file
== INVALID_HANDLE_VALUE
)
2264 WriteFile(file
, html_doc
, sizeof(html_doc
)-1, &size
, NULL
);
2267 file_name
= wszIndexHtml
;
2269 test_file_protocol_url(index_url
);
2270 bindf
= BINDF_FROMURLMON
;
2271 test_file_protocol_url(index_url
);
2272 bindf
= BINDF_FROMURLMON
| BINDF_NEEDFILE
;
2273 test_file_protocol_url(index_url
);
2275 memcpy(buf
, wszFile
, sizeof(wszFile
));
2276 len
= sizeof(wszFile
)/sizeof(WCHAR
)-1;
2277 len
+= GetCurrentDirectoryW(sizeof(buf
)/sizeof(WCHAR
)-len
, buf
+len
);
2279 memcpy(buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2281 file_name
= buf
+ sizeof(wszFile
)/sizeof(WCHAR
)-1;
2283 test_file_protocol_url(buf
);
2284 bindf
= BINDF_FROMURLMON
;
2285 test_file_protocol_url(buf
);
2287 memcpy(buf
, wszFile2
, sizeof(wszFile2
));
2288 len
= GetCurrentDirectoryW(sizeof(file_name_buf
)/sizeof(WCHAR
), file_name_buf
);
2289 file_name_buf
[len
++] = '\\';
2290 memcpy(file_name_buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2291 lstrcpyW(buf
+sizeof(wszFile2
)/sizeof(WCHAR
)-1, file_name_buf
);
2292 file_name
= file_name_buf
;
2294 test_file_protocol_url(buf
);
2295 bindf
= BINDF_FROMURLMON
;
2296 test_file_protocol_url(buf
);
2298 buf
[sizeof(wszFile2
)/sizeof(WCHAR
)] = '|';
2299 test_file_protocol_url(buf
);
2301 memcpy(buf
, wszFile3
, sizeof(wszFile3
));
2302 len
= sizeof(wszFile3
)/sizeof(WCHAR
)-1;
2303 len
+= GetCurrentDirectoryW(sizeof(buf
)/sizeof(WCHAR
)-len
, buf
+len
);
2305 memcpy(buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2307 file_name
= buf
+ sizeof(wszFile3
)/sizeof(WCHAR
)-1;
2309 test_file_protocol_url(buf
);
2310 bindf
= BINDF_FROMURLMON
;
2311 test_file_protocol_url(buf
);
2313 memcpy(buf
, wszFile4
, sizeof(wszFile4
));
2314 len
= GetCurrentDirectoryW(sizeof(file_name_buf
)/sizeof(WCHAR
), file_name_buf
);
2315 file_name_buf
[len
++] = '\\';
2316 memcpy(file_name_buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2317 lstrcpyW(buf
+sizeof(wszFile4
)/sizeof(WCHAR
)-1, file_name_buf
);
2318 file_name
= file_name_buf
;
2320 test_file_protocol_url(buf
);
2321 bindf
= BINDF_FROMURLMON
;
2322 test_file_protocol_url(buf
);
2324 buf
[sizeof(wszFile4
)/sizeof(WCHAR
)] = '|';
2325 test_file_protocol_url(buf
);
2327 DeleteFileW(wszIndexHtml
);
2330 test_file_protocol_fail();
2331 bindf
= BINDF_FROMURLMON
;
2332 test_file_protocol_fail();
2335 static BOOL
http_protocol_start(LPCWSTR url
)
2337 static BOOL got_user_agent
= FALSE
;
2340 SET_EXPECT(GetBindInfo
);
2341 if (!(bindf
& BINDF_FROMURLMON
))
2342 SET_EXPECT(ReportProgress_DIRECTBIND
);
2344 SET_EXPECT(GetBindString_USER_AGENT
);
2345 SET_EXPECT(GetBindString_ACCEPT_MIMES
);
2346 SET_EXPECT(QueryService_HttpNegotiate
);
2347 SET_EXPECT(BeginningTransaction
);
2348 SET_EXPECT(GetRootSecurityId
);
2350 SET_EXPECT(GetBindString_POST_COOKIE
);
2352 hres
= IInternetProtocol_Start(async_protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
2353 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2357 CHECK_CALLED(GetBindInfo
);
2358 if (!(bindf
& BINDF_FROMURLMON
))
2359 CHECK_CALLED(ReportProgress_DIRECTBIND
);
2360 if (!got_user_agent
)
2362 CHECK_CALLED(GetBindString_USER_AGENT
);
2363 got_user_agent
= TRUE
;
2365 CHECK_CALLED(GetBindString_ACCEPT_MIMES
);
2366 CHECK_CALLED(QueryService_HttpNegotiate
);
2367 CHECK_CALLED(BeginningTransaction
);
2368 /* GetRootSecurityId called on WinXP but not on Win98 */
2369 CLEAR_CALLED(GetRootSecurityId
);
2371 CHECK_CALLED(GetBindString_POST_COOKIE
);
2376 static void test_protocol_terminate(IInternetProtocol
*protocol
)
2382 hres
= IInternetProtocol_LockRequest(protocol
, 0);
2383 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2385 hres
= IInternetProtocol_Read(protocol
, buf
, 1, &cb
);
2386 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2388 hres
= IInternetProtocol_Terminate(protocol
, 0);
2389 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2391 /* This wait is to give the internet handles being freed in Terminate
2392 * enough time to actually terminate in all cases. Internet handles
2393 * terminate asynchronously and native reuses the main InternetOpen
2394 * handle. The only case in which this seems to be necessary is on
2395 * wine with native wininet and urlmon, resulting in the next time
2396 * test_http_protocol_url being called the first data notification actually
2397 * being an extra last data notification from the previous connection
2398 * about once out of every ten times. */
2401 hres
= IInternetProtocol_UnlockRequest(protocol
);
2402 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2405 static void test_http_info(IInternetProtocol
*protocol
)
2407 IWinInetHttpInfo
*info
;
2410 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetHttpInfo
, (void**)&info
);
2411 ok(hres
== S_OK
, "Could not get IWinInterHttpInfo iface: %08x\n", hres
);
2415 IWinInetHttpInfo_Release(info
);
2418 /* is_first refers to whether this is the first call to this function
2420 static void test_http_protocol_url(LPCWSTR url
, int prot
, DWORD flags
)
2422 IInternetProtocolInfo
*protocol_info
;
2423 IClassFactory
*factory
;
2427 init_test(prot
, flags
);
2430 hres
= CoGetClassObject(prot
== HTTPS_TEST
? &CLSID_HttpSProtocol
: &CLSID_HttpProtocol
,
2431 CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
2432 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
2436 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
2437 ok(hres
== E_NOINTERFACE
,
2438 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
2441 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
2442 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
2443 IUnknown_Release(unk
);
2447 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
2448 (void**)&async_protocol
);
2449 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2450 if(SUCCEEDED(hres
)) {
2455 test_priority(async_protocol
);
2456 test_http_info(async_protocol
);
2458 SET_EXPECT(ReportProgress_COOKIE_SENT
);
2459 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
2460 SET_EXPECT(ReportProgress_CONNECTING
);
2461 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2463 SET_EXPECT(ReportProgress_REDIRECTING
);
2464 SET_EXPECT(ReportProgress_PROXYDETECTING
);
2465 if(prot
== HTTP_TEST
)
2466 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
2468 SET_EXPECT(QueryService_HttpSecurity
);
2469 if(!(bindf
& BINDF_FROMURLMON
)) {
2470 SET_EXPECT(OnResponse
);
2471 SET_EXPECT(ReportProgress_RAWMIMETYPE
);
2472 SET_EXPECT(ReportData
);
2477 if(!http_protocol_start(url
))
2481 SET_EXPECT(ReportResult
);
2482 expect_hrResult
= S_OK
;
2485 while(wait_for_switch
) {
2487 WaitForSingleObject(event_continue
, INFINITE
);
2488 CHECK_CALLED(Switch
);
2489 call_continue(&continue_protdata
);
2490 SetEvent(event_continue_done
);
2493 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
2494 ok((hres
== E_PENDING
&& cb
==0) ||
2495 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
2497 WaitForSingleObject(event_complete
, INFINITE
);
2498 if(bindf
& BINDF_FROMURLMON
)
2499 CHECK_CALLED(Switch
);
2501 CHECK_CALLED(ReportData
);
2502 if(prot
== HTTPS_TEST
)
2503 CLEAR_CALLED(QueryService_HttpSecurity
);
2506 if(bindf
& BINDF_FROMURLMON
)
2509 SET_EXPECT(ReportData
);
2510 hres
= IInternetProtocol_Read(async_protocol
, buf
, sizeof(buf
), &cb
);
2511 if(hres
== E_PENDING
) {
2512 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
2513 ok((hres
== E_PENDING
&& cb
==0) ||
2514 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
2515 WaitForSingleObject(event_complete
, INFINITE
);
2516 if(bindf
& BINDF_FROMURLMON
)
2517 CHECK_CALLED(Switch
);
2519 CHECK_CALLED(ReportData
);
2521 if(bindf
& BINDF_FROMURLMON
)
2522 CHECK_NOT_CALLED(Switch
);
2524 CHECK_NOT_CALLED(ReportData
);
2528 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2529 CHECK_CALLED(ReportResult
);
2531 if(prot
== HTTPS_TEST
)
2532 CLEAR_CALLED(ReportProgress_SENDINGREQUEST
);
2534 test_protocol_terminate(async_protocol
);
2535 ref
= IInternetProtocol_Release(async_protocol
);
2536 ok(!ref
, "ref=%x\n", hres
);
2539 IClassFactory_Release(factory
);
2542 static void test_http_protocol(void)
2544 static const WCHAR winehq_url
[] =
2545 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
2546 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
2547 static const WCHAR posttest_url
[] =
2548 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
2549 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
2550 'p','o','s','t','t','e','s','t','.','p','h','p',0};
2551 static const WCHAR redirect_url
[] =
2552 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
2553 't','e','s','t','r','e','d','i','r','e','c','t',0};
2555 trace("Testing http protocol (not from urlmon)...\n");
2556 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
;
2557 test_http_protocol_url(winehq_url
, HTTP_TEST
, TEST_FIRST_HTTP
);
2559 trace("Testing http protocol (from urlmon)...\n");
2560 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
;
2561 test_http_protocol_url(winehq_url
, HTTP_TEST
, 0);
2563 trace("Testing http protocol (to file)...\n");
2564 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NEEDFILE
;
2565 test_http_protocol_url(winehq_url
, HTTP_TEST
, 0);
2567 trace("Testing http protocol (post data)...\n");
2568 /* Without this flag we get a ReportProgress_CACHEFILENAMEAVAILABLE
2569 * notification with BINDVERB_POST */
2570 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
2571 test_http_protocol_url(posttest_url
, HTTP_TEST
, TEST_FIRST_HTTP
|TEST_POST
);
2573 trace("Testing http protocol (direct read)...\n");
2574 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
;
2575 test_http_protocol_url(winehq_url
, HTTP_TEST
, TEST_DIRECT_READ
);
2577 trace("Testing http protocol (redirected)...\n");
2578 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
;
2579 test_http_protocol_url(redirect_url
, HTTP_TEST
, TEST_REDIRECT
);
2582 static void test_https_protocol(void)
2584 static const WCHAR codeweavers_url
[] =
2585 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
2586 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0};
2588 trace("Testing https protocol (from urlmon)...\n");
2589 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
2590 test_http_protocol_url(codeweavers_url
, HTTPS_TEST
, TEST_FIRST_HTTP
);
2594 static void test_ftp_protocol(void)
2596 IInternetProtocolInfo
*protocol_info
;
2597 IClassFactory
*factory
;
2604 static const WCHAR ftp_urlW
[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
2605 '/','p','u','b','/','o','t','h','e','r','/',
2606 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
2608 trace("Testing ftp protocol...\n");
2610 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
2612 tested_protocol
= FTP_TEST
;
2613 first_data_notif
= TRUE
;
2614 expect_hrResult
= E_PENDING
;
2616 hres
= CoGetClassObject(&CLSID_FtpProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
2617 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
2621 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
2622 ok(hres
== E_NOINTERFACE
, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
2624 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
2625 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
2626 IUnknown_Release(unk
);
2630 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
2631 (void**)&async_protocol
);
2632 IClassFactory_Release(factory
);
2633 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2635 test_priority(async_protocol
);
2636 test_http_info(async_protocol
);
2638 SET_EXPECT(GetBindInfo
);
2639 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
2640 SET_EXPECT(ReportProgress_CONNECTING
);
2641 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2644 hres
= IInternetProtocol_Start(async_protocol
, ftp_urlW
, &protocol_sink
, &bind_info
, 0, 0);
2645 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2646 CHECK_CALLED(GetBindInfo
);
2648 SET_EXPECT(ReportResult
);
2650 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
2651 ok((hres
== E_PENDING
&& cb
==0) ||
2652 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
2654 WaitForSingleObject(event_complete
, INFINITE
);
2658 hres
= IInternetProtocol_Read(async_protocol
, buf
, sizeof(buf
), &cb
);
2659 if(hres
== E_PENDING
)
2660 WaitForSingleObject(event_complete
, INFINITE
);
2665 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2666 CHECK_CALLED(ReportResult
);
2667 CHECK_CALLED(Switch
);
2669 test_protocol_terminate(async_protocol
);
2671 ref
= IInternetProtocol_Release(async_protocol
);
2672 ok(!ref
, "ref=%d\n", ref
);
2675 static void test_gopher_protocol(void)
2677 IInternetProtocolInfo
*protocol_info
;
2678 IClassFactory
*factory
;
2682 trace("Testing gopher protocol...\n");
2684 hres
= CoGetClassObject(&CLSID_GopherProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
2686 hres
== REGDB_E_CLASSNOTREG
, /* Gopher protocol has been removed as of Vista */
2687 "CoGetClassObject failed: %08x\n", hres
);
2691 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
2692 ok(hres
== E_NOINTERFACE
, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
2694 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
2695 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
2696 IUnknown_Release(unk
);
2700 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
2701 (void**)&async_protocol
);
2702 IClassFactory_Release(factory
);
2703 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2705 test_priority(async_protocol
);
2707 IInternetProtocol_Release(async_protocol
);
2710 static void test_mk_protocol(void)
2712 IInternetProtocolInfo
*protocol_info
;
2713 IInternetProtocol
*protocol
;
2714 IClassFactory
*factory
;
2718 static const WCHAR wrong_url1
[] = {'t','e','s','t',':','@','M','S','I','T','S','t','o','r','e',
2719 ':',':','/','t','e','s','t','.','h','t','m','l',0};
2720 static const WCHAR wrong_url2
[] = {'m','k',':','/','t','e','s','t','.','h','t','m','l',0};
2722 trace("Testing mk protocol...\n");
2723 init_test(MK_TEST
, 0);
2725 hres
= CoGetClassObject(&CLSID_MkProtocol
, CLSCTX_INPROC_SERVER
, NULL
,
2726 &IID_IUnknown
, (void**)&unk
);
2727 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
2729 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
2730 ok(hres
== E_NOINTERFACE
,
2731 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
2734 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
2735 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
2736 IUnknown_Release(unk
);
2740 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
2742 IClassFactory_Release(factory
);
2743 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2745 SET_EXPECT(GetBindInfo
);
2746 hres
= IInternetProtocol_Start(protocol
, wrong_url1
, &protocol_sink
, &bind_info
, 0, 0);
2747 ok(hres
== MK_E_SYNTAX
|| hres
== INET_E_INVALID_URL
,
2748 "Start failed: %08x, expected MK_E_SYNTAX or INET_E_INVALID_URL\n", hres
);
2749 CLEAR_CALLED(GetBindInfo
);
2751 SET_EXPECT(GetBindInfo
);
2752 SET_EXPECT(ReportProgress_DIRECTBIND
);
2753 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2754 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
2755 SET_EXPECT(ReportResult
);
2756 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
2758 hres
= IInternetProtocol_Start(protocol
, wrong_url2
, &protocol_sink
, &bind_info
, 0, 0);
2759 ok(hres
== INET_E_RESOURCE_NOT_FOUND
||
2760 hres
== INET_E_INVALID_URL
, /* win2k3 */
2761 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND or INET_E_INVALID_URL\n", hres
);
2763 if (hres
== INET_E_RESOURCE_NOT_FOUND
) {
2764 CHECK_CALLED(GetBindInfo
);
2765 CLEAR_CALLED(ReportProgress_DIRECTBIND
);
2766 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
2767 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
2768 CHECK_CALLED(ReportResult
);
2770 CLEAR_CALLED(GetBindInfo
);
2771 CLEAR_CALLED(ReportProgress_DIRECTBIND
);
2772 CLEAR_CALLED(ReportProgress_SENDINGREQUEST
);
2773 CLEAR_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
2774 CLEAR_CALLED(ReportResult
);
2777 IInternetProtocol_Release(protocol
);
2780 static void test_CreateBinding(void)
2782 IInternetProtocol
*protocol
;
2783 IInternetPriority
*priority
;
2784 IInternetSession
*session
;
2785 IWinInetHttpInfo
*http_info
;
2786 IWinInetInfo
*inet_info
;
2792 static const WCHAR test_url
[] =
2793 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0};
2794 static const WCHAR wsz_test
[] = {'t','e','s','t',0};
2796 trace("Testing CreateBinding...\n");
2797 init_test(BIND_TEST
, TEST_BINDING
);
2799 hres
= pCoInternetGetSession(0, &session
, 0);
2800 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
2802 hres
= IInternetSession_RegisterNameSpace(session
, &ClassFactory
, &IID_NULL
, wsz_test
, 0, NULL
, 0);
2803 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
2805 hres
= IInternetSession_CreateBinding(session
, NULL
, test_url
, NULL
, NULL
, &protocol
, 0);
2806 binding_protocol
= protocol
;
2807 ok(hres
== S_OK
, "CreateBinding failed: %08x\n", hres
);
2808 ok(protocol
!= NULL
, "protocol == NULL\n");
2810 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetBindInfo
, (void**)&prot_bind_info
);
2811 ok(hres
== S_OK
, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres
);
2813 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetProtocolSink
, (void**)&binding_sink
);
2814 ok(hres
== S_OK
, "Could not get IInternetProtocolSink: %08x\n", hres
);
2816 hres
= IInternetProtocol_Start(protocol
, test_url
, NULL
, &bind_info
, 0, 0);
2817 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2818 hres
= IInternetProtocol_Start(protocol
, test_url
, &protocol_sink
, NULL
, 0, 0);
2819 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2820 hres
= IInternetProtocol_Start(protocol
, NULL
, &protocol_sink
, &bind_info
, 0, 0);
2821 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2823 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetPriority
, (void**)&priority
);
2824 ok(hres
== S_OK
, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres
);
2827 hres
= IInternetPriority_GetPriority(priority
, &p
);
2828 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2829 ok(!p
, "p=%d\n", p
);
2832 hres
= IInternetPriority_SetPriority(priority
, 100);
2833 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
2836 hres
= IInternetPriority_GetPriority(priority
, &p
);
2837 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2838 ok(p
== 100, "p=%d\n", p
);
2840 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetInfo
, (void**)&inet_info
);
2841 ok(hres
== E_NOINTERFACE
, "Could not get IWinInetInfo protocol: %08x\n", hres
);
2843 SET_EXPECT(QueryService_InternetProtocol
);
2844 SET_EXPECT(CreateInstance
);
2845 SET_EXPECT(ReportProgress_PROTOCOLCLASSID
);
2846 SET_EXPECT(SetPriority
);
2849 expect_hrResult
= S_OK
;
2850 hres
= IInternetProtocol_Start(protocol
, test_url
, &protocol_sink
, &bind_info
, 0, 0);
2851 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2853 CHECK_CALLED(QueryService_InternetProtocol
);
2854 CHECK_CALLED(CreateInstance
);
2855 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID
);
2856 CHECK_CALLED(SetPriority
);
2857 CHECK_CALLED(Start
);
2859 SET_EXPECT(QueryInterface_IWinInetInfo
);
2860 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetInfo
, (void**)&inet_info
);
2861 ok(hres
== E_NOINTERFACE
, "Could not get IWinInetInfo protocol: %08x\n", hres
);
2862 CHECK_CALLED(QueryInterface_IWinInetInfo
);
2864 SET_EXPECT(QueryInterface_IWinInetInfo
);
2865 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetInfo
, (void**)&inet_info
);
2866 ok(hres
== E_NOINTERFACE
, "Could not get IWinInetInfo protocol: %08x\n", hres
);
2867 CHECK_CALLED(QueryInterface_IWinInetInfo
);
2869 SET_EXPECT(QueryInterface_IWinInetHttpInfo
);
2870 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
2871 ok(hres
== E_NOINTERFACE
, "Could not get IWinInetInfo protocol: %08x\n", hres
);
2872 CHECK_CALLED(QueryInterface_IWinInetHttpInfo
);
2876 hres
= IInternetProtocol_Read(protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
2877 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2878 ok(read
== 100, "read = %d\n", read
);
2883 hres
= IInternetProtocol_Read(protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
2884 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2885 ok(!read
, "read = %d\n", read
);
2889 hres
= IInternetPriority_GetPriority(priority
, &p
);
2890 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2891 ok(p
== 100, "p=%d\n", p
);
2893 hres
= IInternetPriority_SetPriority(priority
, 101);
2894 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
2896 SET_EXPECT(Terminate
);
2897 hres
= IInternetProtocol_Terminate(protocol
, 0xdeadbeef);
2898 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2899 CHECK_CALLED(Terminate
);
2901 SET_EXPECT(Continue
);
2902 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
2903 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
2904 CHECK_CALLED(Continue
);
2906 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
2907 BINDSTATUS_CACHEFILENAMEAVAILABLE
, expect_wsz
= emptyW
);
2908 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
2910 hres
= IInternetProtocolSink_ReportResult(binding_sink
, S_OK
, ERROR_SUCCESS
, NULL
);
2911 ok(hres
== E_FAIL
, "ReportResult failed: %08x, expected E_FAIL\n", hres
);
2913 hres
= IInternetProtocolSink_ReportData(binding_sink
, 0, 0, 0);
2914 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
2916 IInternetProtocolSink_Release(binding_sink
);
2917 IInternetPriority_Release(priority
);
2918 IInternetBindInfo_Release(prot_bind_info
);
2919 IInternetProtocol_Release(protocol
);
2921 hres
= IInternetSession_UnregisterNameSpace(session
, &ClassFactory
, wsz_test
);
2922 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
2924 IInternetSession_Release(session
);
2927 static void test_binding(int prot
, DWORD grf_pi
, DWORD test_flags
)
2929 IInternetProtocol
*protocol
;
2930 IInternetSession
*session
;
2936 init_test(prot
, test_flags
|TEST_BINDING
);
2938 hres
= pCoInternetGetSession(0, &session
, 0);
2939 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
2941 if(test_flags
& TEST_EMULATEPROT
) {
2942 hres
= IInternetSession_RegisterNameSpace(session
, &ClassFactory
, &IID_NULL
, protocol_names
[prot
], 0, NULL
, 0);
2943 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
2946 hres
= IInternetSession_CreateBinding(session
, NULL
, binding_urls
[prot
], NULL
, NULL
, &protocol
, 0);
2947 binding_protocol
= protocol
;
2948 ok(hres
== S_OK
, "CreateBinding failed: %08x\n", hres
);
2949 ok(protocol
!= NULL
, "protocol == NULL\n");
2951 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetBindInfo
, (void**)&prot_bind_info
);
2952 ok(hres
== S_OK
, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres
);
2954 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetProtocolSink
, (void**)&binding_sink
);
2955 ok(hres
== S_OK
, "QueryInterface(IID_IInternetProtocolSink) failed: %08x\n", hres
);
2958 SET_EXPECT(QueryService_InternetProtocol
);
2959 SET_EXPECT(CreateInstance
);
2960 SET_EXPECT(ReportProgress_PROTOCOLCLASSID
);
2961 SET_EXPECT(SetPriority
);
2964 expect_hrResult
= S_OK
;
2965 hres
= IInternetProtocol_Start(protocol
, binding_urls
[prot
], &protocol_sink
, &bind_info
, pi
, 0);
2966 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2968 CHECK_CALLED(QueryService_InternetProtocol
);
2969 CHECK_CALLED(CreateInstance
);
2970 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID
);
2971 CHECK_CALLED(SetPriority
);
2972 CHECK_CALLED(Start
);
2974 if(prot
== HTTP_TEST
|| prot
== HTTPS_TEST
) {
2975 while(prot_state
< 4) {
2976 WaitForSingleObject(event_complete
, INFINITE
);
2977 if(mimefilter_test
&& filtered_protocol
) {
2978 SET_EXPECT(Continue
);
2979 IInternetProtocol_Continue(filtered_protocol
, pdata
);
2980 CHECK_CALLED(Continue
);
2982 SET_EXPECT(Continue
);
2983 IInternetProtocol_Continue(protocol
, pdata
);
2984 CHECK_CALLED(Continue
);
2986 SetEvent(event_complete2
);
2989 CHECK_CALLED(ReportData
); /* Set in ReportResult */
2990 WaitForSingleObject(event_complete
, INFINITE
);
2993 SET_EXPECT(MimeFilter_LockRequest
);
2995 SET_EXPECT(LockRequest
);
2996 hres
= IInternetProtocol_LockRequest(protocol
, 0);
2997 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2999 CHECK_CALLED(MimeFilter_LockRequest
);
3001 CHECK_CALLED(LockRequest
);
3004 SET_EXPECT(MimeFilter_UnlockRequest
);
3006 SET_EXPECT(UnlockRequest
);
3007 hres
= IInternetProtocol_UnlockRequest(protocol
);
3008 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
3010 CHECK_CALLED(MimeFilter_UnlockRequest
);
3012 CHECK_CALLED(UnlockRequest
);
3016 SET_EXPECT(MimeFilter_Terminate
);
3018 SET_EXPECT(Terminate
);
3019 hres
= IInternetProtocol_Terminate(protocol
, 0);
3020 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
3022 CLEAR_CALLED(MimeFilter_Terminate
);
3024 CHECK_CALLED(Terminate
);
3026 if(filtered_protocol
)
3027 IInternetProtocol_Release(filtered_protocol
);
3028 IInternetBindInfo_Release(prot_bind_info
);
3029 IInternetProtocolSink_Release(binding_sink
);
3030 ref
= IInternetProtocol_Release(protocol
);
3031 ok(!ref
, "ref=%u, expected 0\n", ref
);
3033 if(test_flags
& TEST_EMULATEPROT
) {
3034 hres
= IInternetSession_UnregisterNameSpace(session
, &ClassFactory
, protocol_names
[prot
]);
3035 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
3038 IInternetSession_Release(session
);
3041 static void register_filter(void)
3043 IInternetSession
*session
;
3046 static const WCHAR gzipW
[] = {'g','z','i','p',0};
3048 hres
= pCoInternetGetSession(0, &session
, 0);
3049 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
3051 hres
= IInternetSession_RegisterMimeFilter(session
, &mimefilter_cf
, &IID_IInternetProtocol
, gzipW
);
3052 ok(hres
== S_OK
, "RegisterMimeFilter failed: %08x\n", hres
);
3054 IInternetSession_Release(session
);
3057 START_TEST(protocol
)
3061 hurlmon
= GetModuleHandle("urlmon.dll");
3062 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
3063 pReleaseBindInfo
= (void*) GetProcAddress(hurlmon
, "ReleaseBindInfo");
3065 if (!pCoInternetGetSession
|| !pReleaseBindInfo
) {
3066 win_skip("Various needed functions not present in IE 4.0\n");
3070 OleInitialize(NULL
);
3072 event_complete
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3073 event_complete2
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3074 event_continue
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3075 event_continue_done
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3079 test_file_protocol();
3080 test_http_protocol();
3081 test_https_protocol();
3082 test_ftp_protocol();
3083 test_gopher_protocol();
3085 test_CreateBinding();
3087 bindf
&= ~BINDF_FROMURLMON
;
3088 trace("Testing file binding (mime verification, emulate prot)...\n");
3089 test_binding(FILE_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
);
3090 trace("Testing http binding (mime verification, emulate prot)...\n");
3091 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
);
3092 trace("Testing http binding (mime verification, emulate prot, short read, direct read)...\n");
3093 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_SHORT_READ
|TEST_DIRECT_READ
);
3094 trace("Testing file binding (mime verification, emulate prot, mime filter)...\n");
3095 test_binding(FILE_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_FILTER
);
3096 trace("Testing http binding (mime verification, emulate prot, mime filter)...\n");
3097 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_FILTER
);
3098 trace("Testing http binding (mime verification, emulate prot, direct read)...\n");
3099 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_DIRECT_READ
);
3101 CloseHandle(event_complete
);
3102 CloseHandle(event_complete2
);
3103 CloseHandle(event_continue
);
3104 CloseHandle(event_continue_done
);