2 * Copyright 2005-2011 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
*);
34 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
36 #define DEFINE_EXPECT(func) \
37 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
39 #define SET_EXPECT(func) \
40 expect_ ## func = TRUE
42 #define CHECK_EXPECT2(func) \
44 ok(expect_ ##func, "unexpected call " #func "\n"); \
45 called_ ## func = TRUE; \
48 #define CHECK_EXPECT(func) \
50 CHECK_EXPECT2(func); \
51 expect_ ## func = FALSE; \
54 #define CHECK_CALLED(func) \
56 ok(called_ ## func, "expected " #func "\n"); \
57 expect_ ## func = called_ ## func = FALSE; \
60 #define CHECK_NOT_CALLED(func) \
62 ok(!called_ ## func, "unexpected " #func "\n"); \
63 expect_ ## func = called_ ## func = FALSE; \
66 #define CLEAR_CALLED(func) \
67 expect_ ## func = called_ ## func = FALSE
69 DEFINE_EXPECT(GetBindInfo
);
70 DEFINE_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
71 DEFINE_EXPECT(ReportProgress_DIRECTBIND
);
72 DEFINE_EXPECT(ReportProgress_RAWMIMETYPE
);
73 DEFINE_EXPECT(ReportProgress_FINDINGRESOURCE
);
74 DEFINE_EXPECT(ReportProgress_CONNECTING
);
75 DEFINE_EXPECT(ReportProgress_SENDINGREQUEST
);
76 DEFINE_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
77 DEFINE_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
78 DEFINE_EXPECT(ReportProgress_PROTOCOLCLASSID
);
79 DEFINE_EXPECT(ReportProgress_COOKIE_SENT
);
80 DEFINE_EXPECT(ReportProgress_REDIRECTING
);
81 DEFINE_EXPECT(ReportProgress_ENCODING
);
82 DEFINE_EXPECT(ReportProgress_ACCEPTRANGES
);
83 DEFINE_EXPECT(ReportProgress_PROXYDETECTING
);
84 DEFINE_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
85 DEFINE_EXPECT(ReportProgress_DECODING
);
86 DEFINE_EXPECT(ReportData
);
87 DEFINE_EXPECT(ReportData2
);
88 DEFINE_EXPECT(ReportResult
);
89 DEFINE_EXPECT(GetBindString_ACCEPT_MIMES
);
90 DEFINE_EXPECT(GetBindString_USER_AGENT
);
91 DEFINE_EXPECT(GetBindString_POST_COOKIE
);
92 DEFINE_EXPECT(GetBindString_URL
);
93 DEFINE_EXPECT(QueryService_HttpNegotiate
);
94 DEFINE_EXPECT(QueryService_InternetProtocol
);
95 DEFINE_EXPECT(QueryService_HttpSecurity
);
96 DEFINE_EXPECT(QueryInterface_IWinInetInfo
);
97 DEFINE_EXPECT(QueryInterface_IWinInetHttpInfo
);
98 DEFINE_EXPECT(BeginningTransaction
);
99 DEFINE_EXPECT(GetRootSecurityId
);
100 DEFINE_EXPECT(OnResponse
);
101 DEFINE_EXPECT(Switch
);
102 DEFINE_EXPECT(Continue
);
103 DEFINE_EXPECT(CreateInstance
);
104 DEFINE_EXPECT(Start
);
105 DEFINE_EXPECT(StartEx
);
106 DEFINE_EXPECT(Terminate
);
108 DEFINE_EXPECT(Read2
);
109 DEFINE_EXPECT(SetPriority
);
110 DEFINE_EXPECT(LockRequest
);
111 DEFINE_EXPECT(UnlockRequest
);
112 DEFINE_EXPECT(Abort
);
113 DEFINE_EXPECT(MimeFilter_CreateInstance
);
114 DEFINE_EXPECT(MimeFilter_Start
);
115 DEFINE_EXPECT(MimeFilter_ReportData
);
116 DEFINE_EXPECT(MimeFilter_ReportResult
);
117 DEFINE_EXPECT(MimeFilter_Terminate
);
118 DEFINE_EXPECT(MimeFilter_LockRequest
);
119 DEFINE_EXPECT(MimeFilter_UnlockRequest
);
120 DEFINE_EXPECT(MimeFilter_Read
);
121 DEFINE_EXPECT(MimeFilter_Switch
);
122 DEFINE_EXPECT(MimeFilter_Continue
);
123 DEFINE_EXPECT(Stream_Seek
);
124 DEFINE_EXPECT(Stream_Read
);
126 static const WCHAR wszIndexHtml
[] = {'i','n','d','e','x','.','h','t','m','l',0};
127 static const WCHAR index_url
[] =
128 {'f','i','l','e',':','i','n','d','e','x','.','h','t','m','l',0};
130 static const WCHAR acc_mimeW
[] = {'*','/','*',0};
131 static const WCHAR user_agentW
[] = {'W','i','n','e',0};
132 static const WCHAR text_htmlW
[] = {'t','e','x','t','/','h','t','m','l',0};
133 static const WCHAR hostW
[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
134 static const WCHAR winehq_ipW
[] = {'2','0','9','.','4','6','.','2','5','.','1','3','4',0};
135 static const WCHAR emptyW
[] = {0};
136 static const WCHAR gzipW
[] = {'g','z','i','p',0};
138 static HRESULT expect_hrResult
;
139 static LPCWSTR file_name
, http_url
, expect_wsz
;
140 static IInternetProtocol
*async_protocol
= NULL
;
141 static BOOL first_data_notif
, http_is_first
, test_redirect
;
142 static int prot_state
, read_report_data
, post_stream_read
;
143 static DWORD bindf
, ex_priority
, pi
;
144 static IInternetProtocol
*binding_protocol
, *filtered_protocol
;
145 static IInternetBindInfo
*prot_bind_info
;
146 static IInternetProtocolSink
*binding_sink
, *filtered_sink
;
147 static void *expect_pv
;
148 static HANDLE event_complete
, event_complete2
, event_continue
, event_continue_done
;
149 static BOOL binding_test
;
150 static PROTOCOLDATA protocoldata
, *pdata
, continue_protdata
;
151 static DWORD prot_read
, pi
, filter_state
, http_post_test
, thread_id
;
152 static BOOL security_problem
, test_async_req
, impl_protex
;
153 static BOOL async_read_pending
, mimefilter_test
, direct_read
, wait_for_switch
, emulate_prot
, short_read
, test_abort
;
154 static BOOL empty_file
;
158 STATE_SENDINGREQUEST
,
159 STATE_STARTDOWNLOADING
,
173 static const WCHAR protocol_names
[][10] = {
176 {'h','t','t','p','s',0},
183 static const WCHAR binding_urls
[][130] = {
184 {'f','i','l','e',':','t','e','s','t','.','h','t','m','l',0},
185 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
186 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0},
187 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
188 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0},
189 {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
190 '/','p','u','b','/','o','t','h','e','r',
191 '/','w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0},
192 {'m','k',':','t','e','s','t',0},
193 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0},
194 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0}
197 static const CHAR post_data
[] = "mode=Test";
199 static const char *debugstr_guid(REFIID riid
)
203 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
204 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
205 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
206 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
211 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
214 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
215 return lstrcmpA(stra
, buf
);
218 static HRESULT WINAPI
HttpSecurity_QueryInterface(IHttpSecurity
*iface
, REFIID riid
, void **ppv
)
220 if(IsEqualGUID(&IID_IUnknown
, riid
)
221 || IsEqualGUID(&IID_IHttpSecurity
, riid
)) {
226 ok(0, "unexpected call\n");
227 return E_NOINTERFACE
;
230 static ULONG WINAPI
HttpSecurity_AddRef(IHttpSecurity
*iface
)
235 static ULONG WINAPI
HttpSecurity_Release(IHttpSecurity
*iface
)
240 static HRESULT WINAPI
HttpSecurity_GetWindow(IHttpSecurity
* iface
, REFGUID rguidReason
, HWND
*phwnd
)
242 trace("HttpSecurity_GetWindow\n");
247 static HRESULT WINAPI
HttpSecurity_OnSecurityProblem(IHttpSecurity
*iface
, DWORD dwProblem
)
249 trace("Security problem: %u\n", dwProblem
);
250 ok(dwProblem
== ERROR_INTERNET_SEC_CERT_REV_FAILED
, "Expected ERROR_INTERNET_SEC_CERT_REV_FAILED got %u\n", dwProblem
);
252 /* Only retry once */
253 if (security_problem
)
256 security_problem
= TRUE
;
257 SET_EXPECT(BeginningTransaction
);
262 static IHttpSecurityVtbl HttpSecurityVtbl
= {
263 HttpSecurity_QueryInterface
,
265 HttpSecurity_Release
,
266 HttpSecurity_GetWindow
,
267 HttpSecurity_OnSecurityProblem
270 static IHttpSecurity http_security
= { &HttpSecurityVtbl
};
272 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate2
*iface
, REFIID riid
, void **ppv
)
274 if(IsEqualGUID(&IID_IUnknown
, riid
)
275 || IsEqualGUID(&IID_IHttpNegotiate
, riid
)
276 || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
281 ok(0, "unexpected call\n");
282 return E_NOINTERFACE
;
285 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate2
*iface
)
290 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate2
*iface
)
295 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate2
*iface
, LPCWSTR szURL
,
296 LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
300 static const WCHAR wszHeaders
[] =
301 {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ','a','p','p','l','i','c','a','t',
302 'i','o','n','/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o',
303 'd','e','d','\r','\n',0};
305 CHECK_EXPECT(BeginningTransaction
);
308 ok(!lstrcmpW(szURL
, binding_urls
[tested_protocol
]), "szURL != http_url\n");
310 ok(!lstrcmpW(szURL
, http_url
), "szURL != http_url\n");
311 ok(!dwReserved
, "dwReserved=%d, expected 0\n", dwReserved
);
312 ok(pszAdditionalHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
313 if(pszAdditionalHeaders
)
315 ok(*pszAdditionalHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
318 addl_headers
= CoTaskMemAlloc(sizeof(wszHeaders
));
319 memcpy(addl_headers
, wszHeaders
, sizeof(wszHeaders
));
320 *pszAdditionalHeaders
= addl_headers
;
327 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate2
*iface
, DWORD dwResponseCode
,
328 LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
, LPWSTR
*pszAdditionalRequestHeaders
)
330 CHECK_EXPECT(OnResponse
);
332 ok(dwResponseCode
== 200, "dwResponseCode=%d, expected 200\n", dwResponseCode
);
333 ok(szResponseHeaders
!= NULL
, "szResponseHeaders == NULL\n");
334 ok(szRequestHeaders
== NULL
, "szRequestHeaders != NULL\n");
335 ok(pszAdditionalRequestHeaders
== NULL
, "pszAdditionalHeaders != NULL\n");
340 static HRESULT WINAPI
HttpNegotiate_GetRootSecurityId(IHttpNegotiate2
*iface
,
341 BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
343 static const BYTE sec_id
[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
345 CHECK_EXPECT(GetRootSecurityId
);
347 ok(!dwReserved
, "dwReserved=%ld, expected 0\n", dwReserved
);
348 ok(pbSecurityId
!= NULL
, "pbSecurityId == NULL\n");
349 ok(pcbSecurityId
!= NULL
, "pcbSecurityId == NULL\n");
352 ok(*pcbSecurityId
== 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId
);
353 *pcbSecurityId
= sizeof(sec_id
);
357 memcpy(pbSecurityId
, sec_id
, sizeof(sec_id
));
362 static IHttpNegotiate2Vtbl HttpNegotiateVtbl
= {
363 HttpNegotiate_QueryInterface
,
364 HttpNegotiate_AddRef
,
365 HttpNegotiate_Release
,
366 HttpNegotiate_BeginningTransaction
,
367 HttpNegotiate_OnResponse
,
368 HttpNegotiate_GetRootSecurityId
371 static IHttpNegotiate2 http_negotiate
= { &HttpNegotiateVtbl
};
373 static HRESULT
QueryInterface(REFIID
,void**);
375 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
377 return QueryInterface(riid
, ppv
);
380 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
385 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
390 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
391 REFIID riid
, void **ppv
)
393 if(IsEqualGUID(&IID_IHttpNegotiate
, guidService
) || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
394 CHECK_EXPECT2(QueryService_HttpNegotiate
);
395 return IHttpNegotiate2_QueryInterface(&http_negotiate
, riid
, ppv
);
398 if(IsEqualGUID(&IID_IInternetProtocol
, guidService
)) {
399 ok(IsEqualGUID(&IID_IInternetProtocol
, riid
), "unexpected riid\n");
400 CHECK_EXPECT(QueryService_InternetProtocol
);
401 return E_NOINTERFACE
;
404 if(IsEqualGUID(&IID_IHttpSecurity
, guidService
)) {
405 ok(IsEqualGUID(&IID_IHttpSecurity
, riid
), "unexpected riid\n");
406 CHECK_EXPECT(QueryService_HttpSecurity
);
407 return IHttpSecurity_QueryInterface(&http_security
, riid
, ppv
);
410 ok(0, "unexpected service %s\n", debugstr_guid(guidService
));
414 static const IServiceProviderVtbl ServiceProviderVtbl
= {
415 ServiceProvider_QueryInterface
,
416 ServiceProvider_AddRef
,
417 ServiceProvider_Release
,
418 ServiceProvider_QueryService
421 static IServiceProvider service_provider
= { &ServiceProviderVtbl
};
423 static HRESULT WINAPI
Stream_QueryInterface(IStream
*iface
, REFIID riid
, void **ppv
)
425 ok(0, "unexpected call\n");
426 return E_NOINTERFACE
;
429 static ULONG WINAPI
Stream_AddRef(IStream
*iface
)
434 static ULONG WINAPI
Stream_Release(IStream
*iface
)
439 static HRESULT WINAPI
Stream_Read(IStream
*iface
, void *pv
,
440 ULONG cb
, ULONG
*pcbRead
)
442 CHECK_EXPECT2(Stream_Read
);
444 ok(GetCurrentThreadId() != thread_id
, "wrong thread %d\n", GetCurrentThreadId());
446 ok(pv
!= NULL
, "pv == NULL\n");
447 ok(cb
== 0x20000 || broken(cb
== 0x2000), "cb = %d\n", cb
);
448 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
450 if(post_stream_read
) {
455 memcpy(pv
, post_data
, sizeof(post_data
)-1);
456 post_stream_read
+= *pcbRead
= sizeof(post_data
)-1;
460 static HRESULT WINAPI
Stream_Write(IStream
*iface
, const void *pv
,
461 ULONG cb
, ULONG
*pcbWritten
)
463 ok(0, "unexpected call\n");
467 static HRESULT WINAPI
Stream_Seek(IStream
*iface
, LARGE_INTEGER dlibMove
,
468 DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
470 CHECK_EXPECT(Stream_Seek
);
472 ok(!dlibMove
.QuadPart
, "dlibMove != 0\n");
473 ok(dwOrigin
== STREAM_SEEK_SET
, "dwOrigin = %d\n", dwOrigin
);
474 ok(!plibNewPosition
, "plibNewPosition == NULL\n");
479 static HRESULT WINAPI
Stream_SetSize(IStream
*iface
, ULARGE_INTEGER libNewSize
)
481 ok(0, "unexpected call\n");
485 static HRESULT WINAPI
Stream_CopyTo(IStream
*iface
, IStream
*pstm
,
486 ULARGE_INTEGER cb
, ULARGE_INTEGER
*pcbRead
, ULARGE_INTEGER
*pcbWritten
)
488 ok(0, "unexpected call\n");
492 static HRESULT WINAPI
Stream_Commit(IStream
*iface
, DWORD grfCommitFlags
)
494 ok(0, "unexpected call\n");
498 static HRESULT WINAPI
Stream_Revert(IStream
*iface
)
500 ok(0, "unexpected call\n");
504 static HRESULT WINAPI
Stream_LockRegion(IStream
*iface
, ULARGE_INTEGER libOffset
,
505 ULARGE_INTEGER cb
, DWORD dwLockType
)
507 ok(0, "unexpected call\n");
511 static HRESULT WINAPI
Stream_UnlockRegion(IStream
*iface
,
512 ULARGE_INTEGER libOffset
, ULARGE_INTEGER cb
, DWORD dwLockType
)
514 ok(0, "unexpected call\n");
518 static HRESULT WINAPI
Stream_Stat(IStream
*iface
, STATSTG
*pstatstg
,
521 ok(0, "unexpected call\n");
525 static HRESULT WINAPI
Stream_Clone(IStream
*iface
, IStream
**ppstm
)
527 ok(0, "unexpected call\n");
531 static const IStreamVtbl StreamVtbl
= {
532 Stream_QueryInterface
,
548 static IStream Stream
= { &StreamVtbl
};
550 static HRESULT WINAPI
ProtocolSink_QueryInterface(IInternetProtocolSink
*iface
, REFIID riid
, void **ppv
)
552 return QueryInterface(riid
, ppv
);
555 static ULONG WINAPI
ProtocolSink_AddRef(IInternetProtocolSink
*iface
)
560 static ULONG WINAPI
ProtocolSink_Release(IInternetProtocolSink
*iface
)
565 static void call_continue(PROTOCOLDATA
*protocol_data
)
569 if(state
== STATE_CONNECTING
) {
570 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
)
571 CLEAR_CALLED(ReportProgress_COOKIE_SENT
);
572 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
|| tested_protocol
== FTP_TEST
) {
574 CLEAR_CALLED(ReportProgress_FINDINGRESOURCE
);
575 CLEAR_CALLED(ReportProgress_PROXYDETECTING
);
577 CLEAR_CALLED(ReportProgress_CONNECTING
);
579 if(tested_protocol
== FTP_TEST
)
580 todo_wine
CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
581 else if (tested_protocol
!= HTTPS_TEST
)
582 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
584 CHECK_CALLED(ReportProgress_REDIRECTING
);
585 state
= test_async_req
? STATE_SENDINGREQUEST
: STATE_STARTDOWNLOADING
;
589 case STATE_SENDINGREQUEST
:
590 SET_EXPECT(Stream_Read
);
591 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
593 case STATE_STARTDOWNLOADING
:
594 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
595 SET_EXPECT(OnResponse
);
596 if(tested_protocol
== HTTPS_TEST
|| test_redirect
|| test_abort
|| empty_file
)
597 SET_EXPECT(ReportProgress_ACCEPTRANGES
);
598 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
599 if(bindf
& BINDF_NEEDFILE
)
600 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
606 if(state
!= STATE_SENDINGREQUEST
)
607 SET_EXPECT(ReportData
);
608 hres
= IInternetProtocol_Continue(async_protocol
, protocol_data
);
609 ok(hres
== S_OK
, "Continue failed: %08x\n", hres
);
610 if(tested_protocol
== FTP_TEST
|| security_problem
)
611 CLEAR_CALLED(ReportData
);
612 else if(state
!= STATE_SENDINGREQUEST
)
613 CHECK_CALLED(ReportData
);
616 case STATE_SENDINGREQUEST
:
617 CHECK_CALLED(Stream_Read
);
618 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
619 state
= STATE_STARTDOWNLOADING
;
621 case STATE_STARTDOWNLOADING
:
622 if (! security_problem
)
624 state
= STATE_DOWNLOADING
;
625 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
626 CHECK_CALLED(OnResponse
);
627 if(tested_protocol
== HTTPS_TEST
|| empty_file
)
628 CHECK_CALLED(ReportProgress_ACCEPTRANGES
);
629 else if(test_redirect
|| test_abort
)
630 CLEAR_CALLED(ReportProgress_ACCEPTRANGES
);
631 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
632 if(bindf
& BINDF_NEEDFILE
)
633 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
638 security_problem
= FALSE
;
639 SET_EXPECT(ReportProgress_CONNECTING
);
646 static HRESULT WINAPI
ProtocolSink_Switch(IInternetProtocolSink
*iface
, PROTOCOLDATA
*pProtocolData
)
648 if(tested_protocol
== FTP_TEST
)
649 CHECK_EXPECT2(Switch
);
651 CHECK_EXPECT(Switch
);
653 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
655 ok(pProtocolData
!= &protocoldata
, "pProtocolData == &protocoldata\n");
656 ok(pProtocolData
->grfFlags
== protocoldata
.grfFlags
, "grfFlags wrong %x/%x\n",
657 pProtocolData
->grfFlags
, protocoldata
.grfFlags
);
658 ok(pProtocolData
->dwState
== protocoldata
.dwState
, "dwState wrong %x/%x\n",
659 pProtocolData
->dwState
, protocoldata
.dwState
);
660 ok(pProtocolData
->pData
== protocoldata
.pData
, "pData wrong %p/%p\n",
661 pProtocolData
->pData
, protocoldata
.pData
);
662 ok(pProtocolData
->cbData
== protocoldata
.cbData
, "cbData wrong %x/%x\n",
663 pProtocolData
->cbData
, protocoldata
.cbData
);
666 pdata
= pProtocolData
;
669 SetEvent(event_complete
);
670 WaitForSingleObject(event_complete2
, INFINITE
);
673 continue_protdata
= *pProtocolData
;
674 SetEvent(event_continue
);
675 WaitForSingleObject(event_continue_done
, INFINITE
);
677 call_continue(pProtocolData
);
678 SetEvent(event_complete
);
684 static HRESULT WINAPI
ProtocolSink_ReportProgress(IInternetProtocolSink
*iface
, ULONG ulStatusCode
,
685 LPCWSTR szStatusText
)
687 static const WCHAR null_guid
[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-',
688 '0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}',0};
689 static const WCHAR text_plain
[] = {'t','e','x','t','/','p','l','a','i','n',0};
691 switch(ulStatusCode
) {
692 case BINDSTATUS_MIMETYPEAVAILABLE
:
693 CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
694 if(tested_protocol
!= FILE_TEST
&& tested_protocol
!= ITS_TEST
&& !mimefilter_test
&& (pi
& PI_MIMEVERIFICATION
)) {
695 if(!short_read
|| !direct_read
)
696 CHECK_CALLED(Read
); /* set in Continue */
698 CHECK_CALLED(Read2
); /* set in Read */
700 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
702 if(tested_protocol
== BIND_TEST
)
703 ok(!lstrcmpW(szStatusText
, expect_wsz
), "unexpected szStatusText %s\n", wine_dbgstr_w(szStatusText
));
704 else if (http_post_test
)
705 ok(lstrlenW(text_plain
) <= lstrlenW(szStatusText
) &&
706 !memcmp(szStatusText
, text_plain
, lstrlenW(text_plain
)*sizeof(WCHAR
)),
707 "szStatusText != text/plain\n");
709 ok(!strcmp_wa(szStatusText
, "application/javascript"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
710 else if(!mimefilter_test
)
711 ok(lstrlenW(text_htmlW
) <= lstrlenW(szStatusText
) &&
712 !memcmp(szStatusText
, text_htmlW
, lstrlenW(text_htmlW
)*sizeof(WCHAR
)),
713 "szStatusText != text/html\n");
716 case BINDSTATUS_DIRECTBIND
:
717 CHECK_EXPECT2(ReportProgress_DIRECTBIND
);
718 ok(szStatusText
== NULL
, "szStatusText != NULL\n");
720 case BINDSTATUS_RAWMIMETYPE
:
721 CHECK_EXPECT2(ReportProgress_RAWMIMETYPE
);
722 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
724 ok(lstrlenW(szStatusText
) < lstrlenW(text_htmlW
) ||
725 !memcmp(szStatusText
, text_htmlW
, lstrlenW(text_htmlW
)*sizeof(WCHAR
)),
726 "szStatusText != text/html\n");
728 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
729 CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
730 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
733 ok(!lstrcmpW(szStatusText
, expect_wsz
), "unexpected szStatusText\n");
734 else if(tested_protocol
== FILE_TEST
)
735 ok(!lstrcmpW(szStatusText
, file_name
), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
737 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
740 case BINDSTATUS_FINDINGRESOURCE
:
741 CHECK_EXPECT2(ReportProgress_FINDINGRESOURCE
);
742 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
744 case BINDSTATUS_CONNECTING
:
745 CHECK_EXPECT2(ReportProgress_CONNECTING
);
746 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
748 case BINDSTATUS_SENDINGREQUEST
:
749 CHECK_EXPECT2(ReportProgress_SENDINGREQUEST
);
750 if(tested_protocol
== FILE_TEST
|| tested_protocol
== ITS_TEST
) {
751 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
753 ok(!*szStatusText
, "wrong szStatusText\n");
756 case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
:
757 CHECK_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
758 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
760 ok(!strcmp_wa(szStatusText
, "text/html"), "szStatusText != text/html\n");
762 case BINDSTATUS_PROTOCOLCLASSID
:
763 CHECK_EXPECT(ReportProgress_PROTOCOLCLASSID
);
764 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
765 ok(!lstrcmpW(szStatusText
, null_guid
), "unexpected classid %s\n", wine_dbgstr_w(szStatusText
));
767 case BINDSTATUS_COOKIE_SENT
:
768 CHECK_EXPECT(ReportProgress_COOKIE_SENT
);
769 ok(szStatusText
== NULL
, "szStatusText != NULL\n");
771 case BINDSTATUS_REDIRECTING
:
772 CHECK_EXPECT(ReportProgress_REDIRECTING
);
774 ok(!strcmp_wa(szStatusText
, "http://test.winehq.org/tests/hello.html"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
776 ok(szStatusText
== NULL
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
778 case BINDSTATUS_ENCODING
:
779 CHECK_EXPECT(ReportProgress_ENCODING
);
780 ok(!strcmp_wa(szStatusText
, "gzip"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
782 case BINDSTATUS_ACCEPTRANGES
:
783 CHECK_EXPECT(ReportProgress_ACCEPTRANGES
);
784 ok(!szStatusText
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
786 case BINDSTATUS_PROXYDETECTING
:
787 if(!called_ReportProgress_PROXYDETECTING
)
788 SET_EXPECT(ReportProgress_CONNECTING
);
789 CHECK_EXPECT2(ReportProgress_PROXYDETECTING
);
790 ok(!szStatusText
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
792 case BINDSTATUS_LOADINGMIMEHANDLER
:
793 CHECK_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
794 ok(!szStatusText
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
796 case BINDSTATUS_DECODING
:
797 CHECK_EXPECT(ReportProgress_DECODING
);
798 ok(!lstrcmpW(szStatusText
, gzipW
), "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
801 ok(0, "Unexpected status %d\n", ulStatusCode
);
807 static HRESULT WINAPI
ProtocolSink_ReportData(IInternetProtocolSink
*iface
, DWORD grfBSCF
,
808 ULONG ulProgress
, ULONG ulProgressMax
)
812 static int rec_depth
;
815 if(!mimefilter_test
&& (tested_protocol
== FILE_TEST
|| tested_protocol
== ITS_TEST
)) {
816 CHECK_EXPECT2(ReportData
);
818 ok(ulProgress
== ulProgressMax
, "ulProgress (%d) != ulProgressMax (%d)\n",
819 ulProgress
, ulProgressMax
);
820 ok(ulProgressMax
== 13, "ulProgressMax=%d, expected 13\n", ulProgressMax
);
821 /* BSCF_SKIPDRAINDATAFORFILEURLS added in IE8 */
822 if(tested_protocol
== FILE_TEST
)
823 ok((grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
)) ||
824 (grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
| BSCF_SKIPDRAINDATAFORFILEURLS
)),
825 "grcfBSCF = %08x\n", grfBSCF
);
827 ok(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
| BSCF_DATAFULLYAVAILABLE
), "grcfBSCF = %08x\n", grfBSCF
);
828 }else if(direct_read
) {
832 if(!read_report_data
&& rec_depth
== 1) {
833 BOOL reported_all_data
= called_ReportData2
;
835 CHECK_EXPECT2(ReportData
);
838 ok(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
|BSCF_LASTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
)
839 || grfBSCF
== BSCF_FIRSTDATANOTIFICATION
, /* < IE8 */
840 "grcfBSCF = %08x\n", grfBSCF
);
841 CHECK_CALLED(Read
); /* Set in Continue */
842 first_data_notif
= FALSE
;
843 }else if(first_data_notif
) {
844 ok(grfBSCF
== BSCF_FIRSTDATANOTIFICATION
, "grcfBSCF = %08x\n", grfBSCF
);
845 first_data_notif
= FALSE
;
846 }else if(reported_all_data
) {
847 ok(grfBSCF
== (BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
),
848 "grcfBSCF = %08x\n", grfBSCF
);
849 }else if(!direct_read
) {
850 ok(grfBSCF
== BSCF_INTERMEDIATEDATANOTIFICATION
, "grcfBSCF = %08x\n", grfBSCF
);
858 SET_EXPECT(ReportData2
);
859 SET_EXPECT(ReportResult
);
862 hres
= IInternetProtocol_Read(binding_test
? binding_protocol
: async_protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
863 ok(hres
== E_PENDING
|| hres
== S_FALSE
|| hres
== S_OK
, "Read failed: %08x\n", hres
);
865 ok(read
, "read == 0\n");
866 if(reported_all_data
)
867 ok(hres
== S_FALSE
, "Read failed: %08x, expected S_FALSE\n", hres
);
868 if(!emulate_prot
&& hres
!= E_PENDING
)
869 CHECK_NOT_CALLED(Switch
); /* otherwise checked in wait_for_switch loop */
872 if(!reported_all_data
&& called_ReportData2
) {
874 CHECK_CALLED(ReportData2
);
875 CHECK_CALLED(ReportResult
);
876 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
877 reported_all_data
= TRUE
;
880 CHECK_NOT_CALLED(ReportData2
);
881 CHECK_NOT_CALLED(ReportResult
);
883 }while(hres
== S_OK
);
885 wait_for_switch
= FALSE
;
887 CHECK_EXPECT(ReportData2
);
889 ok(grfBSCF
& BSCF_LASTDATANOTIFICATION
, "grfBSCF = %08x\n", grfBSCF
);
894 hres
= IInternetProtocol_Read(binding_test
? binding_protocol
: async_protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
897 ok(hres
== S_FALSE
, "Read returned: %08x, expected E_FALSE\n", hres
);
898 ok(!read
, "read = %d\n", read
);
900 }else if(!binding_test
&& (tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
901 || tested_protocol
== FTP_TEST
)) {
903 CHECK_EXPECT2(ReportData
);
904 else if(!(grfBSCF
& BSCF_LASTDATANOTIFICATION
) || (grfBSCF
& BSCF_DATAFULLYAVAILABLE
))
905 CHECK_EXPECT(ReportData
);
906 else if (http_post_test
)
907 ok(ulProgress
== 13, "Read %u bytes instead of 13\n", ulProgress
);
910 ok(!ulProgress
, "ulProgress = %d\n", ulProgress
);
911 ok(!ulProgressMax
, "ulProgressMax = %d\n", ulProgressMax
);
913 ok(ulProgress
, "ulProgress == 0\n");
917 ok(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
|BSCF_LASTDATANOTIFICATION
),
918 "grcfBSCF = %08x\n", grfBSCF
);
919 first_data_notif
= FALSE
;
920 }else if(first_data_notif
) {
921 ok(grfBSCF
== BSCF_FIRSTDATANOTIFICATION
922 || grfBSCF
== (BSCF_LASTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
),
923 "grcfBSCF = %08x\n", grfBSCF
);
924 first_data_notif
= FALSE
;
926 ok(grfBSCF
== BSCF_INTERMEDIATEDATANOTIFICATION
927 || grfBSCF
== (BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
)
928 || broken(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
|BSCF_LASTDATANOTIFICATION
)),
929 "grcfBSCF = %08x\n", grfBSCF
);
932 if(!(bindf
& BINDF_FROMURLMON
) &&
933 !(grfBSCF
& BSCF_LASTDATANOTIFICATION
)) {
934 if(state
== STATE_CONNECTING
) {
935 state
= STATE_DOWNLOADING
;
937 CHECK_CALLED(ReportProgress_FINDINGRESOURCE
);
938 CHECK_CALLED(ReportProgress_CONNECTING
);
940 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
941 CHECK_CALLED(OnResponse
);
942 CHECK_CALLED(ReportProgress_RAWMIMETYPE
);
944 SetEvent(event_complete
);
946 }else if(!read_report_data
) {
951 CHECK_EXPECT(ReportData
);
953 if(tested_protocol
!= BIND_TEST
) {
956 SET_EXPECT(MimeFilter_Read
);
957 else if(rec_depth
> 1)
961 hres
= IInternetProtocol_Read(binding_protocol
, expect_pv
=buf
, sizeof(buf
), &read
);
963 CHECK_CALLED(MimeFilter_Read
);
964 else if(rec_depth
> 1)
968 }while(hres
== S_OK
);
976 static HRESULT WINAPI
ProtocolSink_ReportResult(IInternetProtocolSink
*iface
, HRESULT hrResult
,
977 DWORD dwError
, LPCWSTR szResult
)
979 CHECK_EXPECT(ReportResult
);
981 if(tested_protocol
== FTP_TEST
)
982 ok(hrResult
== E_PENDING
|| hrResult
== S_OK
, "hrResult = %08x, expected E_PENDING or S_OK\n", hrResult
);
984 ok(hrResult
== expect_hrResult
, "hrResult = %08x, expected: %08x\n",
985 hrResult
, expect_hrResult
);
986 if(SUCCEEDED(hrResult
) || tested_protocol
== FTP_TEST
|| test_abort
)
987 ok(dwError
== ERROR_SUCCESS
, "dwError = %d, expected ERROR_SUCCESS\n", dwError
);
989 ok(dwError
!= ERROR_SUCCESS
||
990 broken(tested_protocol
== MK_TEST
), /* WinME and NT4 */
991 "dwError == ERROR_SUCCESS\n");
992 ok(!szResult
, "szResult != NULL\n");
995 SET_EXPECT(ReportData
); /* checked after main loop */
1000 static IInternetProtocolSinkVtbl protocol_sink_vtbl
= {
1001 ProtocolSink_QueryInterface
,
1002 ProtocolSink_AddRef
,
1003 ProtocolSink_Release
,
1004 ProtocolSink_Switch
,
1005 ProtocolSink_ReportProgress
,
1006 ProtocolSink_ReportData
,
1007 ProtocolSink_ReportResult
1010 static IInternetProtocolSink protocol_sink
= { &protocol_sink_vtbl
};
1012 static HRESULT WINAPI
MimeProtocolSink_QueryInterface(IInternetProtocolSink
*iface
, REFIID riid
, void **ppv
)
1014 ok(0, "unexpected call\n");
1018 static ULONG WINAPI
MimeProtocolSink_AddRef(IInternetProtocolSink
*iface
)
1023 static ULONG WINAPI
MimeProtocolSink_Release(IInternetProtocolSink
*iface
)
1028 static HRESULT WINAPI
MimeProtocolSink_Switch(IInternetProtocolSink
*iface
, PROTOCOLDATA
*pProtocolData
)
1032 CHECK_EXPECT(MimeFilter_Switch
);
1035 hres
= IInternetProtocolSink_Switch(filtered_sink
, pProtocolData
);
1036 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1037 CHECK_CALLED(Switch
);
1042 static HRESULT WINAPI
MimeProtocolSink_ReportProgress(IInternetProtocolSink
*iface
, ULONG ulStatusCode
,
1043 LPCWSTR szStatusText
)
1045 switch(ulStatusCode
) {
1046 case BINDSTATUS_LOADINGMIMEHANDLER
:
1048 * IE9 for some reason (bug?) calls this on mime handler's protocol sink instead of the
1049 * main protocol sink. We check ReportProgress_LOADINGMIMEHANDLER both here and in
1050 * ProtocolSink_ReportProgress to workaround it.
1052 CHECK_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
1053 ok(!szStatusText
, "szStatusText = %s\n", wine_dbgstr_w(szStatusText
));
1056 ok(0, "Unexpected status code %d\n", ulStatusCode
);
1062 static HRESULT WINAPI
MimeProtocolSink_ReportData(IInternetProtocolSink
*iface
, DWORD grfBSCF
,
1063 ULONG ulProgress
, ULONG ulProgressMax
)
1069 CHECK_EXPECT(MimeFilter_ReportData
);
1073 hres
= IInternetProtocol_Read(filtered_protocol
, buf
, sizeof(buf
), &read
);
1074 if(tested_protocol
== HTTP_TEST
)
1075 ok(hres
== S_OK
|| hres
== E_PENDING
|| hres
== S_FALSE
, "Read failed: %08x\n", hres
);
1077 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
1080 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1081 hres
= IInternetProtocolSink_ReportProgress(filtered_sink
, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
, text_htmlW
);
1082 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
1083 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1085 /* FIXME: test BINDSTATUS_CACHEFILENAMEAVAILABLE */
1088 if(!read_report_data
)
1089 SET_EXPECT(ReportData
);
1090 hres
= IInternetProtocolSink_ReportData(filtered_sink
, grfBSCF
, ulProgress
, ulProgressMax
);
1091 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1092 if(!read_report_data
)
1093 CHECK_CALLED(ReportData
);
1101 static HRESULT WINAPI
MimeProtocolSink_ReportResult(IInternetProtocolSink
*iface
, HRESULT hrResult
,
1102 DWORD dwError
, LPCWSTR szResult
)
1106 CHECK_EXPECT(MimeFilter_ReportResult
);
1108 ok(hrResult
== S_OK
, "hrResult = %08x\n", hrResult
);
1109 ok(dwError
== ERROR_SUCCESS
, "dwError = %u\n", dwError
);
1110 ok(!szResult
, "szResult = %s\n", wine_dbgstr_w(szResult
));
1112 SET_EXPECT(ReportResult
);
1113 hres
= IInternetProtocolSink_ReportResult(filtered_sink
, hrResult
, dwError
, szResult
);
1114 ok(SUCCEEDED(hres
), "ReportResult failed: %08x\n", hres
);
1115 CHECK_CALLED(ReportResult
);
1120 static IInternetProtocolSinkVtbl mime_protocol_sink_vtbl
= {
1121 MimeProtocolSink_QueryInterface
,
1122 MimeProtocolSink_AddRef
,
1123 MimeProtocolSink_Release
,
1124 MimeProtocolSink_Switch
,
1125 MimeProtocolSink_ReportProgress
,
1126 MimeProtocolSink_ReportData
,
1127 MimeProtocolSink_ReportResult
1130 static IInternetProtocolSink mime_protocol_sink
= { &mime_protocol_sink_vtbl
};
1132 static HRESULT
QueryInterface(REFIID riid
, void **ppv
)
1134 static const IID IID_undocumented
= {0x58DFC7D0,0x5381,0x43E5,{0x9D,0x72,0x4C,0xDD,0xE4,0xCB,0x0F,0x1A}};
1138 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocolSink
, riid
))
1139 *ppv
= &protocol_sink
;
1140 if(IsEqualGUID(&IID_IServiceProvider
, riid
))
1141 *ppv
= &service_provider
;
1142 if(IsEqualGUID(&IID_IUriContainer
, riid
))
1143 return E_NOINTERFACE
; /* TODO */
1145 /* NOTE: IE8 queries for undocumented {58DFC7D0-5381-43E5-9D72-4CDDE4CB0F1A} interface. */
1146 if(IsEqualGUID(&IID_undocumented
, riid
))
1147 return E_NOINTERFACE
;
1152 ok(0, "unexpected call %s\n", debugstr_guid(riid
));
1153 return E_NOINTERFACE
;
1156 static HRESULT WINAPI
BindInfo_QueryInterface(IInternetBindInfo
*iface
, REFIID riid
, void **ppv
)
1158 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
1162 return E_NOINTERFACE
;
1165 static ULONG WINAPI
BindInfo_AddRef(IInternetBindInfo
*iface
)
1170 static ULONG WINAPI
BindInfo_Release(IInternetBindInfo
*iface
)
1175 static HRESULT WINAPI
BindInfo_GetBindInfo(IInternetBindInfo
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
1179 CHECK_EXPECT(GetBindInfo
);
1181 ok(grfBINDF
!= NULL
, "grfBINDF == NULL\n");
1182 ok(pbindinfo
!= NULL
, "pbindinfo == NULL\n");
1183 ok(pbindinfo
->cbSize
== sizeof(BINDINFO
), "wrong size of pbindinfo: %d\n", pbindinfo
->cbSize
);
1187 *grfBINDF
|= BINDF_FROMURLMON
;
1188 cbSize
= pbindinfo
->cbSize
;
1189 memset(pbindinfo
, 0, cbSize
);
1190 pbindinfo
->cbSize
= cbSize
;
1194 pbindinfo
->cbstgmedData
= sizeof(post_data
)-1;
1195 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
1196 pbindinfo
->stgmedData
.tymed
= http_post_test
;
1198 if(http_post_test
== TYMED_HGLOBAL
) {
1201 /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly */
1202 data
= GlobalAlloc(GPTR
, sizeof(post_data
));
1203 memcpy(data
, post_data
, sizeof(post_data
));
1204 U(pbindinfo
->stgmedData
).hGlobal
= data
;
1206 IStream
*post_stream
;
1211 /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly */
1212 data
= GlobalAlloc(GPTR
, sizeof(post_data
));
1213 memcpy(data
, post_data
, sizeof(post_data
));
1214 U(pbindinfo
->stgmedData
).hGlobal
= data
;
1216 hres
= CreateStreamOnHGlobal(data
, FALSE
, &post_stream
);
1217 ok(hres
== S_OK
, "CreateStreamOnHGlobal failed: %08x\n", hres
);
1219 U(pbindinfo
->stgmedData
).pstm
=post_stream
;/* &Stream; */
1221 U(pbindinfo
->stgmedData
).pstm
= &Stream
;
1228 static HRESULT WINAPI
BindInfo_GetBindString(IInternetBindInfo
*iface
, ULONG ulStringType
,
1229 LPOLESTR
*ppwzStr
, ULONG cEl
, ULONG
*pcElFetched
)
1231 ok(ppwzStr
!= NULL
, "ppwzStr == NULL\n");
1232 ok(pcElFetched
!= NULL
, "pcElFetched == NULL\n");
1234 switch(ulStringType
) {
1235 case BINDSTRING_ACCEPT_MIMES
:
1236 CHECK_EXPECT(GetBindString_ACCEPT_MIMES
);
1237 ok(cEl
== 256, "cEl=%d, expected 256\n", cEl
);
1239 ok(*pcElFetched
== 256, "*pcElFetched=%d, expected 256\n", *pcElFetched
);
1243 *ppwzStr
= CoTaskMemAlloc(sizeof(acc_mimeW
));
1244 memcpy(*ppwzStr
, acc_mimeW
, sizeof(acc_mimeW
));
1247 case BINDSTRING_USER_AGENT
:
1248 CHECK_EXPECT(GetBindString_USER_AGENT
);
1249 ok(cEl
== 1, "cEl=%d, expected 1\n", cEl
);
1251 ok(*pcElFetched
== 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched
);
1255 *ppwzStr
= CoTaskMemAlloc(sizeof(user_agentW
));
1256 memcpy(*ppwzStr
, user_agentW
, sizeof(user_agentW
));
1259 case BINDSTRING_POST_COOKIE
:
1260 CHECK_EXPECT(GetBindString_POST_COOKIE
);
1261 ok(cEl
== 1, "cEl=%d, expected 1\n", cEl
);
1263 ok(*pcElFetched
== 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched
);
1265 case BINDSTRING_URL
: {
1268 CHECK_EXPECT(GetBindString_URL
);
1269 ok(cEl
== 1, "cEl=%d, expected 1\n", cEl
);
1270 ok(*pcElFetched
== 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched
);
1273 size
= (lstrlenW(binding_urls
[tested_protocol
])+1)*sizeof(WCHAR
);
1274 *ppwzStr
= CoTaskMemAlloc(size
);
1275 memcpy(*ppwzStr
, binding_urls
[tested_protocol
], size
);
1279 ok(0, "unexpected call\n");
1285 static IInternetBindInfoVtbl bind_info_vtbl
= {
1286 BindInfo_QueryInterface
,
1289 BindInfo_GetBindInfo
,
1290 BindInfo_GetBindString
1293 static IInternetBindInfo bind_info
= { &bind_info_vtbl
};
1295 static HRESULT WINAPI
InternetPriority_QueryInterface(IInternetPriority
*iface
,
1296 REFIID riid
, void **ppv
)
1298 ok(0, "unexpected call\n");
1299 return E_NOINTERFACE
;
1302 static ULONG WINAPI
InternetPriority_AddRef(IInternetPriority
*iface
)
1307 static ULONG WINAPI
InternetPriority_Release(IInternetPriority
*iface
)
1312 static HRESULT WINAPI
InternetPriority_SetPriority(IInternetPriority
*iface
, LONG nPriority
)
1314 CHECK_EXPECT(SetPriority
);
1315 ok(nPriority
== ex_priority
, "nPriority=%d\n", nPriority
);
1319 static HRESULT WINAPI
InternetPriority_GetPriority(IInternetPriority
*iface
, LONG
*pnPriority
)
1321 ok(0, "unexpected call\n");
1326 static const IInternetPriorityVtbl InternetPriorityVtbl
= {
1327 InternetPriority_QueryInterface
,
1328 InternetPriority_AddRef
,
1329 InternetPriority_Release
,
1330 InternetPriority_SetPriority
,
1331 InternetPriority_GetPriority
1334 static IInternetPriority InternetPriority
= { &InternetPriorityVtbl
};
1336 static ULONG WINAPI
Protocol_AddRef(IInternetProtocolEx
*iface
)
1341 static ULONG WINAPI
Protocol_Release(IInternetProtocolEx
*iface
)
1346 static HRESULT WINAPI
Protocol_Abort(IInternetProtocolEx
*iface
, HRESULT hrReason
,
1351 CHECK_EXPECT(Abort
);
1353 SET_EXPECT(ReportResult
);
1354 hres
= IInternetProtocolSink_ReportResult(binding_sink
, S_OK
, ERROR_SUCCESS
, NULL
);
1355 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1356 CHECK_CALLED(ReportResult
);
1361 static HRESULT WINAPI
Protocol_Suspend(IInternetProtocolEx
*iface
)
1363 ok(0, "unexpected call\n");
1367 static HRESULT WINAPI
Protocol_Resume(IInternetProtocolEx
*iface
)
1369 ok(0, "unexpected call\n");
1373 static HRESULT WINAPI
Protocol_Seek(IInternetProtocolEx
*iface
,
1374 LARGE_INTEGER dlibMove
, DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
1376 ok(0, "unexpected call\n");
1380 static HRESULT WINAPI
ProtocolEmul_QueryInterface(IInternetProtocolEx
*iface
, REFIID riid
, void **ppv
)
1382 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
1387 if(IsEqualGUID(&IID_IInternetProtocolEx
, riid
)) {
1393 return E_NOINTERFACE
;
1396 if(IsEqualGUID(&IID_IInternetPriority
, riid
)) {
1397 *ppv
= &InternetPriority
;
1401 if(IsEqualGUID(&IID_IWinInetInfo
, riid
)) {
1402 CHECK_EXPECT(QueryInterface_IWinInetInfo
);
1404 return E_NOINTERFACE
;
1407 if(IsEqualGUID(&IID_IWinInetHttpInfo
, riid
)) {
1408 CHECK_EXPECT(QueryInterface_IWinInetHttpInfo
);
1410 return E_NOINTERFACE
;
1413 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1415 return E_NOINTERFACE
;
1418 static DWORD WINAPI
thread_proc(PVOID arg
)
1422 memset(&protocoldata
, -1, sizeof(protocoldata
));
1426 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
1427 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1428 BINDSTATUS_FINDINGRESOURCE
, hostW
);
1429 CHECK_CALLED(ReportProgress_FINDINGRESOURCE
);
1430 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
1432 SET_EXPECT(ReportProgress_CONNECTING
);
1433 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1434 BINDSTATUS_CONNECTING
, winehq_ipW
);
1435 CHECK_CALLED(ReportProgress_CONNECTING
);
1436 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
1438 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1439 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1440 BINDSTATUS_SENDINGREQUEST
, NULL
);
1441 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
1442 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
1446 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
1447 CHECK_CALLED(Switch
);
1448 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1453 SET_EXPECT(MimeFilter_Switch
);
1456 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
1457 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1459 CHECK_CALLED(MimeFilter_Switch
);
1461 CHECK_CALLED(Switch
);
1464 SetEvent(event_complete
);
1470 SET_EXPECT(MimeFilter_Switch
);
1473 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
1474 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1476 CHECK_CALLED(MimeFilter_Switch
);
1478 CHECK_CALLED(Switch
);
1482 SET_EXPECT(MimeFilter_Switch
);
1485 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
1486 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
1488 CHECK_CALLED(MimeFilter_Switch
);
1490 CHECK_CALLED(Switch
);
1493 SetEvent(event_complete
);
1498 static void protocol_start(IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
, DWORD pi
)
1500 BINDINFO bindinfo
, exp_bindinfo
;
1504 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
1505 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
1506 ok(pOIProtSink
!= &protocol_sink
, "unexpected pOIProtSink\n");
1507 ok(pOIBindInfo
!= &bind_info
, "unexpected pOIBindInfo\n");
1508 ok(!pi
, "pi = %x\n", pi
);
1511 ok(pOIProtSink
== binding_sink
, "pOIProtSink != binding_sink\n");
1513 memset(&bindinfo
, 0, sizeof(bindinfo
));
1514 bindinfo
.cbSize
= sizeof(bindinfo
);
1515 memcpy(&exp_bindinfo
, &bindinfo
, sizeof(bindinfo
));
1516 SET_EXPECT(GetBindInfo
);
1517 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &cbindf
, &bindinfo
);
1518 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
1519 CHECK_CALLED(GetBindInfo
);
1520 ok(cbindf
== (bindf
|BINDF_FROMURLMON
), "bindf = %x, expected %x\n",
1521 cbindf
, (bindf
|BINDF_FROMURLMON
));
1522 ok(!memcmp(&exp_bindinfo
, &bindinfo
, sizeof(bindinfo
)), "unexpected bindinfo\n");
1523 pReleaseBindInfo(&bindinfo
);
1525 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
1526 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_SENDINGREQUEST
, emptyW
);
1527 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
1528 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
1530 if(tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
) {
1531 IServiceProvider
*service_provider
;
1532 IHttpNegotiate
*http_negotiate
;
1533 IHttpNegotiate2
*http_negotiate2
;
1534 LPWSTR ua
= (LPWSTR
)0xdeadbeef, accept_mimes
[256];
1535 LPWSTR additional_headers
= NULL
;
1537 DWORD fetched
= 0, size
= 100;
1540 SET_EXPECT(GetBindString_USER_AGENT
);
1541 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_USER_AGENT
,
1543 CHECK_CALLED(GetBindString_USER_AGENT
);
1544 ok(hres
== S_OK
, "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres
);
1545 ok(fetched
== 1, "fetched = %d, expected 254\n", fetched
);
1546 ok(ua
!= NULL
, "ua = %p\n", ua
);
1547 ok(!lstrcmpW(ua
, user_agentW
), "unexpected user agent %s\n", wine_dbgstr_w(ua
));
1551 SET_EXPECT(GetBindString_ACCEPT_MIMES
);
1552 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
1553 accept_mimes
, 256, &fetched
);
1554 CHECK_CALLED(GetBindString_ACCEPT_MIMES
);
1557 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
1558 ok(fetched
== 1, "fetched = %d, expected 1\n", fetched
);
1559 ok(!lstrcmpW(acc_mimeW
, accept_mimes
[0]), "unexpected mimes %s\n", wine_dbgstr_w(accept_mimes
[0]));
1560 CoTaskMemFree(accept_mimes
[0]);
1562 hres
= IInternetBindInfo_QueryInterface(pOIBindInfo
, &IID_IServiceProvider
,
1563 (void**)&service_provider
);
1564 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
1566 SET_EXPECT(QueryService_HttpNegotiate
);
1567 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
1568 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
1569 CHECK_CALLED(QueryService_HttpNegotiate
);
1570 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1572 SET_EXPECT(BeginningTransaction
);
1573 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, binding_urls
[tested_protocol
],
1574 NULL
, 0, &additional_headers
);
1575 CHECK_CALLED(BeginningTransaction
);
1576 IHttpNegotiate_Release(http_negotiate
);
1577 ok(hres
== S_OK
, "BeginningTransction failed: %08x\n", hres
);
1578 ok(additional_headers
== NULL
, "additional_headers=%p\n", additional_headers
);
1580 SET_EXPECT(QueryService_HttpNegotiate
);
1581 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate2
,
1582 &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
1583 CHECK_CALLED(QueryService_HttpNegotiate
);
1584 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1587 SET_EXPECT(GetRootSecurityId
);
1588 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, sec_id
, &size
, 0);
1589 CHECK_CALLED(GetRootSecurityId
);
1590 IHttpNegotiate2_Release(http_negotiate2
);
1591 ok(hres
== E_FAIL
, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres
);
1592 ok(size
== 13, "size=%d\n", size
);
1594 IServiceProvider_Release(service_provider
);
1596 CreateThread(NULL
, 0, thread_proc
, NULL
, 0, &tid
);
1600 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
1601 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
1602 BINDSTATUS_CACHEFILENAMEAVAILABLE
, expect_wsz
= emptyW
);
1603 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
1604 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
1606 if(mimefilter_test
) {
1607 SET_EXPECT(MimeFilter_CreateInstance
);
1608 SET_EXPECT(MimeFilter_Start
);
1609 SET_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
1611 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1612 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
,
1613 mimefilter_test
? gzipW
: (expect_wsz
= text_htmlW
));
1615 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres
);
1616 if(mimefilter_test
) {
1617 CHECK_CALLED(MimeFilter_CreateInstance
);
1618 CHECK_CALLED(MimeFilter_Start
);
1619 CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER
);
1620 todo_wine
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1622 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1626 SET_EXPECT(MimeFilter_ReportData
);
1628 SET_EXPECT(ReportData
);
1629 hres
= IInternetProtocolSink_ReportData(pOIProtSink
,
1630 BSCF_FIRSTDATANOTIFICATION
| (tested_protocol
== ITS_TEST
? BSCF_DATAFULLYAVAILABLE
: BSCF_LASTDATANOTIFICATION
),
1632 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1634 CHECK_CALLED(MimeFilter_ReportData
);
1636 CHECK_CALLED(ReportData
);
1638 if(tested_protocol
== ITS_TEST
) {
1639 SET_EXPECT(ReportData
);
1640 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_BEGINDOWNLOADDATA
, NULL
);
1641 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres
);
1642 CHECK_CALLED(ReportData
);
1645 if(tested_protocol
== BIND_TEST
) {
1646 hres
= IInternetProtocol_Terminate(binding_protocol
, 0);
1647 ok(hres
== E_FAIL
, "Termiante failed: %08x\n", hres
);
1651 SET_EXPECT(MimeFilter_ReportResult
);
1653 SET_EXPECT(ReportResult
);
1654 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, S_OK
, 0, NULL
);
1655 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1657 CHECK_CALLED(MimeFilter_ReportResult
);
1659 CHECK_CALLED(ReportResult
);
1662 static HRESULT WINAPI
ProtocolEmul_Start(IInternetProtocolEx
*iface
, LPCWSTR szUrl
,
1663 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
1664 DWORD grfPI
, HANDLE_PTR dwReserved
)
1666 CHECK_EXPECT(Start
);
1668 ok(!dwReserved
, "dwReserved = %lx\n", dwReserved
);
1669 protocol_start(pOIProtSink
, pOIBindInfo
, grfPI
);
1673 static HRESULT WINAPI
ProtocolEmul_Continue(IInternetProtocolEx
*iface
,
1674 PROTOCOLDATA
*pProtocolData
)
1679 CHECK_EXPECT(Continue
);
1681 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
1682 if(!pProtocolData
|| tested_protocol
== BIND_TEST
)
1685 ok(pProtocolData
!= &protocoldata
, "pProtocolData == &protocoldata\n");
1686 ok(pProtocolData
->grfFlags
== protocoldata
.grfFlags
, "grfFlags wrong %x/%x\n",
1687 pProtocolData
->grfFlags
, protocoldata
.grfFlags
);
1688 ok(pProtocolData
->dwState
== protocoldata
.dwState
, "dwState wrong %x/%x\n",
1689 pProtocolData
->dwState
, protocoldata
.dwState
);
1690 ok(pProtocolData
->pData
== protocoldata
.pData
, "pData wrong %p/%p\n",
1691 pProtocolData
->pData
, protocoldata
.pData
);
1692 ok(pProtocolData
->cbData
== protocoldata
.cbData
, "cbData wrong %x/%x\n",
1693 pProtocolData
->cbData
, protocoldata
.cbData
);
1696 switch(prot_state
) {
1698 IServiceProvider
*service_provider
;
1699 IHttpNegotiate
*http_negotiate
;
1700 static WCHAR header
[] = {'?',0};
1702 hres
= IInternetProtocolSink_QueryInterface(binding_sink
, &IID_IServiceProvider
,
1703 (void**)&service_provider
);
1704 ok(hres
== S_OK
, "Could not get IServiceProvicder\n");
1706 SET_EXPECT(QueryService_HttpNegotiate
);
1707 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
1708 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
1709 IServiceProvider_Release(service_provider
);
1710 CHECK_CALLED(QueryService_HttpNegotiate
);
1711 ok(hres
== S_OK
, "Could not get IHttpNegotiate\n");
1713 SET_EXPECT(OnResponse
);
1714 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, header
, NULL
, NULL
);
1715 IHttpNegotiate_Release(http_negotiate
);
1716 CHECK_CALLED(OnResponse
);
1717 IHttpNegotiate_Release(http_negotiate
);
1718 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
1720 if(mimefilter_test
) {
1721 SET_EXPECT(MimeFilter_CreateInstance
);
1722 SET_EXPECT(MimeFilter_Start
);
1723 SET_EXPECT(ReportProgress_LOADINGMIMEHANDLER
);
1724 }else if(!(pi
& PI_MIMEVERIFICATION
)) {
1725 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1727 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
1728 BINDSTATUS_MIMETYPEAVAILABLE
, mimefilter_test
? gzipW
: text_htmlW
);
1729 if(mimefilter_test
) {
1730 CHECK_CALLED(MimeFilter_CreateInstance
);
1731 CHECK_CALLED(MimeFilter_Start
);
1732 CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER
);
1733 }else if(!(pi
& PI_MIMEVERIFICATION
)) {
1734 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1737 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
1739 bscf
|= BSCF_FIRSTDATANOTIFICATION
;
1744 bscf
= BSCF_INTERMEDIATEDATANOTIFICATION
;
1749 if(mimefilter_test
) {
1750 SET_EXPECT(MimeFilter_ReportData
);
1751 }else if(pi
& PI_MIMEVERIFICATION
) {
1753 SET_EXPECT(Read
); /* checked in ReportData for short_read */
1755 if(!mimefilter_test
)
1756 SET_EXPECT(Read
); /* checked in BINDSTATUS_MIMETYPEAVAILABLE or ReportData */
1757 SET_EXPECT(GetBindInfo
);
1758 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1761 SET_EXPECT(ReportData
);
1763 SET_EXPECT(ReportData
);
1766 hres
= IInternetProtocolSink_ReportData(binding_sink
, bscf
, pr
, 400);
1767 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1769 if(mimefilter_test
) {
1770 SET_EXPECT(MimeFilter_ReportData
);
1771 }else if(pi
& PI_MIMEVERIFICATION
) {
1772 if(!short_read
&& pr
< 200)
1775 CLEAR_CALLED(GetBindInfo
); /* IE9 */
1776 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1779 CHECK_CALLED(ReportData
);
1788 static HRESULT WINAPI
ProtocolEmul_Terminate(IInternetProtocolEx
*iface
, DWORD dwOptions
)
1790 CHECK_EXPECT(Terminate
);
1791 ok(!dwOptions
, "dwOptions=%d\n", dwOptions
);
1795 static HRESULT WINAPI
ProtocolEmul_Read(IInternetProtocolEx
*iface
, void *pv
,
1796 ULONG cb
, ULONG
*pcbRead
)
1798 if(read_report_data
)
1799 CHECK_EXPECT2(Read2
);
1801 if(mimefilter_test
|| short_read
) {
1802 if(!read_report_data
)
1803 CHECK_EXPECT2(Read
);
1804 }else if((pi
& PI_MIMEVERIFICATION
)) {
1805 if(!read_report_data
)
1806 CHECK_EXPECT2(Read
);
1808 if(prot_read
< 300) {
1809 ok(pv
!= expect_pv
, "pv == expect_pv\n");
1811 ok(cb
== 2048-prot_read
, "cb=%d\n", cb
);
1813 ok(cb
== 700, "cb=%d\n", cb
);
1815 ok(expect_pv
<= pv
&& (BYTE
*)pv
< (BYTE
*)expect_pv
+ cb
, "pv != expect_pv\n");
1818 if(!read_report_data
)
1821 ok(pv
== expect_pv
, "pv != expect_pv\n");
1822 ok(cb
== 1000, "cb=%d\n", cb
);
1823 ok(!*pcbRead
, "*pcbRead = %d\n", *pcbRead
);
1825 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
1827 if(prot_state
== 3 || (short_read
&& prot_state
!= 4)) {
1832 SET_EXPECT(Read2
); /* checked in BINDSTATUS_MIMETYPEAVAILABLE */
1833 SET_EXPECT(GetBindInfo
);
1834 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
1837 SET_EXPECT(MimeFilter_ReportData
);
1838 else if(direct_read
)
1839 SET_EXPECT(ReportData2
);
1841 hres
= IInternetProtocolSink_ReportData(binding_sink
,
1842 BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
, 0, 0);
1844 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1846 CLEAR_CALLED(GetBindInfo
); /* IE9 */
1847 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
1850 CHECK_CALLED(MimeFilter_ReportData
);
1851 else if(direct_read
)
1852 CHECK_CALLED(ReportData2
);
1855 SET_EXPECT(MimeFilter_ReportResult
);
1857 SET_EXPECT(ReportResult
);
1858 hres
= IInternetProtocolSink_ReportResult(binding_sink
, S_OK
, ERROR_SUCCESS
, NULL
);
1859 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1861 CHECK_CALLED(MimeFilter_ReportResult
);
1863 CHECK_CALLED(ReportResult
);
1865 memset(pv
, 'x', 100);
1866 prot_read
+= *pcbRead
= 100;
1868 }if(prot_state
== 4) {
1873 if((async_read_pending
= !async_read_pending
)) {
1875 return tested_protocol
== HTTP_TEST
|| tested_protocol
== HTTPS_TEST
? E_PENDING
: S_FALSE
;
1878 memset(pv
, 'x', 100);
1879 prot_read
+= *pcbRead
= 100;
1883 static HRESULT WINAPI
ProtocolEmul_LockRequest(IInternetProtocolEx
*iface
, DWORD dwOptions
)
1885 CHECK_EXPECT(LockRequest
);
1886 ok(dwOptions
== 0, "dwOptions=%x\n", dwOptions
);
1890 static HRESULT WINAPI
ProtocolEmul_UnlockRequest(IInternetProtocolEx
*iface
)
1892 CHECK_EXPECT(UnlockRequest
);
1896 static HRESULT WINAPI
ProtocolEmul_StartEx(IInternetProtocolEx
*iface
, IUri
*pUri
,
1897 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
1898 DWORD grfPI
, HANDLE
*dwReserved
)
1900 CHECK_EXPECT(StartEx
);
1901 ok(!dwReserved
, "dwReserved = %p\n", dwReserved
);
1902 protocol_start(pOIProtSink
, pOIBindInfo
, grfPI
);
1906 static const IInternetProtocolExVtbl ProtocolVtbl
= {
1907 ProtocolEmul_QueryInterface
,
1911 ProtocolEmul_Continue
,
1913 ProtocolEmul_Terminate
,
1918 ProtocolEmul_LockRequest
,
1919 ProtocolEmul_UnlockRequest
,
1920 ProtocolEmul_StartEx
1923 static IInternetProtocolEx Protocol
= { &ProtocolVtbl
};
1925 static HRESULT WINAPI
MimeProtocol_QueryInterface(IInternetProtocolEx
*iface
, REFIID riid
, void **ppv
)
1927 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
1932 if(IsEqualGUID(&IID_IInternetProtocolSink
, riid
)) {
1933 *ppv
= &mime_protocol_sink
;
1937 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1939 return E_NOINTERFACE
;
1942 static HRESULT WINAPI
MimeProtocol_Start(IInternetProtocolEx
*iface
, LPCWSTR szUrl
,
1943 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
1944 DWORD grfPI
, HANDLE_PTR dwReserved
)
1946 PROTOCOLFILTERDATA
*data
;
1947 LPOLESTR url_str
= NULL
;
1953 CHECK_EXPECT(MimeFilter_Start
);
1955 ok(!lstrcmpW(szUrl
, gzipW
), "wrong url %s\n", wine_dbgstr_w(szUrl
));
1956 ok(grfPI
== (PI_FILTER_MODE
|PI_FORCE_ASYNC
), "grfPI=%x, expected PI_FILTER_MODE|PI_FORCE_ASYNC\n", grfPI
);
1957 ok(dwReserved
, "dwReserved == 0\n");
1958 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
1959 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
1962 ok(pOIProtSink
!= binding_sink
, "pOIProtSink == protocol_sink\n");
1963 ok(pOIBindInfo
== prot_bind_info
, "pOIBindInfo != bind_info\n");
1965 ok(pOIProtSink
== &protocol_sink
, "pOIProtSink != protocol_sink\n");
1966 ok(pOIBindInfo
== &bind_info
, "pOIBindInfo != bind_info\n");
1969 data
= (void*)dwReserved
;
1970 ok(data
->cbSize
== sizeof(*data
), "data->cbSize = %d\n", data
->cbSize
);
1971 ok(!data
->pProtocolSink
, "data->pProtocolSink != NULL\n");
1972 ok(data
->pProtocol
!= NULL
, "data->pProtocol == NULL\n");
1973 ok(!data
->pUnk
, "data->pUnk != NULL\n");
1974 ok(!data
->dwFilterFlags
, "data->dwProtocolFlags = %x\n", data
->dwFilterFlags
);
1976 IInternetProtocolSink
*prot_sink
;
1978 IInternetProtocol_QueryInterface(data
->pProtocol
, &IID_IInternetProtocolSink
, (void**)&prot_sink
);
1979 ok(prot_sink
== pOIProtSink
, "QI(data->pProtocol, IID_IInternetProtocolSink) != pOIProtSink\n");
1980 IInternetProtocolSink_Release(prot_sink
);
1982 ok(data
->pProtocol
!= binding_protocol
, "data->pProtocol == binding_protocol\n");
1984 filtered_protocol
= data
->pProtocol
;
1985 IInternetProtocol_AddRef(filtered_protocol
);
1987 IInternetProtocol
*prot
;
1989 IInternetProtocol_QueryInterface(data
->pProtocol
, &IID_IInternetProtocol
, (void**)&prot
);
1990 ok(prot
== async_protocol
, "QI(data->pProtocol, IID_IInternetProtocol) != async_protocol\n");
1991 IInternetProtocol_Release(prot
);
1993 ok(data
->pProtocol
!= async_protocol
, "data->pProtocol == async_protocol\n");
1996 filtered_sink
= pOIProtSink
;
1998 SET_EXPECT(ReportProgress_DECODING
);
1999 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_DECODING
, gzipW
);
2000 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_DECODING) failed: %08x\n", hres
);
2001 CHECK_CALLED(ReportProgress_DECODING
);
2003 SET_EXPECT(GetBindInfo
);
2004 memset(&bindinfo
, 0, sizeof(bindinfo
));
2005 bindinfo
.cbSize
= sizeof(bindinfo
);
2006 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &cbindf
, &bindinfo
);
2007 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
2008 ok(cbindf
== (bindf
|BINDF_FROMURLMON
), "cbindf = %x, expected %x\n", cbindf
, bindf
);
2009 CHECK_CALLED(GetBindInfo
);
2011 SET_EXPECT(GetBindString_URL
);
2012 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_URL
, &url_str
, 1, &fetched
);
2013 ok(hres
== S_OK
, "GetBindString(BINDSTRING_URL) failed: %08x\n", hres
);
2014 ok(fetched
== 1, "fetched = %d\n", fetched
);
2015 ok(!lstrcmpW(url_str
, binding_urls
[tested_protocol
]), "wrong url_str %s\n", wine_dbgstr_w(url_str
));
2016 CoTaskMemFree(url_str
);
2017 CHECK_CALLED(GetBindString_URL
);
2022 static HRESULT WINAPI
Protocol_Continue(IInternetProtocolEx
*iface
,
2023 PROTOCOLDATA
*pProtocolData
)
2025 CHECK_EXPECT(MimeFilter_Continue
);
2029 static HRESULT WINAPI
MimeProtocol_Terminate(IInternetProtocolEx
*iface
, DWORD dwOptions
)
2033 CHECK_EXPECT(MimeFilter_Terminate
);
2035 ok(!dwOptions
, "dwOptions = %x\n", dwOptions
);
2037 SET_EXPECT(Terminate
);
2038 hres
= IInternetProtocol_Terminate(filtered_protocol
, dwOptions
);
2039 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2040 CHECK_CALLED(Terminate
);
2045 static HRESULT WINAPI
MimeProtocol_Read(IInternetProtocolEx
*iface
, void *pv
,
2046 ULONG cb
, ULONG
*pcbRead
)
2052 CHECK_EXPECT(MimeFilter_Read
);
2054 ok(pv
!= NULL
, "pv == NULL\n");
2055 ok(cb
!= 0, "cb == 0\n");
2056 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
2058 if(read_report_data
)
2062 hres
= IInternetProtocol_Read(filtered_protocol
, buf
, sizeof(buf
), &read
);
2063 ok(hres
== S_OK
|| hres
== S_FALSE
|| hres
== E_PENDING
, "Read failed: %08x\n", hres
);
2064 if(read_report_data
)
2065 CHECK_CALLED(Read2
);
2070 ok(*pcbRead
== 0, "*pcbRead=%d, expected 0\n", *pcbRead
);
2074 memset(pv
, 'x', read
);
2078 static HRESULT WINAPI
MimeProtocol_LockRequest(IInternetProtocolEx
*iface
, DWORD dwOptions
)
2082 CHECK_EXPECT(MimeFilter_LockRequest
);
2084 ok(!dwOptions
, "dwOptions = %x\n", dwOptions
);
2086 SET_EXPECT(LockRequest
);
2087 hres
= IInternetProtocol_LockRequest(filtered_protocol
, dwOptions
);
2088 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2089 CHECK_CALLED(LockRequest
);
2094 static HRESULT WINAPI
MimeProtocol_UnlockRequest(IInternetProtocolEx
*iface
)
2098 CHECK_EXPECT(MimeFilter_UnlockRequest
);
2100 SET_EXPECT(UnlockRequest
);
2101 hres
= IInternetProtocol_UnlockRequest(filtered_protocol
);
2102 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2103 CHECK_CALLED(UnlockRequest
);
2108 static const IInternetProtocolExVtbl MimeProtocolVtbl
= {
2109 MimeProtocol_QueryInterface
,
2115 MimeProtocol_Terminate
,
2120 MimeProtocol_LockRequest
,
2121 MimeProtocol_UnlockRequest
2124 static IInternetProtocolEx MimeProtocol
= { &MimeProtocolVtbl
};
2126 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
2128 ok(0, "unexpected call\n");
2129 return E_NOINTERFACE
;
2132 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
2137 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
2142 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
2143 REFIID riid
, void **ppv
)
2145 CHECK_EXPECT(CreateInstance
);
2147 ok(pOuter
== (IUnknown
*)prot_bind_info
, "pOuter != protocol_unk\n");
2148 ok(IsEqualGUID(&IID_IUnknown
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
2149 ok(ppv
!= NULL
, "ppv == NULL\n");
2155 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
2157 ok(0, "unexpected call\n");
2161 static const IClassFactoryVtbl ClassFactoryVtbl
= {
2162 ClassFactory_QueryInterface
,
2163 ClassFactory_AddRef
,
2164 ClassFactory_Release
,
2165 ClassFactory_CreateInstance
,
2166 ClassFactory_LockServer
2169 static IClassFactory ClassFactory
= { &ClassFactoryVtbl
};
2171 static HRESULT WINAPI
MimeFilter_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
2173 CHECK_EXPECT(MimeFilter_CreateInstance
);
2175 ok(!outer
, "outer = %p\n", outer
);
2176 ok(IsEqualGUID(&IID_IInternetProtocol
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
2178 *ppv
= &MimeProtocol
;
2182 static const IClassFactoryVtbl MimeFilterCFVtbl
= {
2183 ClassFactory_QueryInterface
,
2184 ClassFactory_AddRef
,
2185 ClassFactory_Release
,
2186 MimeFilter_CreateInstance
,
2187 ClassFactory_LockServer
2190 static IClassFactory mimefilter_cf
= { &MimeFilterCFVtbl
};
2192 #define TEST_BINDING 0x0001
2193 #define TEST_FILTER 0x0002
2194 #define TEST_FIRST_HTTP 0x0004
2195 #define TEST_DIRECT_READ 0x0008
2196 #define TEST_POST 0x0010
2197 #define TEST_EMULATEPROT 0x0020
2198 #define TEST_SHORT_READ 0x0040
2199 #define TEST_REDIRECT 0x0080
2200 #define TEST_ABORT 0x0100
2201 #define TEST_ASYNCREQ 0x0200
2202 #define TEST_USEIURI 0x0400
2203 #define TEST_IMPLPROTEX 0x0800
2204 #define TEST_EMPTY 0x1000
2206 static void register_filter(BOOL do_register
)
2208 IInternetSession
*session
;
2211 static const WCHAR gzipW
[] = {'g','z','i','p',0};
2213 hres
= pCoInternetGetSession(0, &session
, 0);
2214 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
2217 hres
= IInternetSession_RegisterMimeFilter(session
, &mimefilter_cf
, &IID_IInternetProtocol
, gzipW
);
2218 ok(hres
== S_OK
, "RegisterMimeFilter failed: %08x\n", hres
);
2220 hres
= IInternetSession_UnregisterMimeFilter(session
, &mimefilter_cf
, gzipW
);
2221 ok(hres
== S_OK
, "RegisterMimeFilter failed: %08x\n", hres
);
2224 IInternetSession_Release(session
);
2227 static void init_test(int prot
, DWORD flags
)
2229 tested_protocol
= prot
;
2230 binding_test
= (flags
& TEST_BINDING
) != 0;
2231 first_data_notif
= TRUE
;
2234 async_read_pending
= TRUE
;
2235 mimefilter_test
= (flags
& TEST_FILTER
) != 0;
2237 post_stream_read
= 0;
2238 ResetEvent(event_complete
);
2239 ResetEvent(event_complete2
);
2240 ResetEvent(event_continue
);
2241 ResetEvent(event_continue_done
);
2242 async_protocol
= binding_protocol
= filtered_protocol
= NULL
;
2243 filtered_sink
= NULL
;
2244 http_is_first
= (flags
& TEST_FIRST_HTTP
) != 0;
2245 first_data_notif
= TRUE
;
2246 state
= STATE_CONNECTING
;
2247 test_async_req
= (flags
& TEST_ASYNCREQ
) != 0;
2248 direct_read
= (flags
& TEST_DIRECT_READ
) != 0;
2249 emulate_prot
= (flags
& TEST_EMULATEPROT
) != 0;
2250 wait_for_switch
= TRUE
;
2251 short_read
= (flags
& TEST_SHORT_READ
) != 0;
2252 http_post_test
= TYMED_NULL
;
2253 test_redirect
= (flags
& TEST_REDIRECT
) != 0;
2254 test_abort
= (flags
& TEST_ABORT
) != 0;
2255 impl_protex
= (flags
& TEST_IMPLPROTEX
) != 0;
2256 empty_file
= (flags
& TEST_EMPTY
) != 0;
2258 register_filter(mimefilter_test
);
2261 static void test_priority(IInternetProtocol
*protocol
)
2263 IInternetPriority
*priority
;
2267 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetPriority
,
2269 ok(hres
== S_OK
, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres
);
2273 hres
= IInternetPriority_GetPriority(priority
, &pr
);
2274 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2275 ok(pr
== 0, "pr=%d, expected 0\n", pr
);
2277 hres
= IInternetPriority_SetPriority(priority
, 1);
2278 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
2280 hres
= IInternetPriority_GetPriority(priority
, &pr
);
2281 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
2282 ok(pr
== 1, "pr=%d, expected 1\n", pr
);
2284 IInternetPriority_Release(priority
);
2287 static void test_early_abort(const CLSID
*clsid
)
2289 IInternetProtocol
*protocol
;
2292 hres
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
2293 &IID_IInternetProtocol
, (void**)&protocol
);
2294 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
2296 hres
= IInternetProtocol_Abort(protocol
, E_ABORT
, 0);
2297 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
2299 hres
= IInternetProtocol_Abort(protocol
, E_FAIL
, 0);
2300 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
2302 IInternetProtocol_Release(protocol
);
2305 static BOOL
file_protocol_start(IInternetProtocol
*protocol
, LPCWSTR url
,
2306 IInternetProtocolEx
*protocolex
, IUri
*uri
, BOOL is_first
)
2310 SET_EXPECT(GetBindInfo
);
2311 if(!(bindf
& BINDF_FROMURLMON
))
2312 SET_EXPECT(ReportProgress_DIRECTBIND
);
2314 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2315 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
2316 if(bindf
& BINDF_FROMURLMON
)
2317 SET_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
2319 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
2321 SET_EXPECT(ReportData
);
2323 SET_EXPECT(ReportResult
);
2325 expect_hrResult
= S_OK
;
2328 hres
= IInternetProtocolEx_StartEx(protocolex
, uri
, &protocol_sink
, &bind_info
, 0, 0);
2329 ok(hres
== S_OK
, "StartEx failed: %08x\n", hres
);
2331 hres
= IInternetProtocol_Start(protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
2332 if(hres
== INET_E_RESOURCE_NOT_FOUND
) {
2333 win_skip("Start failed\n");
2336 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2339 CHECK_CALLED(GetBindInfo
);
2340 if(!(bindf
& BINDF_FROMURLMON
))
2341 CHECK_CALLED(ReportProgress_DIRECTBIND
);
2343 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
2344 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE
);
2345 if(bindf
& BINDF_FROMURLMON
)
2346 CHECK_CALLED(ReportProgress_VERIFIEDMIMETYPEAVAILABLE
);
2348 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
2350 CHECK_CALLED(ReportData
);
2352 CHECK_CALLED(ReportResult
);
2357 static void test_file_protocol_url(LPCWSTR url
)
2359 IInternetProtocolInfo
*protocol_info
;
2361 IClassFactory
*factory
;
2362 IInternetProtocol
*protocol
;
2367 hres
= CoGetClassObject(&CLSID_FileProtocol
, CLSCTX_INPROC_SERVER
, NULL
,
2368 &IID_IUnknown
, (void**)&unk
);
2369 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
2373 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
2374 ok(hres
== E_NOINTERFACE
,
2375 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
2377 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
2378 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
2379 IUnknown_Release(unk
);
2383 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
2384 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2386 if(SUCCEEDED(hres
)) {
2387 if(file_protocol_start(protocol
, url
, NULL
, NULL
, TRUE
)) {
2388 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2389 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2390 ok(cb
== 2, "cb=%u expected 2\n", cb
);
2391 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
2392 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2393 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
2394 ok(hres
== S_FALSE
, "Read failed: %08x expected S_FALSE\n", hres
);
2395 ok(cb
== 0, "cb=%u expected 0\n", cb
);
2396 hres
= IInternetProtocol_UnlockRequest(protocol
);
2397 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2400 if(file_protocol_start(protocol
, url
, NULL
, NULL
, FALSE
)) {
2401 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2402 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2403 hres
= IInternetProtocol_LockRequest(protocol
, 0);
2404 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2405 hres
= IInternetProtocol_UnlockRequest(protocol
);
2406 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2409 IInternetProtocol_Release(protocol
);
2412 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
2413 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2414 if(SUCCEEDED(hres
)) {
2415 if(file_protocol_start(protocol
, url
, NULL
, NULL
, TRUE
)) {
2416 hres
= IInternetProtocol_LockRequest(protocol
, 0);
2417 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2418 hres
= IInternetProtocol_Terminate(protocol
, 0);
2419 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2420 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2421 ok(hres
== S_OK
, "Read failed: %08x\n\n", hres
);
2422 hres
= IInternetProtocol_UnlockRequest(protocol
);
2423 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2424 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2425 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2426 hres
= IInternetProtocol_Terminate(protocol
, 0);
2427 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2430 IInternetProtocol_Release(protocol
);
2433 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
2434 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2435 if(SUCCEEDED(hres
)) {
2436 if(file_protocol_start(protocol
, url
, NULL
, NULL
, TRUE
)) {
2437 hres
= IInternetProtocol_Terminate(protocol
, 0);
2438 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2439 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
2440 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2441 ok(cb
== 2, "cb=%u expected 2\n", cb
);
2444 IInternetProtocol_Release(protocol
);
2448 IInternetProtocolEx
*protocolex
;
2451 hres
= pCreateUri(url
, Uri_CREATE_FILE_USE_DOS_PATH
, 0, &uri
);
2452 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
2454 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocolEx
, (void**)&protocolex
);
2455 ok(hres
== S_OK
, "Could not get IInternetProtocolEx: %08x\n", hres
);
2457 if(file_protocol_start(NULL
, NULL
, protocolex
, uri
, TRUE
)) {
2458 hres
= IInternetProtocolEx_Read(protocolex
, buf
, 2, &cb
);
2459 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2460 hres
= IInternetProtocolEx_LockRequest(protocolex
, 0);
2461 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2462 hres
= IInternetProtocolEx_UnlockRequest(protocolex
);
2463 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2467 IInternetProtocolEx_Release(protocolex
);
2469 hres
= pCreateUri(url
, 0, 0, &uri
);
2470 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
2472 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocolEx
, (void**)&protocolex
);
2473 ok(hres
== S_OK
, "Could not get IInternetProtocolEx: %08x\n", hres
);
2475 if(file_protocol_start(NULL
, NULL
, protocolex
, uri
, TRUE
)) {
2476 hres
= IInternetProtocolEx_Read(protocolex
, buf
, 2, &cb
);
2477 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
2478 hres
= IInternetProtocolEx_LockRequest(protocolex
, 0);
2479 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2480 hres
= IInternetProtocolEx_UnlockRequest(protocolex
);
2481 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2485 IInternetProtocolEx_Release(protocolex
);
2487 win_skip("Skipping file protocol StartEx tests\n");
2490 IClassFactory_Release(factory
);
2493 static void test_file_protocol_fail(void)
2495 IInternetProtocol
*protocol
;
2498 static const WCHAR index_url2
[] =
2499 {'f','i','l','e',':','/','/','i','n','d','e','x','.','h','t','m','l',0};
2501 hres
= CoCreateInstance(&CLSID_FileProtocol
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
2502 &IID_IInternetProtocol
, (void**)&protocol
);
2503 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
2507 SET_EXPECT(GetBindInfo
);
2508 expect_hrResult
= MK_E_SYNTAX
;
2509 hres
= IInternetProtocol_Start(protocol
, wszIndexHtml
, &protocol_sink
, &bind_info
, 0, 0);
2510 ok(hres
== MK_E_SYNTAX
||
2511 hres
== E_INVALIDARG
,
2512 "Start failed: %08x, expected MK_E_SYNTAX or E_INVALIDARG\n", hres
);
2513 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
2515 SET_EXPECT(GetBindInfo
);
2516 if(!(bindf
& BINDF_FROMURLMON
))
2517 SET_EXPECT(ReportProgress_DIRECTBIND
);
2518 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2519 SET_EXPECT(ReportResult
);
2520 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
2521 hres
= IInternetProtocol_Start(protocol
, index_url
, &protocol_sink
, &bind_info
, 0, 0);
2522 ok(hres
== INET_E_RESOURCE_NOT_FOUND
,
2523 "Start failed: %08x expected INET_E_RESOURCE_NOT_FOUND\n", hres
);
2524 CHECK_CALLED(GetBindInfo
);
2525 if(!(bindf
& BINDF_FROMURLMON
))
2526 CHECK_CALLED(ReportProgress_DIRECTBIND
);
2527 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
2528 CHECK_CALLED(ReportResult
);
2530 IInternetProtocol_Release(protocol
);
2532 hres
= CoCreateInstance(&CLSID_FileProtocol
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
2533 &IID_IInternetProtocol
, (void**)&protocol
);
2534 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
2538 SET_EXPECT(GetBindInfo
);
2539 if(!(bindf
& BINDF_FROMURLMON
))
2540 SET_EXPECT(ReportProgress_DIRECTBIND
);
2541 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2542 SET_EXPECT(ReportResult
);
2543 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
2545 hres
= IInternetProtocol_Start(protocol
, index_url2
, &protocol_sink
, &bind_info
, 0, 0);
2546 ok(hres
== INET_E_RESOURCE_NOT_FOUND
,
2547 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND\n", hres
);
2548 CHECK_CALLED(GetBindInfo
);
2549 if(!(bindf
& BINDF_FROMURLMON
))
2550 CHECK_CALLED(ReportProgress_DIRECTBIND
);
2551 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
2552 CHECK_CALLED(ReportResult
);
2554 SET_EXPECT(GetBindInfo
);
2555 hres
= IInternetProtocol_Start(protocol
, NULL
, &protocol_sink
, &bind_info
, 0, 0);
2556 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2557 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
2559 SET_EXPECT(GetBindInfo
);
2560 hres
= IInternetProtocol_Start(protocol
, emptyW
, &protocol_sink
, &bind_info
, 0, 0);
2561 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
2562 CLEAR_CALLED(GetBindInfo
); /* GetBindInfo not called in IE7 */
2564 IInternetProtocol_Release(protocol
);
2567 static void test_file_protocol(void) {
2568 WCHAR buf
[INTERNET_MAX_URL_LENGTH
], file_name_buf
[MAX_PATH
];
2573 static const WCHAR wszFile
[] = {'f','i','l','e',':',0};
2574 static const WCHAR wszFile2
[] = {'f','i','l','e',':','/','/',0};
2575 static const WCHAR wszFile3
[] = {'f','i','l','e',':','/','/','/',0};
2576 static const WCHAR wszFile4
[] = {'f','i','l','e',':','\\','\\',0};
2577 static const char html_doc
[] = "<HTML></HTML>";
2579 trace("Testing file protocol...\n");
2580 init_test(FILE_TEST
, 0);
2582 SetLastError(0xdeadbeef);
2583 file
= CreateFileW(wszIndexHtml
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
2584 FILE_ATTRIBUTE_NORMAL
, NULL
);
2585 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed\n");
2586 if(file
== INVALID_HANDLE_VALUE
)
2588 WriteFile(file
, html_doc
, sizeof(html_doc
)-1, &size
, NULL
);
2591 file_name
= wszIndexHtml
;
2593 test_file_protocol_url(index_url
);
2594 bindf
= BINDF_FROMURLMON
;
2595 test_file_protocol_url(index_url
);
2596 bindf
= BINDF_FROMURLMON
| BINDF_NEEDFILE
;
2597 test_file_protocol_url(index_url
);
2599 memcpy(buf
, wszFile
, sizeof(wszFile
));
2600 len
= sizeof(wszFile
)/sizeof(WCHAR
)-1;
2601 len
+= GetCurrentDirectoryW(sizeof(buf
)/sizeof(WCHAR
)-len
, buf
+len
);
2603 memcpy(buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2605 file_name
= buf
+ sizeof(wszFile
)/sizeof(WCHAR
)-1;
2607 test_file_protocol_url(buf
);
2608 bindf
= BINDF_FROMURLMON
;
2609 test_file_protocol_url(buf
);
2611 memcpy(buf
, wszFile2
, sizeof(wszFile2
));
2612 len
= GetCurrentDirectoryW(sizeof(file_name_buf
)/sizeof(WCHAR
), file_name_buf
);
2613 file_name_buf
[len
++] = '\\';
2614 memcpy(file_name_buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2615 lstrcpyW(buf
+sizeof(wszFile2
)/sizeof(WCHAR
)-1, file_name_buf
);
2616 file_name
= file_name_buf
;
2618 test_file_protocol_url(buf
);
2619 bindf
= BINDF_FROMURLMON
;
2620 test_file_protocol_url(buf
);
2622 buf
[sizeof(wszFile2
)/sizeof(WCHAR
)] = '|';
2623 test_file_protocol_url(buf
);
2625 memcpy(buf
, wszFile3
, sizeof(wszFile3
));
2626 len
= sizeof(wszFile3
)/sizeof(WCHAR
)-1;
2627 len
+= GetCurrentDirectoryW(sizeof(buf
)/sizeof(WCHAR
)-len
, buf
+len
);
2629 memcpy(buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2631 file_name
= buf
+ sizeof(wszFile3
)/sizeof(WCHAR
)-1;
2633 test_file_protocol_url(buf
);
2634 bindf
= BINDF_FROMURLMON
;
2635 test_file_protocol_url(buf
);
2637 memcpy(buf
, wszFile4
, sizeof(wszFile4
));
2638 len
= GetCurrentDirectoryW(sizeof(file_name_buf
)/sizeof(WCHAR
), file_name_buf
);
2639 file_name_buf
[len
++] = '\\';
2640 memcpy(file_name_buf
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2641 lstrcpyW(buf
+sizeof(wszFile4
)/sizeof(WCHAR
)-1, file_name_buf
);
2642 file_name
= file_name_buf
;
2644 test_file_protocol_url(buf
);
2645 bindf
= BINDF_FROMURLMON
;
2646 test_file_protocol_url(buf
);
2648 buf
[sizeof(wszFile4
)/sizeof(WCHAR
)] = '|';
2649 test_file_protocol_url(buf
);
2651 DeleteFileW(wszIndexHtml
);
2654 test_file_protocol_fail();
2655 bindf
= BINDF_FROMURLMON
;
2656 test_file_protocol_fail();
2659 static BOOL
http_protocol_start(LPCWSTR url
, BOOL use_iuri
)
2661 static BOOL got_user_agent
= FALSE
;
2665 if(use_iuri
&& pCreateUri
) {
2666 hres
= pCreateUri(url
, 0, 0, &uri
);
2667 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
2670 SET_EXPECT(GetBindInfo
);
2671 if (!(bindf
& BINDF_FROMURLMON
))
2672 SET_EXPECT(ReportProgress_DIRECTBIND
);
2674 SET_EXPECT(GetBindString_USER_AGENT
);
2675 SET_EXPECT(GetBindString_ACCEPT_MIMES
);
2676 SET_EXPECT(QueryService_HttpNegotiate
);
2677 SET_EXPECT(BeginningTransaction
);
2678 SET_EXPECT(GetRootSecurityId
);
2679 if(http_post_test
) {
2680 SET_EXPECT(GetBindString_POST_COOKIE
);
2681 if(http_post_test
== TYMED_ISTREAM
)
2682 SET_EXPECT(Stream_Seek
);
2686 IInternetProtocolEx
*protocolex
;
2688 hres
= IInternetProtocol_QueryInterface(async_protocol
, &IID_IInternetProtocolEx
, (void**)&protocolex
);
2689 ok(hres
== S_OK
, "Could not get IInternetProtocolEx iface: %08x\n", hres
);
2691 hres
= IInternetProtocolEx_StartEx(protocolex
, uri
, &protocol_sink
, &bind_info
, 0, 0);
2692 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2694 IInternetProtocolEx_Release(protocolex
);
2697 hres
= IInternetProtocol_Start(async_protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
2698 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
2703 CHECK_CALLED(GetBindInfo
);
2704 if (!(bindf
& BINDF_FROMURLMON
))
2705 CHECK_CALLED(ReportProgress_DIRECTBIND
);
2706 if (!got_user_agent
)
2708 CHECK_CALLED(GetBindString_USER_AGENT
);
2709 got_user_agent
= TRUE
;
2711 CHECK_CALLED(GetBindString_ACCEPT_MIMES
);
2712 CHECK_CALLED(QueryService_HttpNegotiate
);
2713 CHECK_CALLED(BeginningTransaction
);
2714 /* GetRootSecurityId called on WinXP but not on Win98 */
2715 CLEAR_CALLED(GetRootSecurityId
);
2716 if(http_post_test
) {
2717 CHECK_CALLED(GetBindString_POST_COOKIE
);
2718 if(http_post_test
== TYMED_ISTREAM
)
2719 CHECK_CALLED(Stream_Seek
);
2725 static void test_protocol_terminate(IInternetProtocol
*protocol
)
2731 hres
= IInternetProtocol_LockRequest(protocol
, 0);
2732 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
2734 hres
= IInternetProtocol_Read(protocol
, buf
, 1, &cb
);
2735 ok(hres
== test_abort
? S_OK
: S_FALSE
, "Read failed: %08x\n", hres
);
2737 hres
= IInternetProtocol_Terminate(protocol
, 0);
2738 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
2740 /* This wait is to give the internet handles being freed in Terminate
2741 * enough time to actually terminate in all cases. Internet handles
2742 * terminate asynchronously and native reuses the main InternetOpen
2743 * handle. The only case in which this seems to be necessary is on
2744 * wine with native wininet and urlmon, resulting in the next time
2745 * test_http_protocol_url being called the first data notification actually
2746 * being an extra last data notification from the previous connection
2747 * about once out of every ten times. */
2750 hres
= IInternetProtocol_UnlockRequest(protocol
);
2751 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
2754 static void test_http_info(IInternetProtocol
*protocol
)
2756 IWinInetHttpInfo
*info
;
2759 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetHttpInfo
, (void**)&info
);
2760 ok(hres
== S_OK
, "Could not get IWinInterHttpInfo iface: %08x\n", hres
);
2764 IWinInetHttpInfo_Release(info
);
2767 /* is_first refers to whether this is the first call to this function
2769 static void test_http_protocol_url(LPCWSTR url
, int prot
, DWORD flags
, DWORD tymed
)
2771 IInternetProtocolInfo
*protocol_info
;
2772 IClassFactory
*factory
;
2776 init_test(prot
, flags
);
2778 http_post_test
= tymed
;
2780 hres
= CoGetClassObject(prot
== HTTPS_TEST
? &CLSID_HttpSProtocol
: &CLSID_HttpProtocol
,
2781 CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
2782 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
2786 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
2787 ok(hres
== E_NOINTERFACE
,
2788 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
2791 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
2792 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
2793 IUnknown_Release(unk
);
2797 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
2798 (void**)&async_protocol
);
2799 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
2800 if(SUCCEEDED(hres
)) {
2805 test_priority(async_protocol
);
2806 test_http_info(async_protocol
);
2808 SET_EXPECT(ReportProgress_COOKIE_SENT
);
2810 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
2811 SET_EXPECT(ReportProgress_CONNECTING
);
2813 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
2815 SET_EXPECT(ReportProgress_REDIRECTING
);
2816 SET_EXPECT(ReportProgress_PROXYDETECTING
);
2817 if(prot
== HTTP_TEST
)
2818 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE
);
2820 SET_EXPECT(QueryService_HttpSecurity
);
2821 if(!(bindf
& BINDF_FROMURLMON
)) {
2822 SET_EXPECT(OnResponse
);
2823 SET_EXPECT(ReportProgress_RAWMIMETYPE
);
2824 SET_EXPECT(ReportData
);
2829 if(!http_protocol_start(url
, (flags
& TEST_USEIURI
) != 0))
2832 if(!direct_read
&& !test_abort
)
2833 SET_EXPECT(ReportResult
);
2834 expect_hrResult
= test_abort
? E_ABORT
: S_OK
;
2838 while(wait_for_switch
) {
2839 WaitForSingleObject(event_continue
, INFINITE
);
2840 CHECK_CALLED(Switch
); /* Set in ReportData */
2841 call_continue(&continue_protdata
);
2842 SetEvent(event_continue_done
);
2845 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
2846 ok((hres
== E_PENDING
&& cb
==0) ||
2847 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
2849 WaitForSingleObject(event_complete
, INFINITE
);
2850 if(bindf
& BINDF_FROMURLMON
)
2851 CHECK_CALLED(Switch
);
2853 CHECK_CALLED(ReportData
);
2854 if(prot
== HTTPS_TEST
)
2855 CLEAR_CALLED(QueryService_HttpSecurity
);
2858 if(bindf
& BINDF_FROMURLMON
)
2861 SET_EXPECT(ReportData
);
2862 hres
= IInternetProtocol_Read(async_protocol
, buf
, sizeof(buf
), &cb
);
2863 if(hres
== E_PENDING
) {
2864 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
2865 ok((hres
== E_PENDING
&& cb
==0) ||
2866 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
2867 WaitForSingleObject(event_complete
, INFINITE
);
2868 if(bindf
& BINDF_FROMURLMON
)
2869 CHECK_CALLED(Switch
);
2871 CHECK_CALLED(ReportData
);
2876 SET_EXPECT(ReportResult
);
2877 hres
= IInternetProtocol_Abort(async_protocol
, E_ABORT
, 0);
2878 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
2879 CHECK_CALLED(ReportResult
);
2881 hres
= IInternetProtocol_Abort(async_protocol
, E_ABORT
, 0);
2882 ok(hres
== INET_E_RESULT_DISPATCHED
, "Abort failed: %08x\n", hres
);
2886 if(bindf
& BINDF_FROMURLMON
)
2887 CHECK_NOT_CALLED(Switch
);
2889 CHECK_NOT_CALLED(ReportData
);
2894 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
2895 CHECK_CALLED(ReportResult
);
2898 if(prot
== HTTPS_TEST
)
2899 CLEAR_CALLED(ReportProgress_SENDINGREQUEST
);
2901 hres
= IInternetProtocol_Abort(async_protocol
, E_ABORT
, 0);
2902 ok(hres
== INET_E_RESULT_DISPATCHED
, "Abort failed: %08x\n", hres
);
2904 test_protocol_terminate(async_protocol
);
2906 hres
= IInternetProtocol_Abort(async_protocol
, E_ABORT
, 0);
2907 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
2909 ref
= IInternetProtocol_Release(async_protocol
);
2910 ok(!ref
, "ref=%x\n", ref
);
2913 IClassFactory_Release(factory
);
2916 static void test_http_protocol(void)
2918 static const WCHAR posttest_url
[] =
2919 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
2920 't','e','s','t','s','/','p','o','s','t','.','p','h','p',0};
2921 static const WCHAR redirect_url
[] =
2922 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
2923 't','e','s','t','s','/','r','e','d','i','r','e','c','t',0};
2924 static const WCHAR winetest_url
[] =
2925 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
2926 't','e','s','t','s','/','d','a','t','a','.','p','h','p',0};
2927 static const WCHAR empty_url
[] =
2928 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
2929 't','e','s','t','s','/','e','m','p','t','y','.','j','s',0};
2931 trace("Testing http protocol (not from urlmon)...\n");
2932 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
;
2933 test_http_protocol_url(winetest_url
, HTTP_TEST
, TEST_FIRST_HTTP
, TYMED_NULL
);
2935 trace("Testing http protocol (from urlmon)...\n");
2936 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
;
2937 test_http_protocol_url(winetest_url
, HTTP_TEST
, 0, TYMED_NULL
);
2939 trace("Testing http protocol (to file)...\n");
2940 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NEEDFILE
;
2941 test_http_protocol_url(winetest_url
, HTTP_TEST
, 0, TYMED_NULL
);
2943 trace("Testing http protocol (post data)...\n");
2944 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
;
2945 test_http_protocol_url(posttest_url
, HTTP_TEST
, TEST_FIRST_HTTP
|TEST_POST
, TYMED_HGLOBAL
);
2947 trace("Testing http protocol (post data stream)...\n");
2948 test_http_protocol_url(posttest_url
, HTTP_TEST
, TEST_FIRST_HTTP
|TEST_POST
|TEST_ASYNCREQ
, TYMED_ISTREAM
);
2950 trace("Testing http protocol (direct read)...\n");
2951 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
;
2952 test_http_protocol_url(winetest_url
, HTTP_TEST
, TEST_DIRECT_READ
|TEST_USEIURI
, TYMED_NULL
);
2954 trace("Testing http protocol (redirected)...\n");
2955 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
2956 test_http_protocol_url(redirect_url
, HTTP_TEST
, TEST_REDIRECT
, TYMED_NULL
);
2958 trace("Testing http protocol empty file...\n");
2959 test_http_protocol_url(empty_url
, HTTP_TEST
, TEST_EMPTY
, TYMED_NULL
);
2961 trace("Testing http protocol abort...\n");
2962 test_http_protocol_url(winetest_url
, HTTP_TEST
, TEST_ABORT
, TYMED_NULL
);
2964 test_early_abort(&CLSID_HttpProtocol
);
2965 test_early_abort(&CLSID_HttpSProtocol
);
2968 static void test_https_protocol(void)
2970 static const WCHAR codeweavers_url
[] =
2971 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
2972 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0};
2974 trace("Testing https protocol (from urlmon)...\n");
2975 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
2976 test_http_protocol_url(codeweavers_url
, HTTPS_TEST
, TEST_FIRST_HTTP
, TYMED_NULL
);
2980 static void test_ftp_protocol(void)
2982 IInternetProtocolInfo
*protocol_info
;
2983 IClassFactory
*factory
;
2990 static const WCHAR ftp_urlW
[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
2991 '/','p','u','b','/','o','t','h','e','r','/',
2992 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
2994 trace("Testing ftp protocol...\n");
2996 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
| BINDF_FROMURLMON
| BINDF_NOWRITECACHE
;
2997 state
= STATE_STARTDOWNLOADING
;
2998 tested_protocol
= FTP_TEST
;
2999 first_data_notif
= TRUE
;
3000 expect_hrResult
= E_PENDING
;
3002 hres
= CoGetClassObject(&CLSID_FtpProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
3003 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
3007 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
3008 ok(hres
== E_NOINTERFACE
, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
3010 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
3011 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
3012 IUnknown_Release(unk
);
3016 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
3017 (void**)&async_protocol
);
3018 IClassFactory_Release(factory
);
3019 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
3021 test_priority(async_protocol
);
3022 test_http_info(async_protocol
);
3024 SET_EXPECT(GetBindInfo
);
3025 SET_EXPECT(ReportProgress_FINDINGRESOURCE
);
3026 SET_EXPECT(ReportProgress_CONNECTING
);
3027 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
3030 hres
= IInternetProtocol_Start(async_protocol
, ftp_urlW
, &protocol_sink
, &bind_info
, 0, 0);
3031 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
3032 CHECK_CALLED(GetBindInfo
);
3034 SET_EXPECT(ReportResult
);
3036 hres
= IInternetProtocol_Read(async_protocol
, buf
, 1, &cb
);
3037 ok((hres
== E_PENDING
&& cb
==0) ||
3038 (hres
== S_OK
&& cb
==1), "Read failed: %08x (%d bytes)\n", hres
, cb
);
3040 WaitForSingleObject(event_complete
, INFINITE
);
3043 hres
= IInternetProtocol_Read(async_protocol
, buf
, sizeof(buf
), &cb
);
3044 if(hres
== E_PENDING
)
3045 WaitForSingleObject(event_complete
, INFINITE
);
3050 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
3051 CHECK_CALLED(ReportResult
);
3052 CHECK_CALLED(Switch
);
3054 test_protocol_terminate(async_protocol
);
3057 IInternetProtocolEx
*protocolex
;
3059 hres
= IInternetProtocol_QueryInterface(async_protocol
, &IID_IInternetProtocolEx
, (void**)&protocolex
);
3060 ok(hres
== S_OK
, "Could not get IInternetProtocolEx iface: %08x\n", hres
);
3061 IInternetProtocolEx_Release(protocolex
);
3064 ref
= IInternetProtocol_Release(async_protocol
);
3065 ok(!ref
, "ref=%d\n", ref
);
3067 test_early_abort(&CLSID_FtpProtocol
);
3070 static void test_gopher_protocol(void)
3072 IInternetProtocolInfo
*protocol_info
;
3073 IClassFactory
*factory
;
3077 trace("Testing gopher protocol...\n");
3079 hres
= CoGetClassObject(&CLSID_GopherProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
3081 hres
== REGDB_E_CLASSNOTREG
, /* Gopher protocol has been removed as of Vista */
3082 "CoGetClassObject failed: %08x\n", hres
);
3086 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
3087 ok(hres
== E_NOINTERFACE
, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres
);
3089 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
3090 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
3091 IUnknown_Release(unk
);
3095 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
3096 (void**)&async_protocol
);
3097 IClassFactory_Release(factory
);
3098 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
3100 test_priority(async_protocol
);
3102 IInternetProtocol_Release(async_protocol
);
3104 test_early_abort(&CLSID_GopherProtocol
);
3107 static void test_mk_protocol(void)
3109 IInternetProtocolInfo
*protocol_info
;
3110 IInternetProtocol
*protocol
;
3111 IClassFactory
*factory
;
3115 static const WCHAR wrong_url1
[] = {'t','e','s','t',':','@','M','S','I','T','S','t','o','r','e',
3116 ':',':','/','t','e','s','t','.','h','t','m','l',0};
3117 static const WCHAR wrong_url2
[] = {'m','k',':','/','t','e','s','t','.','h','t','m','l',0};
3119 trace("Testing mk protocol...\n");
3120 init_test(MK_TEST
, 0);
3122 hres
= CoGetClassObject(&CLSID_MkProtocol
, CLSCTX_INPROC_SERVER
, NULL
,
3123 &IID_IUnknown
, (void**)&unk
);
3124 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
3126 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
3127 ok(hres
== E_NOINTERFACE
,
3128 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
3131 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
3132 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
3133 IUnknown_Release(unk
);
3137 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
,
3139 IClassFactory_Release(factory
);
3140 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
3142 SET_EXPECT(GetBindInfo
);
3143 hres
= IInternetProtocol_Start(protocol
, wrong_url1
, &protocol_sink
, &bind_info
, 0, 0);
3144 ok(hres
== MK_E_SYNTAX
|| hres
== INET_E_INVALID_URL
,
3145 "Start failed: %08x, expected MK_E_SYNTAX or INET_E_INVALID_URL\n", hres
);
3146 CLEAR_CALLED(GetBindInfo
);
3148 SET_EXPECT(GetBindInfo
);
3149 SET_EXPECT(ReportProgress_DIRECTBIND
);
3150 SET_EXPECT(ReportProgress_SENDINGREQUEST
);
3151 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE
);
3152 SET_EXPECT(ReportResult
);
3153 expect_hrResult
= INET_E_RESOURCE_NOT_FOUND
;
3155 hres
= IInternetProtocol_Start(protocol
, wrong_url2
, &protocol_sink
, &bind_info
, 0, 0);
3156 ok(hres
== INET_E_RESOURCE_NOT_FOUND
||
3157 hres
== INET_E_INVALID_URL
, /* win2k3 */
3158 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND or INET_E_INVALID_URL\n", hres
);
3160 if (hres
== INET_E_RESOURCE_NOT_FOUND
) {
3161 CHECK_CALLED(GetBindInfo
);
3162 CLEAR_CALLED(ReportProgress_DIRECTBIND
);
3163 CHECK_CALLED(ReportProgress_SENDINGREQUEST
);
3164 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
3165 CHECK_CALLED(ReportResult
);
3167 CLEAR_CALLED(GetBindInfo
);
3168 CLEAR_CALLED(ReportProgress_DIRECTBIND
);
3169 CLEAR_CALLED(ReportProgress_SENDINGREQUEST
);
3170 CLEAR_CALLED(ReportProgress_MIMETYPEAVAILABLE
);
3171 CLEAR_CALLED(ReportResult
);
3174 IInternetProtocol_Release(protocol
);
3177 static void test_CreateBinding(void)
3179 IInternetProtocol
*protocol
;
3180 IInternetPriority
*priority
;
3181 IInternetSession
*session
;
3182 IWinInetHttpInfo
*http_info
;
3183 IWinInetInfo
*inet_info
;
3189 static const WCHAR test_url
[] =
3190 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0};
3191 static const WCHAR wsz_test
[] = {'t','e','s','t',0};
3193 trace("Testing CreateBinding...\n");
3194 init_test(BIND_TEST
, TEST_BINDING
);
3196 hres
= pCoInternetGetSession(0, &session
, 0);
3197 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
3199 hres
= IInternetSession_RegisterNameSpace(session
, &ClassFactory
, &IID_NULL
, wsz_test
, 0, NULL
, 0);
3200 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
3202 hres
= IInternetSession_CreateBinding(session
, NULL
, test_url
, NULL
, NULL
, &protocol
, 0);
3203 binding_protocol
= protocol
;
3204 ok(hres
== S_OK
, "CreateBinding failed: %08x\n", hres
);
3205 ok(protocol
!= NULL
, "protocol == NULL\n");
3207 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetBindInfo
, (void**)&prot_bind_info
);
3208 ok(hres
== S_OK
, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres
);
3210 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetProtocolSink
, (void**)&binding_sink
);
3211 ok(hres
== S_OK
, "Could not get IInternetProtocolSink: %08x\n", hres
);
3213 hres
= IInternetProtocol_Start(protocol
, test_url
, NULL
, &bind_info
, 0, 0);
3214 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
3215 hres
= IInternetProtocol_Start(protocol
, test_url
, &protocol_sink
, NULL
, 0, 0);
3216 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
3217 hres
= IInternetProtocol_Start(protocol
, NULL
, &protocol_sink
, &bind_info
, 0, 0);
3218 ok(hres
== E_INVALIDARG
, "Start failed: %08x, expected E_INVALIDARG\n", hres
);
3220 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetPriority
, (void**)&priority
);
3221 ok(hres
== S_OK
, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres
);
3224 hres
= IInternetPriority_GetPriority(priority
, &p
);
3225 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
3226 ok(!p
, "p=%d\n", p
);
3229 hres
= IInternetPriority_SetPriority(priority
, 100);
3230 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
3233 hres
= IInternetPriority_GetPriority(priority
, &p
);
3234 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
3235 ok(p
== 100, "p=%d\n", p
);
3237 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetInfo
, (void**)&inet_info
);
3238 ok(hres
== E_NOINTERFACE
, "Could not get IWinInetInfo protocol: %08x\n", hres
);
3240 SET_EXPECT(QueryService_InternetProtocol
);
3241 SET_EXPECT(CreateInstance
);
3242 SET_EXPECT(ReportProgress_PROTOCOLCLASSID
);
3243 SET_EXPECT(SetPriority
);
3246 expect_hrResult
= S_OK
;
3247 hres
= IInternetProtocol_Start(protocol
, test_url
, &protocol_sink
, &bind_info
, 0, 0);
3248 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
3250 CHECK_CALLED(QueryService_InternetProtocol
);
3251 CHECK_CALLED(CreateInstance
);
3252 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID
);
3253 CHECK_CALLED(SetPriority
);
3254 CHECK_CALLED(Start
);
3256 SET_EXPECT(QueryInterface_IWinInetInfo
);
3257 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetInfo
, (void**)&inet_info
);
3258 ok(hres
== E_NOINTERFACE
, "Could not get IWinInetInfo protocol: %08x\n", hres
);
3259 CHECK_CALLED(QueryInterface_IWinInetInfo
);
3261 SET_EXPECT(QueryInterface_IWinInetInfo
);
3262 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetInfo
, (void**)&inet_info
);
3263 ok(hres
== E_NOINTERFACE
, "Could not get IWinInetInfo protocol: %08x\n", hres
);
3264 CHECK_CALLED(QueryInterface_IWinInetInfo
);
3266 SET_EXPECT(QueryInterface_IWinInetHttpInfo
);
3267 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
3268 ok(hres
== E_NOINTERFACE
, "Could not get IWinInetInfo protocol: %08x\n", hres
);
3269 CHECK_CALLED(QueryInterface_IWinInetHttpInfo
);
3273 hres
= IInternetProtocol_Read(protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
3274 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
3275 ok(read
== 100, "read = %d\n", read
);
3280 hres
= IInternetProtocol_Read(protocol
, expect_pv
= buf
, sizeof(buf
), &read
);
3281 ok(hres
== S_FALSE
, "Read failed: %08x\n", hres
);
3282 ok(!read
, "read = %d\n", read
);
3286 hres
= IInternetPriority_GetPriority(priority
, &p
);
3287 ok(hres
== S_OK
, "GetPriority failed: %08x\n", hres
);
3288 ok(p
== 100, "p=%d\n", p
);
3290 hres
= IInternetPriority_SetPriority(priority
, 101);
3291 ok(hres
== S_OK
, "SetPriority failed: %08x\n", hres
);
3293 SET_EXPECT(Terminate
);
3294 hres
= IInternetProtocol_Terminate(protocol
, 0xdeadbeef);
3295 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
3296 CHECK_CALLED(Terminate
);
3298 SET_EXPECT(Continue
);
3299 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
3300 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
3301 CHECK_CALLED(Continue
);
3303 hres
= IInternetProtocolSink_ReportProgress(binding_sink
,
3304 BINDSTATUS_CACHEFILENAMEAVAILABLE
, expect_wsz
= emptyW
);
3305 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
3307 hres
= IInternetProtocolSink_ReportResult(binding_sink
, S_OK
, ERROR_SUCCESS
, NULL
);
3308 ok(hres
== E_FAIL
, "ReportResult failed: %08x, expected E_FAIL\n", hres
);
3310 hres
= IInternetProtocolSink_ReportData(binding_sink
, 0, 0, 0);
3311 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
3313 IInternetProtocolSink_Release(binding_sink
);
3314 IInternetPriority_Release(priority
);
3315 IInternetBindInfo_Release(prot_bind_info
);
3316 IInternetProtocol_Release(protocol
);
3318 hres
= IInternetSession_CreateBinding(session
, NULL
, test_url
, NULL
, NULL
, &protocol
, 0);
3319 ok(hres
== S_OK
, "CreateBinding failed: %08x\n", hres
);
3320 ok(protocol
!= NULL
, "protocol == NULL\n");
3322 hres
= IInternetProtocol_Abort(protocol
, E_ABORT
, 0);
3323 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
3325 hres
= IInternetProtocol_Abort(protocol
, E_FAIL
, 0);
3326 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
3328 IInternetProtocol_Release(protocol
);
3330 hres
= IInternetSession_UnregisterNameSpace(session
, &ClassFactory
, wsz_test
);
3331 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
3333 hres
= IInternetSession_CreateBinding(session
, NULL
, test_url
, NULL
, NULL
, &protocol
, 0);
3334 ok(hres
== S_OK
, "CreateBinding failed: %08x\n", hres
);
3335 ok(protocol
!= NULL
, "protocol == NULL\n");
3337 SET_EXPECT(QueryService_InternetProtocol
);
3338 hres
= IInternetProtocol_Start(protocol
, test_url
, &protocol_sink
, &bind_info
, 0, 0);
3339 ok(hres
== MK_E_SYNTAX
, "Start failed: %08x, expected MK_E_SYNTAX\n", hres
);
3340 CHECK_CALLED(QueryService_InternetProtocol
);
3342 IInternetProtocol_Release(protocol
);
3344 IInternetSession_Release(session
);
3347 static void test_binding(int prot
, DWORD grf_pi
, DWORD test_flags
)
3349 IInternetProtocolEx
*protocolex
= NULL
;
3350 IInternetProtocol
*protocol
;
3351 IInternetSession
*session
;
3358 init_test(prot
, test_flags
|TEST_BINDING
);
3360 hres
= pCoInternetGetSession(0, &session
, 0);
3361 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
3363 if(test_flags
& TEST_EMULATEPROT
) {
3364 hres
= IInternetSession_RegisterNameSpace(session
, &ClassFactory
, &IID_NULL
, protocol_names
[prot
], 0, NULL
, 0);
3365 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
3368 hres
= IInternetSession_CreateBinding(session
, NULL
, binding_urls
[prot
], NULL
, NULL
, &protocol
, 0);
3369 binding_protocol
= protocol
;
3370 ok(hres
== S_OK
, "CreateBinding failed: %08x\n", hres
);
3371 ok(protocol
!= NULL
, "protocol == NULL\n");
3373 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetBindInfo
, (void**)&prot_bind_info
);
3374 ok(hres
== S_OK
, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres
);
3376 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetProtocolSink
, (void**)&binding_sink
);
3377 ok(hres
== S_OK
, "QueryInterface(IID_IInternetProtocolSink) failed: %08x\n", hres
);
3379 if(test_flags
& TEST_USEIURI
) {
3380 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetProtocolEx
, (void**)&protocolex
);
3381 ok(hres
== S_OK
, "Could not get IInternetProtocolEx iface: %08x\n", hres
);
3383 hres
= pCreateUri(binding_urls
[prot
], Uri_CREATE_FILE_USE_DOS_PATH
, 0, &uri
);
3384 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
3388 SET_EXPECT(QueryService_InternetProtocol
);
3389 SET_EXPECT(CreateInstance
);
3390 SET_EXPECT(ReportProgress_PROTOCOLCLASSID
);
3391 SET_EXPECT(SetPriority
);
3393 SET_EXPECT(StartEx
);
3397 expect_hrResult
= S_OK
;
3400 hres
= IInternetProtocolEx_StartEx(protocolex
, uri
, &protocol_sink
, &bind_info
, pi
, 0);
3401 ok(hres
== S_OK
, "StartEx failed: %08x\n", hres
);
3403 hres
= IInternetProtocol_Start(protocol
, binding_urls
[prot
], &protocol_sink
, &bind_info
, pi
, 0);
3404 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
3407 CHECK_CALLED(QueryService_InternetProtocol
);
3408 CHECK_CALLED(CreateInstance
);
3409 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID
);
3410 CHECK_CALLED(SetPriority
);
3412 CHECK_CALLED(StartEx
);
3414 CHECK_CALLED(Start
);
3417 IInternetProtocolEx_Release(protocolex
);
3421 if(prot
== HTTP_TEST
|| prot
== HTTPS_TEST
) {
3422 while(prot_state
< 4) {
3423 WaitForSingleObject(event_complete
, INFINITE
);
3424 if(mimefilter_test
&& filtered_protocol
) {
3425 SET_EXPECT(Continue
);
3426 IInternetProtocol_Continue(filtered_protocol
, pdata
);
3427 CHECK_CALLED(Continue
);
3429 SET_EXPECT(Continue
);
3430 IInternetProtocol_Continue(protocol
, pdata
);
3431 CHECK_CALLED(Continue
);
3433 if(test_abort
&& prot_state
== 2) {
3435 hres
= IInternetProtocol_Abort(protocol
, E_ABORT
, 0);
3436 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
3437 CHECK_CALLED(Abort
);
3439 hres
= IInternetProtocol_Abort(protocol
, E_ABORT
, 0);
3440 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
3441 SetEvent(event_complete2
);
3444 SetEvent(event_complete2
);
3447 CHECK_CALLED(ReportData
); /* Set in ReportResult */
3448 WaitForSingleObject(event_complete
, INFINITE
);
3451 SET_EXPECT(MimeFilter_LockRequest
);
3453 SET_EXPECT(LockRequest
);
3454 hres
= IInternetProtocol_LockRequest(protocol
, 0);
3455 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
3457 CHECK_CALLED(MimeFilter_LockRequest
);
3459 CHECK_CALLED(LockRequest
);
3462 SET_EXPECT(MimeFilter_UnlockRequest
);
3464 SET_EXPECT(UnlockRequest
);
3465 hres
= IInternetProtocol_UnlockRequest(protocol
);
3466 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
3468 CHECK_CALLED(MimeFilter_UnlockRequest
);
3470 CHECK_CALLED(UnlockRequest
);
3474 SET_EXPECT(MimeFilter_Terminate
);
3476 SET_EXPECT(Terminate
);
3477 hres
= IInternetProtocol_Terminate(protocol
, 0);
3478 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
3480 CLEAR_CALLED(MimeFilter_Terminate
);
3482 CHECK_CALLED(Terminate
);
3484 if(filtered_protocol
)
3485 IInternetProtocol_Release(filtered_protocol
);
3486 IInternetBindInfo_Release(prot_bind_info
);
3487 IInternetProtocolSink_Release(binding_sink
);
3488 ref
= IInternetProtocol_Release(protocol
);
3489 ok(!ref
, "ref=%u, expected 0\n", ref
);
3491 if(test_flags
& TEST_EMULATEPROT
) {
3492 hres
= IInternetSession_UnregisterNameSpace(session
, &ClassFactory
, protocol_names
[prot
]);
3493 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
3496 IInternetSession_Release(session
);
3499 START_TEST(protocol
)
3503 hurlmon
= GetModuleHandle("urlmon.dll");
3504 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
3505 pReleaseBindInfo
= (void*) GetProcAddress(hurlmon
, "ReleaseBindInfo");
3506 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
3508 if(!GetProcAddress(hurlmon
, "CompareSecurityIds")) {
3509 win_skip("Various needed functions not present, too old IE\n");
3514 win_skip("CreateUri not supported\n");
3516 OleInitialize(NULL
);
3518 event_complete
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3519 event_complete2
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3520 event_continue
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3521 event_continue_done
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3522 thread_id
= GetCurrentThreadId();
3524 test_file_protocol();
3525 test_http_protocol();
3526 test_https_protocol();
3527 test_ftp_protocol();
3528 test_gopher_protocol();
3530 test_CreateBinding();
3532 bindf
&= ~BINDF_FROMURLMON
;
3533 trace("Testing file binding (mime verification, emulate prot)...\n");
3534 test_binding(FILE_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
);
3535 trace("Testing http binding (mime verification, emulate prot)...\n");
3536 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
);
3537 trace("Testing its binding (mime verification, emulate prot)...\n");
3538 test_binding(ITS_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
);
3539 trace("Testing http binding (mime verification, emulate prot, short read, direct read)...\n");
3540 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_SHORT_READ
|TEST_DIRECT_READ
);
3541 trace("Testing file binding (mime verification, emulate prot, mime filter)...\n");
3542 test_binding(FILE_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_FILTER
);
3543 trace("Testing http binding (mime verification, emulate prot, mime filter)...\n");
3544 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_FILTER
);
3545 trace("Testing http binding (mime verification, emulate prot, direct read)...\n");
3546 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_DIRECT_READ
);
3547 trace("Testing http binding (mime verification, emulate prot, abort)...\n");
3548 test_binding(HTTP_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_ABORT
);
3550 trace("Testing file binding (use IUri, mime verification, emulate prot)...\n");
3551 test_binding(FILE_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_USEIURI
);
3552 trace("Testing file binding (use IUri, impl StartEx, mime verification, emulate prot)...\n");
3553 test_binding(FILE_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_USEIURI
|TEST_IMPLPROTEX
);
3554 trace("Testing file binding (impl StartEx, mime verification, emulate prot)...\n");
3555 test_binding(FILE_TEST
, PI_MIMEVERIFICATION
, TEST_EMULATEPROT
|TEST_IMPLPROTEX
);
3558 CloseHandle(event_complete
);
3559 CloseHandle(event_complete2
);
3560 CloseHandle(event_continue
);
3561 CloseHandle(event_continue_done
);