opengl32: glGetString() should return NULL on NULL context.
[wine/hacks.git] / dlls / urlmon / tests / url.c
blobc0e93ec6c5b39d7acffe07b06c272c5bf54be849
1 /*
2 * UrlMon URL tests
4 * Copyright 2004 Kevin Koltzau
5 * Copyright 2004-2007 Jacek Caban for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdarg.h>
23 #include <stdio.h>
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define CONST_VTABLE
29 #include "windef.h"
30 #include "winbase.h"
31 #include "urlmon.h"
32 #include "wininet.h"
33 #include "mshtml.h"
35 #include "wine/test.h"
37 #define DEFINE_EXPECT(func) \
38 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
40 #define SET_EXPECT(func) \
41 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
43 #define CHECK_EXPECT2(func) \
44 do { \
45 ok(expect_ ##func, "unexpected call " #func "\n"); \
46 called_ ## func = TRUE; \
47 }while(0)
49 #define CHECK_EXPECT(func) \
50 do { \
51 CHECK_EXPECT2(func); \
52 expect_ ## func = FALSE; \
53 }while(0)
55 #define CHECK_CALLED(func) \
56 do { \
57 ok(called_ ## func, "expected " #func "\n"); \
58 expect_ ## func = called_ ## func = FALSE; \
59 }while(0)
61 #define CHECK_NOT_CALLED(func) \
62 do { \
63 ok(!called_ ## func, "unexpected " #func "\n"); \
64 expect_ ## func = called_ ## func = FALSE; \
65 }while(0)
67 #define CLEAR_CALLED(func) \
68 expect_ ## func = called_ ## func = FALSE
70 DEFINE_EXPECT(QueryInterface_IServiceProvider);
71 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
72 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
73 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
74 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
75 DEFINE_EXPECT(QueryInterface_IAuthenticate);
76 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
77 DEFINE_EXPECT(QueryService_IAuthenticate);
78 DEFINE_EXPECT(QueryService_IInternetProtocol);
79 DEFINE_EXPECT(QueryService_IInternetBindInfo);
80 DEFINE_EXPECT(BeginningTransaction);
81 DEFINE_EXPECT(OnResponse);
82 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
83 DEFINE_EXPECT(GetRootSecurityId);
84 DEFINE_EXPECT(GetBindInfo);
85 DEFINE_EXPECT(OnStartBinding);
86 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
87 DEFINE_EXPECT(OnProgress_CONNECTING);
88 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
89 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
90 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
91 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
92 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
93 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
94 DEFINE_EXPECT(OnStopBinding);
95 DEFINE_EXPECT(OnDataAvailable);
96 DEFINE_EXPECT(OnObjectAvailable);
97 DEFINE_EXPECT(Obj_OnStartBinding);
98 DEFINE_EXPECT(Obj_OnStopBinding);
99 DEFINE_EXPECT(Obj_GetBindInfo);
100 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
101 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
102 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
103 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
104 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
105 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
106 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
107 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
108 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
109 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
110 DEFINE_EXPECT(Start);
111 DEFINE_EXPECT(Read);
112 DEFINE_EXPECT(LockRequest);
113 DEFINE_EXPECT(Terminate);
114 DEFINE_EXPECT(UnlockRequest);
115 DEFINE_EXPECT(Continue);
116 DEFINE_EXPECT(CreateInstance);
117 DEFINE_EXPECT(Load);
118 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
119 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
121 static const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
122 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
124 static const WCHAR WINE_ABOUT_URL[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
125 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
126 static const WCHAR SHORT_RESPONSE_URL[] =
127 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
128 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
129 'p','o','s','t','t','e','s','t','.','p','h','p',0};
130 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
131 static WCHAR INDEX_HTML[MAX_PATH];
132 static const WCHAR ITS_URL[] =
133 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
134 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
135 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
137 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
139 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
141 static const WCHAR wszWineHQSite[] =
142 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
143 static const WCHAR wszWineHQIP[] =
144 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
145 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
146 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
147 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
148 static const WCHAR emptyW[] = {0};
150 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
151 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api;
152 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed;
153 static CHAR mime_type[512];
154 static IInternetProtocolSink *protocol_sink = NULL;
155 static HANDLE complete_event, complete_event2;
156 static HRESULT binding_hres;
158 extern IID IID_IBindStatusCallbackHolder;
160 static LPCWSTR urls[] = {
161 WINE_ABOUT_URL,
162 ABOUT_BLANK,
163 INDEX_HTML,
164 ITS_URL,
165 MK_URL
168 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
170 static enum {
171 HTTP_TEST,
172 ABOUT_TEST,
173 FILE_TEST,
174 ITS_TEST,
175 MK_TEST
176 } test_protocol;
178 static enum {
179 BEFORE_DOWNLOAD,
180 DOWNLOADING,
181 END_DOWNLOAD
182 } download_state;
184 static const char *debugstr_w(LPCWSTR str)
186 static char buf[1024];
187 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
188 return buf;
191 static const char *debugstr_guid(REFIID riid)
193 static char buf[50];
195 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
196 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
197 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
198 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
200 return buf;
203 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
205 HRESULT hr;
206 IMoniker *mon1 = NULL;
207 IMoniker *mon2 = NULL;
209 hr = CreateURLMoniker(NULL, url1, &mon1);
210 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
211 if(SUCCEEDED(hr)) {
212 hr = CreateURLMoniker(mon1, url2, &mon2);
213 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
215 if(mon1) IMoniker_Release(mon1);
216 if(mon2) IMoniker_Release(mon2);
219 static void test_create(void)
221 test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
224 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
226 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
227 *ppv = iface;
228 return S_OK;
231 *ppv = NULL;
232 return E_NOINTERFACE;
235 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
237 return 2;
240 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
242 return 1;
245 static DWORD WINAPI thread_proc(PVOID arg)
247 PROTOCOLDATA protocoldata;
248 HRESULT hres;
250 if(bind_to_object)
251 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
252 else
253 SET_EXPECT(OnProgress_FINDINGRESOURCE);
254 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
255 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
256 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
257 WaitForSingleObject(complete_event, INFINITE);
258 if(bind_to_object)
259 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
260 else
261 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
263 if(bind_to_object)
264 SET_EXPECT(Obj_OnProgress_CONNECTING);
265 else
266 SET_EXPECT(OnProgress_CONNECTING);
267 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
268 BINDSTATUS_CONNECTING, wszWineHQIP);
269 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
270 WaitForSingleObject(complete_event, INFINITE);
271 if(bind_to_object)
272 CHECK_CALLED(Obj_OnProgress_CONNECTING);
273 else
274 CHECK_CALLED(OnProgress_CONNECTING);
276 if(bind_to_object)
277 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
278 else
279 SET_EXPECT(OnProgress_SENDINGREQUEST);
280 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
281 BINDSTATUS_SENDINGREQUEST, NULL);
282 ok(hres == S_OK, "ReportProxgress failed: %08x\n", hres);
283 WaitForSingleObject(complete_event, INFINITE);
284 if(bind_to_object)
285 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
286 else
287 CHECK_CALLED(OnProgress_SENDINGREQUEST);
289 SET_EXPECT(Continue);
290 prot_state = 1;
291 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
292 ok(hres == S_OK, "Switch failed: %08x\n", hres);
293 WaitForSingleObject(complete_event, INFINITE);
295 CHECK_CALLED(Continue);
296 CHECK_CALLED(Read);
297 if(bind_to_object) {
298 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
299 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
300 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
301 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
302 CHECK_CALLED(CreateInstance);
303 CHECK_CALLED(PutProperty_MIMETYPEPROP);
304 CLEAR_CALLED(PutProperty_CLASSIDPROP);
305 CHECK_CALLED(Load);
306 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
307 CHECK_CALLED(OnObjectAvailable);
308 CHECK_CALLED(Obj_OnStopBinding);
309 }else {
310 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
311 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
312 CHECK_CALLED(LockRequest);
313 CHECK_CALLED(OnDataAvailable);
316 SET_EXPECT(Continue);
317 prot_state = 2;
318 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
319 ok(hres == S_OK, "Switch failed: %08x\n", hres);
320 WaitForSingleObject(complete_event, INFINITE);
321 CHECK_CALLED(Continue);
322 CHECK_CALLED(Read);
323 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
324 CHECK_CALLED(OnDataAvailable);
326 SET_EXPECT(Continue);
327 prot_state = 2;
328 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
329 ok(hres == S_OK, "Switch failed: %08x\n", hres);
330 WaitForSingleObject(complete_event, INFINITE);
331 CHECK_CALLED(Continue);
332 CHECK_CALLED(Read);
333 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
334 CHECK_CALLED(OnDataAvailable);
336 SET_EXPECT(Continue);
337 prot_state = 3;
338 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
339 ok(hres == S_OK, "Switch failed: %08x\n", hres);
340 WaitForSingleObject(complete_event, INFINITE);
341 CHECK_CALLED(Continue);
342 CHECK_CALLED(Read);
343 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
344 CHECK_CALLED(OnDataAvailable);
345 CHECK_CALLED(OnStopBinding);
347 SET_EXPECT(Read);
349 SetEvent(complete_event2);
350 return 0;
353 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
354 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
355 DWORD grfPI, DWORD dwReserved)
357 BINDINFO bindinfo;
358 DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
359 HRESULT hres;
361 static const STGMEDIUM stgmed_zero = {0};
362 static const SECURITY_ATTRIBUTES sa_zero = {0};
364 CHECK_EXPECT(Start);
366 read = 0;
368 if(!filedwl_api) /* FIXME */
369 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", debugstr_w(szUrl));
370 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
371 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
372 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
373 ok(dwReserved == 0, "dwReserved=%d, expected 0\n", dwReserved);
375 if(!filedwl_api && binding_hres != S_OK) {
376 SET_EXPECT(OnStopBinding);
377 SET_EXPECT(Terminate);
378 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
379 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
380 CHECK_CALLED(OnStopBinding);
381 CHECK_CALLED(Terminate);
383 return S_OK;
386 memset(&bindinfo, 0, sizeof(bindinfo));
387 bindinfo.cbSize = sizeof(bindinfo);
388 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
389 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
391 if(filedwl_api) {
392 ok(bindf == (BINDF_PULLDATA|BINDF_FROMURLMON|BINDF_NEEDFILE), "bindf=%08x\n", bindf);
393 }else if(tymed == TYMED_ISTREAM
394 && (test_protocol == FILE_TEST || test_protocol == MK_TEST || test_protocol == HTTP_TEST)) {
395 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
396 |BINDF_FROMURLMON),
397 "bindf=%08x\n", bindf);
398 }else {
399 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
400 |BINDF_FROMURLMON|BINDF_NEEDFILE),
401 "bindf=%08x\n", bindf);
404 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
405 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
406 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
407 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
408 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
409 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
410 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
411 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
412 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
413 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
414 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
415 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
416 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
417 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
419 switch(test_protocol) {
420 case MK_TEST:
421 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
422 BINDSTATUS_DIRECTBIND, NULL);
423 ok(hres == S_OK,
424 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
426 case FILE_TEST:
427 case ITS_TEST:
428 if(bind_to_object)
429 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
430 else
431 SET_EXPECT(OnProgress_SENDINGREQUEST);
432 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
433 BINDSTATUS_SENDINGREQUEST, emptyW);
434 ok(hres == S_OK,
435 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
436 if(bind_to_object)
437 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
438 else
439 CHECK_CALLED(OnProgress_SENDINGREQUEST);
440 default:
441 break;
444 if(test_protocol == HTTP_TEST) {
445 IServiceProvider *service_provider;
446 IHttpNegotiate *http_negotiate;
447 IHttpNegotiate2 *http_negotiate2;
448 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
449 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
450 BYTE sec_id[100];
451 DWORD fetched = 256, size = 100;
452 DWORD tid;
454 static const WCHAR wszMimes[] = {'*','/','*',0};
456 SET_EXPECT(QueryInterface_IInternetBindInfo);
457 SET_EXPECT(QueryService_IInternetBindInfo);
458 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
459 &ua, 1, &fetched);
460 todo_wine {
461 CHECK_CALLED(QueryInterface_IInternetBindInfo);
462 CHECK_CALLED(QueryService_IInternetBindInfo);
464 ok(hres == E_NOINTERFACE,
465 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
466 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
467 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
469 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
470 accept_mimes, 256, &fetched);
471 ok(hres == S_OK,
472 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
473 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
474 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
476 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
477 NULL, 256, &fetched);
478 ok(hres == E_INVALIDARG,
479 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
481 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
482 accept_mimes, 256, NULL);
483 ok(hres == E_INVALIDARG,
484 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
486 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
487 (void**)&service_provider);
488 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
490 SET_EXPECT(QueryInterface_IHttpNegotiate);
491 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
492 &IID_IHttpNegotiate, (void**)&http_negotiate);
493 CHECK_CALLED(QueryInterface_IHttpNegotiate);
494 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
496 SET_EXPECT(BeginningTransaction);
497 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
498 NULL, 0, &additional_headers);
499 CHECK_CALLED(BeginningTransaction);
500 IHttpNegotiate_Release(http_negotiate);
501 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
502 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
504 SET_EXPECT(QueryInterface_IHttpNegotiate2);
505 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
506 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
507 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
508 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
510 size = 512;
511 SET_EXPECT(GetRootSecurityId);
512 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
513 CHECK_CALLED(GetRootSecurityId);
514 IHttpNegotiate2_Release(http_negotiate2);
515 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
516 ok(size == 13, "size=%d\n", size);
518 IServiceProvider_Release(service_provider);
520 IInternetProtocolSink_AddRef(pOIProtSink);
521 protocol_sink = pOIProtSink;
522 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
524 return S_OK;
527 if(test_protocol == FILE_TEST) {
528 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
529 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
530 ok(hres == S_OK,
531 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
533 if(bind_to_object)
534 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
535 else
536 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
537 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
538 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
539 ok(hres == S_OK,
540 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
541 if(bind_to_object)
542 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
543 else
544 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
545 }else {
546 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
547 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
548 ok(hres == S_OK,
549 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
552 if(test_protocol == ABOUT_TEST)
553 bscf |= BSCF_DATAFULLYAVAILABLE;
554 if(test_protocol == ITS_TEST)
555 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
557 SET_EXPECT(Read);
558 if(bind_to_object) {
559 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
560 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
561 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
562 if(test_protocol == FILE_TEST)
563 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
564 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
565 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
566 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
567 SET_EXPECT(CreateInstance);
568 SET_EXPECT(PutProperty_MIMETYPEPROP);
569 SET_EXPECT(PutProperty_CLASSIDPROP);
570 SET_EXPECT(Load);
571 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
572 SET_EXPECT(OnObjectAvailable);
573 SET_EXPECT(Obj_OnStopBinding);
574 }else {
575 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
576 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
577 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
578 if(test_protocol == FILE_TEST)
579 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
580 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
581 SET_EXPECT(LockRequest);
582 if(!filedwl_api)
583 SET_EXPECT(OnDataAvailable);
584 SET_EXPECT(OnStopBinding);
587 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
588 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
590 CHECK_CALLED(Read);
591 if(bind_to_object) {
592 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
593 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
594 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
595 if(test_protocol == FILE_TEST)
596 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
597 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
598 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
599 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
600 CHECK_CALLED(CreateInstance);
601 CHECK_CALLED(PutProperty_MIMETYPEPROP);
602 CLEAR_CALLED(PutProperty_CLASSIDPROP);
603 CHECK_CALLED(Load);
604 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
605 CHECK_CALLED(OnObjectAvailable);
606 CHECK_CALLED(Obj_OnStopBinding);
607 }else {
608 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
609 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
610 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
611 if(test_protocol == FILE_TEST)
612 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
613 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
614 CHECK_CALLED(LockRequest);
615 if(!filedwl_api)
616 CHECK_CALLED(OnDataAvailable);
617 CHECK_CALLED(OnStopBinding);
620 if(test_protocol == ITS_TEST) {
621 SET_EXPECT(Read);
622 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
623 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
624 CHECK_CALLED(Read);
627 SET_EXPECT(Terminate);
628 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
629 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
630 CHECK_CALLED(Terminate);
632 return S_OK;
635 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
636 PROTOCOLDATA *pProtocolData)
638 DWORD bscf = 0;
639 HRESULT hres;
641 CHECK_EXPECT(Continue);
643 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
645 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
646 if(!pProtocolData)
647 return S_OK;
649 switch(prot_state) {
650 case 1: {
651 IServiceProvider *service_provider;
652 IHttpNegotiate *http_negotiate;
653 static WCHAR header[] = {'?',0};
655 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
656 (void**)&service_provider);
657 ok(hres == S_OK, "Could not get IServiceProvicder\n");
659 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
660 &IID_IHttpNegotiate, (void**)&http_negotiate);
661 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
663 SET_EXPECT(OnResponse);
664 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
665 CHECK_CALLED(OnResponse);
666 IHttpNegotiate_Release(http_negotiate);
667 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
669 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
670 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
671 ok(hres == S_OK,
672 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
674 if(tymed == TYMED_FILE) {
675 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
676 BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_fileW);
677 ok(hres == S_OK,
678 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
681 bscf |= BSCF_FIRSTDATANOTIFICATION;
682 break;
684 case 2:
685 case 3:
686 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
687 break;
690 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
691 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
693 SET_EXPECT(Read);
694 switch(prot_state) {
695 case 1:
696 if(bind_to_object) {
697 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
698 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
699 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
700 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
701 SET_EXPECT(CreateInstance);
702 SET_EXPECT(PutProperty_MIMETYPEPROP);
703 SET_EXPECT(PutProperty_CLASSIDPROP);
704 SET_EXPECT(Load);
705 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
706 SET_EXPECT(OnObjectAvailable);
707 SET_EXPECT(Obj_OnStopBinding);
708 }else {
709 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
710 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
711 SET_EXPECT(LockRequest);
713 break;
714 case 2:
715 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
716 break;
717 case 3:
718 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
719 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
721 if(!bind_to_object || prot_state >= 2)
722 SET_EXPECT(OnDataAvailable);
723 if(prot_state == 3)
724 SET_EXPECT(OnStopBinding);
726 return S_OK;
729 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
730 DWORD dwOptions)
732 ok(0, "unexpected call\n");
733 return E_NOTIMPL;
736 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
738 CHECK_EXPECT(Terminate);
740 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
742 if(protocol_sink) {
743 IInternetProtocolSink_Release(protocol_sink);
744 protocol_sink = NULL;
747 return S_OK;
750 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
752 ok(0, "unexpected call\n");
753 return E_NOTIMPL;
756 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
758 ok(0, "unexpected call\n");
759 return E_NOTIMPL;
762 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
763 ULONG cb, ULONG *pcbRead)
765 static const char data[] = "<HTML></HTML>";
767 CHECK_EXPECT2(Read);
769 if(test_protocol == HTTP_TEST) {
770 HRESULT hres;
772 static BOOL pending = TRUE;
774 pending = !pending;
776 switch(prot_state) {
777 case 1:
778 case 2:
779 if(pending) {
780 *pcbRead = 10;
781 memset(pv, '?', 10);
782 return E_PENDING;
783 }else {
784 memset(pv, '?', cb);
785 *pcbRead = cb;
786 read++;
787 return S_OK;
789 case 3:
790 prot_state++;
792 *pcbRead = 0;
794 hres = IInternetProtocolSink_ReportData(protocol_sink,
795 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
796 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
798 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
799 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
801 return S_FALSE;
802 case 4:
803 *pcbRead = 0;
804 return S_FALSE;
808 if(read) {
809 *pcbRead = 0;
810 return S_FALSE;
813 ok(pv != NULL, "pv == NULL\n");
814 ok(cb != 0, "cb == 0\n");
815 ok(pcbRead != NULL, "pcbRead == NULL\n");
816 if(pcbRead) {
817 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
818 read += *pcbRead = sizeof(data)-1;
820 if(pv)
821 memcpy(pv, data, sizeof(data));
823 return S_OK;
826 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
827 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
829 ok(0, "unexpected call\n");
830 return E_NOTIMPL;
833 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
835 CHECK_EXPECT(LockRequest);
836 return S_OK;
839 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
841 CHECK_EXPECT(UnlockRequest);
842 return S_OK;
845 static const IInternetProtocolVtbl ProtocolVtbl = {
846 Protocol_QueryInterface,
847 Protocol_AddRef,
848 Protocol_Release,
849 Protocol_Start,
850 Protocol_Continue,
851 Protocol_Abort,
852 Protocol_Terminate,
853 Protocol_Suspend,
854 Protocol_Resume,
855 Protocol_Read,
856 Protocol_Seek,
857 Protocol_LockRequest,
858 Protocol_UnlockRequest
861 static IInternetProtocol Protocol = { &ProtocolVtbl };
863 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
865 if(IsEqualGUID(&IID_IUnknown, riid)
866 || IsEqualGUID(&IID_IHttpNegotiate, riid)
867 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
868 *ppv = iface;
869 return S_OK;
872 ok(0, "unexpected call\n");
873 return E_NOINTERFACE;
876 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
878 return 2;
881 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
883 return 1;
886 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
887 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
889 CHECK_EXPECT(BeginningTransaction);
891 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
893 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
894 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
895 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
896 if(pszAdditionalHeaders)
897 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
899 return S_OK;
902 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
903 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
905 CHECK_EXPECT(OnResponse);
907 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
909 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
910 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
911 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
912 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
913 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
914 if(pszAdditionalRequestHeaders)
915 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
917 return S_OK;
920 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
921 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
923 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
925 CHECK_EXPECT(GetRootSecurityId);
927 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
929 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
930 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
931 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
933 if(pbSecurityId == (void*)0xdeadbeef)
934 return E_NOTIMPL;
936 if(pcbSecurityId) {
937 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
938 *pcbSecurityId = sizeof(sec_id);
941 if(pbSecurityId)
942 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
944 return E_FAIL;
947 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
948 HttpNegotiate_QueryInterface,
949 HttpNegotiate_AddRef,
950 HttpNegotiate_Release,
951 HttpNegotiate_BeginningTransaction,
952 HttpNegotiate_OnResponse,
953 HttpNegotiate_GetRootSecurityId
956 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
958 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
960 ok(0, "unexpected call\n");
961 return E_NOINTERFACE;
964 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
966 return 2;
969 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
971 return 1;
974 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
975 REFGUID guidService, REFIID riid, void **ppv)
977 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
978 CHECK_EXPECT(QueryService_IAuthenticate);
979 return E_NOTIMPL;
982 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
983 CHECK_EXPECT2(QueryService_IInternetProtocol);
984 return E_NOTIMPL;
987 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
988 CHECK_EXPECT(QueryService_IInternetBindInfo);
989 return E_NOTIMPL;
992 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
993 return E_NOINTERFACE;
996 static IServiceProviderVtbl ServiceProviderVtbl = {
997 ServiceProvider_QueryInterface,
998 ServiceProvider_AddRef,
999 ServiceProvider_Release,
1000 ServiceProvider_QueryService
1003 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1005 static IBindStatusCallback objbsc;
1007 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
1009 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1011 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1012 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1013 if(emulate_protocol) {
1014 *ppv = &Protocol;
1015 return S_OK;
1016 }else {
1017 return E_NOINTERFACE;
1020 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1022 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1023 *ppv = &ServiceProvider;
1024 return S_OK;
1026 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1028 CHECK_EXPECT(QueryInterface_IHttpNegotiate);
1029 *ppv = &HttpNegotiate;
1030 return S_OK;
1032 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1034 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1035 *ppv = &HttpNegotiate;
1036 return S_OK;
1038 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1040 CHECK_EXPECT(QueryInterface_IAuthenticate);
1041 return E_NOINTERFACE;
1043 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1045 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1046 *ppv = iface;
1047 return S_OK;
1049 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1051 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1052 return E_NOINTERFACE;
1054 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1056 /* TODO */
1057 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1059 else
1061 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1064 return E_NOINTERFACE;
1067 static ULONG WINAPI statusclb_AddRef(IBindStatusCallback *iface)
1069 return 2;
1072 static ULONG WINAPI statusclb_Release(IBindStatusCallback *iface)
1074 return 1;
1077 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved,
1078 IBinding *pib)
1080 IWinInetHttpInfo *http_info;
1081 HRESULT hres;
1082 IMoniker *mon;
1084 if(iface == &objbsc)
1085 CHECK_EXPECT(Obj_OnStartBinding);
1086 else
1087 CHECK_EXPECT(OnStartBinding);
1089 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1091 ok(pib != NULL, "pib should not be NULL\n");
1092 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1094 if(pib == (void*)0xdeadbeef)
1095 return S_OK;
1097 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1098 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1099 if(SUCCEEDED(hres))
1100 IMoniker_Release(mon);
1102 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1103 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1105 return S_OK;
1108 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
1110 ok(0, "unexpected call\n");
1111 return E_NOTIMPL;
1114 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
1116 ok(0, "unexpected call\n");
1117 return E_NOTIMPL;
1120 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
1121 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1123 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1125 switch(ulStatusCode) {
1126 case BINDSTATUS_FINDINGRESOURCE:
1127 if(iface == &objbsc)
1128 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1129 else
1130 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1131 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1132 SetEvent(complete_event);
1133 break;
1134 case BINDSTATUS_CONNECTING:
1135 if(iface == &objbsc)
1136 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1137 else
1138 CHECK_EXPECT(OnProgress_CONNECTING);
1139 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1140 SetEvent(complete_event);
1141 break;
1142 case BINDSTATUS_SENDINGREQUEST:
1143 if(iface == &objbsc)
1144 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1145 else
1146 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1147 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1148 SetEvent(complete_event);
1149 break;
1150 case BINDSTATUS_MIMETYPEAVAILABLE:
1151 if(iface == &objbsc)
1152 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1153 else
1154 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1155 if(!bind_to_object)
1156 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1157 download_state);
1158 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1159 break;
1160 case BINDSTATUS_BEGINDOWNLOADDATA:
1161 if(iface == &objbsc)
1162 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1163 else
1164 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1165 ok(szStatusText != NULL, "szStatusText == NULL\n");
1166 if(szStatusText) {
1167 if(filedwl_api) {
1168 /* FIXME */
1169 }else {
1170 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1173 if(!bind_to_object)
1174 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1175 download_state);
1176 download_state = DOWNLOADING;
1177 break;
1178 case BINDSTATUS_DOWNLOADINGDATA:
1179 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1180 if(iface == &objbsc)
1181 todo_wine ok(0, "unexpected call\n");
1182 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1183 download_state);
1184 break;
1185 case BINDSTATUS_ENDDOWNLOADDATA:
1186 if(iface == &objbsc)
1187 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1188 else
1189 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1190 ok(szStatusText != NULL, "szStatusText == NULL\n");
1191 if(szStatusText) {
1192 if(filedwl_api) {
1193 /* FIXME */
1194 }else {
1195 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1198 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1199 download_state);
1200 download_state = END_DOWNLOAD;
1201 break;
1202 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1203 if(test_protocol != HTTP_TEST) {
1204 if(iface == &objbsc)
1205 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1206 else
1207 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1208 }else { /* FIXME */
1209 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1210 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1213 ok(szStatusText != NULL, "szStatusText == NULL\n");
1214 if(szStatusText && test_protocol == FILE_TEST)
1215 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1216 break;
1217 case BINDSTATUS_CLASSIDAVAILABLE:
1219 CLSID clsid;
1220 HRESULT hr;
1221 if(iface != &objbsc)
1222 ok(0, "unexpected call\n");
1223 else if(1||emulate_protocol)
1224 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1225 else
1226 todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1227 hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
1228 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1229 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1230 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1231 break;
1233 case BINDSTATUS_BEGINSYNCOPERATION:
1234 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1235 if(iface != &objbsc)
1236 ok(0, "unexpected call\n");
1237 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1238 break;
1239 case BINDSTATUS_ENDSYNCOPERATION:
1240 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1241 if(iface != &objbsc)
1242 ok(0, "unexpected call\n");
1243 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1244 break;
1245 default:
1246 ok(0, "unexpected code %d\n", ulStatusCode);
1248 return S_OK;
1251 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
1253 if(iface == &objbsc) {
1254 CHECK_EXPECT(Obj_OnStopBinding);
1255 stopped_obj_binding = TRUE;
1256 }else {
1257 CHECK_EXPECT(OnStopBinding);
1258 stopped_binding = TRUE;
1261 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1263 /* ignore DNS failure */
1264 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1265 return S_OK;
1267 if(filedwl_api)
1268 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1269 else
1270 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1271 ok(szError == NULL, "szError should be NULL\n");
1273 if(test_protocol == HTTP_TEST && emulate_protocol) {
1274 SetEvent(complete_event);
1275 if(iface != &objbsc)
1276 WaitForSingleObject(complete_event2, INFINITE);
1279 return S_OK;
1282 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1284 DWORD cbSize;
1286 if(iface == &objbsc)
1287 CHECK_EXPECT(Obj_GetBindInfo);
1288 else
1289 CHECK_EXPECT(GetBindInfo);
1291 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1293 *grfBINDF = bindf;
1294 cbSize = pbindinfo->cbSize;
1295 memset(pbindinfo, 0, cbSize);
1296 pbindinfo->cbSize = cbSize;
1298 return S_OK;
1301 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
1302 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1304 HRESULT hres;
1305 DWORD readed;
1306 BYTE buf[512];
1307 CHAR clipfmt[512];
1309 if(iface == &objbsc)
1310 ok(0, "unexpected call\n");
1312 CHECK_EXPECT2(OnDataAvailable);
1314 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1316 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1317 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1318 download_state);
1319 data_available = TRUE;
1321 ok(pformatetc != NULL, "pformatetx == NULL\n");
1322 if(pformatetc) {
1323 if (mime_type[0]) {
1324 clipfmt[0] = 0;
1325 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1326 "GetClipboardFormatName failed, error %d\n", GetLastError());
1327 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1328 pformatetc->cfFormat, clipfmt, mime_type);
1329 } else {
1330 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1332 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1333 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1334 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1335 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1338 ok(pstgmed != NULL, "stgmeg == NULL\n");
1339 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1340 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1342 switch(pstgmed->tymed) {
1343 case TYMED_ISTREAM:
1344 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1345 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1346 ok(hres == STG_E_ACCESSDENIED,
1347 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1349 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1350 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1352 hres = IStream_Revert(U(*pstgmed).pstm);
1353 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1356 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1357 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1358 while(hres == S_OK);
1359 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1360 break;
1362 case TYMED_FILE:
1363 if(test_protocol == FILE_TEST)
1364 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1365 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1366 else if(emulate_protocol)
1367 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1368 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1369 else
1370 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1373 if(test_protocol == HTTP_TEST && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1374 SetEvent(complete_event);
1376 return S_OK;
1379 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
1381 CHECK_EXPECT(OnObjectAvailable);
1383 if(iface != &objbsc)
1384 ok(0, "unexpected call\n");
1386 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1387 ok(punk != NULL, "punk == NULL\n");
1389 return S_OK;
1392 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
1393 statusclb_QueryInterface,
1394 statusclb_AddRef,
1395 statusclb_Release,
1396 statusclb_OnStartBinding,
1397 statusclb_GetPriority,
1398 statusclb_OnLowResource,
1399 statusclb_OnProgress,
1400 statusclb_OnStopBinding,
1401 statusclb_GetBindInfo,
1402 statusclb_OnDataAvailable,
1403 statusclb_OnObjectAvailable
1406 static IBindStatusCallback bsc = { &BindStatusCallbackVtbl };
1407 static IBindStatusCallback objbsc = { &BindStatusCallbackVtbl };
1409 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1411 *ppv = NULL;
1412 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1413 return E_NOINTERFACE;
1416 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
1418 return 2;
1421 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
1423 return 1;
1426 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
1428 switch(mkp) {
1429 case MIMETYPEPROP:
1430 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
1431 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", debugstr_w(val));
1432 break;
1433 case CLASSIDPROP:
1434 CHECK_EXPECT(PutProperty_CLASSIDPROP);
1435 break;
1436 default:
1437 break;
1440 return S_OK;
1443 static const IMonikerPropVtbl MonikerPropVtbl = {
1444 MonikerProp_QueryInterface,
1445 MonikerProp_AddRef,
1446 MonikerProp_Release,
1447 MonikerProp_PutProperty
1450 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
1452 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
1454 *ppv = NULL;
1456 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
1457 *ppv = iface;
1458 else if(IsEqualGUID(&IID_IMonikerProp, riid))
1459 *ppv = &MonikerProp;
1461 if(*ppv)
1462 return S_OK;
1464 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1465 return E_NOINTERFACE;
1468 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
1470 return 2;
1473 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
1475 return 1;
1478 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
1480 ok(0, "unexpected call\n");
1481 return E_NOTIMPL;
1484 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
1486 ok(0, "unexpected call\n");
1487 return E_NOTIMPL;
1490 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
1491 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
1493 IUnknown *unk;
1494 HRESULT hres;
1496 static WCHAR cbinding_contextW[] =
1497 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1499 CHECK_EXPECT(Load);
1500 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1502 if(test_protocol == HTTP_TEST)
1503 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1504 else
1505 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1506 ok(pimkName != NULL, "pimkName == NULL\n");
1507 ok(pibc != NULL, "pibc == NULL\n");
1508 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
1510 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
1511 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
1512 if(SUCCEEDED(hres)) {
1513 IBinding *binding;
1515 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
1516 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
1518 IBinding_Release(binding);
1519 IUnknown_Release(unk);
1522 SET_EXPECT(QueryInterface_IServiceProvider);
1523 hres = RegisterBindStatusCallback(pibc, &bsc, NULL, 0);
1524 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1525 CHECK_CALLED(QueryInterface_IServiceProvider);
1527 SET_EXPECT(GetBindInfo);
1528 SET_EXPECT(OnStartBinding);
1529 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1530 if(test_protocol == FILE_TEST)
1531 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1532 if(test_protocol != HTTP_TEST)
1533 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1534 SET_EXPECT(LockRequest);
1535 SET_EXPECT(OnDataAvailable);
1536 if(test_protocol != HTTP_TEST)
1537 SET_EXPECT(OnStopBinding);
1539 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
1540 ok(hres == S_OK, "Load failed: %08x\n", hres);
1542 CHECK_CALLED(GetBindInfo);
1543 CHECK_CALLED(OnStartBinding);
1544 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1545 if(test_protocol == FILE_TEST)
1546 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1547 if(test_protocol != HTTP_TEST)
1548 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1549 CHECK_CALLED(LockRequest);
1550 CHECK_CALLED(OnDataAvailable);
1551 if(test_protocol != HTTP_TEST)
1552 CHECK_CALLED(OnStopBinding);
1554 if(unk)
1555 IUnknown_Release(unk);
1557 return S_OK;
1560 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
1562 ok(0, "unexpected call\n");
1563 return E_NOTIMPL;
1566 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
1568 ok(0, "unexpected call\n");
1569 return E_NOTIMPL;
1572 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
1574 ok(0, "unexpected call\n");
1575 return E_NOTIMPL;
1578 static const IPersistMonikerVtbl PersistMonikerVtbl = {
1579 PersistMoniker_QueryInterface,
1580 PersistMoniker_AddRef,
1581 PersistMoniker_Release,
1582 PersistMoniker_GetClassID,
1583 PersistMoniker_IsDirty,
1584 PersistMoniker_Load,
1585 PersistMoniker_Save,
1586 PersistMoniker_SaveCompleted,
1587 PersistMoniker_GetCurMoniker
1590 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
1592 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1594 *ppv = NULL;
1596 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1597 *ppv = iface;
1598 return S_OK;
1601 if(IsEqualGUID(&IID_IMarshal, riid))
1602 return E_NOINTERFACE;
1603 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1604 return E_NOINTERFACE;
1606 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1607 return E_NOTIMPL;
1610 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1612 return 2;
1615 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1617 return 1;
1620 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1622 CHECK_EXPECT(CreateInstance);
1623 ok(!outer, "outer = %p\n", outer);
1624 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1625 *ppv = &PersistMoniker;
1626 return S_OK;
1629 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1631 ok(0, "unexpected call\n");
1632 return S_OK;
1635 static const IClassFactoryVtbl ClassFactoryVtbl = {
1636 ClassFactory_QueryInterface,
1637 ClassFactory_AddRef,
1638 ClassFactory_Release,
1639 ClassFactory_CreateInstance,
1640 ClassFactory_LockServer
1643 static IClassFactory mime_cf = { &ClassFactoryVtbl };
1645 static void test_CreateAsyncBindCtx(void)
1647 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1648 IUnknown *unk;
1649 HRESULT hres;
1650 ULONG ref;
1651 BIND_OPTS bindopts;
1653 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1654 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1655 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1657 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1658 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1660 SET_EXPECT(QueryInterface_IServiceProvider);
1661 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1662 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1663 CHECK_CALLED(QueryInterface_IServiceProvider);
1665 bindopts.cbStruct = sizeof(bindopts);
1666 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1667 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1668 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1669 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1670 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1671 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1672 bindopts.grfMode);
1673 ok(bindopts.dwTickCountDeadline == 0,
1674 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1676 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1677 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1678 if(SUCCEEDED(hres))
1679 IUnknown_Release(unk);
1681 ref = IBindCtx_Release(bctx);
1682 ok(ref == 0, "bctx should be destroyed here\n");
1685 static void test_CreateAsyncBindCtxEx(void)
1687 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1688 IUnknown *unk;
1689 BIND_OPTS bindopts;
1690 HRESULT hres;
1692 static WCHAR testW[] = {'t','e','s','t',0};
1694 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1695 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1697 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1698 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1700 if(SUCCEEDED(hres)) {
1701 bindopts.cbStruct = sizeof(bindopts);
1702 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1703 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1704 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1705 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1706 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1707 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1708 bindopts.grfMode);
1709 ok(bindopts.dwTickCountDeadline == 0,
1710 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1712 IBindCtx_Release(bctx);
1715 CreateBindCtx(0, &bctx_arg);
1716 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1717 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1719 if(SUCCEEDED(hres)) {
1720 bindopts.cbStruct = sizeof(bindopts);
1721 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1722 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1723 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1724 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1725 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1726 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1727 bindopts.grfMode);
1728 ok(bindopts.dwTickCountDeadline == 0,
1729 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1731 IBindCtx_Release(bctx);
1734 IBindCtx_Release(bctx_arg);
1736 SET_EXPECT(QueryInterface_IServiceProvider);
1737 hres = CreateAsyncBindCtxEx(NULL, 0, &bsc, NULL, &bctx, 0);
1738 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1739 CHECK_CALLED(QueryInterface_IServiceProvider);
1741 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1742 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1743 if(SUCCEEDED(hres))
1744 IUnknown_Release(unk);
1746 IBindCtx_Release(bctx);
1748 hres = CreateBindCtx(0, &bctx2);
1749 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1751 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1752 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1754 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1755 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1757 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1758 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1759 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1761 IBindCtx_Release(bctx);
1762 IBindCtx_Release(bctx2);
1765 static void test_bscholder(IBindStatusCallback *holder)
1767 IServiceProvider *serv_prov;
1768 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1769 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1770 IAuthenticate *authenticate, *authenticate_serv;
1771 IInternetProtocol *protocol;
1772 BINDINFO bindinfo = {sizeof(bindinfo)};
1773 LPWSTR wstr;
1774 DWORD dw;
1775 HRESULT hres;
1777 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
1778 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
1780 dw = 0xdeadbeef;
1781 SET_EXPECT(GetBindInfo);
1782 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
1783 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1784 CHECK_CALLED(GetBindInfo);
1786 SET_EXPECT(OnStartBinding);
1787 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
1788 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1789 CHECK_CALLED(OnStartBinding);
1791 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
1792 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
1794 wstr = (void*)0xdeadbeef;
1795 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol], (void*)0xdeadbeef, 0xff, &wstr);
1796 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1797 ok(wstr == NULL, "wstr = %p\n", wstr);
1799 SET_EXPECT(QueryInterface_IHttpNegotiate);
1800 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1801 (void**)&http_negotiate_serv);
1802 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1803 CHECK_CALLED(QueryInterface_IHttpNegotiate);
1805 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1807 wstr = (void*)0xdeadbeef;
1808 SET_EXPECT(BeginningTransaction);
1809 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
1810 CHECK_CALLED(BeginningTransaction);
1811 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1812 ok(wstr == NULL, "wstr = %p\n", wstr);
1814 IHttpNegotiate_Release(http_negotiate_serv);
1816 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1817 (void**)&http_negotiate_serv);
1818 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1819 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1820 IHttpNegotiate_Release(http_negotiate_serv);
1822 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
1823 if(SUCCEEDED(hres)) {
1824 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1825 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x\n", hres);
1827 SET_EXPECT(QueryInterface_IHttpNegotiate2);
1828 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
1829 (void**)&http_negotiate2_serv);
1830 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
1831 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
1832 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
1834 SET_EXPECT(GetRootSecurityId);
1835 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1836 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
1837 CHECK_CALLED(GetRootSecurityId);
1839 IHttpNegotiate_Release(http_negotiate2_serv);
1840 IHttpNegotiate_Release(http_negotiate2);
1841 }else {
1842 skip("Could not get IHttpNegotiate2\n");
1845 SET_EXPECT(OnProgress_FINDINGRESOURCE);
1846 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
1847 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
1848 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
1850 SET_EXPECT(OnResponse);
1851 wstr = (void*)0xdeadbeef;
1852 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
1853 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
1854 CHECK_CALLED(OnResponse);
1856 IHttpNegotiate_Release(http_negotiate);
1858 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
1859 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
1861 SET_EXPECT(QueryInterface_IAuthenticate);
1862 SET_EXPECT(QueryService_IAuthenticate);
1863 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1864 (void**)&authenticate_serv);
1865 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1866 CHECK_CALLED(QueryInterface_IAuthenticate);
1867 CHECK_CALLED(QueryService_IAuthenticate);
1868 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1869 IAuthenticate_Release(authenticate_serv);
1871 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1872 (void**)&authenticate_serv);
1873 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1874 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1876 IAuthenticate_Release(authenticate);
1877 IAuthenticate_Release(authenticate_serv);
1879 SET_EXPECT(OnStopBinding);
1880 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
1881 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1882 CHECK_CALLED(OnStopBinding);
1884 SET_EXPECT(QueryInterface_IInternetProtocol);
1885 SET_EXPECT(QueryService_IInternetProtocol);
1886 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
1887 (void**)&protocol);
1888 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
1889 CHECK_CALLED(QueryInterface_IInternetProtocol);
1890 CHECK_CALLED(QueryService_IInternetProtocol);
1892 IServiceProvider_Release(serv_prov);
1895 static void test_RegisterBindStatusCallback(void)
1897 IBindStatusCallback *prevbsc, *clb;
1898 IBindCtx *bindctx;
1899 IUnknown *unk;
1900 HRESULT hres;
1902 hres = CreateBindCtx(0, &bindctx);
1903 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
1905 SET_EXPECT(QueryInterface_IServiceProvider);
1907 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
1908 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1910 SET_EXPECT(QueryInterface_IBindStatusCallback);
1911 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
1912 prevbsc = (void*)0xdeadbeef;
1913 hres = RegisterBindStatusCallback(bindctx, &bsc, &prevbsc, 0);
1914 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1915 ok(prevbsc == &bsc, "prevbsc=%p\n", prevbsc);
1916 CHECK_CALLED(QueryInterface_IBindStatusCallback);
1917 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
1919 CHECK_CALLED(QueryInterface_IServiceProvider);
1921 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1922 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1924 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
1925 IUnknown_Release(unk);
1926 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
1927 ok(clb != &bsc, "bsc == clb\n");
1929 test_bscholder(clb);
1931 IBindStatusCallback_Release(clb);
1933 hres = RevokeBindStatusCallback(bindctx, &bsc);
1934 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1936 unk = (void*)0xdeadbeef;
1937 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1938 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
1939 ok(unk == NULL, "unk != NULL\n");
1941 if(unk)
1942 IUnknown_Release(unk);
1944 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
1945 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1947 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
1948 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1950 hres = RevokeBindStatusCallback(bindctx, NULL);
1951 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1953 IBindCtx_Release(bindctx);
1956 #define BINDTEST_EMULATE 1
1957 #define BINDTEST_TOOBJECT 2
1958 #define BINDTEST_FILEDWLAPI 4
1960 static void init_bind_test(int protocol, DWORD flags, DWORD t)
1962 test_protocol = protocol;
1963 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
1964 download_state = BEFORE_DOWNLOAD;
1965 stopped_binding = FALSE;
1966 stopped_obj_binding = FALSE;
1967 data_available = FALSE;
1968 mime_type[0] = 0;
1969 binding_hres = S_OK;
1970 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
1971 tymed = t;
1972 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
1975 static void test_BindToStorage(int protocol, BOOL emul, DWORD t)
1977 IMoniker *mon;
1978 HRESULT hres;
1979 LPOLESTR display_name;
1980 IBindCtx *bctx;
1981 MSG msg;
1982 IBindStatusCallback *previousclb;
1983 IUnknown *unk = (IUnknown*)0x00ff00ff;
1984 IBinding *bind;
1986 init_bind_test(protocol, emul ? BINDTEST_EMULATE : 0, t);
1988 SET_EXPECT(QueryInterface_IServiceProvider);
1989 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1990 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
1991 CHECK_CALLED(QueryInterface_IServiceProvider);
1992 if(FAILED(hres))
1993 return;
1995 SET_EXPECT(QueryInterface_IServiceProvider);
1996 hres = RegisterBindStatusCallback(bctx, &bsc, &previousclb, 0);
1997 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1998 ok(previousclb == &bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
1999 CHECK_CALLED(QueryInterface_IServiceProvider);
2000 if(previousclb)
2001 IBindStatusCallback_Release(previousclb);
2003 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2004 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2005 if(FAILED(hres)) {
2006 IBindCtx_Release(bctx);
2007 return;
2010 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2011 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2012 if(SUCCEEDED(hres))
2013 IBinding_Release(bind);
2015 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2016 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2017 ok(!lstrcmpW(display_name, urls[test_protocol]),
2018 "GetDisplayName got wrong name %s\n", debugstr_w(display_name));
2019 CoTaskMemFree(display_name);
2021 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2022 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2024 SET_EXPECT(GetBindInfo);
2025 SET_EXPECT(QueryInterface_IInternetProtocol);
2026 if(!emulate_protocol)
2027 SET_EXPECT(QueryService_IInternetProtocol);
2028 SET_EXPECT(OnStartBinding);
2029 if(emulate_protocol) {
2030 SET_EXPECT(Start);
2031 if(test_protocol == HTTP_TEST)
2032 SET_EXPECT(Terminate);
2033 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2034 SET_EXPECT(UnlockRequest);
2035 }else {
2036 if(test_protocol == HTTP_TEST) {
2037 SET_EXPECT(QueryInterface_IInternetBindInfo);
2038 SET_EXPECT(QueryService_IInternetBindInfo);
2039 SET_EXPECT(QueryInterface_IHttpNegotiate);
2040 SET_EXPECT(BeginningTransaction);
2041 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2042 SET_EXPECT(GetRootSecurityId);
2043 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2044 SET_EXPECT(OnProgress_CONNECTING);
2046 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2047 SET_EXPECT(OnProgress_SENDINGREQUEST);
2048 if(test_protocol == HTTP_TEST)
2049 SET_EXPECT(OnResponse);
2050 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2051 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2052 if(test_protocol == FILE_TEST)
2053 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2054 if(test_protocol == HTTP_TEST)
2055 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2056 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2057 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2058 SET_EXPECT(OnDataAvailable);
2059 SET_EXPECT(OnStopBinding);
2062 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2063 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2065 skip("Network unreachable, skipping tests\n");
2066 return;
2069 if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2070 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2071 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2072 ok(unk == NULL, "istr should be NULL\n");
2073 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2074 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2075 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2076 ok(unk == NULL, "istr should be NULL\n");
2077 }else {
2078 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2079 ok(unk != NULL, "unk == NULL\n");
2081 if(unk)
2082 IUnknown_Release(unk);
2084 if(FAILED(hres))
2085 return;
2087 while((bindf & BINDF_ASYNCHRONOUS) &&
2088 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
2089 TranslateMessage(&msg);
2090 DispatchMessage(&msg);
2093 CHECK_CALLED(GetBindInfo);
2094 CHECK_CALLED(QueryInterface_IInternetProtocol);
2095 if(!emulate_protocol)
2096 CHECK_CALLED(QueryService_IInternetProtocol);
2097 CHECK_CALLED(OnStartBinding);
2098 if(emulate_protocol) {
2099 CHECK_CALLED(Start);
2100 if(test_protocol == HTTP_TEST) {
2101 if(tymed == TYMED_FILE)
2102 CLEAR_CALLED(Read);
2103 CHECK_CALLED(Terminate);
2105 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2106 CHECK_CALLED(UnlockRequest);
2107 }else {
2108 if(test_protocol == HTTP_TEST) {
2109 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2110 CLEAR_CALLED(QueryService_IInternetBindInfo);
2111 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2112 CHECK_CALLED(BeginningTransaction);
2113 /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
2114 * called on WinXP but not on Win98 */
2115 CLEAR_CALLED(QueryInterface_IHttpNegotiate2);
2116 CLEAR_CALLED(GetRootSecurityId);
2117 if(http_is_first) {
2118 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2119 CHECK_CALLED(OnProgress_CONNECTING);
2120 }else todo_wine {
2121 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2122 CHECK_NOT_CALLED(OnProgress_CONNECTING);
2125 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2126 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2127 if(test_protocol == HTTP_TEST)
2128 CHECK_CALLED(OnResponse);
2129 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2130 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2131 if(test_protocol == FILE_TEST)
2132 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2133 if(test_protocol == HTTP_TEST)
2134 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2135 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2136 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2137 CHECK_CALLED(OnDataAvailable);
2138 CHECK_CALLED(OnStopBinding);
2141 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2142 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2144 if(test_protocol == HTTP_TEST)
2145 http_is_first = FALSE;
2148 static void test_BindToObject(int protocol, BOOL emul)
2150 IMoniker *mon;
2151 HRESULT hres;
2152 LPOLESTR display_name;
2153 IBindCtx *bctx;
2154 DWORD regid;
2155 MSG msg;
2156 IUnknown *unk = (IUnknown*)0x00ff00ff;
2157 IBinding *bind;
2159 init_bind_test(protocol, BINDTEST_TOOBJECT | (emul ? BINDTEST_EMULATE : 0), TYMED_ISTREAM);
2161 if(emul)
2162 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
2163 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid);
2165 SET_EXPECT(QueryInterface_IServiceProvider);
2166 hres = CreateAsyncBindCtx(0, &objbsc, NULL, &bctx);
2167 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
2168 CHECK_CALLED(QueryInterface_IServiceProvider);
2169 if(FAILED(hres))
2170 return;
2172 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2173 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2174 if(FAILED(hres)) {
2175 IBindCtx_Release(bctx);
2176 return;
2179 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2180 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2181 if(SUCCEEDED(hres))
2182 IBinding_Release(bind);
2184 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2185 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2186 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
2188 SET_EXPECT(Obj_GetBindInfo);
2189 SET_EXPECT(QueryInterface_IInternetProtocol);
2190 if(!emulate_protocol)
2191 SET_EXPECT(QueryService_IInternetProtocol);
2192 SET_EXPECT(Obj_OnStartBinding);
2193 if(emulate_protocol) {
2194 SET_EXPECT(Start);
2195 if(test_protocol == HTTP_TEST)
2196 SET_EXPECT(Terminate);
2197 if(test_protocol == FILE_TEST)
2198 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2199 SET_EXPECT(UnlockRequest);
2200 }else {
2201 if(test_protocol == HTTP_TEST) {
2202 SET_EXPECT(QueryInterface_IHttpNegotiate);
2203 SET_EXPECT(BeginningTransaction);
2204 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2205 SET_EXPECT(GetRootSecurityId);
2206 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
2207 SET_EXPECT(Obj_OnProgress_CONNECTING);
2209 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2210 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
2211 if(test_protocol == HTTP_TEST)
2212 SET_EXPECT(OnResponse);
2213 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
2214 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
2215 if(test_protocol == FILE_TEST)
2216 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2217 if(test_protocol == HTTP_TEST)
2218 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2219 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
2220 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
2221 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
2222 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
2223 SET_EXPECT(OnObjectAvailable);
2224 SET_EXPECT(Obj_OnStopBinding);
2227 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
2229 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2231 skip( "Network unreachable, skipping tests\n" );
2232 return;
2235 /* no point testing the calls if binding didn't even work */
2236 if (FAILED(hres)) return;
2238 if(bindf & BINDF_ASYNCHRONOUS) {
2239 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
2240 ok(unk == NULL, "istr should be NULL\n");
2241 }else {
2242 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2243 ok(unk != NULL, "unk == NULL\n");
2244 if(emul)
2245 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
2247 if(unk)
2248 IUnknown_Release(unk);
2250 while((bindf & BINDF_ASYNCHRONOUS) &&
2251 !((!emul || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
2252 TranslateMessage(&msg);
2253 DispatchMessage(&msg);
2256 CHECK_CALLED(Obj_GetBindInfo);
2257 CHECK_CALLED(QueryInterface_IInternetProtocol);
2258 if(!emulate_protocol)
2259 CHECK_CALLED(QueryService_IInternetProtocol);
2260 CHECK_CALLED(Obj_OnStartBinding);
2261 if(emulate_protocol) {
2262 CHECK_CALLED(Start);
2263 if(test_protocol == HTTP_TEST)
2264 CHECK_CALLED(Terminate);
2265 if(test_protocol == FILE_TEST)
2266 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
2267 CHECK_CALLED(UnlockRequest);
2268 }else {
2269 if(test_protocol == HTTP_TEST) {
2270 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2271 CHECK_CALLED(BeginningTransaction);
2272 /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
2273 * called on WinXP but not on Win98 */
2274 CLEAR_CALLED(QueryInterface_IHttpNegotiate2);
2275 CLEAR_CALLED(GetRootSecurityId);
2276 if(http_is_first) {
2277 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2278 CHECK_CALLED(Obj_OnProgress_CONNECTING);
2279 }else todo_wine {
2280 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2281 CHECK_NOT_CALLED(Obj_OnProgress_CONNECTING);
2284 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST) {
2285 if(urls[test_protocol] == SHORT_RESPONSE_URL)
2286 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
2287 else
2288 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
2290 if(test_protocol == HTTP_TEST)
2291 CHECK_CALLED(OnResponse);
2292 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
2293 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
2294 if(test_protocol == FILE_TEST)
2295 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2296 if(test_protocol == HTTP_TEST)
2297 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2298 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
2299 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
2300 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
2301 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
2302 CHECK_CALLED(OnObjectAvailable);
2303 CHECK_CALLED(Obj_OnStopBinding);
2306 if(test_protocol != HTTP_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL) {
2307 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2308 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2309 }else {
2310 todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2312 if(bindf & BINDF_ASYNCHRONOUS)
2313 ok(IBindCtx_Release(bctx) != 0, "bctx should not be destroyed here\n");
2314 else
2315 todo_wine ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2318 if(emul)
2319 CoRevokeClassObject(regid);
2321 if(test_protocol == HTTP_TEST)
2322 http_is_first = FALSE;
2325 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
2327 BOOL res;
2328 HRESULT hres;
2330 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
2332 SET_EXPECT(GetBindInfo);
2333 SET_EXPECT(QueryInterface_IInternetProtocol);
2334 if(!emulate_protocol) {
2335 SET_EXPECT(QueryInterface_IServiceProvider);
2336 SET_EXPECT(QueryService_IInternetProtocol);
2338 SET_EXPECT(OnStartBinding);
2339 if(emulate_protocol) {
2340 SET_EXPECT(Start);
2341 SET_EXPECT(UnlockRequest);
2342 }else {
2343 if(test_protocol == HTTP_TEST) {
2344 SET_EXPECT(QueryInterface_IHttpNegotiate);
2345 SET_EXPECT(BeginningTransaction);
2346 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2347 SET_EXPECT(GetRootSecurityId);
2349 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2350 SET_EXPECT(OnProgress_SENDINGREQUEST);
2351 if(test_protocol == HTTP_TEST)
2352 SET_EXPECT(OnResponse);
2353 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2354 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2355 if(test_protocol == FILE_TEST)
2356 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2357 if(test_protocol == HTTP_TEST)
2358 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2359 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2360 SET_EXPECT(OnStopBinding);
2363 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], dwl_htmlW, 0, &bsc);
2364 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2366 CHECK_CALLED(GetBindInfo);
2367 CHECK_CALLED(QueryInterface_IInternetProtocol);
2368 if(!emulate_protocol) {
2369 CHECK_CALLED(QueryInterface_IServiceProvider);
2370 CHECK_CALLED(QueryService_IInternetProtocol);
2372 CHECK_CALLED(OnStartBinding);
2373 if(emulate_protocol) {
2374 CHECK_CALLED(Start);
2375 CHECK_CALLED(UnlockRequest);
2376 }else {
2377 if(test_protocol == HTTP_TEST) {
2378 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2379 CHECK_CALLED(BeginningTransaction);
2380 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2381 CHECK_CALLED(GetRootSecurityId);
2383 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
2384 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2385 if(test_protocol == HTTP_TEST)
2386 CHECK_CALLED(OnResponse);
2387 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2388 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2389 if(test_protocol == FILE_TEST)
2390 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2391 if(test_protocol == HTTP_TEST)
2392 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2393 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2394 CHECK_CALLED(OnStopBinding);
2397 res = DeleteFileW(dwl_htmlW);
2398 ok(res, "DeleteFile failed: %u\n", GetLastError());
2400 if(prot != FILE_TEST || emul)
2401 return;
2403 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
2404 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2406 res = DeleteFileW(dwl_htmlW);
2407 ok(res, "DeleteFile failed: %u\n", GetLastError());
2410 static void set_file_url(void)
2412 int len;
2414 static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
2416 memcpy(file_url, wszFile, sizeof(wszFile));
2417 len = sizeof(wszFile)/sizeof(WCHAR);
2418 file_url[len++] = '/';
2419 len += GetCurrentDirectoryW(sizeof(file_url)/sizeof(WCHAR)-len, file_url+len);
2420 file_url[len++] = '\\';
2421 memcpy(file_url+len, wszIndexHtml, sizeof(wszIndexHtml));
2423 memcpy(INDEX_HTML, wszFile, sizeof(wszIndexHtml));
2424 memmove(INDEX_HTML+7, file_url+8, (lstrlenW(file_url+8)+1)*sizeof(WCHAR));
2427 static void create_file(void)
2429 HANDLE file;
2430 DWORD size;
2432 static const char html_doc[] = "<HTML></HTML>";
2434 file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2435 FILE_ATTRIBUTE_NORMAL, NULL);
2436 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2437 if(file == INVALID_HANDLE_VALUE)
2438 return;
2440 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2441 CloseHandle(file);
2443 set_file_url();
2446 static void test_ReportResult(HRESULT exhres)
2448 IMoniker *mon = NULL;
2449 IBindCtx *bctx = NULL;
2450 IUnknown *unk = (void*)0xdeadbeef;
2451 HRESULT hres;
2453 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2454 binding_hres = exhres;
2456 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2457 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2459 SET_EXPECT(QueryInterface_IServiceProvider);
2460 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
2461 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2462 CHECK_CALLED(QueryInterface_IServiceProvider);
2464 SET_EXPECT(GetBindInfo);
2465 SET_EXPECT(QueryInterface_IInternetProtocol);
2466 SET_EXPECT(OnStartBinding);
2467 SET_EXPECT(Start);
2469 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2470 if(SUCCEEDED(exhres))
2471 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
2472 else
2473 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
2474 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
2476 CHECK_CALLED(GetBindInfo);
2477 CHECK_CALLED(QueryInterface_IInternetProtocol);
2478 CHECK_CALLED(OnStartBinding);
2479 CHECK_CALLED(Start);
2481 ok(unk == NULL, "unk=%p\n", unk);
2483 IBindCtx_Release(bctx);
2484 IMoniker_Release(mon);
2487 static void test_BindToStorage_fail(void)
2489 IMoniker *mon = NULL;
2490 IBindCtx *bctx = NULL;
2491 IUnknown *unk;
2492 HRESULT hres;
2494 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2495 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2496 if(FAILED(hres))
2497 return;
2499 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2500 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2502 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2503 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
2504 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
2506 IBindCtx_Release(bctx);
2508 IMoniker_Release(mon);
2510 test_ReportResult(E_NOTIMPL);
2511 test_ReportResult(S_FALSE);
2514 static void gecko_installer_workaround(BOOL disable)
2516 HKEY hkey;
2517 DWORD res;
2519 static BOOL has_url = FALSE;
2520 static char url[2048];
2522 if(!disable && !has_url)
2523 return;
2525 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
2526 if(res != ERROR_SUCCESS)
2527 return;
2529 if(disable) {
2530 DWORD type, size = sizeof(url);
2532 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
2533 if(res == ERROR_SUCCESS && type == REG_SZ)
2534 has_url = TRUE;
2536 RegDeleteValue(hkey, "GeckoUrl");
2537 }else {
2538 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
2541 RegCloseKey(hkey);
2544 START_TEST(url)
2546 gecko_installer_workaround(TRUE);
2548 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2549 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2550 thread_id = GetCurrentThreadId();
2551 create_file();
2553 test_create();
2554 test_CreateAsyncBindCtx();
2555 test_CreateAsyncBindCtxEx();
2556 test_RegisterBindStatusCallback();
2557 test_BindToStorage_fail();
2559 trace("synchronous http test (COM not initialised)...\n");
2560 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2562 CoInitialize(NULL);
2564 trace("synchronous http test...\n");
2565 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2567 trace("synchronous http test (to object)...\n");
2568 test_BindToObject(HTTP_TEST, FALSE);
2570 trace("synchronous file test...\n");
2571 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2573 trace("synchronous file test (to object)...\n");
2574 test_BindToObject(FILE_TEST, FALSE);
2576 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2578 trace("http test...\n");
2579 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2581 trace("http test (to file)...\n");
2582 test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE);
2584 trace("http test (to object)...\n");
2585 test_BindToObject(HTTP_TEST, FALSE);
2587 trace("http test (short response)...\n");
2588 http_is_first = TRUE;
2589 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
2590 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2592 trace("http test (short response, to object)...\n");
2593 test_BindToObject(HTTP_TEST, FALSE);
2595 trace("emulated http test...\n");
2596 test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM);
2598 trace("emulated http test (to object)...\n");
2599 test_BindToObject(HTTP_TEST, TRUE);
2601 trace("emulated http test (to file)...\n");
2602 test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE);
2604 trace("about test...\n");
2605 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM);
2607 trace("about test (to file)...\n");
2608 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE);
2610 trace("about test (to object)...\n");
2611 test_BindToObject(ABOUT_TEST, FALSE);
2613 trace("emulated about test...\n");
2614 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM);
2616 trace("emulated about test (to file)...\n");
2617 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE);
2619 trace("emulated about test (to object)...\n");
2620 test_BindToObject(ABOUT_TEST, TRUE);
2622 trace("file test...\n");
2623 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2625 trace("file test (to file)...\n");
2626 test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE);
2628 trace("file test (to object)...\n");
2629 test_BindToObject(FILE_TEST, FALSE);
2631 trace("emulated file test...\n");
2632 test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM);
2634 trace("emulated file test (to file)...\n");
2635 test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE);
2637 trace("emulated file test (to object)...\n");
2638 test_BindToObject(FILE_TEST, TRUE);
2640 trace("emulated its test...\n");
2641 test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM);
2643 trace("emulated its test (to file)...\n");
2644 test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE);
2646 trace("emulated mk test...\n");
2647 test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM);
2649 trace("test URLDownloadToFile for file protocol...\n");
2650 test_URLDownloadToFile(FILE_TEST, FALSE);
2652 trace("test URLDownloadToFile for emulated file protocol...\n");
2653 test_URLDownloadToFile(FILE_TEST, TRUE);
2655 trace("test URLDownloadToFile for http protocol...\n");
2656 test_URLDownloadToFile(HTTP_TEST, FALSE);
2658 trace("test failures...\n");
2659 test_BindToStorage_fail();
2661 DeleteFileW(wszIndexHtml);
2662 CloseHandle(complete_event);
2663 CloseHandle(complete_event2);
2664 CoUninitialize();
2666 gecko_installer_workaround(FALSE);