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>
31 #define DEFINE_EXPECT(func) \
32 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
34 #define SET_EXPECT(func) \
35 expect_ ## func = TRUE
37 #define CHECK_EXPECT(func) \
39 ok(expect_ ##func, "unexpected call " #func "\n"); \
40 expect_ ## func = FALSE; \
41 called_ ## func = TRUE; \
44 #define CHECK_EXPECT2(func) \
46 ok(expect_ ##func, "unexpected call " #func "\n"); \
47 called_ ## func = TRUE; \
50 #define CHECK_CALLED(func) \
52 ok(called_ ## func, "expected " #func "\n"); \
53 expect_ ## func = called_ ## func = FALSE; \
56 DEFINE_GUID(CLSID_ResProtocol
, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
57 DEFINE_GUID(CLSID_AboutProtocol
, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
59 DEFINE_EXPECT(GetBindInfo
);
60 DEFINE_EXPECT(ReportProgress
);
61 DEFINE_EXPECT(ReportData
);
62 DEFINE_EXPECT(ReportResult
);
64 static HRESULT expect_hrResult
;
65 static BOOL expect_hr_win32err
= FALSE
;
67 static HRESULT WINAPI
ProtocolSink_QueryInterface(IInternetProtocolSink
*iface
, REFIID riid
, void **ppv
)
69 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocolSink
, riid
)) {
76 static ULONG WINAPI
ProtocolSink_AddRef(IInternetProtocolSink
*iface
)
81 static ULONG WINAPI
ProtocolSink_Release(IInternetProtocolSink
*iface
)
86 static HRESULT WINAPI
ProtocolSink_Switch(IInternetProtocolSink
*iface
, PROTOCOLDATA
*pProtocolData
)
88 ok(0, "unexpected call\n");
92 static HRESULT WINAPI
ProtocolSink_ReportProgress(IInternetProtocolSink
*iface
, ULONG ulStatusCode
,
95 static const WCHAR text_html
[] = {'t','e','x','t','/','h','t','m','l',0};
97 CHECK_EXPECT(ReportProgress
);
99 ok(ulStatusCode
== BINDSTATUS_MIMETYPEAVAILABLE
100 || ulStatusCode
== BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
,
101 "ulStatusCode=%ld\n", ulStatusCode
);
102 ok(!lstrcmpW(szStatusText
, text_html
), "szStatusText != text/html\n");
107 static HRESULT WINAPI
ProtocolSink_ReportData(IInternetProtocolSink
*iface
, DWORD grfBSCF
, ULONG ulProgress
,
110 CHECK_EXPECT(ReportData
);
112 ok(ulProgress
== ulProgressMax
, "ulProgress != ulProgressMax\n");
113 ok(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
| BSCF_DATAFULLYAVAILABLE
),
114 "grcf = %08lx\n", grfBSCF
);
119 static HRESULT WINAPI
ProtocolSink_ReportResult(IInternetProtocolSink
*iface
, HRESULT hrResult
, DWORD dwError
,
122 CHECK_EXPECT(ReportResult
);
124 if(expect_hr_win32err
)
125 ok((hrResult
&0xffff0000) == ((FACILITY_WIN32
<< 16)|0x80000000) || expect_hrResult
,
126 "expected win32 err or %08lx got: %08lx\n", expect_hrResult
, hrResult
);
128 ok(hrResult
== expect_hrResult
, "expected: %08lx got: %08lx\n", expect_hrResult
, hrResult
);
129 ok(dwError
== 0, "dwError = %ld\n", dwError
);
130 ok(!szResult
, "szResult != NULL\n");
135 static IInternetProtocolSinkVtbl protocol_sink_vtbl
= {
136 ProtocolSink_QueryInterface
,
138 ProtocolSink_Release
,
140 ProtocolSink_ReportProgress
,
141 ProtocolSink_ReportData
,
142 ProtocolSink_ReportResult
145 static IInternetProtocolSink protocol_sink
= {
149 static HRESULT WINAPI
BindInfo_QueryInterface(IInternetBindInfo
*iface
, REFIID riid
, void **ppv
)
151 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
155 return E_NOINTERFACE
;
158 static ULONG WINAPI
BindInfo_AddRef(IInternetBindInfo
*iface
)
163 static ULONG WINAPI
BindInfo_Release(IInternetBindInfo
*iface
)
168 static HRESULT WINAPI
BindInfo_GetBindInfo(IInternetBindInfo
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
170 CHECK_EXPECT(GetBindInfo
);
172 ok(grfBINDF
!= NULL
, "grfBINDF == NULL\n");
174 ok(!*grfBINDF
, "*grfBINDF != 0\n");
175 ok(pbindinfo
!= NULL
, "pbindinfo == NULL\n");
176 ok(pbindinfo
->cbSize
== sizeof(BINDINFO
), "wrong size of pbindinfo: %ld\n", pbindinfo
->cbSize
);
181 static HRESULT WINAPI
BindInfo_GetBindString(IInternetBindInfo
*iface
, ULONG ulStringType
, LPOLESTR
*ppwzStr
,
182 ULONG cEl
, ULONG
*pcElFetched
)
184 ok(0, "unexpected call\n");
188 static IInternetBindInfoVtbl bind_info_vtbl
= {
189 BindInfo_QueryInterface
,
192 BindInfo_GetBindInfo
,
193 BindInfo_GetBindString
196 static IInternetBindInfo bind_info
= {
200 static void test_protocol_fail(IInternetProtocol
*protocol
, LPCWSTR url
, HRESULT expected_hres
,
201 BOOL expect_win32err
)
205 SET_EXPECT(GetBindInfo
);
206 SET_EXPECT(ReportResult
);
208 expect_hrResult
= expected_hres
;
209 expect_hr_win32err
= expect_win32err
;
210 hres
= IInternetProtocol_Start(protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
212 ok((hres
&0xffff0000) == ((FACILITY_WIN32
<< 16)|0x80000000) || hres
== expect_hrResult
,
213 "expected win32 err or %08lx got: %08lx\n", expected_hres
, hres
);
215 ok(hres
== expected_hres
, "expected: %08lx got: %08lx\n", expected_hres
, hres
);
217 CHECK_CALLED(GetBindInfo
);
218 CHECK_CALLED(ReportResult
);
221 static void protocol_start(IInternetProtocol
*protocol
, LPCWSTR url
)
225 SET_EXPECT(GetBindInfo
);
226 SET_EXPECT(ReportResult
);
227 SET_EXPECT(ReportProgress
);
228 SET_EXPECT(ReportData
);
229 expect_hrResult
= S_OK
;
230 expect_hr_win32err
= FALSE
;
232 hres
= IInternetProtocol_Start(protocol
, url
, &protocol_sink
, &bind_info
, 0, 0);
233 ok(hres
== S_OK
, "Start failed: %08lx\n", hres
);
235 CHECK_CALLED(GetBindInfo
);
236 CHECK_CALLED(ReportProgress
);
237 CHECK_CALLED(ReportData
);
238 CHECK_CALLED(ReportResult
);
241 static void test_res_protocol(void)
243 IInternetProtocolInfo
*protocol_info
;
245 IClassFactory
*factory
;
248 static const WCHAR blank_url
[] =
249 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
250 static const WCHAR wrong_url1
[] =
251 {'m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','m','t','h',0};
252 static const WCHAR wrong_url2
[] =
253 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',0};
254 static const WCHAR wrong_url3
[] =
255 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','x','x','.','h','t','m',0};
256 static const WCHAR wrong_url4
[] =
257 {'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
260 hres
= CoGetClassObject(&CLSID_ResProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
261 ok(hres
== S_OK
, "CoGetClassObject failed: %08lx\n", hres
);
265 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
266 ok(hres
== S_OK
, "Could not get IInternetProtocolInfo interface: %08lx\n", hres
);
267 if(SUCCEEDED(hres
)) {
272 for(i
= PARSE_CANONICALIZE
; i
<= PARSE_UNESCAPE
; i
++) {
273 if(i
!= PARSE_SECURITY_URL
&& i
!= PARSE_DOMAIN
) {
274 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, i
, 0, buf
,
275 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
276 ok(hres
== INET_E_DEFAULT_ACTION
,
277 "[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i
, hres
);
281 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_SECURITY_URL
, 0, buf
,
282 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
283 ok(hres
== S_OK
, "ParseUrl failed: %08lx\n", hres
);
285 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_SECURITY_URL
, 0, buf
,
287 ok(hres
== S_FALSE
, "ParseUrl failed: %08lx, expected S_FALSE\n", hres
);
289 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, wrong_url1
, PARSE_SECURITY_URL
, 0, buf
,
290 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
291 ok(hres
== MK_E_SYNTAX
, "ParseUrl failed: %08lx, expected MK_E_SYNTAX\n", hres
);
295 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_DOMAIN
, 0, buf
,
296 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
297 ok(hres
== S_OK
|| hres
== E_FAIL
, "ParseUrl failed: %08lx\n", hres
);
298 ok(buf
[0] == '?', "buf changed\n");
299 ok(size
== sizeof(blank_url
)/sizeof(WCHAR
),
300 "size=%ld, ezpected %d\n", size
, sizeof(wrong_url1
)/sizeof(WCHAR
));
303 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, wrong_url1
, PARSE_DOMAIN
, 0, buf
,
304 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
305 ok(hres
== S_OK
|| hres
== E_FAIL
, "ParseUrl failed: %08lx\n", hres
);
306 ok(buf
[0] == '?', "buf changed\n");
307 ok(size
== sizeof(wrong_url1
)/sizeof(WCHAR
),
308 "size=%ld, ezpected %d\n", size
, sizeof(wrong_url1
)/sizeof(WCHAR
));
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: %08lx, expected INET_E_DEFAULT_ACTION\n", hres
);
337 ok(buf
[0] == '?', "buf changed\n");
339 IInternetProtocolInfo_Release(protocol_info
);
342 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
343 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
344 if(SUCCEEDED(hres
)) {
345 IInternetProtocol
*protocol
;
348 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
349 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08lx\n", hres
);
351 if(SUCCEEDED(hres
)) {
352 test_protocol_fail(protocol
, wrong_url1
, MK_E_SYNTAX
, FALSE
);
353 test_protocol_fail(protocol
, wrong_url2
, MK_E_SYNTAX
, FALSE
);
354 test_protocol_fail(protocol
, wrong_url3
, E_FAIL
, TRUE
);
355 test_protocol_fail(protocol
, wrong_url4
, E_FAIL
, TRUE
);
358 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
359 ok(hres
== E_FAIL
, "Read returned %08lx expected E_FAIL\n", hres
);
360 ok(cb
== 0xdeadbeef, "cb=%lu expected 0xdeadbeef\n", cb
);
362 protocol_start(protocol
, blank_url
);
363 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
364 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
365 ok(cb
== 2, "cb=%lu expected 2\n", cb
);
366 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
367 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
368 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
369 ok(hres
== S_FALSE
, "Read failed: %08lx expected S_FALSE\n", hres
);
370 ok(cb
== 0, "cb=%lu expected 0\n", cb
);
371 hres
= IInternetProtocol_UnlockRequest(protocol
);
372 ok(hres
== S_OK
, "UnlockRequest failed: %08lx\n", hres
);
374 protocol_start(protocol
, blank_url
);
375 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
376 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
377 hres
= IInternetProtocol_LockRequest(protocol
, 0);
378 ok(hres
== S_OK
, "LockRequest failed: %08lx\n", hres
);
379 hres
= IInternetProtocol_UnlockRequest(protocol
);
380 ok(hres
== S_OK
, "UnlockRequest failed: %08lx\n", hres
);
381 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
382 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
384 protocol_start(protocol
, blank_url
);
385 hres
= IInternetProtocol_LockRequest(protocol
, 0);
386 ok(hres
== S_OK
, "LockRequest failed: %08lx\n", hres
);
387 hres
= IInternetProtocol_Terminate(protocol
, 0);
388 ok(hres
== S_OK
, "Terminate failed: %08lx\n", hres
);
389 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
390 ok(hres
== S_OK
, "Read failed: %08lx\n\n", hres
);
391 hres
= IInternetProtocol_UnlockRequest(protocol
);
392 ok(hres
== S_OK
, "UnlockRequest failed: %08lx\n", hres
);
393 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
394 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
395 hres
= IInternetProtocol_Terminate(protocol
, 0);
396 ok(hres
== S_OK
, "Terminate failed: %08lx\n", hres
);
397 hres
= IInternetProtocol_Read(protocol
, buf
, 2, &cb
);
398 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
399 ok(cb
== 2, "cb=%lu expected 2\n", cb
);
401 protocol_start(protocol
, blank_url
);
402 hres
= IInternetProtocol_LockRequest(protocol
, 0);
403 ok(hres
== S_OK
, "LockRequest failed: %08lx\n", hres
);
404 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
405 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
406 protocol_start(protocol
, blank_url
);
407 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
408 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
409 hres
= IInternetProtocol_Terminate(protocol
, 0);
410 ok(hres
== S_OK
, "Terminate failed: %08lx\n", hres
);
412 IInternetProtocol_Release(protocol
);
415 IClassFactory_Release(factory
);
418 IUnknown_Release(unk
);
421 static void test_about_protocol(void)
423 IInternetProtocolInfo
*protocol_info
;
425 IClassFactory
*factory
;
428 static const WCHAR blank_url
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
429 static const WCHAR test_url
[] = {'a','b','o','u','t',':','t','e','s','t',0};
430 static const WCHAR res_url
[] = {'r','e','s',':','b','l','a','n','k',0};
431 static const WCHAR blank_html
[] = {0xfeff,'<','H','T','M','L','>','<','/','H','T','M','L','>',0};
432 static const WCHAR test_html
[] =
433 {0xfeff,'<','H','T','M','L','>','t','e','s','t','<','/','H','T','M','L','>',0};
435 hres
= CoGetClassObject(&CLSID_AboutProtocol
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IUnknown
, (void**)&unk
);
436 ok(hres
== S_OK
, "CoGetClassObject failed: %08lx\n", hres
);
440 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocolInfo
, (void**)&protocol_info
);
441 ok(hres
== S_OK
, "Could not get IInternetProtocolInfo interface: %08lx\n", hres
);
442 if(SUCCEEDED(hres
)) {
447 for(i
= PARSE_CANONICALIZE
; i
<= PARSE_UNESCAPE
; i
++) {
448 if(i
!= PARSE_SECURITY_URL
&& i
!= PARSE_DOMAIN
) {
449 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, i
, 0, buf
,
450 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
451 ok(hres
== INET_E_DEFAULT_ACTION
,
452 "[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i
, hres
);
456 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_SECURITY_URL
, 0, buf
,
457 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
458 ok(hres
== S_OK
, "ParseUrl failed: %08lx\n", hres
);
459 ok(!lstrcmpW(blank_url
, buf
), "buf != blank_url\n");
461 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_SECURITY_URL
, 0, buf
,
463 ok(hres
== S_FALSE
, "ParseUrl failed: %08lx, expected S_FALSE\n", hres
);
465 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, test_url
, PARSE_SECURITY_URL
, 0, buf
,
466 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
467 ok(hres
== S_OK
, "ParseUrl failed: %08lx\n", hres
);
468 ok(!lstrcmpW(test_url
, buf
), "buf != test_url\n");
472 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_DOMAIN
, 0, buf
,
473 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
474 ok(hres
== S_OK
|| hres
== E_FAIL
, "ParseUrl failed: %08lx\n", hres
);
475 ok(buf
[0] == '?', "buf changed\n");
476 ok(size
== sizeof(blank_url
)/sizeof(WCHAR
),
477 "size=%ld, expected %d\n", size
, sizeof(blank_url
)/sizeof(WCHAR
));
479 #if 0 /* Crashes on win9x */
482 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, NULL
, PARSE_DOMAIN
, 0, buf
,
483 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
484 ok(hres
== E_FAIL
, "ParseUrl failed: %08lx\n", hres
);
485 ok(buf
[0] == '?', "buf changed\n");
486 ok(size
== 1, "size=%ld, ezpected 1\n", size
);
489 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_DOMAIN
, 0, buf
,
490 sizeof(buf
)/sizeof(buf
[0]), NULL
, 0);
491 ok(hres
== E_POINTER
, "ParseUrl failed: %08lx\n", hres
);
492 ok(buf
[0] == '?', "buf changed\n");
495 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, NULL
, PARSE_DOMAIN
, 0, buf
,
496 sizeof(buf
)/sizeof(buf
[0]), NULL
, 0);
497 ok(hres
== E_POINTER
, "ParseUrl failed: %08lx\n", hres
);
498 ok(buf
[0] == '?', "buf changed\n");
501 hres
= IInternetProtocolInfo_ParseUrl(protocol_info
, blank_url
, PARSE_UNESCAPE
+1, 0, buf
,
502 sizeof(buf
)/sizeof(buf
[0]), &size
, 0);
503 ok(hres
== INET_E_DEFAULT_ACTION
,
504 "ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres
);
506 IInternetProtocolInfo_Release(protocol_info
);
509 hres
= IUnknown_QueryInterface(unk
, &IID_IClassFactory
, (void**)&factory
);
510 ok(hres
== S_OK
, "Could not get IClassFactory interface\n");
511 if(SUCCEEDED(hres
)) {
512 IInternetProtocol
*protocol
;
515 hres
= IClassFactory_CreateInstance(factory
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
516 ok(hres
== S_OK
, "Could not get IInternetProtocol: %08lx\n", hres
);
518 if(SUCCEEDED(hres
)) {
519 protocol_start(protocol
, blank_url
);
520 hres
= IInternetProtocol_LockRequest(protocol
, 0);
521 ok(hres
== S_OK
, "LockRequest failed: %08lx\n", hres
);
522 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
523 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
524 ok(cb
== sizeof(blank_html
), "cb=%ld, expected %d\n", cb
, sizeof(blank_html
));
525 ok(!memcmp(buf
, blank_html
, cb
), "Readed wrong data\n");
526 hres
= IInternetProtocol_UnlockRequest(protocol
);
527 ok(hres
== S_OK
, "UnlockRequest failed: %08lx\n", hres
);
529 protocol_start(protocol
, test_url
);
530 hres
= IInternetProtocol_LockRequest(protocol
, 0);
531 ok(hres
== S_OK
, "LockRequest failed: %08lx\n", hres
);
532 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
533 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
534 ok(cb
== sizeof(test_html
), "cb=%ld, expected %d\n", cb
, sizeof(test_html
));
535 ok(!memcmp(buf
, test_html
, cb
), "Readed wrong data\n");
536 hres
= IInternetProtocol_UnlockRequest(protocol
);
537 ok(hres
== S_OK
, "UnlockRequest failed: %08lx\n", hres
);
539 protocol_start(protocol
, res_url
);
540 hres
= IInternetProtocol_LockRequest(protocol
, 0);
541 ok(hres
== S_OK
, "LockRequest failed: %08lx\n", hres
);
542 hres
= IInternetProtocol_Read(protocol
, buf
, sizeof(buf
), &cb
);
543 ok(hres
== S_OK
, "Read failed: %08lx\n", hres
);
544 ok(cb
== sizeof(blank_html
), "cb=%ld, expected %d\n", cb
, sizeof(blank_html
));
545 ok(!memcmp(buf
, blank_html
, cb
), "Readed wrong data\n");
546 hres
= IInternetProtocol_UnlockRequest(protocol
);
547 ok(hres
== S_OK
, "UnlockRequest failed: %08lx\n", hres
);
549 IInternetProtocol_Release(protocol
);
552 IClassFactory_Release(factory
);
555 IUnknown_Release(unk
);
563 test_about_protocol();