2 * Copyright 2005 Jacek Caban
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
21 #include <wine/test.h>
32 #define DEFINE_EXPECT(func) \
33 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
35 #define SET_EXPECT(func) \
36 expect_ ## func = TRUE
38 #define CHECK_EXPECT(func) \
40 ok(expect_ ##func, "unexpected call " #func "\n"); \
41 expect_ ## func = FALSE; \
42 called_ ## func = TRUE; \
45 #define CHECK_EXPECT2(func) \
47 ok(expect_ ##func, "unexpected call " #func "\n"); \
48 called_ ## func = TRUE; \
51 #define CHECK_CALLED(func) \
53 ok(called_ ## func, "expected " #func "\n"); \
54 expect_ ## func = called_ ## func = FALSE; \
57 DEFINE_GUID(CLSID_ResProtocol
, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
58 DEFINE_GUID(CLSID_AboutProtocol
, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
60 DEFINE_EXPECT(GetBindInfo
);
61 DEFINE_EXPECT(ReportProgress
);
62 DEFINE_EXPECT(ReportData
);
63 DEFINE_EXPECT(ReportResult
);
65 static HRESULT expect_hrResult
;
66 static BOOL expect_hr_win32err
= FALSE
;
68 static HRESULT WINAPI
ProtocolSink_QueryInterface(IInternetProtocolSink
*iface
, REFIID riid
, void **ppv
)
70 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocolSink
, riid
)) {
77 static ULONG WINAPI
ProtocolSink_AddRef(IInternetProtocolSink
*iface
)
82 static ULONG WINAPI
ProtocolSink_Release(IInternetProtocolSink
*iface
)
87 static HRESULT WINAPI
ProtocolSink_Switch(IInternetProtocolSink
*iface
, PROTOCOLDATA
*pProtocolData
)
89 ok(0, "unexpected call\n");
93 static HRESULT WINAPI
ProtocolSink_ReportProgress(IInternetProtocolSink
*iface
, ULONG ulStatusCode
,
96 static const WCHAR text_html
[] = {'t','e','x','t','/','h','t','m','l',0};
98 CHECK_EXPECT(ReportProgress
);
100 ok(ulStatusCode
== BINDSTATUS_MIMETYPEAVAILABLE
101 || ulStatusCode
== BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
,
102 "ulStatusCode=%d\n", ulStatusCode
);
103 ok(!lstrcmpW(szStatusText
, text_html
), "szStatusText != text/html\n");
108 static HRESULT WINAPI
ProtocolSink_ReportData(IInternetProtocolSink
*iface
, DWORD grfBSCF
, ULONG ulProgress
,
111 CHECK_EXPECT(ReportData
);
113 ok(ulProgress
== ulProgressMax
, "ulProgress != ulProgressMax\n");
114 ok(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
| BSCF_DATAFULLYAVAILABLE
),
115 "grcf = %08x\n", grfBSCF
);
120 static HRESULT WINAPI
ProtocolSink_ReportResult(IInternetProtocolSink
*iface
, HRESULT hrResult
, DWORD dwError
,
123 CHECK_EXPECT(ReportResult
);
125 if(expect_hr_win32err
)
126 ok((hrResult
&0xffff0000) == ((FACILITY_WIN32
<< 16)|0x80000000) || expect_hrResult
,
127 "expected win32 err or %08x got: %08x\n", expect_hrResult
, hrResult
);
129 ok(hrResult
== expect_hrResult
|| ((expect_hrResult
== E_INVALIDARG
||
130 expect_hrResult
== HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND
)) &&
131 hrResult
== MK_E_SYNTAX
), "expected: %08x got: %08x\n", expect_hrResult
, hrResult
);
132 ok(dwError
== 0, "dwError = %d\n", dwError
);
133 ok(!szResult
, "szResult != NULL\n");
138 static IInternetProtocolSinkVtbl protocol_sink_vtbl
= {
139 ProtocolSink_QueryInterface
,
141 ProtocolSink_Release
,
143 ProtocolSink_ReportProgress
,
144 ProtocolSink_ReportData
,
145 ProtocolSink_ReportResult
148 static IInternetProtocolSink protocol_sink
= {
152 static HRESULT WINAPI
BindInfo_QueryInterface(IInternetBindInfo
*iface
, REFIID riid
, void **ppv
)
154 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
158 return E_NOINTERFACE
;
161 static ULONG WINAPI
BindInfo_AddRef(IInternetBindInfo
*iface
)
166 static ULONG WINAPI
BindInfo_Release(IInternetBindInfo
*iface
)
171 static HRESULT WINAPI
BindInfo_GetBindInfo(IInternetBindInfo
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
173 CHECK_EXPECT(GetBindInfo
);
175 ok(grfBINDF
!= NULL
, "grfBINDF == NULL\n");
177 ok(!*grfBINDF
, "*grfBINDF != 0\n");
178 ok(pbindinfo
!= NULL
, "pbindinfo == NULL\n");
179 ok(pbindinfo
->cbSize
== sizeof(BINDINFO
), "wrong size of pbindinfo: %d\n", pbindinfo
->cbSize
);
184 static HRESULT WINAPI
BindInfo_GetBindString(IInternetBindInfo
*iface
, ULONG ulStringType
, LPOLESTR
*ppwzStr
,
185 ULONG cEl
, ULONG
*pcElFetched
)
187 ok(0, "unexpected call\n");
191 static IInternetBindInfoVtbl bind_info_vtbl
= {
192 BindInfo_QueryInterface
,
195 BindInfo_GetBindInfo
,
196 BindInfo_GetBindString
199 static IInternetBindInfo bind_info
= {
203 static void test_protocol_fail(IInternetProtocol
*protocol
, LPCWSTR url
, HRESULT expected_hres
,
204 BOOL expect_win32err
)
208 SET_EXPECT(GetBindInfo
);
209 SET_EXPECT(ReportResult
);
211 expect_hrResult
= expected_hres
;
212 expect_hr_win32err
= expect_win32err
;
213 hres
= IInternetProtocol_Start(protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
215 ok((hres
&0xffff0000) == ((FACILITY_WIN32
<< 16)|0x80000000) || hres
== expect_hrResult
,
216 "expected win32 err or %08x got: %08x\n", expected_hres
, hres
);
218 ok(hres
== expected_hres
|| ((expected_hres
== E_INVALIDARG
||
219 expected_hres
== HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND
)) && hres
== MK_E_SYNTAX
),
220 "expected: %08x got: %08x\n", expected_hres
, hres
);
222 CHECK_CALLED(GetBindInfo
);
223 CHECK_CALLED(ReportResult
);
226 static void protocol_start(IInternetProtocol
*protocol
, LPCWSTR url
)
230 SET_EXPECT(GetBindInfo
);
231 SET_EXPECT(ReportResult
);
232 SET_EXPECT(ReportProgress
);
233 SET_EXPECT(ReportData
);
234 expect_hrResult
= S_OK
;
235 expect_hr_win32err
= FALSE
;
237 hres
= IInternetProtocol_Start(protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
238 ok(hres
== S_OK
, "Start failed: %08x\n", hres
);
240 CHECK_CALLED(GetBindInfo
);
241 CHECK_CALLED(ReportProgress
);
242 CHECK_CALLED(ReportData
);
243 CHECK_CALLED(ReportResult
);
246 static void test_res_protocol(void)
248 IInternetProtocolInfo
*protocol_info
;
250 IClassFactory
*factory
;
253 static const WCHAR blank_url
[] =
254 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
255 static const WCHAR test_part_url
[] = {'r','e','s',':','/','/','C','S','S','/','t','e','s','t',0};
256 static const WCHAR wrong_url1
[] =
257 {'m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','m','t','h',0};
258 static const WCHAR wrong_url2
[] =
259 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',0};
260 static const WCHAR wrong_url3
[] =
261 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','x','x','.','h','t','m',0};
262 static const WCHAR wrong_url4
[] =
263 {'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
266 hres
= CoGetClassObject(&CLSID_ResProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
267 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
271 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
272 ok(hres
== S_OK
, "Could not get IInternetProtocolInfo interface: %08x\n", hres
);
273 if(SUCCEEDED(hres
)) {
278 for(i
= PARSE_CANONICALIZE
; i
<= PARSE_UNESCAPE
; i
++) {
279 if(i
!= PARSE_SECURITY_URL
&& i
!= PARSE_DOMAIN
) {
280 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, i
, 0, buf
,
281 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
282 ok(hres
== INET_E_DEFAULT_ACTION
,
283 "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i
, hres
);
287 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_SECURITY_URL
, 0, buf
,
288 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
289 ok(hres
== S_OK
, "ParseUrl failed: %08x\n", hres
);
291 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_SECURITY_URL
, 0, buf
,
293 ok(hres
== S_FALSE
, "ParseUrl failed: %08x, expected S_FALSE\n", hres
);
295 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, wrong_url1
, PARSE_SECURITY_URL
, 0, buf
,
296 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
297 ok(hres
== MK_E_SYNTAX
|| hres
== E_INVALIDARG
,
298 "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres
);
302 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_DOMAIN
, 0, buf
,
303 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
304 ok(hres
== S_OK
|| hres
== E_FAIL
, "ParseUrl failed: %08x\n", hres
);
305 ok(buf
[0] == '?', "buf changed\n");
306 ok(size
== sizeof(blank_url
)/sizeof(WCHAR
), "size=%d\n", size
);
309 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, wrong_url1
, PARSE_DOMAIN
, 0, buf
,
310 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
311 ok(hres
== S_OK
|| hres
== E_FAIL
, "ParseUrl failed: %08x\n", hres
);
312 ok(buf
[0] == '?', "buf changed\n");
313 ok(size
== sizeof(wrong_url1
)/sizeof(WCHAR
), "size=%d\n", size
);
317 /* Crashes on win9x */
320 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, NULL
, PARSE_DOMAIN
, 0, buf
,
321 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
322 ok(hres
== E_FAIL
, "ParseUrl failed: %08x\n", hres
);
323 ok(buf
[0] == '?', "buf changed\n");
324 ok(size
== 1, "size=%u, ezpected 1\n", size
);
327 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_DOMAIN
, 0, buf
,
328 sizeof(buf
)/sizeof(buf
[0]), NULL
, 0);
329 ok(hres
== E_POINTER
, "ParseUrl failed: %08x\n", hres
);
330 ok(buf
[0] == '?', "buf changed\n");
333 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, NULL
, PARSE_DOMAIN
, 0, buf
,
334 sizeof(buf
)/sizeof(buf
[0]), NULL
, 0);
335 ok(hres
== E_POINTER
, "ParseUrl failed: %08x\n", hres
);
336 ok(buf
[0] == '?', "buf changed\n");
340 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_UNESCAPE
+1, 0, buf
,
341 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
342 ok(hres
== INET_E_DEFAULT_ACTION
,
343 "ParseUrl failed: %08x, expected INET_E_DEFAULT_ACTION\n", hres
);
344 ok(buf
[0] == '?', "buf changed\n");
347 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, blank_url
, test_part_url
,
348 0, buf
, sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
349 ok(hres
== INET_E_USE_DEFAULT_PROTOCOLHANDLER
, "CombineUrl failed: %08x\n", hres
);
350 ok(size
== 0xdeadbeef, "size=%d\n", size
);
353 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, blank_url
, test_part_url
,
354 URL_FILE_USE_PATHURL
, buf
, sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
355 ok(hres
== INET_E_USE_DEFAULT_PROTOCOLHANDLER
, "CombineUrl failed: %08x\n", hres
);
356 ok(size
== 0xdeadbeef, "size=%d\n", size
);
359 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, NULL
, NULL
,
360 URL_FILE_USE_PATHURL
, NULL
, 0xdeadbeef, NULL
, 0);
361 ok(hres
== INET_E_USE_DEFAULT_PROTOCOLHANDLER
, "CombineUrl failed: %08x\n", hres
);
362 ok(size
== 0xdeadbeef, "size=%d\n", size
);
364 hres
= IInternetProtocolInfo_CompareUrl(protocol_info
, blank_url
, blank_url
, 0);
365 ok(hres
== E_NOTIMPL
, "CompareUrl failed: %08x\n", hres
);
367 hres
= IInternetProtocolInfo_CompareUrl(protocol_info
, NULL
, NULL
, 0xdeadbeef);
368 ok(hres
== E_NOTIMPL
, "CompareUrl failed: %08x\n", hres
);
370 IInternetProtocolInfo_Release(protocol_info
);
373 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
374 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
375 if(SUCCEEDED(hres
)) {
376 IInternetProtocol
*protocol
;
379 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
380 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
382 if(SUCCEEDED(hres
)) {
383 test_protocol_fail(protocol
, wrong_url1
, E_INVALIDARG
, FALSE
);
384 test_protocol_fail(protocol
, wrong_url2
,
385 HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND
), FALSE
);
386 test_protocol_fail(protocol
, wrong_url3
, E_FAIL
, TRUE
);
387 test_protocol_fail(protocol
, wrong_url4
, E_FAIL
, TRUE
);
390 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
391 ok(hres
== E_FAIL
, "Read returned %08x expected E_FAIL\n", hres
);
392 ok(cb
== 0xdeadbeef, "cb=%u expected 0xdeadbeef\n", cb
);
394 protocol_start(protocol
, blank_url
);
395 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
396 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
397 ok(cb
== 2, "cb=%u expected 2\n", cb
);
398 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
399 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
400 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
401 ok(hres
== S_FALSE
, "Read failed: %08x expected S_FALSE\n", hres
);
402 ok(cb
== 0, "cb=%u expected 0\n", cb
);
403 hres
= IInternetProtocol_UnlockRequest(protocol
);
404 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
406 protocol_start(protocol
, blank_url
);
407 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
408 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
409 hres
= IInternetProtocol_LockRequest(protocol
, 0);
410 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
411 hres
= IInternetProtocol_UnlockRequest(protocol
);
412 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
413 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
414 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
416 protocol_start(protocol
, blank_url
);
417 hres
= IInternetProtocol_LockRequest(protocol
, 0);
418 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
419 hres
= IInternetProtocol_Terminate(protocol
, 0);
420 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
421 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
422 ok(hres
== S_OK
, "Read failed: %08x\n\n", hres
);
423 hres
= IInternetProtocol_UnlockRequest(protocol
);
424 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
425 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
426 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
427 hres
= IInternetProtocol_Terminate(protocol
, 0);
428 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
429 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
430 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
431 ok(cb
== 2, "cb=%u expected 2\n", cb
);
433 protocol_start(protocol
, blank_url
);
434 hres
= IInternetProtocol_LockRequest(protocol
, 0);
435 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
436 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
437 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
438 protocol_start(protocol
, blank_url
);
439 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
440 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
441 hres
= IInternetProtocol_Terminate(protocol
, 0);
442 ok(hres
== S_OK
, "Terminate failed: %08x\n", hres
);
444 IInternetProtocol_Release(protocol
);
447 IClassFactory_Release(factory
);
450 IUnknown_Release(unk
);
453 static void test_about_protocol(void)
455 IInternetProtocolInfo
*protocol_info
;
457 IClassFactory
*factory
;
460 static const WCHAR blank_url
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
461 static const WCHAR test_url
[] = {'a','b','o','u','t',':','t','e','s','t',0};
462 static const WCHAR res_url
[] = {'r','e','s',':','b','l','a','n','k',0};
463 static const WCHAR blank_html
[] = {0xfeff,'<','H','T','M','L','>','<','/','H','T','M','L','>',0};
464 static const WCHAR test_html
[] =
465 {0xfeff,'<','H','T','M','L','>','t','e','s','t','<','/','H','T','M','L','>',0};
467 hres
= CoGetClassObject(&CLSID_AboutProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
468 ok(hres
== S_OK
, "CoGetClassObject failed: %08x\n", hres
);
472 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
473 ok(hres
== S_OK
, "Could not get IInternetProtocolInfo interface: %08x\n", hres
);
474 if(SUCCEEDED(hres
)) {
479 for(i
= PARSE_CANONICALIZE
; i
<= PARSE_UNESCAPE
; i
++) {
480 if(i
!= PARSE_SECURITY_URL
&& i
!= PARSE_DOMAIN
) {
481 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, i
, 0, buf
,
482 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
483 ok(hres
== INET_E_DEFAULT_ACTION
,
484 "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i
, hres
);
488 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_SECURITY_URL
, 0, buf
,
489 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
490 ok(hres
== S_OK
, "ParseUrl failed: %08x\n", hres
);
491 ok(!lstrcmpW(blank_url
, buf
), "buf != blank_url\n");
493 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_SECURITY_URL
, 0, buf
,
495 ok(hres
== S_FALSE
, "ParseUrl failed: %08x, expected S_FALSE\n", hres
);
497 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, test_url
, PARSE_SECURITY_URL
, 0, buf
,
498 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
499 ok(hres
== S_OK
, "ParseUrl failed: %08x\n", hres
);
500 ok(!lstrcmpW(test_url
, buf
), "buf != test_url\n");
504 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_DOMAIN
, 0, buf
,
505 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
506 ok(hres
== S_OK
|| hres
== E_FAIL
, "ParseUrl failed: %08x\n", hres
);
507 ok(buf
[0] == '?', "buf changed\n");
508 ok(size
== sizeof(blank_url
)/sizeof(WCHAR
), "size=%d\n", size
);
512 /* Crashes on win9x */
515 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, NULL
, PARSE_DOMAIN
, 0, buf
,
516 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
517 ok(hres
== E_FAIL
, "ParseUrl failed: %08x\n", hres
);
518 ok(buf
[0] == '?', "buf changed\n");
519 ok(size
== 1, "size=%u, ezpected 1\n", size
);
522 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_DOMAIN
, 0, buf
,
523 sizeof(buf
)/sizeof(buf
[0]), NULL
, 0);
524 ok(hres
== E_POINTER
, "ParseUrl failed: %08x\n", hres
);
525 ok(buf
[0] == '?', "buf changed\n");
528 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, NULL
, PARSE_DOMAIN
, 0, buf
,
529 sizeof(buf
)/sizeof(buf
[0]), NULL
, 0);
530 ok(hres
== E_POINTER
, "ParseUrl failed: %08x\n", hres
);
531 ok(buf
[0] == '?', "buf changed\n");
534 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_UNESCAPE
+1, 0, buf
,
535 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
536 ok(hres
== INET_E_DEFAULT_ACTION
,
537 "ParseUrl failed: %08x, expected INET_E_DEFAULT_ACTION\n", hres
);
540 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, blank_url
, test_url
,
541 0, buf
, sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
542 ok(hres
== INET_E_USE_DEFAULT_PROTOCOLHANDLER
, "CombineUrl failed: %08x\n", hres
);
543 ok(size
== 0xdeadbeef, "size=%d\n", size
);
546 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, blank_url
, test_url
,
547 URL_FILE_USE_PATHURL
, buf
, sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
548 ok(hres
== INET_E_USE_DEFAULT_PROTOCOLHANDLER
, "CombineUrl failed: %08x\n", hres
);
549 ok(size
== 0xdeadbeef, "size=%d\n", size
);
552 hres
= IInternetProtocolInfo_CombineUrl(protocol_info
, NULL
, NULL
,
553 URL_FILE_USE_PATHURL
, buf
, sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
554 ok(hres
== INET_E_USE_DEFAULT_PROTOCOLHANDLER
, "CombineUrl failed: %08x\n", hres
);
555 ok(size
== 0xdeadbeef, "size=%d\n", size
);
557 hres
= IInternetProtocolInfo_CompareUrl(protocol_info
, blank_url
, blank_url
, 0);
558 ok(hres
== E_NOTIMPL
, "CompareUrl failed: %08x\n", hres
);
560 hres
= IInternetProtocolInfo_CompareUrl(protocol_info
, NULL
, NULL
, 0xdeadbeef);
561 ok(hres
== E_NOTIMPL
, "CompareUrl failed: %08x\n", hres
);
563 IInternetProtocolInfo_Release(protocol_info
);
566 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
567 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
568 if(SUCCEEDED(hres
)) {
569 IInternetProtocol
*protocol
;
572 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
573 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08x\n", hres
);
575 if(SUCCEEDED(hres
)) {
576 protocol_start(protocol
, blank_url
);
577 hres
= IInternetProtocol_LockRequest(protocol
, 0);
578 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
579 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
580 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
581 ok(cb
== sizeof(blank_html
), "cb=%d\n", cb
);
582 ok(!memcmp(buf
, blank_html
, cb
), "Readed wrong data\n");
583 hres
= IInternetProtocol_UnlockRequest(protocol
);
584 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
586 protocol_start(protocol
, test_url
);
587 hres
= IInternetProtocol_LockRequest(protocol
, 0);
588 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
589 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
590 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
591 ok(cb
== sizeof(test_html
), "cb=%d\n", cb
);
592 ok(!memcmp(buf
, test_html
, cb
), "Readed wrong data\n");
593 hres
= IInternetProtocol_UnlockRequest(protocol
);
594 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
596 protocol_start(protocol
, res_url
);
597 hres
= IInternetProtocol_LockRequest(protocol
, 0);
598 ok(hres
== S_OK
, "LockRequest failed: %08x\n", hres
);
599 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
600 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
601 ok(cb
== sizeof(blank_html
), "cb=%d\n", cb
);
602 ok(!memcmp(buf
, blank_html
, cb
), "Readed wrong data\n");
603 hres
= IInternetProtocol_UnlockRequest(protocol
);
604 ok(hres
== S_OK
, "UnlockRequest failed: %08x\n", hres
);
606 IInternetProtocol_Release(protocol
);
609 IClassFactory_Release(factory
);
612 IUnknown_Release(unk
);
620 test_about_protocol();