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, "expected: %08x got: %08x\n", expect_hrResult, hrResult);
130 ok(dwError == 0, "dwError = %d\n", dwError);
131 ok(!szResult, "szResult != NULL\n");
136 static IInternetProtocolSinkVtbl protocol_sink_vtbl = {
137 ProtocolSink_QueryInterface,
139 ProtocolSink_Release,
141 ProtocolSink_ReportProgress,
142 ProtocolSink_ReportData,
143 ProtocolSink_ReportResult
146 static IInternetProtocolSink protocol_sink = {
150 static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
152 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) {
156 return E_NOINTERFACE;
159 static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
164 static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
169 static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
171 CHECK_EXPECT(GetBindInfo);
173 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
175 ok(!*grfBINDF, "*grfBINDF != 0\n");
176 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
177 ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %d\n", pbindinfo->cbSize);
182 static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType, LPOLESTR *ppwzStr,
183 ULONG cEl, ULONG *pcElFetched)
185 ok(0, "unexpected call\n");
189 static IInternetBindInfoVtbl bind_info_vtbl = {
190 BindInfo_QueryInterface,
193 BindInfo_GetBindInfo,
194 BindInfo_GetBindString
197 static IInternetBindInfo bind_info = {
201 static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT expected_hres,
202 BOOL expect_win32err)
206 SET_EXPECT(GetBindInfo);
207 SET_EXPECT(ReportResult);
209 expect_hrResult = expected_hres;
210 expect_hr_win32err = expect_win32err;
211 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
213 ok((hres&0xffff0000) == ((FACILITY_WIN32 << 16)|0x80000000) || hres == expect_hrResult,
214 "expected win32 err or %08x got: %08x\n", expected_hres, hres);
216 ok(hres == expected_hres, "expected: %08x got: %08x\n", expected_hres, hres);
218 CHECK_CALLED(GetBindInfo);
219 CHECK_CALLED(ReportResult);
222 static void protocol_start(IInternetProtocol *protocol, LPCWSTR url)
226 SET_EXPECT(GetBindInfo);
227 SET_EXPECT(ReportResult);
228 SET_EXPECT(ReportProgress);
229 SET_EXPECT(ReportData);
230 expect_hrResult = S_OK;
231 expect_hr_win32err = FALSE;
233 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
234 ok(hres == S_OK, "Start failed: %08x\n", hres);
236 CHECK_CALLED(GetBindInfo);
237 CHECK_CALLED(ReportProgress);
238 CHECK_CALLED(ReportData);
239 CHECK_CALLED(ReportResult);
242 static void test_res_protocol(void)
244 IInternetProtocolInfo *protocol_info;
246 IClassFactory *factory;
249 static const WCHAR blank_url[] =
250 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
251 static const WCHAR test_part_url[] = {'r','e','s',':','/','/','C','S','S','/','t','e','s','t',0};
252 static const WCHAR wrong_url1[] =
253 {'m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','m','t','h',0};
254 static const WCHAR wrong_url2[] =
255 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',0};
256 static const WCHAR wrong_url3[] =
257 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','x','x','.','h','t','m',0};
258 static const WCHAR wrong_url4[] =
259 {'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
262 hres = CoGetClassObject(&CLSID_ResProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
263 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
267 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
268 ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08x\n", hres);
269 if(SUCCEEDED(hres)) {
274 for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
275 if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
276 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
277 sizeof(buf)/sizeof(buf[0]), &size, 0);
278 ok(hres == INET_E_DEFAULT_ACTION,
279 "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i, hres);
283 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
284 sizeof(buf)/sizeof(buf[0]), &size, 0);
285 ok(hres == S_OK, "ParseUrl failed: %08x\n", hres);
287 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
289 ok(hres == S_FALSE, "ParseUrl failed: %08x, expected S_FALSE\n", hres);
291 hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_SECURITY_URL, 0, buf,
292 sizeof(buf)/sizeof(buf[0]), &size, 0);
293 ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres);
297 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
298 sizeof(buf)/sizeof(buf[0]), &size, 0);
299 ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08x\n", hres);
300 ok(buf[0] == '?', "buf changed\n");
301 ok(size == sizeof(blank_url)/sizeof(WCHAR), "size=%d\n", size);
304 hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_DOMAIN, 0, buf,
305 sizeof(buf)/sizeof(buf[0]), &size, 0);
306 ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08x\n", hres);
307 ok(buf[0] == '?', "buf changed\n");
308 ok(size == sizeof(wrong_url1)/sizeof(WCHAR), "size=%d\n", size);
310 #if 0 /* Crashes on win9x */
313 hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf,
314 sizeof(buf)/sizeof(buf[0]), &size, 0);
315 ok(hres == E_FAIL, "ParseUrl failed: %08lx\n", hres);
316 ok(buf[0] == '?', "buf changed\n");
317 ok(size == 1, "size=%ld, ezpected 1\n", size);
320 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
321 sizeof(buf)/sizeof(buf[0]), NULL, 0);
322 ok(hres == E_POINTER, "ParseUrl failed: %08lx\n", hres);
323 ok(buf[0] == '?', "buf changed\n");
326 hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf,
327 sizeof(buf)/sizeof(buf[0]), NULL, 0);
328 ok(hres == E_POINTER, "ParseUrl failed: %08lx\n", hres);
329 ok(buf[0] == '?', "buf changed\n");
333 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
334 sizeof(buf)/sizeof(buf[0]), &size, 0);
335 ok(hres == INET_E_DEFAULT_ACTION,
336 "ParseUrl failed: %08x, expected INET_E_DEFAULT_ACTION\n", hres);
337 ok(buf[0] == '?', "buf changed\n");
340 hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_part_url,
341 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
342 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
343 ok(size == 0xdeadbeef, "size=%d\n", size);
346 hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_part_url,
347 URL_FILE_USE_PATHURL, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
348 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
349 ok(size == 0xdeadbeef, "size=%d\n", size);
352 hres = IInternetProtocolInfo_CombineUrl(protocol_info, NULL, NULL,
353 URL_FILE_USE_PATHURL, NULL, 0xdeadbeef, NULL, 0);
354 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
355 ok(size == 0xdeadbeef, "size=%d\n", size);
357 hres = IInternetProtocolInfo_CompareUrl(protocol_info, blank_url, blank_url, 0);
358 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
360 hres = IInternetProtocolInfo_CompareUrl(protocol_info, NULL, NULL, 0xdeadbeef);
361 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
363 IInternetProtocolInfo_Release(protocol_info);
366 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
367 ok(hres == S_OK, "Could not get IClassFactory interface\n");
368 if(SUCCEEDED(hres)) {
369 IInternetProtocol *protocol;
372 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
373 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
375 if(SUCCEEDED(hres)) {
376 test_protocol_fail(protocol, wrong_url1, MK_E_SYNTAX, FALSE);
377 test_protocol_fail(protocol, wrong_url2, MK_E_SYNTAX, FALSE);
378 test_protocol_fail(protocol, wrong_url3, E_FAIL, TRUE);
379 test_protocol_fail(protocol, wrong_url4, E_FAIL, TRUE);
382 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
383 ok(hres == E_FAIL, "Read returned %08x expected E_FAIL\n", hres);
384 ok(cb == 0xdeadbeef, "cb=%u expected 0xdeadbeef\n", cb);
386 protocol_start(protocol, blank_url);
387 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
388 ok(hres == S_OK, "Read failed: %08x\n", hres);
389 ok(cb == 2, "cb=%u expected 2\n", cb);
390 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
391 ok(hres == S_OK, "Read failed: %08x\n", hres);
392 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
393 ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres);
394 ok(cb == 0, "cb=%u expected 0\n", cb);
395 hres = IInternetProtocol_UnlockRequest(protocol);
396 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
398 protocol_start(protocol, blank_url);
399 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
400 ok(hres == S_OK, "Read failed: %08x\n", hres);
401 hres = IInternetProtocol_LockRequest(protocol, 0);
402 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
403 hres = IInternetProtocol_UnlockRequest(protocol);
404 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
405 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
406 ok(hres == S_OK, "Read failed: %08x\n", hres);
408 protocol_start(protocol, blank_url);
409 hres = IInternetProtocol_LockRequest(protocol, 0);
410 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
411 hres = IInternetProtocol_Terminate(protocol, 0);
412 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
413 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
414 ok(hres == S_OK, "Read failed: %08x\n\n", hres);
415 hres = IInternetProtocol_UnlockRequest(protocol);
416 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
417 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
418 ok(hres == S_OK, "Read 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", hres);
423 ok(cb == 2, "cb=%u expected 2\n", cb);
425 protocol_start(protocol, blank_url);
426 hres = IInternetProtocol_LockRequest(protocol, 0);
427 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
428 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
429 ok(hres == S_OK, "Read failed: %08x\n", hres);
430 protocol_start(protocol, blank_url);
431 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
432 ok(hres == S_OK, "Read failed: %08x\n", hres);
433 hres = IInternetProtocol_Terminate(protocol, 0);
434 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
436 IInternetProtocol_Release(protocol);
439 IClassFactory_Release(factory);
442 IUnknown_Release(unk);
445 static void test_about_protocol(void)
447 IInternetProtocolInfo *protocol_info;
449 IClassFactory *factory;
452 static const WCHAR blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
453 static const WCHAR test_url[] = {'a','b','o','u','t',':','t','e','s','t',0};
454 static const WCHAR res_url[] = {'r','e','s',':','b','l','a','n','k',0};
455 static const WCHAR blank_html[] = {0xfeff,'<','H','T','M','L','>','<','/','H','T','M','L','>',0};
456 static const WCHAR test_html[] =
457 {0xfeff,'<','H','T','M','L','>','t','e','s','t','<','/','H','T','M','L','>',0};
459 hres = CoGetClassObject(&CLSID_AboutProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
460 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
464 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
465 ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08x\n", hres);
466 if(SUCCEEDED(hres)) {
471 for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
472 if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
473 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
474 sizeof(buf)/sizeof(buf[0]), &size, 0);
475 ok(hres == INET_E_DEFAULT_ACTION,
476 "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i, hres);
480 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
481 sizeof(buf)/sizeof(buf[0]), &size, 0);
482 ok(hres == S_OK, "ParseUrl failed: %08x\n", hres);
483 ok(!lstrcmpW(blank_url, buf), "buf != blank_url\n");
485 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
487 ok(hres == S_FALSE, "ParseUrl failed: %08x, expected S_FALSE\n", hres);
489 hres = IInternetProtocolInfo_ParseUrl(protocol_info, test_url, PARSE_SECURITY_URL, 0, buf,
490 sizeof(buf)/sizeof(buf[0]), &size, 0);
491 ok(hres == S_OK, "ParseUrl failed: %08x\n", hres);
492 ok(!lstrcmpW(test_url, buf), "buf != test_url\n");
496 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
497 sizeof(buf)/sizeof(buf[0]), &size, 0);
498 ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08x\n", hres);
499 ok(buf[0] == '?', "buf changed\n");
500 ok(size == sizeof(blank_url)/sizeof(WCHAR), "size=%d\n", size);
502 #if 0 /* Crashes on win9x */
505 hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf,
506 sizeof(buf)/sizeof(buf[0]), &size, 0);
507 ok(hres == E_FAIL, "ParseUrl failed: %08lx\n", hres);
508 ok(buf[0] == '?', "buf changed\n");
509 ok(size == 1, "size=%ld, ezpected 1\n", size);
512 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
513 sizeof(buf)/sizeof(buf[0]), NULL, 0);
514 ok(hres == E_POINTER, "ParseUrl failed: %08lx\n", hres);
515 ok(buf[0] == '?', "buf changed\n");
518 hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf,
519 sizeof(buf)/sizeof(buf[0]), NULL, 0);
520 ok(hres == E_POINTER, "ParseUrl failed: %08lx\n", hres);
521 ok(buf[0] == '?', "buf changed\n");
524 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
525 sizeof(buf)/sizeof(buf[0]), &size, 0);
526 ok(hres == INET_E_DEFAULT_ACTION,
527 "ParseUrl failed: %08x, expected INET_E_DEFAULT_ACTION\n", hres);
530 hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_url,
531 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
532 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
533 ok(size == 0xdeadbeef, "size=%d\n", size);
536 hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_url,
537 URL_FILE_USE_PATHURL, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
538 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
539 ok(size == 0xdeadbeef, "size=%d\n", size);
542 hres = IInternetProtocolInfo_CombineUrl(protocol_info, NULL, NULL,
543 URL_FILE_USE_PATHURL, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
544 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
545 ok(size == 0xdeadbeef, "size=%d\n", size);
547 hres = IInternetProtocolInfo_CompareUrl(protocol_info, blank_url, blank_url, 0);
548 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
550 hres = IInternetProtocolInfo_CompareUrl(protocol_info, NULL, NULL, 0xdeadbeef);
551 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
553 IInternetProtocolInfo_Release(protocol_info);
556 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
557 ok(hres == S_OK, "Could not get IClassFactory interface\n");
558 if(SUCCEEDED(hres)) {
559 IInternetProtocol *protocol;
562 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
563 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
565 if(SUCCEEDED(hres)) {
566 protocol_start(protocol, blank_url);
567 hres = IInternetProtocol_LockRequest(protocol, 0);
568 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
569 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
570 ok(hres == S_OK, "Read failed: %08x\n", hres);
571 ok(cb == sizeof(blank_html), "cb=%d\n", cb);
572 ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n");
573 hres = IInternetProtocol_UnlockRequest(protocol);
574 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
576 protocol_start(protocol, test_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(test_html), "cb=%d\n", cb);
582 ok(!memcmp(buf, test_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, res_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(blank_html), "cb=%d\n", cb);
592 ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n");
593 hres = IInternetProtocol_UnlockRequest(protocol);
594 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
596 IInternetProtocol_Release(protocol);
599 IClassFactory_Release(factory);
602 IUnknown_Release(unk);
610 test_about_protocol();