ReactOS 0.4.17-dev-966-gf06eace
protocol.c
Go to the documentation of this file.
1/*
2 * Copyright 2006 Jacek Caban for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#define COBJMACROS
20#ifdef __REACTOS__
21#define CONST_VTABLE
22#endif
23
24#include <wine/test.h>
25#include <stdarg.h>
26
27#include "windef.h"
28#include "winbase.h"
29#include "initguid.h"
30#include "ole2.h"
31#include "urlmon.h"
32#include "shlwapi.h"
33
34#define DEFINE_EXPECT(func) \
35 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
36
37#define SET_EXPECT(func) \
38 expect_ ## func = TRUE
39
40#define CHECK_EXPECT(func) \
41 do { \
42 ok(expect_ ##func, "unexpected call " #func "\n"); \
43 expect_ ## func = FALSE; \
44 called_ ## func = TRUE; \
45 }while(0)
46
47#define SET_CALLED(func) \
48 expect_ ## func = called_ ## func = FALSE
49
50#define CHECK_CALLED(func) \
51 do { \
52 ok(called_ ## func, "expected " #func "\n"); \
53 SET_CALLED(func); \
54 }while(0)
55
56DEFINE_GUID(CLSID_ITSProtocol,0x9d148291,0xb9c8,0x11d0,0xa4,0xcc,0x00,0x00,0xf8,0x01,0x49,0xf6);
57
58DEFINE_EXPECT(GetBindInfo);
59DEFINE_EXPECT(ReportProgress_BEGINDOWNLOADDATA);
60DEFINE_EXPECT(ReportProgress_SENDINGREQUEST);
61DEFINE_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
62DEFINE_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
63DEFINE_EXPECT(ReportProgress_DIRECTBIND);
64DEFINE_EXPECT(ReportData);
65DEFINE_EXPECT(ReportResult);
66DEFINE_EXPECT(outer_QI_test);
67
70static DWORD bindf;
71
72static const WCHAR blank_url1[] = L"its:test.chm::/blank.html";
73static const WCHAR blank_url2[] = L"mS-iTs:test.chm::/blank.html";
74static const WCHAR blank_url3[] = L"mk:@MSITStore:test.chm::/blank.html";
75static const WCHAR blank_url4[] = L"its:test.chm::blank.html";
76static const WCHAR blank_url5[] = L"its:test.chm::\\blank.html";
77static const WCHAR blank_url6[] = L"its:test.chm::/%62lank.html";
78static const WCHAR blank_url7[] = L"mk:@MSITStore:test.chm::\\blank.html";
79static const WCHAR blank_url8[] = L"mk:@MSITStore:test.chm::/blank.html/";
80static const WCHAR blank_url9[] = L"its:test.chm::/dir/../blank.html";
81
82static enum {
86
87static const WCHAR cache_file1[] = L"test.chm::/blank.html";
88static const WCHAR cache_file2[] = L"test.chm::\\blank.html";
89static const WCHAR cache_file3[] = L"test.chm::/blank.html/";
91
93{
94 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
95 *ppv = iface;
96 return S_OK;
97 }
98 return E_NOINTERFACE;
99}
100
102{
103 return 2;
104}
105
107{
108 return 1;
109}
110
111static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
112{
113 ok(0, "unexpected call\n");
114 return E_NOTIMPL;
115}
116
118 LPCWSTR szStatusText)
119{
120 switch(ulStatusCode) {
121 case BINDSTATUS_BEGINDOWNLOADDATA:
122 CHECK_EXPECT(ReportProgress_BEGINDOWNLOADDATA);
123 ok(!szStatusText, "szStatusText != NULL\n");
124 break;
125 case BINDSTATUS_SENDINGREQUEST:
126 CHECK_EXPECT(ReportProgress_SENDINGREQUEST);
128 ok(!lstrcmpW(szStatusText, L"blank.html"), "unexpected szStatusText\n");
129 else
130 ok(szStatusText == NULL, "szStatusText != NULL\n");
131 break;
132 case BINDSTATUS_MIMETYPEAVAILABLE:
133 CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
134 ok(!lstrcmpW(szStatusText, L"text/html"), "unexpected szStatusText\n");
135 break;
136 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
137 CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
138 ok(!lstrcmpW(szStatusText, cache_file), "unexpected szStatusText\n");
139 break;
140 case BINDSTATUS_DIRECTBIND:
141 CHECK_EXPECT(ReportProgress_DIRECTBIND);
142 ok(!szStatusText, "szStatusText != NULL\n");
143 break;
144 default:
145 ok(0, "unexpected ulStatusCode %ld\n", ulStatusCode);
146 break;
147 }
148
149 return S_OK;
150}
151
153 ULONG ulProgressMax)
154{
155 CHECK_EXPECT(ReportData);
156
157 ok(ulProgress == ulProgressMax, "ulProgress != ulProgressMax\n");
159 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE), "grcf = %08lx\n", grfBSCF);
160 else
161 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION), "grcf = %08lx\n", grfBSCF);
162
163 if(read_protocol) {
164 BYTE buf[100];
165 DWORD cb = 0xdeadbeef;
167
168 hres = IInternetProtocol_Read(read_protocol, buf, sizeof(buf), &cb);
169 ok(hres == S_OK, "Read failed: %08lx\n", hres);
170 ok(cb == 13, "cb=%lu expected 13\n", cb);
171 ok(!memcmp(buf, "<html></html>", 13), "unexpected data\n");
172 }
173
174 return S_OK;
175}
176
178 DWORD dwError, LPCWSTR szResult)
179{
180 CHECK_EXPECT(ReportResult);
181
182 ok(hrResult == expect_hrResult, "expected: %08lx got: %08lx\n", expect_hrResult, hrResult);
183 ok(dwError == 0, "dwError = %ld\n", dwError);
184 ok(!szResult, "szResult != NULL\n");
185
186 return S_OK;
187}
188
189static IInternetProtocolSinkVtbl protocol_sink_vtbl = {
197};
198
201};
202
204{
205 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) {
206 *ppv = iface;
207 return S_OK;
208 }
209 return E_NOINTERFACE;
210}
211
213{
214 return 2;
215}
216
218{
219 return 1;
220}
221
222static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
223{
224 CHECK_EXPECT(GetBindInfo);
225
226 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
227 if(grfBINDF)
228 ok(!*grfBINDF, "*grfBINDF != 0\n");
229 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
230 ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %ld\n", pbindinfo->cbSize);
231
232 *grfBINDF = bindf;
233 return S_OK;
234}
235
236static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType, LPOLESTR *ppwzStr,
237 ULONG cEl, ULONG *pcElFetched)
238{
239 ok(0, "unexpected call\n");
240 return E_NOTIMPL;
241}
242
243static IInternetBindInfoVtbl bind_info_vtbl = {
249};
250
253};
254
256{
258
259 SET_EXPECT(GetBindInfo);
260 SET_EXPECT(ReportResult);
261
262 expect_hrResult = expected_hres;
263 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
264 ok(hres == expected_hres, "expected: %08lx got: %08lx\n", expected_hres, hres);
265
266 CHECK_CALLED(GetBindInfo);
267 CHECK_CALLED(ReportResult);
268}
269
270#define protocol_start(p,u,e) _protocol_start(__LINE__,p,u,e)
272{
274
275 SET_EXPECT(GetBindInfo);
277 SET_EXPECT(ReportProgress_DIRECTBIND);
278 SET_EXPECT(ReportProgress_SENDINGREQUEST);
279 if(expect_mime)
280 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
282 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
283 SET_EXPECT(ReportData);
285 SET_EXPECT(ReportProgress_BEGINDOWNLOADDATA);
286 SET_EXPECT(ReportResult);
288
289 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
290
291 if(FAILED(hres)) {
292 SET_CALLED(GetBindInfo);
294 SET_CALLED(ReportProgress_DIRECTBIND);
295 SET_CALLED(ReportProgress_SENDINGREQUEST);
296 if(expect_mime)
297 SET_CALLED(ReportProgress_MIMETYPEAVAILABLE);
299 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
300 SET_CALLED(ReportData);
302 SET_CALLED(ReportProgress_BEGINDOWNLOADDATA);
303 SET_CALLED(ReportResult);
304 }else {
305 CHECK_CALLED(GetBindInfo);
307 SET_CALLED(ReportProgress_DIRECTBIND);
308 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
309 if(expect_mime)
310 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
312 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
313 CHECK_CALLED(ReportData);
315 CHECK_CALLED(ReportProgress_BEGINDOWNLOADDATA);
316 CHECK_CALLED(ReportResult);
317 }
318
319 return hres;
320}
321
323{
325 BYTE buf[512];
326 ULONG cb, ref;
328
329 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
330 ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
331 if(FAILED(hres))
332 return;
333
334 hres = protocol_start(protocol, url, expect_mime);
335 if(FAILED(hres)) {
336 IInternetProtocol_Release(protocol);
337 return;
338 }
339
340 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
341 ok(hres == S_OK, "Read failed: %08lx\n", hres);
342 ok(cb == 13, "cb=%lu expected 13\n", cb);
343 ok(!memcmp(buf, "<html></html>", 13), "unexpected data\n");
344 ref = IInternetProtocol_Release(protocol);
345 ok(!ref, "protocol ref=%ld\n", ref);
346
347 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
348 ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
349 if(FAILED(hres))
350 return;
351
352 cb = 0xdeadbeef;
353 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
355 "Read returned %08lx\n", hres);
356 ok(cb == 0xdeadbeef, "cb=%lu expected 0xdeadbeef\n", cb);
357
358 protocol_start(protocol, url, expect_mime);
359 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
360 ok(hres == S_OK, "Read failed: %08lx\n", hres);
361 ok(cb == 2, "cb=%lu expected 2\n", cb);
362 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
363 ok(hres == S_OK, "Read failed: %08lx\n", hres);
364 ok(cb == 11, "cb=%lu, expected 11\n", cb);
365 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
366 ok(hres == S_FALSE, "Read failed: %08lx expected S_FALSE\n", hres);
367 ok(cb == 0, "cb=%lu expected 0\n", cb);
368 hres = IInternetProtocol_UnlockRequest(protocol);
369 ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
370 ref = IInternetProtocol_Release(protocol);
371 ok(!ref, "protocol ref=%ld\n", ref);
372
373 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
374 ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
375 if(FAILED(hres))
376 return;
377
378 protocol_start(protocol, url, expect_mime);
379 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
380 ok(hres == S_OK, "Read failed: %08lx\n", hres);
381 hres = IInternetProtocol_LockRequest(protocol, 0);
382 ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
383 hres = IInternetProtocol_UnlockRequest(protocol);
384 ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
385 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
386 ok(hres == S_OK, "Read failed: %08lx\n", hres);
387 ok(cb == 11, "cb=%lu, expected 11\n", cb);
388 ref = IInternetProtocol_Release(protocol);
389 ok(!ref, "protocol ref=%ld\n", ref);
390
391 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
392 ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
393 if(FAILED(hres))
394 return;
395
396 protocol_start(protocol, url, expect_mime);
397 hres = IInternetProtocol_LockRequest(protocol, 0);
398 ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
399 hres = IInternetProtocol_Terminate(protocol, 0);
400 ok(hres == S_OK, "Terminate failed: %08lx\n", hres);
401 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
402 ok(hres == S_OK, "Read failed: %08lx\n", hres);
403 ok(cb == 2, "cb=%lu, expected 2\n", cb);
404 hres = IInternetProtocol_UnlockRequest(protocol);
405 ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
406 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
407 ok(hres == S_OK, "Read failed: %08lx\n", hres);
408 ok(cb == 2, "cb=%lu, expected 2\n", cb);
409 hres = IInternetProtocol_Terminate(protocol, 0);
410 ok(hres == S_OK, "Terminate failed: %08lx\n", hres);
411 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
412 ok(hres == S_OK, "Read failed: %08lx\n", hres);
413 ok(cb == 2, "cb=%lu expected 2\n", cb);
414 ref = IInternetProtocol_Release(protocol);
415 ok(!ref, "protocol ref=%ld\n", ref);
416
417 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&read_protocol);
418 ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
419 if(FAILED(hres))
420 return;
421
422 protocol_start(read_protocol, url, expect_mime);
423 ref = IInternetProtocol_Release(read_protocol);
424 ok(!ref, "protocol ref=%ld\n", ref);
426}
427
428static const struct {
434} combine_tests[] = {
435 {L"its:test.chm::/blank.html", L"its:test.chm::/blank.html", 0, STG_E_INVALIDNAME, NULL},
436 {L"mS-iTs:test.chm::/blank.html", L"mS-iTs:test.chm::/blank.html", 0, STG_E_INVALIDNAME, NULL},
437 {L"its:test.chm::/blank.html", L"test.html", 0, S_OK, L"its:test.chm::/test.html"},
438 {L"its:test.chm::/blank.html", L"test.chm::/test.html", 0, STG_E_INVALIDNAME, NULL},
439 {L"its:test.chm::/blank.html", L"/test.html", 0, S_OK, L"its:test.chm::/test.html"},
440 {L"its:test.chm::/blank.html", L"te:t.html", 0, STG_E_INVALIDNAME, NULL},
441 {L"its:test.chm::/blank.html", L"/test.html", URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, S_OK, L"its:test.chm::/test.html"},
442 {L"its:test.chm::/blank.html", L"dir/test.html", 0, S_OK, L"its:test.chm::/dir/test.html"},
443 {L"test.html", L"test.chm::/test.html", 0, 0x80041001, NULL},
444 {L"its:test:.chm::/blank.html", L"test.html", 0, S_OK, L"its:test:.chm::/test.html"},
445 {L"its:test.chm::/dir/blank.html", L"test.html", 0, S_OK, L"its:test.chm::/dir/test.html"},
446 {L"its:test.chm::blank.html", L"test.html", 0, S_OK, L"its:test.chm::blank.htmltest.html"},
447 {L"ms-its:test.chm::/dir/blank.html", L"test.html", 0, S_OK, L"ms-its:test.chm::/dir/test.html"},
448 {L"mk:@MSITStore:test.chm::/dir/blank.html", L"test.html", 0, S_OK, L"mk:@MSITStore:test.chm::/dir/test.html"},
449 {L"xxx:test.chm::/dir/blank.html", L"test.html", 0, INET_E_USE_DEFAULT_PROTOCOLHANDLER, NULL},
450 {L"its:test.chm::/dir/blank.html", L"/test.html", 0, S_OK, L"its:test.chm::/test.html"},
451 {L"its:test.chm::/blank.html", L"#frag", 0, S_OK, L"its:test.chm::/blank.html#frag"},
452 {L"its:test.chm::/blank.html#hash", L"#frag", 0, S_OK, L"its:test.chm::/blank.html#hash#frag"},
453 {L"its:test.chm::/blank.html", L"test.html#frag", 0, S_OK, L"its:test.chm::/test.html#frag"},
454 {L"its:test.chm::/blank.html", L"/test.html#frag", 0, S_OK, L"its:test.chm::/test.html#frag"},
455 {L"its:test.chm::/blank.html", L"?query", 0, S_OK, L"its:test.chm::/?query"},
456 {L"its:test.chm::/blank.html#frag/blank", L"test.html", 0, S_OK, L"its:test.chm::/blank.html#frag/test.html"},
458
460{
462 WCHAR buf[1024];
463 DWORD size, i;
465
466 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolInfo, (void**)&info);
467 ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres);
468 if(FAILED(hres))
469 return;
470
471 for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
472 if(i != PARSE_CANONICALIZE && i != PARSE_SECURITY_URL) {
473 hres = IInternetProtocolInfo_ParseUrl(info, blank_url1, i, 0, buf,
474 ARRAY_SIZE(buf), &size, 0);
475 ok(hres == INET_E_DEFAULT_ACTION,
476 "[%ld] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres);
477 }
478 }
479
480 for(i=0; i < ARRAY_SIZE(combine_tests); i++) {
481 size = 0xdeadbeef;
482 memset(buf, 0xfe, sizeof(buf));
483 hres = IInternetProtocolInfo_CombineUrl(info, combine_tests[i].base_url,
485 ok(hres == combine_tests[i].hres, "[%ld] CombineUrl returned %08lx, expected %08lx\n",
488 : 0xdeadbeef), "[%ld] unexpected size=%ld\n", i, size);
490 ok(!lstrcmpW(buf, combine_tests[i].combined_url), "[%ld] unexpected result: %s\n", i, wine_dbgstr_w(buf));
491 else
492 ok(buf[0] == 0xfefe, "buf changed\n");
493 }
494
495 size = 0xdeadbeef;
496 memset(buf, 0xfe, sizeof(buf));
497 hres = IInternetProtocolInfo_CombineUrl(info, L"its:test.chm::/blank.html", L"test.html", 0, buf,
498 1, &size, 0);
499 ok(hres == E_OUTOFMEMORY, "CombineUrl failed: %08lx\n", hres);
500 ok(size == 25, "size=%ld\n", size);
501 ok(buf[0] == 0xfefe, "buf changed\n");
502
503 IInternetProtocolInfo_Release(info);
504}
505
506static void test_its_protocol(void)
507{
510 IUnknown *unk;
511 ULONG ref;
513
514 static const WCHAR wrong_url1[] = L"its:test.chm::/blan.html";
515 static const WCHAR wrong_url2[] = L"its:tes.chm::b/lank.html";
516 static const WCHAR wrong_url3[] = L"its:test.chm/blank.html";
517 static const WCHAR wrong_url4[] = L"mk:@MSITStor:test.chm::/blank.html";
518 static const WCHAR wrong_url5[] = L"file:tes.chm::/blank.html";
519
521
522 hres = CoGetClassObject(&CLSID_ITSProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
523 ok(hres == S_OK ||
524 broken(hres == REGDB_E_CLASSNOTREG), /* Some W95 and NT4 */
525 "CoGetClassObject failed: %08lx\n", hres);
526 if(FAILED(hres))
527 return;
528
529 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&info);
530 ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo: %08lx\n", hres);
531
532 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
533 ok(hres == S_OK, "Could not get IClassFactory interface\n");
534 if(SUCCEEDED(hres)) {
536
537 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
538 ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
539 if(SUCCEEDED(hres)) {
541
545
546 hres = IInternetProtocol_Start(protocol, wrong_url4, &protocol_sink, &bind_info, 0, 0);
547 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER,
548 "Start failed: %08lx, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", hres);
549
550 hres = IInternetProtocol_Start(protocol, wrong_url5, &protocol_sink, &bind_info, 0, 0);
551 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER,
552 "Start failed: %08lx, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", hres);
553
554 ref = IInternetProtocol_Release(protocol);
555 ok(!ref, "protocol ref=%ld\n", ref);
556
565 bindf = BINDF_FROMURLMON | BINDF_NEEDFILE;
567 }
568
569 IClassFactory_Release(factory);
570 }
571
572 IUnknown_Release(unk);
573}
574
575static void test_mk_protocol(void)
576{
579
581
582 hres = CoGetClassObject(&CLSID_MkProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory,
583 (void**)&cf);
584 ok(hres == S_OK ||
585 broken(hres == REGDB_E_CLASSNOTREG), /* Some W95 and NT4 */
586 "CoGetClassObject failed: %08lx\n", hres);
587 if(FAILED(hres))
588 return;
589
596
597 IClassFactory_Release(cf);
598}
599
600static BOOL create_chm(void)
601{
602 HANDLE file;
603 HRSRC src;
604 DWORD size;
605
608 ok(file != INVALID_HANDLE_VALUE, "Could not create test.chm file\n");
610 return FALSE;
611
613
616
617 return TRUE;
618}
619
620static void delete_chm(void)
621{
622 BOOL ret;
623
624 ret = DeleteFileA("test.chm");
625 ok(ret, "DeleteFileA failed: %ld\n", GetLastError());
626}
627
628static const IID outer_test_iid = {0xabcabc00,0,0,{0,0,0,0,0,0,0,0x66}};
629
631{
633 CHECK_EXPECT(outer_QI_test);
634 *ppv = (IUnknown*)0xdeadbeef;
635 return S_OK;
636 }
637 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
638 return E_NOINTERFACE;
639}
640
642{
643 return 2;
644}
645
647{
648 return 1;
649}
650
651static const IUnknownVtbl outer_vtbl = {
655};
656
658{
661 IUnknown *unk, *unk2, *unk3;
663
664 hres = CoGetClassObject(clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&class_factory);
665 ok(hres == S_OK, "CoGetClassObject failed: %08lx\n", hres);
666
667 hres = IClassFactory_CreateInstance(class_factory, &outer, &IID_IUnknown, (void**)&unk);
668 ok(hres == S_OK, "CreateInstance returned: %08lx\n", hres);
669
670 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocol, (void**)&unk2);
671 ok(hres == S_OK, "Could not get IInternetProtocol iface: %08lx\n", hres);
672
673 SET_EXPECT(outer_QI_test);
674 hres = IUnknown_QueryInterface(unk2, &outer_test_iid, (void**)&unk3);
675 CHECK_CALLED(outer_QI_test);
676 ok(hres == S_OK, "Could not get IInternetProtocol iface: %08lx\n", hres);
677 ok(unk3 == (IUnknown*)0xdeadbeef, "unexpected unk2\n");
678
679 IUnknown_Release(unk2);
680 IUnknown_Release(unk);
681
682 unk = (void*)0xdeadbeef;
683 hres = IClassFactory_CreateInstance(class_factory, &outer, &IID_IInternetProtocol, (void**)&unk);
684 ok(hres == CLASS_E_NOAGGREGATION, "CreateInstance returned: %08lx\n", hres);
685 ok(!unk, "unk = %p\n", unk);
686
687 IClassFactory_Release(class_factory);
688}
689
691{
693
694 if(!create_chm())
695 return;
696
699 test_com_aggregation(&CLSID_ITSProtocol);
700
701 delete_chm();
703}
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscontext, COSERVERINFO *server_info, REFIID riid, void **obj)
Definition: combase.c:1925
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:162
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:218
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define wine_dbgstr_w
Definition: kernel32.h:34
#define CREATE_ALWAYS
Definition: disk.h:72
static const WCHAR url[]
Definition: encode.c:1384
static IInternetProtocolSink protocol_sink
Definition: mimeole.c:1384
static IInternetBindInfo bind_info
Definition: mimeole.c:1246
static const struct @1928 combine_tests[]
static HRESULT _protocol_start(unsigned line, IInternetProtocol *protocol, LPCWSTR url, BOOL expect_mime)
Definition: protocol.c:271
#define SET_EXPECT(func)
Definition: protocol.c:37
const WCHAR * base_url
Definition: protocol.c:429
static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode, LPCWSTR szStatusText)
Definition: protocol.c:117
@ ITS_PROTOCOL
Definition: protocol.c:83
@ MK_PROTOCOL
Definition: protocol.c:84
static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
Definition: protocol.c:111
static const WCHAR blank_url1[]
Definition: protocol.c:72
const WCHAR * rel_url
Definition: protocol.c:430
static const IUnknownVtbl outer_vtbl
Definition: protocol.c:651
static const WCHAR blank_url3[]
Definition: protocol.c:74
DWORD flags
Definition: protocol.c:431
static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
Definition: protocol.c:217
static IInternetBindInfoVtbl bind_info_vtbl
Definition: protocol.c:243
static IInternetProtocolSinkVtbl protocol_sink_vtbl
Definition: protocol.c:189
static ULONG WINAPI outer_AddRef(IUnknown *iface)
Definition: protocol.c:641
HRESULT hres
Definition: protocol.c:432
static void delete_chm(void)
Definition: protocol.c:620
static const WCHAR blank_url9[]
Definition: protocol.c:80
#define CHECK_EXPECT(func)
Definition: protocol.c:40
static ULONG WINAPI ProtocolSink_Release(IInternetProtocolSink *iface)
Definition: protocol.c:106
static const WCHAR blank_url2[]
Definition: protocol.c:73
static void test_its_protocol_info(IInternetProtocol *protocol)
Definition: protocol.c:459
#define DEFINE_EXPECT(func)
Definition: protocol.c:34
static const IID outer_test_iid
Definition: protocol.c:628
static const WCHAR blank_url7[]
Definition: protocol.c:78
static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
Definition: protocol.c:203
static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
Definition: protocol.c:222
static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
Definition: protocol.c:92
static void test_mk_protocol(void)
Definition: protocol.c:575
static const WCHAR blank_url8[]
Definition: protocol.c:79
#define protocol_start(p, u, e)
Definition: protocol.c:270
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: protocol.c:630
static const WCHAR blank_url5[]
Definition: protocol.c:76
static HRESULT expect_hrResult
Definition: protocol.c:68
static const WCHAR cache_file1[]
Definition: protocol.c:87
static const WCHAR cache_file3[]
Definition: protocol.c:89
static void test_protocol_url(IClassFactory *factory, LPCWSTR url, BOOL expect_mime)
Definition: protocol.c:322
static void test_com_aggregation(const CLSID *clsid)
Definition: protocol.c:657
static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT expected_hres)
Definition: protocol.c:255
static BOOL create_chm(void)
Definition: protocol.c:600
#define CHECK_CALLED(func)
Definition: protocol.c:50
static DWORD bindf
Definition: protocol.c:70
static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
Definition: protocol.c:177
static void test_its_protocol(void)
Definition: protocol.c:506
static enum @1927 test_protocol
static const WCHAR cache_file2[]
Definition: protocol.c:88
static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
Definition: protocol.c:152
static const WCHAR * cache_file
Definition: protocol.c:90
static const WCHAR blank_url4[]
Definition: protocol.c:75
const WCHAR * combined_url
Definition: protocol.c:433
static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType, LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
Definition: protocol.c:236
static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
Definition: protocol.c:212
#define SET_CALLED(func)
Definition: protocol.c:47
static const WCHAR blank_url6[]
Definition: protocol.c:77
static IInternetProtocol * read_protocol
Definition: protocol.c:69
static ULONG WINAPI ProtocolSink_AddRef(IInternetProtocolSink *iface)
Definition: protocol.c:101
static ULONG WINAPI outer_Release(IUnknown *iface)
Definition: protocol.c:646
static IUnknown * outer
Definition: compobj.c:82
const CLSID * clsid
Definition: msctf.cpp:50
#define GENERIC_WRITE
Definition: nt_native.h:90
short WCHAR
Definition: pedump.c:58
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define URL_DONT_ESCAPE_EXTRA_INFO
Definition: shlwapi.h:529
#define URL_ESCAPE_SPACES_ONLY
Definition: shlwapi.h:530
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:181
#define memset(x, y, z)
Definition: compat.h:39
Definition: main.c:439
Definition: fci.c:123
Definition: parser.c:49
Definition: send.c:48
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:3801
#define INET_E_DATA_NOT_AVAILABLE
Definition: winerror.h:4657
#define S_FALSE
Definition: winerror.h:3451
#define STG_E_INVALIDNAME
Definition: winerror.h:3680
#define E_NOINTERFACE
Definition: winerror.h:3479
#define STG_E_FILENOTFOUND
Definition: winerror.h:3660
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
unsigned char BYTE
Definition: xxhash.c:193