secur32: Update ntlm_auth version detection to detect new samba4 version numbers.
[wine] / dlls / mshtml / tests / protocol.c
1 /*
2  * Copyright 2005 Jacek Caban
3  *
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.
8  *
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.
13  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #define COBJMACROS
20
21 #include <wine/test.h>
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ole2.h"
27 #include "urlmon.h"
28
29 #include "initguid.h"
30
31 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
32 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
33
34 static BOOL expect_GetBindInfo = FALSE, called_GetBindInfo = FALSE;
35 static BOOL expect_ReportProgress = FALSE, called_ReportProgress = FALSE;
36 static BOOL expect_ReportData = FALSE, called_ReportData = FALSE;
37 static BOOL expect_ReportResult = FALSE, called_ReportResult = FALSE;
38
39 static HRESULT expect_hrResult;
40 static BOOL expect_hr_win32err = FALSE;
41
42 static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
43 {
44     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
45         *ppv = iface;
46         return S_OK;
47     }
48     return E_NOINTERFACE;
49 }
50
51 static ULONG WINAPI ProtocolSink_AddRef(IInternetProtocolSink *iface)
52 {
53     return 2;
54 }
55
56 static ULONG WINAPI ProtocolSink_Release(IInternetProtocolSink *iface)
57 {
58     return 1;
59 }
60
61 static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
62 {
63     ok(0, "unexpected call\n");
64     return E_NOTIMPL;
65 }
66
67 static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
68         LPCWSTR szStatusText)
69 {
70     static const WCHAR text_html[] = {'t','e','x','t','/','h','t','m','l',0};
71
72     ok(expect_ReportProgress, "unexpected call\n");
73     ok(ulStatusCode == BINDSTATUS_MIMETYPEAVAILABLE
74             || ulStatusCode == BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, "ulStatusCode=%ld\n", ulStatusCode);
75     ok(!lstrcmpW(szStatusText, text_html), "szStatusText != text/html\n");
76     expect_ReportProgress = FALSE;
77     called_ReportProgress = TRUE;
78     return S_OK;
79 }
80
81 static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, ULONG ulProgress,
82         ULONG ulProgressMax)
83 {
84     ok(expect_ReportData, "unexpected call\n");
85     ok(ulProgress == ulProgressMax, "ulProgress != ulProgressMax\n");
86     ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE),
87             "grcf = %08lx\n", grfBSCF);
88     expect_ReportData = FALSE;
89     called_ReportData = TRUE;
90     return S_OK;
91 }
92
93 static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult, DWORD dwError,
94         LPCWSTR szResult)
95 {
96     ok(expect_ReportResult, "unexpected call\n");
97     if(expect_hr_win32err)
98         ok((hrResult&0xffff0000) == ((FACILITY_WIN32 << 16)|0x80000000) || expect_hrResult,
99                 "expected win32 err or %08lx got: %08lx\n", expect_hrResult, hrResult);
100     else
101         ok(hrResult == expect_hrResult, "expected: %08lx got: %08lx\n", expect_hrResult, hrResult);
102     ok(dwError == 0, "dwError = %ld\n", dwError);
103     ok(!szResult, "szResult != NULL\n");
104     called_ReportResult = TRUE;
105     expect_ReportResult = FALSE;
106     return S_OK;
107 }
108
109 static IInternetProtocolSinkVtbl protocol_sink_vtbl = {
110     ProtocolSink_QueryInterface,
111     ProtocolSink_AddRef,
112     ProtocolSink_Release,
113     ProtocolSink_Switch,
114     ProtocolSink_ReportProgress,
115     ProtocolSink_ReportData,
116     ProtocolSink_ReportResult
117 };
118
119 static IInternetProtocolSink protocol_sink = {
120     &protocol_sink_vtbl
121 };
122
123 static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
124 {
125     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) {
126         *ppv = iface;
127         return S_OK;
128     }
129     return E_NOINTERFACE;
130 }
131
132 static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
133 {
134     return 2;
135 }
136
137 static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
138 {
139     return 1;
140 }
141
142 static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
143 {
144     ok(expect_GetBindInfo, "unexpected call\n");
145     ok(grfBINDF != NULL, "grfBINDF == NULL\n");
146     if(grfBINDF)
147         ok(!*grfBINDF, "*grfBINDF != 0\n");
148     ok(pbindinfo != NULL, "pbindinfo == NULL\n");
149     ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %ld\n", pbindinfo->cbSize);
150     called_GetBindInfo = TRUE;
151     expect_GetBindInfo = FALSE;
152     return S_OK;
153 }
154
155 static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType, LPOLESTR *ppwzStr,
156         ULONG cEl, ULONG *pcElFetched)
157 {
158     ok(0, "unexpected call\n");
159     return E_NOTIMPL;
160 }
161
162 static IInternetBindInfoVtbl bind_info_vtbl = {
163     BindInfo_QueryInterface,
164     BindInfo_AddRef,
165     BindInfo_Release,
166     BindInfo_GetBindInfo,
167     BindInfo_GetBindString
168 };
169
170 static IInternetBindInfo bind_info = {
171     &bind_info_vtbl
172 };
173
174 static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT expected_hres,
175         BOOL expect_win32err)
176 {
177     HRESULT hres;
178
179     expect_ReportResult = TRUE;
180     expect_GetBindInfo = TRUE;
181     expect_hrResult = expected_hres;
182     expect_hr_win32err = expect_win32err;
183     hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
184     if(expect_win32err)
185         ok((hres&0xffff0000) == ((FACILITY_WIN32 << 16)|0x80000000) || hres == expect_hrResult,
186                 "expected win32 err or %08lx got: %08lx\n", expected_hres, hres);
187     else
188         ok(hres == expected_hres, "expected: %08lx got: %08lx\n", expected_hres, hres);
189     ok(called_ReportResult, "expected ReportResult\n");
190     ok(called_GetBindInfo, "expected GetBindInfo\n");
191     expect_ReportResult =  called_ReportResult = FALSE;
192     expect_GetBindInfo = called_GetBindInfo = FALSE;
193 }
194
195 static void protocol_start(IInternetProtocol *protocol, LPCWSTR url)
196 {
197     HRESULT hres;
198
199     expect_GetBindInfo = TRUE;
200     expect_ReportResult = TRUE;
201     expect_ReportProgress = TRUE;
202     expect_ReportData = TRUE;
203     expect_hrResult = S_OK;
204     expect_hr_win32err = FALSE;
205
206     hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
207     ok(hres == S_OK, "Start failed: %08lx\n", hres);
208
209     ok(called_GetBindInfo, "expected GetBindInfo\n");
210     ok(called_ReportProgress, "expected ReportProgress\n");
211     ok(called_ReportData, "expected ReportData\n");
212     ok(called_ReportResult, "expected ReportResult\n");
213     called_GetBindInfo =  expect_GetBindInfo = FALSE;
214     called_ReportProgress = expect_ReportProgress = FALSE;
215     called_ReportData = expect_ReportData = FALSE;
216     called_ReportResult = expect_ReportResult = FALSE;
217 }
218
219 static void test_res_protocol(void)
220 {
221     IInternetProtocolInfo *protocol_info;
222     IUnknown *unk;
223     IClassFactory *factory;
224     HRESULT hres;
225
226     static const WCHAR blank_url[] =
227         {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
228     static const WCHAR wrong_url1[] =
229         {'m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','m','t','h',0};
230     static const WCHAR wrong_url2[] =
231         {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',0};
232     static const WCHAR wrong_url3[] =
233         {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','x','x','.','h','t','m',0};
234     static const WCHAR wrong_url4[] =
235         {'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
236
237
238     hres = CoGetClassObject(&CLSID_ResProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
239     ok(hres == S_OK, "CoGetClassObject failed: %08lx\n", hres);
240     if(!SUCCEEDED(hres))
241         return;
242
243     hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
244     ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres);
245     if(SUCCEEDED(hres)) {
246         WCHAR buf[128];
247         DWORD size;
248         int i;
249
250         for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
251             if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
252                 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
253                         sizeof(buf)/sizeof(buf[0]), &size, 0);
254                 ok(hres == INET_E_DEFAULT_ACTION,
255                         "[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres);
256             }
257         }
258
259         hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
260                 sizeof(buf)/sizeof(buf[0]), &size, 0);
261         ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
262
263         hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
264                 3, &size, 0);
265         ok(hres == S_FALSE, "ParseUrl failed: %08lx, expected S_FALSE\n", hres);
266
267         hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_SECURITY_URL, 0, buf,
268                 sizeof(buf)/sizeof(buf[0]), &size, 0);
269         ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08lx, expected MK_E_SYNTAX\n", hres);
270
271         buf[0] = '?';
272         hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
273                 sizeof(buf)/sizeof(buf[0]), &size, 0);
274         ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
275         ok(buf[0] == '?', "buf changed\n");
276
277         hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_DOMAIN, 0, buf,
278                 sizeof(buf)/sizeof(buf[0]), &size, 0);
279         ok(hres == S_OK, "ParseUrl failed: %08lx, expected MK_E_SYNTAX\n", hres);
280         ok(buf[0] == '?', "buf changed\n");
281
282         hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
283                 sizeof(buf)/sizeof(buf[0]), &size, 0);
284         ok(hres == INET_E_DEFAULT_ACTION,
285                 "ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres);
286
287         IInternetProtocolInfo_Release(protocol_info);
288     }
289
290     hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
291     ok(hres == S_OK, "Could not get IClassFactory interface\n");
292     if(SUCCEEDED(hres)) {
293         IInternetProtocol *protocol;
294         BYTE buf[512];
295         ULONG cb;
296         hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
297         ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
298
299         if(SUCCEEDED(hres)) {
300             test_protocol_fail(protocol, wrong_url1, MK_E_SYNTAX, FALSE);
301             test_protocol_fail(protocol, wrong_url2, MK_E_SYNTAX, FALSE);
302             test_protocol_fail(protocol, wrong_url3, E_FAIL, TRUE);
303             test_protocol_fail(protocol, wrong_url4, E_FAIL, TRUE);
304
305             cb = 0xdeadbeef;
306             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
307             ok(hres == E_FAIL, "Read returned %08lx expected E_FAIL\n", hres);
308             ok(cb == 0xdeadbeef, "cb=%lu expected 0xdeadbeef\n", cb);
309     
310             protocol_start(protocol, blank_url);
311             hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
312             ok(hres == S_OK, "Read failed: %08lx\n", hres);
313             ok(cb == 2, "cb=%lu expected 2\n", cb);
314             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
315             ok(hres == S_OK, "Read failed: %08lx\n", hres);
316             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
317             ok(hres == S_FALSE, "Read failed: %08lx expected S_FALSE\n", hres);
318             ok(cb == 0, "cb=%lu expected 0\n", cb);
319             hres = IInternetProtocol_UnlockRequest(protocol);
320             ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
321
322             protocol_start(protocol, blank_url);
323             hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
324             ok(hres == S_OK, "Read failed: %08lx\n", hres);
325             hres = IInternetProtocol_LockRequest(protocol, 0);
326             ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
327             hres = IInternetProtocol_UnlockRequest(protocol);
328             ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
329             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
330             ok(hres == S_OK, "Read failed: %08lx\n", hres);
331
332             protocol_start(protocol, blank_url);
333             hres = IInternetProtocol_LockRequest(protocol, 0);
334             ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
335             hres = IInternetProtocol_Terminate(protocol, 0);
336             ok(hres == S_OK, "Terminate failed: %08lx\n", hres);
337             hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
338             ok(hres == S_OK, "Read failed: %08lx\n\n", hres);
339             hres = IInternetProtocol_UnlockRequest(protocol);
340             ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
341             hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
342             ok(hres == S_OK, "Read failed: %08lx\n", hres);
343             hres = IInternetProtocol_Terminate(protocol, 0);
344             ok(hres == S_OK, "Terminate failed: %08lx\n", hres);
345             hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
346             ok(hres == S_OK, "Read failed: %08lx\n", hres);
347             ok(cb == 2, "cb=%lu expected 2\n", cb);
348
349             protocol_start(protocol, blank_url);
350             hres = IInternetProtocol_LockRequest(protocol, 0);
351             ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
352             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
353             ok(hres == S_OK, "Read failed: %08lx\n", hres);
354             protocol_start(protocol, blank_url);
355             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
356             ok(hres == S_OK, "Read failed: %08lx\n", hres);
357             hres = IInternetProtocol_Terminate(protocol, 0);
358             ok(hres == S_OK, "Terminate failed: %08lx\n", hres);
359
360             IInternetProtocol_Release(protocol);
361         }
362
363         IClassFactory_Release(factory);
364     }
365
366     IUnknown_Release(unk);
367 }
368
369 static void test_about_protocol(void)
370 {
371     IInternetProtocolInfo *protocol_info;
372     IUnknown *unk;
373     IClassFactory *factory;
374     HRESULT hres;
375
376     static const WCHAR blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
377     static const WCHAR test_url[] = {'a','b','o','u','t',':','t','e','s','t',0};
378     static const WCHAR res_url[] = {'r','e','s',':','b','l','a','n','k',0};
379     static const WCHAR blank_html[] = {0xfeff,'<','H','T','M','L','>','<','/','H','T','M','L','>',0};
380     static const WCHAR test_html[] =
381         {0xfeff,'<','H','T','M','L','>','t','e','s','t','<','/','H','T','M','L','>',0};
382
383     hres = CoGetClassObject(&CLSID_AboutProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
384     ok(hres == S_OK, "CoGetClassObject failed: %08lx\n", hres);
385     if(!SUCCEEDED(hres))
386         return;
387
388     hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
389     ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres);
390     if(SUCCEEDED(hres)) {
391         WCHAR buf[128];
392         DWORD size;
393         int i;
394
395         for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
396             if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
397                 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
398                         sizeof(buf)/sizeof(buf[0]), &size, 0);
399                 ok(hres == INET_E_DEFAULT_ACTION,
400                         "[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres);
401             }
402         }
403
404         hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
405                 sizeof(buf)/sizeof(buf[0]), &size, 0);
406         ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
407         ok(!lstrcmpW(blank_url, buf), "buf != blank_url\n");
408
409         hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
410                 3, &size, 0);
411         ok(hres == S_FALSE, "ParseUrl failed: %08lx, expected S_FALSE\n", hres);
412
413         hres = IInternetProtocolInfo_ParseUrl(protocol_info, test_url, PARSE_SECURITY_URL, 0, buf,
414                 sizeof(buf)/sizeof(buf[0]), &size, 0);
415         ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
416         ok(!lstrcmpW(test_url, buf), "buf != test_url\n");
417
418         buf[0] = '?';
419         hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
420                 sizeof(buf)/sizeof(buf[0]), &size, 0);
421         ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
422         ok(buf[0] == '?', "buf changed\n");
423
424         hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
425                 sizeof(buf)/sizeof(buf[0]), &size, 0);
426         ok(hres == INET_E_DEFAULT_ACTION,
427                 "ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres);
428
429         IInternetProtocolInfo_Release(protocol_info);
430     }
431
432     hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
433     ok(hres == S_OK, "Could not get IClassFactory interface\n");
434     if(SUCCEEDED(hres)) {
435         IInternetProtocol *protocol;
436         BYTE buf[512];
437         ULONG cb;
438         hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
439         ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
440
441         if(SUCCEEDED(hres)) {
442             protocol_start(protocol, blank_url);
443             hres = IInternetProtocol_LockRequest(protocol, 0);
444             ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
445             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
446             ok(hres == S_OK, "Read failed: %08lx\n", hres);
447             ok(cb == sizeof(blank_html), "cb=%ld, expected %d\n", cb, sizeof(blank_html));
448             ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n");
449             hres = IInternetProtocol_UnlockRequest(protocol);
450             ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
451
452             protocol_start(protocol, test_url);
453             hres = IInternetProtocol_LockRequest(protocol, 0);
454             ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
455             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
456             ok(hres == S_OK, "Read failed: %08lx\n", hres);
457             ok(cb == sizeof(test_html), "cb=%ld, expected %d\n", cb, sizeof(test_html));
458             ok(!memcmp(buf, test_html, cb), "Readed wrong data\n");
459             hres = IInternetProtocol_UnlockRequest(protocol);
460             ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
461
462             protocol_start(protocol, res_url);
463             hres = IInternetProtocol_LockRequest(protocol, 0);
464             ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
465             hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
466             ok(hres == S_OK, "Read failed: %08lx\n", hres);
467             ok(cb == sizeof(blank_html), "cb=%ld, expected %d\n", cb, sizeof(blank_html));
468             ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n");
469             hres = IInternetProtocol_UnlockRequest(protocol);
470             ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
471
472             IInternetProtocol_Release(protocol);
473         }
474
475         IClassFactory_Release(factory);
476     }
477
478     IUnknown_Release(unk);
479 }
480
481 START_TEST(protocol)
482 {
483     OleInitialize(NULL);
484
485     test_res_protocol();
486     test_about_protocol();
487
488     OleUninitialize();
489 }