2 * Copyright 2006 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
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_ITSProtocol,0x9d148291,0xb9c8,0x11d0,0xa4,0xcc,0x00,0x00,0xf8,0x01,0x49,0xf6);
59 DEFINE_EXPECT(GetBindInfo);
60 DEFINE_EXPECT(ReportProgress_BEGINDOWNLOADDATA);
61 DEFINE_EXPECT(ReportProgress_SENDINGREQUEST);
62 DEFINE_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
63 DEFINE_EXPECT(ReportProgress_CACHEFILENAMEAVAIABLE);
64 DEFINE_EXPECT(ReportProgress_DIRECTBIND);
65 DEFINE_EXPECT(ReportData);
66 DEFINE_EXPECT(ReportResult);
68 static HRESULT expect_hrResult;
69 static IInternetProtocol *read_protocol = NULL;
71 static const WCHAR blank_url1[] = {'i','t','s',':',
72 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
73 static const WCHAR blank_url2[] = {'m','S','-','i','T','s',':',
74 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
75 static const WCHAR blank_url3[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
76 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
77 static const WCHAR blank_url4[] = {'i','t','s',':',
78 't','e','s','t','.','c','h','m',':',':','b','l','a','n','k','.','h','t','m','l',0};
79 static const WCHAR blank_url5[] = {'i','t','s',':',
80 't','e','s','t','.','c','h','m',':',':','\\','b','l','a','n','k','.','h','t','m','l',0};
81 static const WCHAR blank_url6[] = {'i','t','s',':',
82 't','e','s','t','.','c','h','m',':',':','/','%','6','2','l','a','n','k','.','h','t','m','l',0};
83 static const WCHAR blank_url7[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
84 't','e','s','t','.','c','h','m',':',':','\\','b','l','a','n','k','.','h','t','m','l',0};
92 static const WCHAR cache_file1[] =
93 {'t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
94 static const WCHAR cache_file2[] =
95 {'t','e','s','t','.','c','h','m',':',':','\\','b','l','a','n','k','.','h','t','m','l',0};
96 static const WCHAR *cache_file = cache_file1;
98 static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
100 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
104 return E_NOINTERFACE;
107 static ULONG WINAPI ProtocolSink_AddRef(IInternetProtocolSink *iface)
112 static ULONG WINAPI ProtocolSink_Release(IInternetProtocolSink *iface)
117 static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
119 ok(0, "unexpected call\n");
123 static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
124 LPCWSTR szStatusText)
126 static const WCHAR blank_html[] = {'b','l','a','n','k','.','h','t','m','l',0};
127 static const WCHAR text_html[] = {'t','e','x','t','/','h','t','m','l',0};
129 switch(ulStatusCode) {
130 case BINDSTATUS_BEGINDOWNLOADDATA:
131 CHECK_EXPECT(ReportProgress_BEGINDOWNLOADDATA);
132 ok(!szStatusText, "szStatusText != NULL\n");
134 case BINDSTATUS_SENDINGREQUEST:
135 CHECK_EXPECT(ReportProgress_SENDINGREQUEST);
136 if(test_protocol == ITS_PROTOCOL)
137 ok(!lstrcmpW(szStatusText, blank_html), "unexpected szStatusText\n");
139 ok(szStatusText == NULL, "szStatusText != NULL\n");
141 case BINDSTATUS_MIMETYPEAVAILABLE:
142 CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
143 ok(!lstrcmpW(szStatusText, text_html), "unexpected szStatusText\n");
145 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
146 CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAIABLE);
147 ok(!lstrcmpW(szStatusText, cache_file), "unexpected szStatusText\n");
149 case BINDSTATUS_DIRECTBIND:
150 CHECK_EXPECT(ReportProgress_DIRECTBIND);
151 ok(!szStatusText, "szStatusText != NULL\n");
154 ok(0, "unexpected ulStatusCode %d\n", ulStatusCode);
161 static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, ULONG ulProgress,
164 CHECK_EXPECT(ReportData);
166 ok(ulProgress == ulProgressMax, "ulProgress != ulProgressMax\n");
167 if(test_protocol == ITS_PROTOCOL)
168 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE), "grcf = %08x\n", grfBSCF);
170 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION), "grcf = %08x\n", grfBSCF);
174 DWORD cb = 0xdeadbeef;
177 hres = IInternetProtocol_Read(read_protocol, buf, sizeof(buf), &cb);
178 ok(hres == S_OK, "Read failed: %08x\n", hres);
179 ok(cb == 13, "cb=%u expected 13\n", cb);
180 ok(!memcmp(buf, "<html></html>", 13), "unexpected data\n");
186 static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult,
187 DWORD dwError, LPCWSTR szResult)
189 CHECK_EXPECT(ReportResult);
191 ok(hrResult == expect_hrResult, "expected: %08x got: %08x\n", expect_hrResult, hrResult);
192 ok(dwError == 0, "dwError = %d\n", dwError);
193 ok(!szResult, "szResult != NULL\n");
198 static IInternetProtocolSinkVtbl protocol_sink_vtbl = {
199 ProtocolSink_QueryInterface,
201 ProtocolSink_Release,
203 ProtocolSink_ReportProgress,
204 ProtocolSink_ReportData,
205 ProtocolSink_ReportResult
208 static IInternetProtocolSink protocol_sink = {
212 static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
214 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) {
218 return E_NOINTERFACE;
221 static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
226 static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
231 static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
233 CHECK_EXPECT(GetBindInfo);
235 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
237 ok(!*grfBINDF, "*grfBINDF != 0\n");
238 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
239 ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %d\n", pbindinfo->cbSize);
244 static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType, LPOLESTR *ppwzStr,
245 ULONG cEl, ULONG *pcElFetched)
247 ok(0, "unexpected call\n");
251 static IInternetBindInfoVtbl bind_info_vtbl = {
252 BindInfo_QueryInterface,
255 BindInfo_GetBindInfo,
256 BindInfo_GetBindString
259 static IInternetBindInfo bind_info = {
263 static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT expected_hres)
267 SET_EXPECT(GetBindInfo);
268 SET_EXPECT(ReportResult);
270 expect_hrResult = expected_hres;
271 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
272 ok(hres == expected_hres, "expected: %08x got: %08x\n", expected_hres, hres);
274 CHECK_CALLED(GetBindInfo);
275 CHECK_CALLED(ReportResult);
278 static void protocol_start(IInternetProtocol *protocol, LPCWSTR url)
282 SET_EXPECT(GetBindInfo);
283 if(test_protocol == MK_PROTOCOL)
284 SET_EXPECT(ReportProgress_DIRECTBIND);
285 SET_EXPECT(ReportProgress_SENDINGREQUEST);
286 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
287 if(test_protocol == MK_PROTOCOL)
288 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAIABLE);
289 SET_EXPECT(ReportData);
290 if(test_protocol == ITS_PROTOCOL)
291 SET_EXPECT(ReportProgress_BEGINDOWNLOADDATA);
292 SET_EXPECT(ReportResult);
293 expect_hrResult = S_OK;
295 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
296 ok(hres == S_OK, "Start failed: %08x\n", hres);
298 CHECK_CALLED(GetBindInfo);
299 if(test_protocol == MK_PROTOCOL)
300 CHECK_CALLED(ReportProgress_DIRECTBIND);
301 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
302 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
303 if(test_protocol == MK_PROTOCOL)
304 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAIABLE);
305 CHECK_CALLED(ReportData);
306 if(test_protocol == ITS_PROTOCOL)
307 CHECK_CALLED(ReportProgress_BEGINDOWNLOADDATA);
308 CHECK_CALLED(ReportResult);
311 static void test_protocol_url(IClassFactory *factory, LPCWSTR url)
313 IInternetProtocol *protocol;
318 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
319 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
323 protocol_start(protocol, url);
324 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
325 ok(hres == S_OK, "Read failed: %08x\n", hres);
326 ok(cb == 13, "cb=%u expected 13\n", cb);
327 ok(!memcmp(buf, "<html></html>", 13), "unexpected data\n");
328 ref = IInternetProtocol_Release(protocol);
329 ok(!ref, "protocol ref=%d\n", ref);
331 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
332 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
337 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
338 ok(hres == (test_protocol == ITS_PROTOCOL ? INET_E_DATA_NOT_AVAILABLE : E_FAIL),
339 "Read returned %08x\n", hres);
340 ok(cb == 0xdeadbeef, "cb=%u expected 0xdeadbeef\n", cb);
342 protocol_start(protocol, url);
343 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
344 ok(hres == S_OK, "Read failed: %08x\n", hres);
345 ok(cb == 2, "cb=%u expected 2\n", cb);
346 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
347 ok(hres == S_OK, "Read failed: %08x\n", hres);
348 ok(cb == 11, "cb=%u, expected 11\n", cb);
349 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
350 ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres);
351 ok(cb == 0, "cb=%u expected 0\n", cb);
352 hres = IInternetProtocol_UnlockRequest(protocol);
353 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
354 ref = IInternetProtocol_Release(protocol);
355 ok(!ref, "protocol ref=%d\n", ref);
357 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
358 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
362 protocol_start(protocol, url);
363 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
364 ok(hres == S_OK, "Read failed: %08x\n", hres);
365 hres = IInternetProtocol_LockRequest(protocol, 0);
366 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
367 hres = IInternetProtocol_UnlockRequest(protocol);
368 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
369 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
370 ok(hres == S_OK, "Read failed: %08x\n", hres);
371 ok(cb == 11, "cb=%u, expected 11\n", cb);
372 ref = IInternetProtocol_Release(protocol);
373 ok(!ref, "protocol ref=%d\n", ref);
375 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
376 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
380 protocol_start(protocol, url);
381 hres = IInternetProtocol_LockRequest(protocol, 0);
382 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
383 hres = IInternetProtocol_Terminate(protocol, 0);
384 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
385 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
386 ok(hres == S_OK, "Read failed: %08x\n", hres);
387 ok(cb == 2, "cb=%u, expected 2\n", cb);
388 hres = IInternetProtocol_UnlockRequest(protocol);
389 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
390 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
391 ok(hres == S_OK, "Read failed: %08x\n", hres);
392 ok(cb == 2, "cb=%u, expected 2\n", cb);
393 hres = IInternetProtocol_Terminate(protocol, 0);
394 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
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 ref = IInternetProtocol_Release(protocol);
399 ok(!ref, "protocol ref=%d\n", ref);
401 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&read_protocol);
402 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
406 protocol_start(read_protocol, url);
407 ref = IInternetProtocol_Release(read_protocol);
408 ok(!ref, "protocol ref=%d\n", ref);
409 read_protocol = NULL;
412 static const WCHAR rel_url1[] =
413 {'t','e','s','t','.','h','t','m','l',0};
414 static const WCHAR rel_url2[] =
415 {'t','e','s','t','.','c','h','m',':',':','/','t','e','s','t','.','h','t','m','l',0};
416 static const WCHAR rel_url3[] =
417 {'/','t','e','s','t','.','h','t','m','l',0};
418 static const WCHAR rel_url4[] =
419 {'t','e',':','t','.','h','t','m','l',0};
420 static const WCHAR rel_url5[] =
421 {'d','i','r','/','t','e','s','t','.','h','t','m','l',0};
423 static const WCHAR base_url1[] = {'i','t','s',':',
424 't','e','s','t',':','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
425 static const WCHAR base_url2[] = {'i','t','s',':','t','e','s','t','.','c','h','m',
426 ':',':','/','d','i','r','/','b','l','a','n','k','.','h','t','m','l',0};
427 static const WCHAR base_url3[] = {'m','s','-','i','t','s',':','t','e','s','t','.','c','h','m',
428 ':',':','/','d','i','r','/','b','l','a','n','k','.','h','t','m','l',0};
429 static const WCHAR base_url4[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
430 't','e','s','t','.','c','h','m',':',':','/','d','i','r','/',
431 'b','l','a','n','k','.','h','t','m','l',0};
432 static const WCHAR base_url5[] = {'x','x','x',':','t','e','s','t','.','c','h','m',
433 ':',':','/','d','i','r','/','b','l','a','n','k','.','h','t','m','l',0};
435 static const WCHAR combined_url1[] = {'i','t','s',':',
436 't','e','s','t','.','c','h','m',':',':','/','t','e','s','t','.','h','t','m','l',0};
437 static const WCHAR combined_url2[] = {'i','t','s',':',
438 't','e','s','t','.','c','h','m',':',':','/','d','i','r','/','t','e','s','t','.','h','t','m','l',0};
439 static const WCHAR combined_url3[] = {'i','t','s',':',
440 't','e','s','t',':','.','c','h','m',':',':','/','t','e','s','t','.','h','t','m','l',0};
441 static const WCHAR combined_url4[] = {'i','t','s',':','t','e','s','t','.','c','h','m',
442 ':',':','b','l','a','n','k','.','h','t','m','l','t','e','s','t','.','h','t','m','l',0};
443 static const WCHAR combined_url5[] = {'m','s','-','i','t','s',':',
444 't','e','s','t','.','c','h','m',':',':','/','d','i','r','/','t','e','s','t','.','h','t','m','l',0};
445 static const WCHAR combined_url6[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
446 't','e','s','t','.','c','h','m',':',':','/','d','i','r','/','t','e','s','t','.','h','t','m','l',0};
448 static const struct {
453 LPCWSTR combined_url;
454 } combine_tests[] = {
455 {blank_url1, blank_url1, 0, STG_E_INVALIDNAME, NULL},
456 {blank_url2, blank_url2, 0, STG_E_INVALIDNAME, NULL},
457 {blank_url1, rel_url1, 0, S_OK, combined_url1},
458 {blank_url1, rel_url2, 0, STG_E_INVALIDNAME, NULL},
459 {blank_url1, rel_url3, 0, S_OK, combined_url1},
460 {blank_url1, rel_url4, 0, STG_E_INVALIDNAME, NULL},
461 {blank_url1, rel_url3, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, S_OK, combined_url1},
462 {blank_url1, rel_url5, 0, S_OK, combined_url2},
463 {rel_url1, rel_url2, 0, 0x80041001, NULL},
464 {base_url1, rel_url1, 0, S_OK, combined_url3},
465 {base_url2, rel_url1, 0, S_OK, combined_url2},
466 {blank_url4, rel_url1, 0, S_OK, combined_url4},
467 {base_url3, rel_url1, 0, S_OK, combined_url5},
468 {base_url4, rel_url1, 0, S_OK, combined_url6},
469 {base_url5, rel_url1, 0, INET_E_USE_DEFAULT_PROTOCOLHANDLER, NULL},
470 {base_url2, rel_url3, 0, S_OK, combined_url1},
473 static void test_its_protocol_info(IInternetProtocol *protocol)
475 IInternetProtocolInfo *info;
480 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolInfo, (void**)&info);
481 ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08x\n", hres);
485 for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
486 if(i != PARSE_CANONICALIZE && i != PARSE_SECURITY_URL) {
487 hres = IInternetProtocolInfo_ParseUrl(info, blank_url1, i, 0, buf,
488 sizeof(buf)/sizeof(buf[0]), &size, 0);
489 ok(hres == INET_E_DEFAULT_ACTION,
490 "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i, hres);
494 for(i=0; i < sizeof(combine_tests)/sizeof(combine_tests[0]); i++) {
496 memset(buf, 0xfe, sizeof(buf));
497 hres = IInternetProtocolInfo_CombineUrl(info, combine_tests[i].base_url,
498 combine_tests[i].rel_url, combine_tests[i].flags, buf,
499 sizeof(buf)/sizeof(WCHAR), &size, 0);
500 ok(hres == combine_tests[i].hres, "[%d] CombineUrl returned %08x, expected %08x\n",
501 i, hres, combine_tests[i].hres);
502 ok(size == (combine_tests[i].combined_url ? lstrlenW(combine_tests[i].combined_url)+1
503 : 0xdeadbeef), "[%d] unexpected size=%d\n", i, size);
504 if(combine_tests[i].combined_url)
505 ok(!lstrcmpW(combine_tests[i].combined_url, buf), "[%d] unexpected result\n", i);
507 ok(buf[0] == 0xfefe, "buf changed\n");
511 memset(buf, 0xfe, sizeof(buf));
512 hres = IInternetProtocolInfo_CombineUrl(info, blank_url1, rel_url1, 0, buf,
514 ok(hres == E_OUTOFMEMORY, "CombineUrl failed: %08x\n", hres);
515 ok(size == sizeof(combined_url1)/sizeof(WCHAR), "size=%d\n", size);
516 ok(buf[0] == 0xfefe, "buf changed\n");
518 IInternetProtocolInfo_Release(info);
521 static void test_its_protocol(void)
523 IInternetProtocolInfo *info;
524 IClassFactory *factory;
529 static const WCHAR wrong_url1[] =
530 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','.','h','t','m','l',0};
531 static const WCHAR wrong_url2[] =
532 {'i','t','s',':','t','e','s','.','c','h','m',':',':','b','/','l','a','n','k','.','h','t','m','l',0};
533 static const WCHAR wrong_url3[] =
534 {'i','t','s',':','t','e','s','t','.','c','h','m','/','b','l','a','n','k','.','h','t','m','l',0};
535 static const WCHAR wrong_url4[] = {'m','k',':','@','M','S','I','T','S','t','o','r',':',
536 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
537 static const WCHAR wrong_url5[] = {'f','i','l','e',':',
538 't','e','s','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
540 test_protocol = ITS_PROTOCOL;
542 hres = CoGetClassObject(&CLSID_ITSProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
543 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
547 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&info);
548 ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo: %08x\n", hres);
550 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
551 ok(hres == S_OK, "Could not get IClassFactory interface\n");
552 if(SUCCEEDED(hres)) {
553 IInternetProtocol *protocol;
555 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
556 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
557 if(SUCCEEDED(hres)) {
558 test_its_protocol_info(protocol);
560 test_protocol_fail(protocol, wrong_url1, STG_E_FILENOTFOUND);
561 test_protocol_fail(protocol, wrong_url2, STG_E_FILENOTFOUND);
562 test_protocol_fail(protocol, wrong_url3, STG_E_FILENOTFOUND);
564 hres = IInternetProtocol_Start(protocol, wrong_url4, &protocol_sink, &bind_info, 0, 0);
565 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER,
566 "Start failed: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", hres);
568 hres = IInternetProtocol_Start(protocol, wrong_url5, &protocol_sink, &bind_info, 0, 0);
569 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER,
570 "Start failed: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", hres);
572 ref = IInternetProtocol_Release(protocol);
573 ok(!ref, "protocol ref=%d\n", ref);
575 test_protocol_url(factory, blank_url1);
576 test_protocol_url(factory, blank_url2);
577 test_protocol_url(factory, blank_url3);
578 test_protocol_url(factory, blank_url4);
579 test_protocol_url(factory, blank_url5);
580 test_protocol_url(factory, blank_url6);
583 IClassFactory_Release(factory);
586 IUnknown_Release(unk);
589 static void test_mk_protocol(void)
594 test_protocol = MK_PROTOCOL;
596 hres = CoGetClassObject(&CLSID_MkProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory,
598 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
602 cache_file = cache_file1;
603 test_protocol_url(cf, blank_url3);
604 cache_file = cache_file2;
605 test_protocol_url(cf, blank_url7);
607 IClassFactory_Release(cf);
610 static BOOL create_chm(void)
616 file = CreateFileA("test.chm", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
617 FILE_ATTRIBUTE_NORMAL, NULL);
618 ok(file != INVALID_HANDLE_VALUE, "Could not create test.chm file\n");
619 if(file == INVALID_HANDLE_VALUE)
622 src = FindResourceA(NULL, MAKEINTRESOURCEA(60), MAKEINTRESOURCEA(60));
624 WriteFile(file, LoadResource(NULL, src), SizeofResource(NULL, src), &size, NULL);
630 static void delete_chm(void)
634 ret = DeleteFileA("test.chm");
635 ok(ret, "DeleteFileA failed: %d\n", GetLastError());