urlmon: Fix PutProperty_CLASSIDPROP check under win98 to w2k.
[wine/multimedia.git] / dlls / urlmon / tests / url.c
blob094d21dd54610e958b0f734d758c5ba64433c79a
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 "initguid.h"
32 #include "urlmon.h"
33 #include "wininet.h"
34 #include "mshtml.h"
36 #include "wine/test.h"
38 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
39 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
40 DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
42 #define DEFINE_EXPECT(func) \
43 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
45 #define SET_EXPECT(func) \
46 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
48 #define CHECK_EXPECT2(func) \
49 do { \
50 ok(expect_ ##func, "unexpected call " #func "\n"); \
51 called_ ## func = TRUE; \
52 }while(0)
54 #define CHECK_EXPECT(func) \
55 do { \
56 CHECK_EXPECT2(func); \
57 expect_ ## func = FALSE; \
58 }while(0)
60 #define CHECK_CALLED(func) \
61 do { \
62 ok(called_ ## func, "expected " #func "\n"); \
63 expect_ ## func = called_ ## func = FALSE; \
64 }while(0)
66 #define CHECK_NOT_CALLED(func) \
67 do { \
68 ok(!called_ ## func, "unexpected " #func "\n"); \
69 expect_ ## func = called_ ## func = FALSE; \
70 }while(0)
72 #define CHECK_CALLED_BROKEN(func) \
73 do { \
74 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
75 expect_ ## func = called_ ## func = FALSE; \
76 }while(0)
78 #define CLEAR_CALLED(func) \
79 expect_ ## func = called_ ## func = FALSE
81 DEFINE_EXPECT(QueryInterface_IServiceProvider);
82 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
83 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
84 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
85 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
86 DEFINE_EXPECT(QueryInterface_IAuthenticate);
87 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
88 DEFINE_EXPECT(QueryService_IAuthenticate);
89 DEFINE_EXPECT(QueryService_IInternetProtocol);
90 DEFINE_EXPECT(QueryService_IInternetBindInfo);
91 DEFINE_EXPECT(BeginningTransaction);
92 DEFINE_EXPECT(OnResponse);
93 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
94 DEFINE_EXPECT(GetRootSecurityId);
95 DEFINE_EXPECT(GetBindInfo);
96 DEFINE_EXPECT(OnStartBinding);
97 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
98 DEFINE_EXPECT(OnProgress_CONNECTING);
99 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
100 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
101 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
102 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
103 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
104 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
105 DEFINE_EXPECT(OnStopBinding);
106 DEFINE_EXPECT(OnDataAvailable);
107 DEFINE_EXPECT(OnObjectAvailable);
108 DEFINE_EXPECT(Obj_OnStartBinding);
109 DEFINE_EXPECT(Obj_OnStopBinding);
110 DEFINE_EXPECT(Obj_GetBindInfo);
111 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
112 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
113 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
114 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
115 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
116 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
117 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
118 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
119 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
120 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
121 DEFINE_EXPECT(Start);
122 DEFINE_EXPECT(Read);
123 DEFINE_EXPECT(LockRequest);
124 DEFINE_EXPECT(Terminate);
125 DEFINE_EXPECT(UnlockRequest);
126 DEFINE_EXPECT(Continue);
127 DEFINE_EXPECT(CreateInstance);
128 DEFINE_EXPECT(Load);
129 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
130 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
132 static const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
133 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
135 static const WCHAR WINE_ABOUT_URL[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
136 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
137 static const WCHAR SHORT_RESPONSE_URL[] =
138 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
139 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
140 'p','o','s','t','t','e','s','t','.','p','h','p',0};
141 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
142 static WCHAR INDEX_HTML[MAX_PATH];
143 static const WCHAR ITS_URL[] =
144 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
145 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
146 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
147 static const WCHAR https_urlW[] =
148 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',
149 '/','t','e','s','t','.','h','t','m','l',0};
152 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
154 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
156 static const WCHAR wszWineHQSite[] =
157 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
158 static const WCHAR wszWineHQIP[] =
159 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
160 static const CHAR wszIndexHtmlA[] = "index.html";
161 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
162 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
163 static const CHAR dwl_htmlA[] = "dwl.html";
164 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
165 static const WCHAR emptyW[] = {0};
167 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
168 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api;
169 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed;
170 static CHAR mime_type[512];
171 static IInternetProtocolSink *protocol_sink = NULL;
172 static HANDLE complete_event, complete_event2;
173 static HRESULT binding_hres;
174 static BOOL have_IHttpNegotiate2;
176 static LPCWSTR urls[] = {
177 WINE_ABOUT_URL,
178 ABOUT_BLANK,
179 INDEX_HTML,
180 ITS_URL,
181 MK_URL,
182 https_urlW
185 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
187 static enum {
188 HTTP_TEST,
189 ABOUT_TEST,
190 FILE_TEST,
191 ITS_TEST,
192 MK_TEST,
193 HTTPS_TEST
194 } test_protocol;
196 static enum {
197 BEFORE_DOWNLOAD,
198 DOWNLOADING,
199 END_DOWNLOAD
200 } download_state;
202 static const char *debugstr_w(LPCWSTR str)
204 static char buf[1024];
205 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
206 return buf;
209 static const char *debugstr_guid(REFIID riid)
211 static char buf[50];
213 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
214 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
215 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
216 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
218 return buf;
221 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
223 HRESULT hr;
224 IMoniker *mon1 = NULL;
225 IMoniker *mon2 = NULL;
227 hr = CreateURLMoniker(NULL, url1, &mon1);
228 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
229 if(SUCCEEDED(hr)) {
230 hr = CreateURLMoniker(mon1, url2, &mon2);
231 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
233 if(mon1) IMoniker_Release(mon1);
234 if(mon2) IMoniker_Release(mon2);
237 static void test_create(void)
239 test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
242 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
244 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
245 *ppv = iface;
246 return S_OK;
249 *ppv = NULL;
250 return E_NOINTERFACE;
253 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
255 return 2;
258 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
260 return 1;
263 static DWORD WINAPI thread_proc(PVOID arg)
265 PROTOCOLDATA protocoldata;
266 HRESULT hres;
268 if(bind_to_object)
269 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
270 else
271 SET_EXPECT(OnProgress_FINDINGRESOURCE);
272 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
273 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
274 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
275 WaitForSingleObject(complete_event, INFINITE);
276 if(bind_to_object)
277 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
278 else
279 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
281 if(bind_to_object)
282 SET_EXPECT(Obj_OnProgress_CONNECTING);
283 else
284 SET_EXPECT(OnProgress_CONNECTING);
285 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
286 BINDSTATUS_CONNECTING, wszWineHQIP);
287 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
288 WaitForSingleObject(complete_event, INFINITE);
289 if(bind_to_object)
290 CHECK_CALLED(Obj_OnProgress_CONNECTING);
291 else
292 CHECK_CALLED(OnProgress_CONNECTING);
294 if(bind_to_object)
295 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
296 else
297 SET_EXPECT(OnProgress_SENDINGREQUEST);
298 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
299 BINDSTATUS_SENDINGREQUEST, NULL);
300 ok(hres == S_OK, "ReportProxgress failed: %08x\n", hres);
301 WaitForSingleObject(complete_event, INFINITE);
302 if(bind_to_object)
303 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
304 else
305 CHECK_CALLED(OnProgress_SENDINGREQUEST);
307 SET_EXPECT(Continue);
308 prot_state = 1;
309 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
310 ok(hres == S_OK, "Switch failed: %08x\n", hres);
311 WaitForSingleObject(complete_event, INFINITE);
313 CHECK_CALLED(Continue);
314 CHECK_CALLED(Read);
315 if(bind_to_object) {
316 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
317 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
318 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
319 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
320 CHECK_CALLED(CreateInstance);
321 CHECK_CALLED(PutProperty_MIMETYPEPROP);
322 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
323 CHECK_CALLED(Load);
324 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
325 CHECK_CALLED(OnObjectAvailable);
326 CHECK_CALLED(Obj_OnStopBinding);
327 }else {
328 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
329 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
330 CHECK_CALLED(LockRequest);
331 CHECK_CALLED(OnDataAvailable);
334 SET_EXPECT(Continue);
335 prot_state = 2;
336 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
337 ok(hres == S_OK, "Switch failed: %08x\n", hres);
338 WaitForSingleObject(complete_event, INFINITE);
339 CHECK_CALLED(Continue);
340 CHECK_CALLED(Read);
341 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
342 CHECK_CALLED(OnDataAvailable);
344 SET_EXPECT(Continue);
345 prot_state = 2;
346 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
347 ok(hres == S_OK, "Switch failed: %08x\n", hres);
348 WaitForSingleObject(complete_event, INFINITE);
349 CHECK_CALLED(Continue);
350 CHECK_CALLED(Read);
351 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
352 CHECK_CALLED(OnDataAvailable);
354 SET_EXPECT(Continue);
355 prot_state = 3;
356 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
357 ok(hres == S_OK, "Switch failed: %08x\n", hres);
358 WaitForSingleObject(complete_event, INFINITE);
359 CHECK_CALLED(Continue);
360 CHECK_CALLED(Read);
361 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
362 CHECK_CALLED(OnDataAvailable);
363 CHECK_CALLED(OnStopBinding);
365 SET_EXPECT(Read);
367 SetEvent(complete_event2);
368 return 0;
371 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
372 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
373 DWORD grfPI, DWORD dwReserved)
375 BINDINFO bindinfo;
376 DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
377 HRESULT hres;
379 static const STGMEDIUM stgmed_zero = {0};
380 static const SECURITY_ATTRIBUTES sa_zero = {0};
382 CHECK_EXPECT(Start);
384 read = 0;
386 if(!filedwl_api) /* FIXME */
387 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", debugstr_w(szUrl));
388 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
389 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
390 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
391 ok(dwReserved == 0, "dwReserved=%d, expected 0\n", dwReserved);
393 if(!filedwl_api && binding_hres != S_OK) {
394 SET_EXPECT(OnStopBinding);
395 SET_EXPECT(Terminate);
396 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
397 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
398 CHECK_CALLED(OnStopBinding);
399 CHECK_CALLED(Terminate);
401 return S_OK;
404 memset(&bindinfo, 0, sizeof(bindinfo));
405 bindinfo.cbSize = sizeof(bindinfo);
406 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
407 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
409 if(filedwl_api) {
410 ok(bindf == (BINDF_PULLDATA|BINDF_FROMURLMON|BINDF_NEEDFILE), "bindf=%08x\n", bindf);
411 }else if(tymed == TYMED_ISTREAM
412 && (test_protocol == FILE_TEST || test_protocol == MK_TEST
413 || test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)) {
414 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
415 |BINDF_FROMURLMON),
416 "bindf=%08x\n", bindf);
417 }else {
418 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
419 |BINDF_FROMURLMON|BINDF_NEEDFILE),
420 "bindf=%08x\n", bindf);
423 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
424 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
425 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
426 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
427 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
428 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
429 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
430 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
431 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
432 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
433 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
434 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
435 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
436 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
438 switch(test_protocol) {
439 case MK_TEST:
440 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
441 BINDSTATUS_DIRECTBIND, NULL);
442 ok(hres == S_OK,
443 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
445 case FILE_TEST:
446 case ITS_TEST:
447 if(bind_to_object)
448 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
449 else
450 SET_EXPECT(OnProgress_SENDINGREQUEST);
451 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
452 BINDSTATUS_SENDINGREQUEST, emptyW);
453 ok(hres == S_OK,
454 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
455 if(bind_to_object)
456 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
457 else
458 CHECK_CALLED(OnProgress_SENDINGREQUEST);
459 default:
460 break;
463 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
464 IServiceProvider *service_provider;
465 IHttpNegotiate *http_negotiate;
466 IHttpNegotiate2 *http_negotiate2;
467 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
468 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
469 BYTE sec_id[100];
470 DWORD fetched = 256, size = 100;
471 DWORD tid;
473 static const WCHAR wszMimes[] = {'*','/','*',0};
475 SET_EXPECT(QueryInterface_IInternetBindInfo);
476 SET_EXPECT(QueryService_IInternetBindInfo);
477 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
478 &ua, 1, &fetched);
479 todo_wine {
480 CHECK_CALLED(QueryInterface_IInternetBindInfo);
481 CHECK_CALLED(QueryService_IInternetBindInfo);
483 ok(hres == E_NOINTERFACE,
484 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
485 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
486 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
488 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
489 accept_mimes, 256, &fetched);
490 ok(hres == S_OK,
491 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
492 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
493 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
495 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
496 NULL, 256, &fetched);
497 ok(hres == E_INVALIDARG,
498 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
500 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
501 accept_mimes, 256, NULL);
502 ok(hres == E_INVALIDARG,
503 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
505 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
506 (void**)&service_provider);
507 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
509 SET_EXPECT(QueryInterface_IHttpNegotiate);
510 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
511 &IID_IHttpNegotiate, (void**)&http_negotiate);
512 CHECK_CALLED(QueryInterface_IHttpNegotiate);
513 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
515 SET_EXPECT(BeginningTransaction);
516 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
517 NULL, 0, &additional_headers);
518 CHECK_CALLED(BeginningTransaction);
519 IHttpNegotiate_Release(http_negotiate);
520 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
521 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
523 SET_EXPECT(QueryInterface_IHttpNegotiate2);
524 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
525 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
526 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
527 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
529 size = 512;
530 SET_EXPECT(GetRootSecurityId);
531 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
532 CHECK_CALLED(GetRootSecurityId);
533 IHttpNegotiate2_Release(http_negotiate2);
534 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
535 ok(size == 13, "size=%d\n", size);
537 IServiceProvider_Release(service_provider);
539 IInternetProtocolSink_AddRef(pOIProtSink);
540 protocol_sink = pOIProtSink;
541 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
543 return S_OK;
546 if(test_protocol == FILE_TEST) {
547 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
548 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
549 ok(hres == S_OK,
550 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
552 if(bind_to_object)
553 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
554 else
555 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
556 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
557 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
558 ok(hres == S_OK,
559 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
560 if(bind_to_object)
561 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
562 else
563 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
564 }else {
565 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
566 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
567 ok(hres == S_OK,
568 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
571 if(test_protocol == ABOUT_TEST)
572 bscf |= BSCF_DATAFULLYAVAILABLE;
573 if(test_protocol == ITS_TEST)
574 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
576 SET_EXPECT(Read);
577 if(bind_to_object) {
578 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
579 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
580 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
581 if(test_protocol == FILE_TEST)
582 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
583 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
584 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
585 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
586 SET_EXPECT(CreateInstance);
587 SET_EXPECT(PutProperty_MIMETYPEPROP);
588 SET_EXPECT(PutProperty_CLASSIDPROP);
589 SET_EXPECT(Load);
590 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
591 SET_EXPECT(OnObjectAvailable);
592 SET_EXPECT(Obj_OnStopBinding);
593 }else {
594 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
595 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
596 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
597 if(test_protocol == FILE_TEST)
598 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
599 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
600 SET_EXPECT(LockRequest);
601 if(!filedwl_api)
602 SET_EXPECT(OnDataAvailable);
603 SET_EXPECT(OnStopBinding);
606 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
607 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
609 CHECK_CALLED(Read);
610 if(bind_to_object) {
611 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
612 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
613 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
614 if(test_protocol == FILE_TEST)
615 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
616 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
617 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
618 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
619 CHECK_CALLED(CreateInstance);
620 CHECK_CALLED(PutProperty_MIMETYPEPROP);
621 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
622 CHECK_CALLED(Load);
623 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
624 CHECK_CALLED(OnObjectAvailable);
625 CHECK_CALLED(Obj_OnStopBinding);
626 }else {
627 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
628 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
629 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
630 if(test_protocol == FILE_TEST)
631 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
632 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
633 CHECK_CALLED(LockRequest);
634 if(!filedwl_api)
635 CHECK_CALLED(OnDataAvailable);
636 CHECK_CALLED(OnStopBinding);
639 if(test_protocol == ITS_TEST) {
640 SET_EXPECT(Read);
641 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
642 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
643 CHECK_CALLED(Read);
646 SET_EXPECT(Terminate);
647 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
648 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
649 CHECK_CALLED(Terminate);
651 return S_OK;
654 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
655 PROTOCOLDATA *pProtocolData)
657 DWORD bscf = 0;
658 HRESULT hres;
660 CHECK_EXPECT(Continue);
662 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
664 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
665 if(!pProtocolData)
666 return S_OK;
668 switch(prot_state) {
669 case 1: {
670 IServiceProvider *service_provider;
671 IHttpNegotiate *http_negotiate;
672 static WCHAR header[] = {'?',0};
674 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
675 (void**)&service_provider);
676 ok(hres == S_OK, "Could not get IServiceProvicder\n");
678 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
679 &IID_IHttpNegotiate, (void**)&http_negotiate);
680 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
682 SET_EXPECT(OnResponse);
683 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
684 CHECK_CALLED(OnResponse);
685 IHttpNegotiate_Release(http_negotiate);
686 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
688 if(test_protocol == HTTPS_TEST) {
689 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
690 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
693 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
694 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
695 ok(hres == S_OK,
696 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
698 if(tymed == TYMED_FILE) {
699 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
700 BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_fileW);
701 ok(hres == S_OK,
702 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
705 bscf |= BSCF_FIRSTDATANOTIFICATION;
706 break;
708 case 2:
709 case 3:
710 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
711 break;
714 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
715 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
717 SET_EXPECT(Read);
718 switch(prot_state) {
719 case 1:
720 if(bind_to_object) {
721 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
722 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
723 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
724 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
725 SET_EXPECT(CreateInstance);
726 SET_EXPECT(PutProperty_MIMETYPEPROP);
727 SET_EXPECT(PutProperty_CLASSIDPROP);
728 SET_EXPECT(Load);
729 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
730 SET_EXPECT(OnObjectAvailable);
731 SET_EXPECT(Obj_OnStopBinding);
732 }else {
733 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
734 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
735 SET_EXPECT(LockRequest);
737 break;
738 case 2:
739 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
740 break;
741 case 3:
742 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
743 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
745 if(!bind_to_object || prot_state >= 2)
746 SET_EXPECT(OnDataAvailable);
747 if(prot_state == 3)
748 SET_EXPECT(OnStopBinding);
750 return S_OK;
753 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
754 DWORD dwOptions)
756 ok(0, "unexpected call\n");
757 return E_NOTIMPL;
760 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
762 CHECK_EXPECT(Terminate);
764 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
766 if(protocol_sink) {
767 IInternetProtocolSink_Release(protocol_sink);
768 protocol_sink = NULL;
771 return S_OK;
774 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
776 ok(0, "unexpected call\n");
777 return E_NOTIMPL;
780 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
782 ok(0, "unexpected call\n");
783 return E_NOTIMPL;
786 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
787 ULONG cb, ULONG *pcbRead)
789 static const char data[] = "<HTML></HTML>";
791 CHECK_EXPECT2(Read);
793 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
794 HRESULT hres;
796 static BOOL pending = TRUE;
798 pending = !pending;
800 switch(prot_state) {
801 case 1:
802 case 2:
803 if(pending) {
804 *pcbRead = 10;
805 memset(pv, '?', 10);
806 return E_PENDING;
807 }else {
808 memset(pv, '?', cb);
809 *pcbRead = cb;
810 read++;
811 return S_OK;
813 case 3:
814 prot_state++;
816 *pcbRead = 0;
818 hres = IInternetProtocolSink_ReportData(protocol_sink,
819 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
820 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
822 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
823 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
825 return S_FALSE;
826 case 4:
827 *pcbRead = 0;
828 return S_FALSE;
832 if(read) {
833 *pcbRead = 0;
834 return S_FALSE;
837 ok(pv != NULL, "pv == NULL\n");
838 ok(cb != 0, "cb == 0\n");
839 ok(pcbRead != NULL, "pcbRead == NULL\n");
840 if(pcbRead) {
841 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
842 read += *pcbRead = sizeof(data)-1;
844 if(pv)
845 memcpy(pv, data, sizeof(data));
847 return S_OK;
850 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
851 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
853 ok(0, "unexpected call\n");
854 return E_NOTIMPL;
857 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
859 CHECK_EXPECT(LockRequest);
860 return S_OK;
863 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
865 CHECK_EXPECT(UnlockRequest);
866 return S_OK;
869 static const IInternetProtocolVtbl ProtocolVtbl = {
870 Protocol_QueryInterface,
871 Protocol_AddRef,
872 Protocol_Release,
873 Protocol_Start,
874 Protocol_Continue,
875 Protocol_Abort,
876 Protocol_Terminate,
877 Protocol_Suspend,
878 Protocol_Resume,
879 Protocol_Read,
880 Protocol_Seek,
881 Protocol_LockRequest,
882 Protocol_UnlockRequest
885 static IInternetProtocol Protocol = { &ProtocolVtbl };
887 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
889 if(IsEqualGUID(&IID_IUnknown, riid)
890 || IsEqualGUID(&IID_IHttpNegotiate, riid)
891 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
892 *ppv = iface;
893 return S_OK;
896 ok(0, "unexpected call\n");
897 return E_NOINTERFACE;
900 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
902 return 2;
905 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
907 return 1;
910 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
911 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
913 CHECK_EXPECT(BeginningTransaction);
915 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
917 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
918 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
919 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
920 if(pszAdditionalHeaders)
921 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
923 return S_OK;
926 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
927 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
929 CHECK_EXPECT(OnResponse);
931 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
933 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
934 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
935 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
936 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
937 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
938 if(pszAdditionalRequestHeaders)
939 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
941 return S_OK;
944 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
945 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
947 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
949 CHECK_EXPECT(GetRootSecurityId);
951 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
953 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
954 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
955 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
957 if(pbSecurityId == (void*)0xdeadbeef)
958 return E_NOTIMPL;
960 if(pcbSecurityId) {
961 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
962 *pcbSecurityId = sizeof(sec_id);
965 if(pbSecurityId)
966 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
968 return E_FAIL;
971 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
972 HttpNegotiate_QueryInterface,
973 HttpNegotiate_AddRef,
974 HttpNegotiate_Release,
975 HttpNegotiate_BeginningTransaction,
976 HttpNegotiate_OnResponse,
977 HttpNegotiate_GetRootSecurityId
980 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
982 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
984 ok(0, "unexpected call\n");
985 return E_NOINTERFACE;
988 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
990 return 2;
993 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
995 return 1;
998 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
999 REFGUID guidService, REFIID riid, void **ppv)
1001 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1002 CHECK_EXPECT(QueryService_IAuthenticate);
1003 return E_NOTIMPL;
1006 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1007 CHECK_EXPECT2(QueryService_IInternetProtocol);
1008 return E_NOTIMPL;
1011 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1012 CHECK_EXPECT(QueryService_IInternetBindInfo);
1013 return E_NOTIMPL;
1016 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
1017 return E_NOINTERFACE;
1020 static IServiceProviderVtbl ServiceProviderVtbl = {
1021 ServiceProvider_QueryInterface,
1022 ServiceProvider_AddRef,
1023 ServiceProvider_Release,
1024 ServiceProvider_QueryService
1027 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1029 static IBindStatusCallback objbsc;
1031 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
1033 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1035 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1036 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1037 if(emulate_protocol) {
1038 *ppv = &Protocol;
1039 return S_OK;
1040 }else {
1041 return E_NOINTERFACE;
1044 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1046 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1047 *ppv = &ServiceProvider;
1048 return S_OK;
1050 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1052 CHECK_EXPECT(QueryInterface_IHttpNegotiate);
1053 *ppv = &HttpNegotiate;
1054 return S_OK;
1056 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1058 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1059 *ppv = &HttpNegotiate;
1060 return S_OK;
1062 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1064 CHECK_EXPECT(QueryInterface_IAuthenticate);
1065 return E_NOINTERFACE;
1067 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1069 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1070 *ppv = iface;
1071 return S_OK;
1073 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1075 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1076 return E_NOINTERFACE;
1078 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1080 /* TODO */
1081 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1083 else
1085 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1088 return E_NOINTERFACE;
1091 static ULONG WINAPI statusclb_AddRef(IBindStatusCallback *iface)
1093 return 2;
1096 static ULONG WINAPI statusclb_Release(IBindStatusCallback *iface)
1098 return 1;
1101 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved,
1102 IBinding *pib)
1104 IWinInetHttpInfo *http_info;
1105 HRESULT hres;
1106 IMoniker *mon;
1108 if(iface == &objbsc)
1109 CHECK_EXPECT(Obj_OnStartBinding);
1110 else
1111 CHECK_EXPECT(OnStartBinding);
1113 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1115 ok(pib != NULL, "pib should not be NULL\n");
1116 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1118 if(pib == (void*)0xdeadbeef)
1119 return S_OK;
1121 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1122 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1123 if(SUCCEEDED(hres))
1124 IMoniker_Release(mon);
1126 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1127 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1129 return S_OK;
1132 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
1134 ok(0, "unexpected call\n");
1135 return E_NOTIMPL;
1138 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
1140 ok(0, "unexpected call\n");
1141 return E_NOTIMPL;
1144 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
1145 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1147 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1149 switch(ulStatusCode) {
1150 case BINDSTATUS_FINDINGRESOURCE:
1151 if(iface == &objbsc)
1152 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1153 else
1154 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1155 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1156 SetEvent(complete_event);
1157 break;
1158 case BINDSTATUS_CONNECTING:
1159 if(iface == &objbsc)
1160 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1161 else
1162 CHECK_EXPECT(OnProgress_CONNECTING);
1163 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1164 SetEvent(complete_event);
1165 break;
1166 case BINDSTATUS_SENDINGREQUEST:
1167 if(iface == &objbsc)
1168 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1169 else
1170 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1171 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1172 SetEvent(complete_event);
1173 break;
1174 case BINDSTATUS_MIMETYPEAVAILABLE:
1175 if(iface == &objbsc)
1176 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1177 else
1178 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1179 if(!bind_to_object)
1180 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1181 download_state);
1182 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1183 break;
1184 case BINDSTATUS_BEGINDOWNLOADDATA:
1185 if(iface == &objbsc)
1186 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1187 else
1188 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1189 ok(szStatusText != NULL, "szStatusText == NULL\n");
1190 if(szStatusText) {
1191 if(filedwl_api) {
1192 /* FIXME */
1193 }else {
1194 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1197 if(!bind_to_object)
1198 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1199 download_state);
1200 download_state = DOWNLOADING;
1201 break;
1202 case BINDSTATUS_DOWNLOADINGDATA:
1203 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1204 if(iface == &objbsc)
1205 todo_wine ok(0, "unexpected call\n");
1206 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1207 download_state);
1208 break;
1209 case BINDSTATUS_ENDDOWNLOADDATA:
1210 if(iface == &objbsc)
1211 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1212 else
1213 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1214 ok(szStatusText != NULL, "szStatusText == NULL\n");
1215 if(szStatusText) {
1216 if(filedwl_api) {
1217 /* FIXME */
1218 }else {
1219 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1222 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1223 download_state);
1224 download_state = END_DOWNLOAD;
1225 break;
1226 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1227 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST) {
1228 if(iface == &objbsc)
1229 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1230 else
1231 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1232 }else { /* FIXME */
1233 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1234 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1237 ok(szStatusText != NULL, "szStatusText == NULL\n");
1238 if(szStatusText && test_protocol == FILE_TEST)
1239 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", debugstr_w(szStatusText));
1240 break;
1241 case BINDSTATUS_CLASSIDAVAILABLE:
1243 CLSID clsid;
1244 HRESULT hr;
1245 if(iface != &objbsc)
1246 ok(0, "unexpected call\n");
1247 else if(1||emulate_protocol)
1248 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1249 else
1250 todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1251 hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
1252 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1253 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1254 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1255 break;
1257 case BINDSTATUS_BEGINSYNCOPERATION:
1258 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1259 if(iface != &objbsc)
1260 ok(0, "unexpected call\n");
1261 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1262 break;
1263 case BINDSTATUS_ENDSYNCOPERATION:
1264 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1265 if(iface != &objbsc)
1266 ok(0, "unexpected call\n");
1267 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1268 break;
1269 case BINDSTATUS_PROXYDETECTING:
1270 trace("BINDSTATUS_PROXYDETECTING\n");
1271 break;
1272 default:
1273 ok(0, "unexpected code %d\n", ulStatusCode);
1275 return S_OK;
1278 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
1280 if(iface == &objbsc) {
1281 CHECK_EXPECT(Obj_OnStopBinding);
1282 stopped_obj_binding = TRUE;
1283 }else {
1284 CHECK_EXPECT(OnStopBinding);
1285 stopped_binding = TRUE;
1288 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1290 /* ignore DNS failure */
1291 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1292 return S_OK;
1294 if(filedwl_api)
1295 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1296 else
1297 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1298 ok(szError == NULL, "szError should be NULL\n");
1300 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) && emulate_protocol) {
1301 SetEvent(complete_event);
1302 if(iface != &objbsc)
1303 WaitForSingleObject(complete_event2, INFINITE);
1306 return S_OK;
1309 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1311 DWORD cbSize;
1313 if(iface == &objbsc)
1314 CHECK_EXPECT(Obj_GetBindInfo);
1315 else
1316 CHECK_EXPECT(GetBindInfo);
1318 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1320 *grfBINDF = bindf;
1321 cbSize = pbindinfo->cbSize;
1322 memset(pbindinfo, 0, cbSize);
1323 pbindinfo->cbSize = cbSize;
1325 return S_OK;
1328 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
1329 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1331 HRESULT hres;
1332 DWORD readed;
1333 BYTE buf[512];
1334 CHAR clipfmt[512];
1336 if(iface == &objbsc)
1337 ok(0, "unexpected call\n");
1339 CHECK_EXPECT2(OnDataAvailable);
1341 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1343 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1344 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1345 download_state);
1346 data_available = TRUE;
1348 ok(pformatetc != NULL, "pformatetx == NULL\n");
1349 if(pformatetc) {
1350 if (mime_type[0]) {
1351 clipfmt[0] = 0;
1352 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1353 "GetClipboardFormatName failed, error %d\n", GetLastError());
1354 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1355 pformatetc->cfFormat, clipfmt, mime_type);
1356 } else {
1357 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1359 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1360 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1361 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1362 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1365 ok(pstgmed != NULL, "stgmeg == NULL\n");
1366 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1367 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1369 switch(pstgmed->tymed) {
1370 case TYMED_ISTREAM:
1371 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1372 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1373 ok(hres == STG_E_ACCESSDENIED,
1374 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1376 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1377 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1379 hres = IStream_Revert(U(*pstgmed).pstm);
1380 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1383 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1384 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1385 while(hres == S_OK);
1386 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1387 break;
1389 case TYMED_FILE:
1390 if(test_protocol == FILE_TEST)
1391 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1392 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1393 else if(emulate_protocol)
1394 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1395 "unexpected file name %s\n", debugstr_w(pstgmed->u.lpszFileName));
1396 else
1397 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1400 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
1401 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1402 SetEvent(complete_event);
1404 return S_OK;
1407 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
1409 CHECK_EXPECT(OnObjectAvailable);
1411 if(iface != &objbsc)
1412 ok(0, "unexpected call\n");
1414 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1415 ok(punk != NULL, "punk == NULL\n");
1417 return S_OK;
1420 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
1421 statusclb_QueryInterface,
1422 statusclb_AddRef,
1423 statusclb_Release,
1424 statusclb_OnStartBinding,
1425 statusclb_GetPriority,
1426 statusclb_OnLowResource,
1427 statusclb_OnProgress,
1428 statusclb_OnStopBinding,
1429 statusclb_GetBindInfo,
1430 statusclb_OnDataAvailable,
1431 statusclb_OnObjectAvailable
1434 static IBindStatusCallback bsc = { &BindStatusCallbackVtbl };
1435 static IBindStatusCallback objbsc = { &BindStatusCallbackVtbl };
1437 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1439 *ppv = NULL;
1440 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1441 return E_NOINTERFACE;
1444 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
1446 return 2;
1449 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
1451 return 1;
1454 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
1456 switch(mkp) {
1457 case MIMETYPEPROP:
1458 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
1459 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", debugstr_w(val));
1460 break;
1461 case CLASSIDPROP:
1462 CHECK_EXPECT(PutProperty_CLASSIDPROP);
1463 break;
1464 default:
1465 break;
1468 return S_OK;
1471 static const IMonikerPropVtbl MonikerPropVtbl = {
1472 MonikerProp_QueryInterface,
1473 MonikerProp_AddRef,
1474 MonikerProp_Release,
1475 MonikerProp_PutProperty
1478 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
1480 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
1482 *ppv = NULL;
1484 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
1485 *ppv = iface;
1486 else if(IsEqualGUID(&IID_IMonikerProp, riid))
1487 *ppv = &MonikerProp;
1489 if(*ppv)
1490 return S_OK;
1492 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1493 return E_NOINTERFACE;
1496 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
1498 return 2;
1501 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
1503 return 1;
1506 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
1508 ok(0, "unexpected call\n");
1509 return E_NOTIMPL;
1512 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
1514 ok(0, "unexpected call\n");
1515 return E_NOTIMPL;
1518 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
1519 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
1521 IUnknown *unk;
1522 HRESULT hres;
1524 static WCHAR cbinding_contextW[] =
1525 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1527 CHECK_EXPECT(Load);
1528 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1530 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
1531 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1532 else
1533 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1534 ok(pimkName != NULL, "pimkName == NULL\n");
1535 ok(pibc != NULL, "pibc == NULL\n");
1536 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
1538 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
1539 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
1540 if(SUCCEEDED(hres)) {
1541 IBinding *binding;
1543 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
1544 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
1546 IBinding_Release(binding);
1547 IUnknown_Release(unk);
1550 SET_EXPECT(QueryInterface_IServiceProvider);
1551 hres = RegisterBindStatusCallback(pibc, &bsc, NULL, 0);
1552 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1553 CHECK_CALLED(QueryInterface_IServiceProvider);
1555 SET_EXPECT(GetBindInfo);
1556 SET_EXPECT(OnStartBinding);
1557 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1558 if(test_protocol == FILE_TEST)
1559 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1560 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1561 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1562 SET_EXPECT(LockRequest);
1563 SET_EXPECT(OnDataAvailable);
1564 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1565 SET_EXPECT(OnStopBinding);
1567 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
1568 ok(hres == S_OK, "Load failed: %08x\n", hres);
1570 CHECK_CALLED(GetBindInfo);
1571 CHECK_CALLED(OnStartBinding);
1572 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1573 if(test_protocol == FILE_TEST)
1574 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1575 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1576 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1577 CHECK_CALLED(LockRequest);
1578 CHECK_CALLED(OnDataAvailable);
1579 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1580 CHECK_CALLED(OnStopBinding);
1582 if(unk)
1583 IUnknown_Release(unk);
1585 return S_OK;
1588 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
1590 ok(0, "unexpected call\n");
1591 return E_NOTIMPL;
1594 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
1596 ok(0, "unexpected call\n");
1597 return E_NOTIMPL;
1600 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
1602 ok(0, "unexpected call\n");
1603 return E_NOTIMPL;
1606 static const IPersistMonikerVtbl PersistMonikerVtbl = {
1607 PersistMoniker_QueryInterface,
1608 PersistMoniker_AddRef,
1609 PersistMoniker_Release,
1610 PersistMoniker_GetClassID,
1611 PersistMoniker_IsDirty,
1612 PersistMoniker_Load,
1613 PersistMoniker_Save,
1614 PersistMoniker_SaveCompleted,
1615 PersistMoniker_GetCurMoniker
1618 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
1620 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1622 *ppv = NULL;
1624 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1625 *ppv = iface;
1626 return S_OK;
1629 if(IsEqualGUID(&IID_IMarshal, riid))
1630 return E_NOINTERFACE;
1631 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1632 return E_NOINTERFACE;
1634 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1635 return E_NOTIMPL;
1638 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1640 return 2;
1643 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1645 return 1;
1648 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1650 CHECK_EXPECT(CreateInstance);
1651 ok(!outer, "outer = %p\n", outer);
1652 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1653 *ppv = &PersistMoniker;
1654 return S_OK;
1657 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1659 ok(0, "unexpected call\n");
1660 return S_OK;
1663 static const IClassFactoryVtbl ClassFactoryVtbl = {
1664 ClassFactory_QueryInterface,
1665 ClassFactory_AddRef,
1666 ClassFactory_Release,
1667 ClassFactory_CreateInstance,
1668 ClassFactory_LockServer
1671 static IClassFactory mime_cf = { &ClassFactoryVtbl };
1673 static void test_CreateAsyncBindCtx(void)
1675 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1676 IUnknown *unk;
1677 HRESULT hres;
1678 ULONG ref;
1679 BIND_OPTS bindopts;
1681 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1682 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1683 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1685 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1686 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1688 SET_EXPECT(QueryInterface_IServiceProvider);
1689 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1690 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1691 CHECK_CALLED(QueryInterface_IServiceProvider);
1693 bindopts.cbStruct = sizeof(bindopts);
1694 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1695 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1696 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1697 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1698 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1699 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1700 bindopts.grfMode);
1701 ok(bindopts.dwTickCountDeadline == 0,
1702 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1704 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1705 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1706 if(SUCCEEDED(hres))
1707 IUnknown_Release(unk);
1709 ref = IBindCtx_Release(bctx);
1710 ok(ref == 0, "bctx should be destroyed here\n");
1713 static void test_CreateAsyncBindCtxEx(void)
1715 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1716 IUnknown *unk;
1717 BIND_OPTS bindopts;
1718 HRESULT hres;
1720 static WCHAR testW[] = {'t','e','s','t',0};
1722 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1723 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1725 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1726 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1728 if(SUCCEEDED(hres)) {
1729 bindopts.cbStruct = sizeof(bindopts);
1730 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1731 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1732 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1733 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1734 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1735 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1736 bindopts.grfMode);
1737 ok(bindopts.dwTickCountDeadline == 0,
1738 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1740 IBindCtx_Release(bctx);
1743 CreateBindCtx(0, &bctx_arg);
1744 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1745 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1747 if(SUCCEEDED(hres)) {
1748 bindopts.cbStruct = sizeof(bindopts);
1749 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1750 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1751 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1752 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1753 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1754 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1755 bindopts.grfMode);
1756 ok(bindopts.dwTickCountDeadline == 0,
1757 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1759 IBindCtx_Release(bctx);
1762 IBindCtx_Release(bctx_arg);
1764 SET_EXPECT(QueryInterface_IServiceProvider);
1765 hres = CreateAsyncBindCtxEx(NULL, 0, &bsc, NULL, &bctx, 0);
1766 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1767 CHECK_CALLED(QueryInterface_IServiceProvider);
1769 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1770 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1771 if(SUCCEEDED(hres))
1772 IUnknown_Release(unk);
1774 IBindCtx_Release(bctx);
1776 hres = CreateBindCtx(0, &bctx2);
1777 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1779 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1780 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1782 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1783 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1785 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1786 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1787 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1789 IBindCtx_Release(bctx);
1790 IBindCtx_Release(bctx2);
1793 static BOOL test_bscholder(IBindStatusCallback *holder)
1795 IServiceProvider *serv_prov;
1796 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1797 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1798 IAuthenticate *authenticate, *authenticate_serv;
1799 IInternetProtocol *protocol;
1800 BINDINFO bindinfo = {sizeof(bindinfo)};
1801 BOOL ret = TRUE;
1802 LPWSTR wstr;
1803 DWORD dw;
1804 HRESULT hres;
1806 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
1807 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
1809 dw = 0xdeadbeef;
1810 SET_EXPECT(GetBindInfo);
1811 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
1812 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1813 CHECK_CALLED(GetBindInfo);
1815 SET_EXPECT(OnStartBinding);
1816 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
1817 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1818 CHECK_CALLED(OnStartBinding);
1820 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
1821 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
1823 wstr = (void*)0xdeadbeef;
1824 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol], (void*)0xdeadbeef, 0xff, &wstr);
1825 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1826 ok(wstr == NULL, "wstr = %p\n", wstr);
1828 SET_EXPECT(QueryInterface_IHttpNegotiate);
1829 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1830 (void**)&http_negotiate_serv);
1831 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1832 CHECK_CALLED(QueryInterface_IHttpNegotiate);
1834 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1836 wstr = (void*)0xdeadbeef;
1837 SET_EXPECT(BeginningTransaction);
1838 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
1839 CHECK_CALLED(BeginningTransaction);
1840 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1841 ok(wstr == NULL, "wstr = %p\n", wstr);
1843 IHttpNegotiate_Release(http_negotiate_serv);
1845 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1846 (void**)&http_negotiate_serv);
1847 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1848 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1849 IHttpNegotiate_Release(http_negotiate_serv);
1851 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
1852 if(SUCCEEDED(hres)) {
1853 have_IHttpNegotiate2 = TRUE;
1854 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1855 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x\n", hres);
1857 SET_EXPECT(QueryInterface_IHttpNegotiate2);
1858 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
1859 (void**)&http_negotiate2_serv);
1860 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
1861 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
1862 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
1864 SET_EXPECT(GetRootSecurityId);
1865 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1866 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
1867 CHECK_CALLED(GetRootSecurityId);
1869 IHttpNegotiate_Release(http_negotiate2_serv);
1870 IHttpNegotiate_Release(http_negotiate2);
1871 }else {
1872 skip("Could not get IHttpNegotiate2\n");
1873 ret = FALSE;
1876 SET_EXPECT(OnProgress_FINDINGRESOURCE);
1877 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
1878 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
1879 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
1881 SET_EXPECT(OnResponse);
1882 wstr = (void*)0xdeadbeef;
1883 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
1884 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
1885 CHECK_CALLED(OnResponse);
1887 IHttpNegotiate_Release(http_negotiate);
1889 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
1890 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
1892 SET_EXPECT(QueryInterface_IAuthenticate);
1893 SET_EXPECT(QueryService_IAuthenticate);
1894 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1895 (void**)&authenticate_serv);
1896 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1897 CHECK_CALLED(QueryInterface_IAuthenticate);
1898 CHECK_CALLED(QueryService_IAuthenticate);
1899 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1900 IAuthenticate_Release(authenticate_serv);
1902 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1903 (void**)&authenticate_serv);
1904 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1905 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1907 IAuthenticate_Release(authenticate);
1908 IAuthenticate_Release(authenticate_serv);
1910 SET_EXPECT(OnStopBinding);
1911 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
1912 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1913 CHECK_CALLED(OnStopBinding);
1915 SET_EXPECT(QueryInterface_IInternetProtocol);
1916 SET_EXPECT(QueryService_IInternetProtocol);
1917 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
1918 (void**)&protocol);
1919 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
1920 CHECK_CALLED(QueryInterface_IInternetProtocol);
1921 CHECK_CALLED(QueryService_IInternetProtocol);
1923 IServiceProvider_Release(serv_prov);
1924 return ret;
1927 static BOOL test_RegisterBindStatusCallback(void)
1929 IBindStatusCallback *prevbsc, *clb;
1930 IBindCtx *bindctx;
1931 BOOL ret = TRUE;
1932 IUnknown *unk;
1933 HRESULT hres;
1935 hres = CreateBindCtx(0, &bindctx);
1936 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
1938 SET_EXPECT(QueryInterface_IServiceProvider);
1940 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
1941 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1943 SET_EXPECT(QueryInterface_IBindStatusCallback);
1944 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
1945 prevbsc = (void*)0xdeadbeef;
1946 hres = RegisterBindStatusCallback(bindctx, &bsc, &prevbsc, 0);
1947 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1948 ok(prevbsc == &bsc, "prevbsc=%p\n", prevbsc);
1949 CHECK_CALLED(QueryInterface_IBindStatusCallback);
1950 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
1952 CHECK_CALLED(QueryInterface_IServiceProvider);
1954 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1955 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1957 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
1958 IUnknown_Release(unk);
1959 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
1960 ok(clb != &bsc, "bsc == clb\n");
1962 if(!test_bscholder(clb))
1963 ret = FALSE;
1965 IBindStatusCallback_Release(clb);
1967 hres = RevokeBindStatusCallback(bindctx, &bsc);
1968 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1970 unk = (void*)0xdeadbeef;
1971 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1972 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
1973 ok(unk == NULL, "unk != NULL\n");
1975 if(unk)
1976 IUnknown_Release(unk);
1978 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
1979 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1981 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
1982 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1984 hres = RevokeBindStatusCallback(bindctx, NULL);
1985 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1987 IBindCtx_Release(bindctx);
1988 return ret;
1991 #define BINDTEST_EMULATE 1
1992 #define BINDTEST_TOOBJECT 2
1993 #define BINDTEST_FILEDWLAPI 4
1995 static void init_bind_test(int protocol, DWORD flags, DWORD t)
1997 test_protocol = protocol;
1998 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
1999 download_state = BEFORE_DOWNLOAD;
2000 stopped_binding = FALSE;
2001 stopped_obj_binding = FALSE;
2002 data_available = FALSE;
2003 mime_type[0] = 0;
2004 binding_hres = S_OK;
2005 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
2006 tymed = t;
2007 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
2010 static void test_BindToStorage(int protocol, BOOL emul, DWORD t)
2012 IMoniker *mon;
2013 HRESULT hres;
2014 LPOLESTR display_name;
2015 IBindCtx *bctx;
2016 MSG msg;
2017 IBindStatusCallback *previousclb;
2018 IUnknown *unk = (IUnknown*)0x00ff00ff;
2019 IBinding *bind;
2021 init_bind_test(protocol, emul ? BINDTEST_EMULATE : 0, t);
2023 SET_EXPECT(QueryInterface_IServiceProvider);
2024 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
2025 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2026 CHECK_CALLED(QueryInterface_IServiceProvider);
2027 if(FAILED(hres))
2028 return;
2030 SET_EXPECT(QueryInterface_IServiceProvider);
2031 hres = RegisterBindStatusCallback(bctx, &bsc, &previousclb, 0);
2032 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2033 ok(previousclb == &bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2034 CHECK_CALLED(QueryInterface_IServiceProvider);
2035 if(previousclb)
2036 IBindStatusCallback_Release(previousclb);
2038 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2039 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2040 if(FAILED(hres)) {
2041 IBindCtx_Release(bctx);
2042 return;
2045 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2046 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2047 if(SUCCEEDED(hres))
2048 IBinding_Release(bind);
2050 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2051 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2052 ok(!lstrcmpW(display_name, urls[test_protocol]),
2053 "GetDisplayName got wrong name %s\n", debugstr_w(display_name));
2054 CoTaskMemFree(display_name);
2056 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2057 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2059 SET_EXPECT(GetBindInfo);
2060 SET_EXPECT(QueryInterface_IInternetProtocol);
2061 if(!emulate_protocol)
2062 SET_EXPECT(QueryService_IInternetProtocol);
2063 SET_EXPECT(OnStartBinding);
2064 if(emulate_protocol) {
2065 SET_EXPECT(Start);
2066 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2067 SET_EXPECT(Terminate);
2068 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2069 SET_EXPECT(UnlockRequest);
2070 }else {
2071 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2072 SET_EXPECT(QueryInterface_IInternetBindInfo);
2073 SET_EXPECT(QueryService_IInternetBindInfo);
2074 SET_EXPECT(QueryInterface_IHttpNegotiate);
2075 SET_EXPECT(BeginningTransaction);
2076 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2077 SET_EXPECT(GetRootSecurityId);
2078 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2079 SET_EXPECT(OnProgress_CONNECTING);
2081 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2082 SET_EXPECT(OnProgress_SENDINGREQUEST);
2083 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2084 SET_EXPECT(OnResponse);
2085 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2086 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2087 if(test_protocol == FILE_TEST)
2088 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2089 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2090 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2091 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2092 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2093 SET_EXPECT(OnDataAvailable);
2094 SET_EXPECT(OnStopBinding);
2097 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2098 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2099 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2101 skip("Network unreachable, skipping tests\n");
2102 return;
2105 if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2106 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2107 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2108 ok(unk == NULL, "istr should be NULL\n");
2109 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2110 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2111 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2112 ok(unk == NULL, "istr should be NULL\n");
2113 }else {
2114 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2115 ok(unk != NULL, "unk == NULL\n");
2117 if(unk)
2118 IUnknown_Release(unk);
2120 if(FAILED(hres))
2121 return;
2123 while((bindf & BINDF_ASYNCHRONOUS) &&
2124 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
2125 TranslateMessage(&msg);
2126 DispatchMessage(&msg);
2129 CHECK_CALLED(GetBindInfo);
2130 CHECK_CALLED(QueryInterface_IInternetProtocol);
2131 if(!emulate_protocol)
2132 CHECK_CALLED(QueryService_IInternetProtocol);
2133 CHECK_CALLED(OnStartBinding);
2134 if(emulate_protocol) {
2135 CHECK_CALLED(Start);
2136 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2137 if(tymed == TYMED_FILE)
2138 CLEAR_CALLED(Read);
2139 CHECK_CALLED(Terminate);
2141 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2142 CHECK_CALLED(UnlockRequest);
2143 }else {
2144 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2145 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2146 CLEAR_CALLED(QueryService_IInternetBindInfo);
2147 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2148 CHECK_CALLED(BeginningTransaction);
2149 if (have_IHttpNegotiate2)
2151 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2152 CHECK_CALLED(GetRootSecurityId);
2154 if(http_is_first || test_protocol == HTTPS_TEST) {
2155 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2156 CHECK_CALLED(OnProgress_CONNECTING);
2157 }else todo_wine {
2158 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2159 /* IE7 does call this */
2160 CLEAR_CALLED(OnProgress_CONNECTING);
2163 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2164 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2165 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2166 CHECK_CALLED(OnResponse);
2167 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2168 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2169 if(test_protocol == FILE_TEST)
2170 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2171 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2172 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2173 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2174 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2175 CHECK_CALLED(OnDataAvailable);
2176 CHECK_CALLED(OnStopBinding);
2179 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2180 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2182 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2183 http_is_first = FALSE;
2186 static void test_BindToObject(int protocol, BOOL emul)
2188 IMoniker *mon;
2189 HRESULT hres;
2190 LPOLESTR display_name;
2191 IBindCtx *bctx;
2192 DWORD regid;
2193 MSG msg;
2194 IUnknown *unk = (IUnknown*)0x00ff00ff;
2195 IBinding *bind;
2197 init_bind_test(protocol, BINDTEST_TOOBJECT | (emul ? BINDTEST_EMULATE : 0), TYMED_ISTREAM);
2199 if(emul)
2200 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
2201 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid);
2203 SET_EXPECT(QueryInterface_IServiceProvider);
2204 hres = CreateAsyncBindCtx(0, &objbsc, NULL, &bctx);
2205 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
2206 CHECK_CALLED(QueryInterface_IServiceProvider);
2207 if(FAILED(hres))
2208 return;
2210 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2211 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2212 if(FAILED(hres)) {
2213 IBindCtx_Release(bctx);
2214 return;
2217 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2218 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2219 if(SUCCEEDED(hres))
2220 IBinding_Release(bind);
2222 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2223 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2224 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
2226 SET_EXPECT(Obj_GetBindInfo);
2227 SET_EXPECT(QueryInterface_IInternetProtocol);
2228 if(!emulate_protocol)
2229 SET_EXPECT(QueryService_IInternetProtocol);
2230 SET_EXPECT(Obj_OnStartBinding);
2231 if(emulate_protocol) {
2232 SET_EXPECT(Start);
2233 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2234 SET_EXPECT(Terminate);
2235 if(test_protocol == FILE_TEST)
2236 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2237 SET_EXPECT(UnlockRequest);
2238 }else {
2239 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2240 SET_EXPECT(QueryInterface_IHttpNegotiate);
2241 SET_EXPECT(BeginningTransaction);
2242 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2243 SET_EXPECT(GetRootSecurityId);
2244 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
2245 SET_EXPECT(Obj_OnProgress_CONNECTING);
2247 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2248 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
2249 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2250 SET_EXPECT(OnResponse);
2251 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
2252 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
2253 if(test_protocol == FILE_TEST)
2254 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2255 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2256 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2257 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
2258 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
2259 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
2260 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
2261 SET_EXPECT(OnObjectAvailable);
2262 SET_EXPECT(Obj_OnStopBinding);
2265 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
2267 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2268 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2270 skip( "Network unreachable, skipping tests\n" );
2271 return;
2274 /* no point testing the calls if binding didn't even work */
2275 if (FAILED(hres)) return;
2277 if(bindf & BINDF_ASYNCHRONOUS) {
2278 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
2279 ok(unk == NULL, "istr should be NULL\n");
2280 }else {
2281 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2282 ok(unk != NULL, "unk == NULL\n");
2283 if(emul)
2284 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
2286 if(unk)
2287 IUnknown_Release(unk);
2289 while((bindf & BINDF_ASYNCHRONOUS) &&
2290 !((!emul || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
2291 TranslateMessage(&msg);
2292 DispatchMessage(&msg);
2295 CHECK_CALLED(Obj_GetBindInfo);
2296 CHECK_CALLED(QueryInterface_IInternetProtocol);
2297 if(!emulate_protocol)
2298 CHECK_CALLED(QueryService_IInternetProtocol);
2299 CHECK_CALLED(Obj_OnStartBinding);
2300 if(emulate_protocol) {
2301 CHECK_CALLED(Start);
2302 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2303 CHECK_CALLED(Terminate);
2304 if(test_protocol == FILE_TEST)
2305 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
2306 CHECK_CALLED(UnlockRequest);
2307 }else {
2308 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2309 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2310 CHECK_CALLED(BeginningTransaction);
2311 if (have_IHttpNegotiate2)
2313 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2314 CHECK_CALLED(GetRootSecurityId);
2316 if(http_is_first) {
2317 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2318 CHECK_CALLED(Obj_OnProgress_CONNECTING);
2319 }else todo_wine {
2320 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2321 /* IE7 does call this */
2322 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
2325 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) {
2326 if(urls[test_protocol] == SHORT_RESPONSE_URL)
2327 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
2328 else
2329 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
2331 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2332 CHECK_CALLED(OnResponse);
2333 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
2334 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
2335 if(test_protocol == FILE_TEST)
2336 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2337 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2338 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2339 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
2340 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
2341 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
2342 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
2343 CHECK_CALLED(OnObjectAvailable);
2344 CHECK_CALLED(Obj_OnStopBinding);
2347 if(test_protocol != HTTP_TEST || test_protocol == HTTPS_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL) {
2348 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2349 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2350 }else {
2351 todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2353 if(bindf & BINDF_ASYNCHRONOUS)
2354 IBindCtx_Release(bctx);
2355 else
2356 todo_wine ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2359 if(emul)
2360 CoRevokeClassObject(regid);
2362 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2363 http_is_first = FALSE;
2366 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
2368 BOOL res;
2369 HRESULT hres;
2371 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
2373 SET_EXPECT(GetBindInfo);
2374 SET_EXPECT(QueryInterface_IInternetProtocol);
2375 if(!emulate_protocol) {
2376 SET_EXPECT(QueryInterface_IServiceProvider);
2377 SET_EXPECT(QueryService_IInternetProtocol);
2379 SET_EXPECT(OnStartBinding);
2380 if(emulate_protocol) {
2381 SET_EXPECT(Start);
2382 SET_EXPECT(UnlockRequest);
2383 }else {
2384 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2385 SET_EXPECT(QueryInterface_IHttpNegotiate);
2386 SET_EXPECT(BeginningTransaction);
2387 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2388 SET_EXPECT(GetRootSecurityId);
2390 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2391 SET_EXPECT(OnProgress_SENDINGREQUEST);
2392 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2393 SET_EXPECT(OnResponse);
2394 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2395 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2396 if(test_protocol == FILE_TEST)
2397 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2398 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2399 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2400 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2401 SET_EXPECT(OnStopBinding);
2404 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], dwl_htmlW, 0, &bsc);
2405 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2407 CHECK_CALLED(GetBindInfo);
2408 CHECK_CALLED(QueryInterface_IInternetProtocol);
2409 if(!emulate_protocol) {
2410 CHECK_CALLED(QueryInterface_IServiceProvider);
2411 CHECK_CALLED(QueryService_IInternetProtocol);
2413 CHECK_CALLED(OnStartBinding);
2414 if(emulate_protocol) {
2415 CHECK_CALLED(Start);
2416 CHECK_CALLED(UnlockRequest);
2417 }else {
2418 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2419 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2420 CHECK_CALLED(BeginningTransaction);
2421 if (have_IHttpNegotiate2)
2423 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2424 CHECK_CALLED(GetRootSecurityId);
2427 if(test_protocol == FILE_TEST)
2428 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2429 else if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2430 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
2431 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2432 CHECK_CALLED(OnResponse);
2433 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2434 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2435 if(test_protocol == FILE_TEST)
2436 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2437 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2438 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2439 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2440 CHECK_CALLED(OnStopBinding);
2443 res = DeleteFileA(dwl_htmlA);
2444 ok(res, "DeleteFile failed: %u\n", GetLastError());
2446 if(prot != FILE_TEST || emul)
2447 return;
2449 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
2450 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2452 res = DeleteFileA(dwl_htmlA);
2453 ok(res, "DeleteFile failed: %u\n", GetLastError());
2456 static void set_file_url(char *path)
2458 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
2459 CHAR INDEX_HTMLA[MAX_PATH];
2461 lstrcpyA(file_urlA, "file:///");
2462 lstrcatA(file_urlA, path);
2463 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
2465 lstrcpyA(INDEX_HTMLA, "file://");
2466 lstrcatA(INDEX_HTMLA, path);
2467 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
2470 static void create_file(void)
2472 HANDLE file;
2473 DWORD size;
2474 CHAR path[MAX_PATH];
2476 static const char html_doc[] = "<HTML></HTML>";
2478 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2479 FILE_ATTRIBUTE_NORMAL, NULL);
2480 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2481 if(file == INVALID_HANDLE_VALUE)
2482 return;
2484 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2485 CloseHandle(file);
2487 GetCurrentDirectoryA(MAX_PATH, path);
2488 lstrcatA(path, "\\");
2489 lstrcatA(path, wszIndexHtmlA);
2490 set_file_url(path);
2493 static void test_ReportResult(HRESULT exhres)
2495 IMoniker *mon = NULL;
2496 IBindCtx *bctx = NULL;
2497 IUnknown *unk = (void*)0xdeadbeef;
2498 HRESULT hres;
2500 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2501 binding_hres = exhres;
2503 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2504 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2506 SET_EXPECT(QueryInterface_IServiceProvider);
2507 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
2508 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2509 CHECK_CALLED(QueryInterface_IServiceProvider);
2511 SET_EXPECT(GetBindInfo);
2512 SET_EXPECT(QueryInterface_IInternetProtocol);
2513 SET_EXPECT(OnStartBinding);
2514 SET_EXPECT(Start);
2516 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2517 if(SUCCEEDED(exhres))
2518 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
2519 else
2520 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
2521 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
2523 CHECK_CALLED(GetBindInfo);
2524 CHECK_CALLED(QueryInterface_IInternetProtocol);
2525 CHECK_CALLED(OnStartBinding);
2526 CHECK_CALLED(Start);
2528 ok(unk == NULL, "unk=%p\n", unk);
2530 IBindCtx_Release(bctx);
2531 IMoniker_Release(mon);
2534 static void test_BindToStorage_fail(void)
2536 IMoniker *mon = NULL;
2537 IBindCtx *bctx = NULL;
2538 IUnknown *unk;
2539 HRESULT hres;
2541 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2542 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2543 if(FAILED(hres))
2544 return;
2546 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2547 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2549 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2550 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
2551 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
2553 IBindCtx_Release(bctx);
2555 IMoniker_Release(mon);
2557 test_ReportResult(E_NOTIMPL);
2558 test_ReportResult(S_FALSE);
2561 static void gecko_installer_workaround(BOOL disable)
2563 HKEY hkey;
2564 DWORD res;
2566 static BOOL has_url = FALSE;
2567 static char url[2048];
2569 if(!disable && !has_url)
2570 return;
2572 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
2573 if(res != ERROR_SUCCESS)
2574 return;
2576 if(disable) {
2577 DWORD type, size = sizeof(url);
2579 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
2580 if(res == ERROR_SUCCESS && type == REG_SZ)
2581 has_url = TRUE;
2583 RegDeleteValue(hkey, "GeckoUrl");
2584 }else {
2585 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
2588 RegCloseKey(hkey);
2591 START_TEST(url)
2593 gecko_installer_workaround(TRUE);
2595 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2596 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2597 thread_id = GetCurrentThreadId();
2598 create_file();
2600 test_create();
2601 test_CreateAsyncBindCtx();
2602 test_CreateAsyncBindCtxEx();
2604 if(test_RegisterBindStatusCallback()) {
2605 test_BindToStorage_fail();
2607 trace("synchronous http test (COM not initialised)...\n");
2608 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2610 CoInitialize(NULL);
2612 trace("synchronous http test...\n");
2613 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2615 trace("synchronous http test (to object)...\n");
2616 test_BindToObject(HTTP_TEST, FALSE);
2618 trace("synchronous file test...\n");
2619 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2621 trace("synchronous file test (to object)...\n");
2622 test_BindToObject(FILE_TEST, FALSE);
2624 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2626 trace("http test...\n");
2627 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2629 trace("http test (to file)...\n");
2630 test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE);
2632 trace("http test (to object)...\n");
2633 test_BindToObject(HTTP_TEST, FALSE);
2635 trace("http test (short response)...\n");
2636 http_is_first = TRUE;
2637 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
2638 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2640 trace("http test (short response, to object)...\n");
2641 test_BindToObject(HTTP_TEST, FALSE);
2643 trace("emulated http test...\n");
2644 test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM);
2646 trace("emulated http test (to object)...\n");
2647 test_BindToObject(HTTP_TEST, TRUE);
2649 trace("emulated http test (to file)...\n");
2650 test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE);
2652 trace("asynchronous https test...\n");
2653 test_BindToStorage(HTTPS_TEST, FALSE, TYMED_ISTREAM);
2655 trace("emulated https test...\n");
2656 test_BindToStorage(HTTPS_TEST, TRUE, TYMED_ISTREAM);
2658 trace("about test...\n");
2659 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM);
2661 trace("about test (to file)...\n");
2662 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE);
2664 trace("about test (to object)...\n");
2665 test_BindToObject(ABOUT_TEST, FALSE);
2667 trace("emulated about test...\n");
2668 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM);
2670 trace("emulated about test (to file)...\n");
2671 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE);
2673 trace("emulated about test (to object)...\n");
2674 test_BindToObject(ABOUT_TEST, TRUE);
2676 trace("file test...\n");
2677 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2679 trace("file test (to file)...\n");
2680 test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE);
2682 trace("file test (to object)...\n");
2683 test_BindToObject(FILE_TEST, FALSE);
2685 trace("emulated file test...\n");
2686 test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM);
2688 trace("emulated file test (to file)...\n");
2689 test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE);
2691 trace("emulated file test (to object)...\n");
2692 test_BindToObject(FILE_TEST, TRUE);
2694 trace("emulated its test...\n");
2695 test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM);
2697 trace("emulated its test (to file)...\n");
2698 test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE);
2700 trace("emulated mk test...\n");
2701 test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM);
2703 trace("test URLDownloadToFile for file protocol...\n");
2704 test_URLDownloadToFile(FILE_TEST, FALSE);
2706 trace("test URLDownloadToFile for emulated file protocol...\n");
2707 test_URLDownloadToFile(FILE_TEST, TRUE);
2709 trace("test URLDownloadToFile for http protocol...\n");
2710 test_URLDownloadToFile(HTTP_TEST, FALSE);
2712 trace("test failures...\n");
2713 test_BindToStorage_fail();
2716 DeleteFileA(wszIndexHtmlA);
2717 CloseHandle(complete_event);
2718 CloseHandle(complete_event2);
2719 CoUninitialize();
2721 gecko_installer_workaround(FALSE);