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
34 #include "wine/test.h"
36 #define DEFINE_EXPECT(func) \
37 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
39 #define SET_EXPECT(func) \
40 expect_ ## func = TRUE
42 #define CHECK_EXPECT2(func) \
44 ok(expect_ ##func, "unexpected call " #func "\n"); \
45 called_ ## func = TRUE; \
48 #define CHECK_EXPECT(func) \
50 CHECK_EXPECT2(func); \
51 expect_ ## func = FALSE; \
54 #define CHECK_CALLED(func) \
56 ok(called_ ## func, "expected " #func "\n"); \
57 expect_ ## func = called_ ## func = FALSE; \
60 #define CHECK_NOT_CALLED(func) \
62 ok(!called_ ## func, "unexpected " #func "\n"); \
63 expect_ ## func = called_ ## func = FALSE; \
66 #define CLEAR_CALLED(func) \
67 expect_ ## func = called_ ## func = FALSE
69 DEFINE_EXPECT(QueryInterface_IServiceProvider);
70 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
71 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
72 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
73 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
74 DEFINE_EXPECT(QueryInterface_IAuthenticate);
75 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
76 DEFINE_EXPECT(QueryService_IAuthenticate);
77 DEFINE_EXPECT(QueryService_IInternetProtocol);
78 DEFINE_EXPECT(QueryService_IInternetBindInfo);
79 DEFINE_EXPECT(BeginningTransaction);
80 DEFINE_EXPECT(OnResponse);
81 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
82 DEFINE_EXPECT(GetRootSecurityId);
83 DEFINE_EXPECT(GetBindInfo);
84 DEFINE_EXPECT(OnStartBinding);
85 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
86 DEFINE_EXPECT(OnProgress_CONNECTING);
87 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
88 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
89 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
90 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
91 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
92 DEFINE_EXPECT(OnProgress_CLASSIDAVAILABLE);
93 DEFINE_EXPECT(OnProgress_BEGINSYNCOPERATION);
94 DEFINE_EXPECT(OnProgress_ENDSYNCOPERATION);
95 DEFINE_EXPECT(OnStopBinding);
96 DEFINE_EXPECT(OnDataAvailable);
97 DEFINE_EXPECT(OnObjectAvailable);
100 DEFINE_EXPECT(LockRequest);
101 DEFINE_EXPECT(Terminate);
102 DEFINE_EXPECT(UnlockRequest);
103 DEFINE_EXPECT(Continue);
105 static const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
106 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
108 static const WCHAR WINE_ABOUT_URL[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
109 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
110 static const WCHAR SHORT_RESPONSE_URL[] =
111 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
112 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
113 'p','o','s','t','t','e','s','t','.','p','h','p',0};
114 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
115 static WCHAR INDEX_HTML[MAX_PATH];
116 static const WCHAR ITS_URL[] =
117 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
118 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
119 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
121 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
123 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
125 static const WCHAR wszWineHQSite[] =
126 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
127 static const WCHAR wszWineHQIP[] =
128 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
129 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
131 static BOOL stopped_binding = FALSE, emulate_protocol = FALSE,
132 data_available = FALSE, http_is_first = TRUE;
133 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id;
134 static CHAR mime_type[512];
135 static IInternetProtocolSink *protocol_sink = NULL;
136 static HANDLE complete_event, complete_event2;
138 extern IID IID_IBindStatusCallbackHolder;
140 static LPCWSTR urls[] = {
162 static const char *debugstr_guid(REFIID riid)
166 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
167 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
168 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
169 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
174 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
177 IMoniker *mon1 = NULL;
178 IMoniker *mon2 = NULL;
180 hr = CreateURLMoniker(NULL, url1, &mon1);
181 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
183 hr = CreateURLMoniker(mon1, url2, &mon2);
184 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
186 if(mon1) IMoniker_Release(mon1);
187 if(mon2) IMoniker_Release(mon2);
190 static void test_create(void)
192 test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
195 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
197 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
203 return E_NOINTERFACE;
206 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
211 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
216 static DWORD WINAPI thread_proc(PVOID arg)
218 PROTOCOLDATA protocoldata;
221 SET_EXPECT(OnProgress_FINDINGRESOURCE);
222 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
223 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
224 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
225 WaitForSingleObject(complete_event, INFINITE);
226 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
228 SET_EXPECT(OnProgress_CONNECTING);
229 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
230 BINDSTATUS_CONNECTING, wszWineHQIP);
231 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
232 WaitForSingleObject(complete_event, INFINITE);
233 CHECK_CALLED(OnProgress_CONNECTING);
235 SET_EXPECT(OnProgress_SENDINGREQUEST);
236 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
237 BINDSTATUS_SENDINGREQUEST, NULL);
238 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
239 WaitForSingleObject(complete_event, INFINITE);
240 CHECK_CALLED(OnProgress_SENDINGREQUEST);
242 SET_EXPECT(Continue);
244 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
245 ok(hres == S_OK, "Switch failed: %08x\n", hres);
246 WaitForSingleObject(complete_event, INFINITE);
247 CHECK_CALLED(Continue);
249 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
250 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
251 CHECK_CALLED(LockRequest);
252 CHECK_CALLED(OnDataAvailable);
254 SET_EXPECT(Continue);
256 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
257 ok(hres == S_OK, "Switch failed: %08x\n", hres);
258 WaitForSingleObject(complete_event, INFINITE);
259 CHECK_CALLED(Continue);
261 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
262 CHECK_CALLED(OnDataAvailable);
264 SET_EXPECT(Continue);
266 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
267 ok(hres == S_OK, "Switch failed: %08x\n", hres);
268 WaitForSingleObject(complete_event, INFINITE);
269 CHECK_CALLED(Continue);
271 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
272 CHECK_CALLED(OnDataAvailable);
274 SET_EXPECT(Continue);
276 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
277 ok(hres == S_OK, "Switch failed: %08x\n", hres);
278 WaitForSingleObject(complete_event, INFINITE);
279 CHECK_CALLED(Continue);
281 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
282 CHECK_CALLED(OnDataAvailable);
283 CHECK_CALLED(OnStopBinding);
285 SetEvent(complete_event2);
290 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
291 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
292 DWORD grfPI, DWORD dwReserved)
294 BINDINFO bindinfo, bi = {sizeof(bi), 0};
295 DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
303 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url\n");
304 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
305 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
306 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
307 ok(dwReserved == 0, "dwReserved=%d, expected 0\n", dwReserved);
309 memset(&bindinfo, 0, sizeof(bindinfo));
310 bindinfo.cbSize = sizeof(bindinfo);
311 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
312 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
314 if(test_protocol == FILE_TEST || test_protocol == MK_TEST || test_protocol == HTTP_TEST) {
315 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
317 "bindf=%08x\n", bindf);
319 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA|
320 BINDF_FROMURLMON|BINDF_NEEDFILE),
321 "bindf=%08x\n", bindf);
324 ok(!memcmp(&bindinfo, &bi, sizeof(bindinfo)), "wrong bindinfo\n");
326 switch(test_protocol) {
328 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
329 BINDSTATUS_DIRECTBIND, NULL);
331 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
335 SET_EXPECT(OnProgress_SENDINGREQUEST);
336 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
337 BINDSTATUS_SENDINGREQUEST, &null_char);
339 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
340 CHECK_CALLED(OnProgress_SENDINGREQUEST);
345 if(test_protocol == HTTP_TEST) {
346 IServiceProvider *service_provider;
347 IHttpNegotiate *http_negotiate;
348 IHttpNegotiate2 *http_negotiate2;
349 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
350 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
352 DWORD fetched = 256, size = 100;
354 static const WCHAR wszMimes[] = {'*','/','*',0};
356 SET_EXPECT(QueryInterface_IInternetBindInfo);
357 SET_EXPECT(QueryService_IInternetBindInfo);
358 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
361 CHECK_CALLED(QueryInterface_IInternetBindInfo);
362 CHECK_CALLED(QueryService_IInternetBindInfo);
364 ok(hres == E_NOINTERFACE,
365 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
366 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
367 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
369 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
370 accept_mimes, 256, &fetched);
372 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
373 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
374 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
376 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
377 NULL, 256, &fetched);
378 ok(hres == E_INVALIDARG,
379 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
381 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
382 accept_mimes, 256, NULL);
383 ok(hres == E_INVALIDARG,
384 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
386 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
387 (void**)&service_provider);
388 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
390 SET_EXPECT(QueryInterface_IHttpNegotiate);
391 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
392 &IID_IHttpNegotiate, (void**)&http_negotiate);
393 CHECK_CALLED(QueryInterface_IHttpNegotiate);
394 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
396 SET_EXPECT(BeginningTransaction);
397 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
398 NULL, 0, &additional_headers);
399 CHECK_CALLED(BeginningTransaction);
400 IHttpNegotiate_Release(http_negotiate);
401 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
402 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
404 SET_EXPECT(QueryInterface_IHttpNegotiate2);
405 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
406 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
407 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
408 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
411 SET_EXPECT(GetRootSecurityId);
412 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
413 CHECK_CALLED(GetRootSecurityId);
414 IHttpNegotiate2_Release(http_negotiate2);
415 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
416 ok(size == 13, "size=%d\n", size);
418 IServiceProvider_Release(service_provider);
420 IInternetProtocolSink_AddRef(pOIProtSink);
421 protocol_sink = pOIProtSink;
422 CreateThread(NULL, 0, thread_proc, NULL, 0, NULL);
427 if(test_protocol == FILE_TEST) {
428 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
429 BINDSTATUS_CACHEFILENAMEAVAILABLE, &null_char);
431 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
433 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
434 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
435 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
437 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
438 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
440 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
441 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
443 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
446 if(test_protocol == ABOUT_TEST)
447 bscf |= BSCF_DATAFULLYAVAILABLE;
448 if(test_protocol == ITS_TEST)
449 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
452 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
453 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
454 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
455 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
456 SET_EXPECT(LockRequest);
457 SET_EXPECT(OnDataAvailable);
458 SET_EXPECT(OnStopBinding);
460 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
461 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
464 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
465 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
466 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
467 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
468 CHECK_CALLED(LockRequest);
469 CHECK_CALLED(OnDataAvailable);
470 CHECK_CALLED(OnStopBinding);
472 if(test_protocol == ITS_TEST) {
474 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
475 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
479 SET_EXPECT(Terminate);
480 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
481 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
482 CHECK_CALLED(Terminate);
487 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
488 PROTOCOLDATA *pProtocolData)
493 CHECK_EXPECT(Continue);
495 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
497 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
503 IServiceProvider *service_provider;
504 IHttpNegotiate *http_negotiate;
505 static WCHAR header[] = {'?',0};
507 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
508 (void**)&service_provider);
509 ok(hres == S_OK, "Could not get IServiceProvicder\n");
511 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
512 &IID_IHttpNegotiate, (void**)&http_negotiate);
513 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
515 SET_EXPECT(OnResponse);
516 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
517 CHECK_CALLED(OnResponse);
518 IHttpNegotiate_Release(http_negotiate);
519 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
521 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
522 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
524 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
526 bscf |= BSCF_FIRSTDATANOTIFICATION;
531 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
535 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
536 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
541 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
542 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
543 SET_EXPECT(LockRequest);
546 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
549 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
550 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
552 SET_EXPECT(OnDataAvailable);
554 SET_EXPECT(OnStopBinding);
559 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
562 ok(0, "unexpected call\n");
566 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
568 CHECK_EXPECT(Terminate);
570 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
573 IInternetProtocolSink_Release(protocol_sink);
574 protocol_sink = NULL;
580 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
582 ok(0, "unexpected call\n");
586 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
588 ok(0, "unexpected call\n");
592 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
593 ULONG cb, ULONG *pcbRead)
595 static const char data[] = "<HTML></HTML>";
599 if(test_protocol == HTTP_TEST) {
602 static BOOL pending = TRUE;
624 hres = IInternetProtocolSink_ReportData(protocol_sink,
625 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
626 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
628 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
629 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
643 ok(pv != NULL, "pv == NULL\n");
644 ok(cb != 0, "cb == 0\n");
645 ok(pcbRead != NULL, "pcbRead == NULL\n");
647 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
648 read += *pcbRead = sizeof(data)-1;
651 memcpy(pv, data, sizeof(data));
656 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
657 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
659 ok(0, "unexpected call\n");
663 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
665 CHECK_EXPECT(LockRequest);
669 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
671 CHECK_EXPECT(UnlockRequest);
675 static const IInternetProtocolVtbl ProtocolVtbl = {
676 Protocol_QueryInterface,
687 Protocol_LockRequest,
688 Protocol_UnlockRequest
691 static IInternetProtocol Protocol = { &ProtocolVtbl };
693 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
695 if(IsEqualGUID(&IID_IUnknown, riid)
696 || IsEqualGUID(&IID_IHttpNegotiate, riid)
697 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
702 ok(0, "unexpected call\n");
703 return E_NOINTERFACE;
706 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
711 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
716 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
717 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
719 CHECK_EXPECT(BeginningTransaction);
721 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
723 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
724 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
725 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
726 if(pszAdditionalHeaders)
727 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
732 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
733 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
735 CHECK_EXPECT(OnResponse);
737 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
739 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
740 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
741 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
742 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
743 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
744 if(pszAdditionalRequestHeaders)
745 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
750 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
751 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
753 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
755 CHECK_EXPECT(GetRootSecurityId);
757 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
759 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
760 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
761 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
763 if(pbSecurityId == (void*)0xdeadbeef)
767 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
768 *pcbSecurityId = sizeof(sec_id);
772 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
777 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
778 HttpNegotiate_QueryInterface,
779 HttpNegotiate_AddRef,
780 HttpNegotiate_Release,
781 HttpNegotiate_BeginningTransaction,
782 HttpNegotiate_OnResponse,
783 HttpNegotiate_GetRootSecurityId
786 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
788 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
790 ok(0, "unexpected call\n");
791 return E_NOINTERFACE;
794 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
799 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
804 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
805 REFGUID guidService, REFIID riid, void **ppv)
807 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
808 CHECK_EXPECT(QueryService_IAuthenticate);
812 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
813 CHECK_EXPECT2(QueryService_IInternetProtocol);
817 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
818 CHECK_EXPECT(QueryService_IInternetBindInfo);
822 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
823 return E_NOINTERFACE;
826 static IServiceProviderVtbl ServiceProviderVtbl = {
827 ServiceProvider_QueryInterface,
828 ServiceProvider_AddRef,
829 ServiceProvider_Release,
830 ServiceProvider_QueryService
833 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
835 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
837 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
839 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
840 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
841 if(emulate_protocol) {
845 return E_NOINTERFACE;
848 else if (IsEqualGUID(&IID_IServiceProvider, riid))
850 CHECK_EXPECT2(QueryInterface_IServiceProvider);
851 *ppv = &ServiceProvider;
854 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
856 CHECK_EXPECT(QueryInterface_IHttpNegotiate);
857 *ppv = &HttpNegotiate;
860 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
862 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
863 *ppv = &HttpNegotiate;
866 else if (IsEqualGUID(&IID_IAuthenticate, riid))
868 CHECK_EXPECT(QueryInterface_IAuthenticate);
869 return E_NOINTERFACE;
871 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
873 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
877 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
879 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
880 return E_NOINTERFACE;
882 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
885 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
889 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
892 return E_NOINTERFACE;
895 static ULONG WINAPI statusclb_AddRef(IBindStatusCallback *iface)
900 static ULONG WINAPI statusclb_Release(IBindStatusCallback *iface)
905 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved,
911 CHECK_EXPECT(OnStartBinding);
913 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
915 ok(pib != NULL, "pib should not be NULL\n");
916 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
918 if(pib == (void*)0xdeadbeef)
921 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
922 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
924 IMoniker_Release(mon);
929 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
931 ok(0, "unexpected call\n");
935 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
937 ok(0, "unexpected call\n");
941 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
942 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
944 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
946 switch(ulStatusCode) {
947 case BINDSTATUS_FINDINGRESOURCE:
948 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
949 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
950 SetEvent(complete_event);
952 case BINDSTATUS_CONNECTING:
953 CHECK_EXPECT(OnProgress_CONNECTING);
954 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
955 SetEvent(complete_event);
957 case BINDSTATUS_SENDINGREQUEST:
958 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
959 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
960 SetEvent(complete_event);
962 case BINDSTATUS_MIMETYPEAVAILABLE:
963 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
964 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
966 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
968 case BINDSTATUS_BEGINDOWNLOADDATA:
969 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
970 ok(szStatusText != NULL, "szStatusText == NULL\n");
972 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText\n");
973 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
975 download_state = DOWNLOADING;
977 case BINDSTATUS_DOWNLOADINGDATA:
978 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
979 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
982 case BINDSTATUS_ENDDOWNLOADDATA:
983 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
984 ok(szStatusText != NULL, "szStatusText == NULL\n");
986 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText\n");
987 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
989 download_state = END_DOWNLOAD;
991 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
992 ok(szStatusText != NULL, "szStatusText == NULL\n");
993 if(szStatusText && test_protocol == FILE_TEST)
994 ok(!lstrcmpW(INDEX_HTML+7, szStatusText), "wrong szStatusText\n");
996 case BINDSTATUS_CLASSIDAVAILABLE:
1000 CHECK_EXPECT(OnProgress_CLASSIDAVAILABLE);
1001 hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
1002 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1003 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1004 "Expected clsid to be CLSID_HTMLDocument instead of {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
1005 clsid.Data1, clsid.Data2, clsid.Data3,
1006 clsid.Data4[0], clsid.Data4[1], clsid.Data4[2], clsid.Data4[3],
1007 clsid.Data4[4], clsid.Data4[5], clsid.Data4[6], clsid.Data4[7]);
1010 case BINDSTATUS_BEGINSYNCOPERATION:
1011 CHECK_EXPECT(OnProgress_BEGINSYNCOPERATION);
1012 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1014 case BINDSTATUS_ENDSYNCOPERATION:
1015 CHECK_EXPECT(OnProgress_ENDSYNCOPERATION);
1016 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1019 ok(0, "unexpexted code %d\n", ulStatusCode);
1024 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
1026 CHECK_EXPECT(OnStopBinding);
1028 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1030 stopped_binding = TRUE;
1032 /* ignore DNS failure */
1033 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1036 ok(hresult == S_OK, "binding failed: %08x\n", hresult);
1037 ok(szError == NULL, "szError should be NULL\n");
1039 if(test_protocol == HTTP_TEST && emulate_protocol) {
1040 SetEvent(complete_event);
1041 WaitForSingleObject(complete_event2, INFINITE);
1047 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1051 CHECK_EXPECT(GetBindInfo);
1053 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1056 cbSize = pbindinfo->cbSize;
1057 memset(pbindinfo, 0, cbSize);
1058 pbindinfo->cbSize = cbSize;
1063 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
1064 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1071 CHECK_EXPECT2(OnDataAvailable);
1073 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1075 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1076 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1078 data_available = TRUE;
1080 ok(pformatetc != NULL, "pformatetx == NULL\n");
1084 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1085 "GetClipboardFormatName failed, error %d\n", GetLastError());
1086 ok(!lstrcmp(clipfmt, mime_type), "clipformat != mime_type, \"%s\" != \"%s\"\n",
1087 clipfmt, mime_type);
1089 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1091 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1092 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1093 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1094 ok(pformatetc->tymed == TYMED_ISTREAM, "tymed=%u\n", pformatetc->tymed);
1097 ok(pstgmed != NULL, "stgmeg == NULL\n");
1099 ok(pstgmed->tymed == TYMED_ISTREAM, "tymed=%u\n", pstgmed->tymed);
1100 ok(U(*pstgmed).pstm != NULL, "pstm == NULL\n");
1101 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1104 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1105 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1106 ok(hres == STG_E_ACCESSDENIED,
1107 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1109 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1110 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1112 hres = IStream_Revert(U(*pstgmed).pstm);
1113 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1116 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1118 if(U(*pstgmed).pstm) {
1119 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1120 while(hres == S_OK);
1121 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1124 if(test_protocol == HTTP_TEST && emulate_protocol && prot_state < 4)
1125 SetEvent(complete_event);
1130 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
1132 CHECK_EXPECT(OnObjectAvailable);
1136 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
1137 statusclb_QueryInterface,
1140 statusclb_OnStartBinding,
1141 statusclb_GetPriority,
1142 statusclb_OnLowResource,
1143 statusclb_OnProgress,
1144 statusclb_OnStopBinding,
1145 statusclb_GetBindInfo,
1146 statusclb_OnDataAvailable,
1147 statusclb_OnObjectAvailable
1150 static IBindStatusCallback bsc = { &BindStatusCallbackVtbl };
1152 static void test_CreateAsyncBindCtx(void)
1154 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1160 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1161 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1162 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1164 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1165 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1167 SET_EXPECT(QueryInterface_IServiceProvider);
1168 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1169 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1170 CHECK_CALLED(QueryInterface_IServiceProvider);
1172 bindopts.cbStruct = sizeof(bindopts);
1173 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1174 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1175 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1176 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1177 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1178 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1180 ok(bindopts.dwTickCountDeadline == 0,
1181 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1183 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1184 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1186 IUnknown_Release(unk);
1188 ref = IBindCtx_Release(bctx);
1189 ok(ref == 0, "bctx should be destroyed here\n");
1192 static void test_CreateAsyncBindCtxEx(void)
1194 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1199 static WCHAR testW[] = {'t','e','s','t',0};
1201 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1202 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1204 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1205 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1207 if(SUCCEEDED(hres)) {
1208 bindopts.cbStruct = sizeof(bindopts);
1209 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1210 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1211 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1212 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1213 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1214 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1216 ok(bindopts.dwTickCountDeadline == 0,
1217 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1219 IBindCtx_Release(bctx);
1222 CreateBindCtx(0, &bctx_arg);
1223 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1224 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1226 if(SUCCEEDED(hres)) {
1227 bindopts.cbStruct = sizeof(bindopts);
1228 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1229 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1230 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1231 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1232 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1233 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1235 ok(bindopts.dwTickCountDeadline == 0,
1236 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1238 IBindCtx_Release(bctx);
1241 IBindCtx_Release(bctx_arg);
1243 SET_EXPECT(QueryInterface_IServiceProvider);
1244 hres = CreateAsyncBindCtxEx(NULL, 0, &bsc, NULL, &bctx, 0);
1245 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1246 CHECK_CALLED(QueryInterface_IServiceProvider);
1248 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1249 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1251 IUnknown_Release(unk);
1253 IBindCtx_Release(bctx);
1255 hres = CreateBindCtx(0, &bctx2);
1256 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1258 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1259 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1261 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1262 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1264 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1265 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1266 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1268 IBindCtx_Release(bctx);
1269 IBindCtx_Release(bctx2);
1272 static void test_bscholder(IBindStatusCallback *holder)
1274 IServiceProvider *serv_prov;
1275 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1276 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1277 IAuthenticate *authenticate, *authenticate_serv;
1278 IInternetProtocol *protocol;
1279 BINDINFO bindinfo = {sizeof(bindinfo)};
1284 static const WCHAR emptyW[] = {0};
1286 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
1287 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
1290 SET_EXPECT(GetBindInfo);
1291 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
1292 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1293 CHECK_CALLED(GetBindInfo);
1295 SET_EXPECT(OnStartBinding);
1296 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
1297 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1298 CHECK_CALLED(OnStartBinding);
1300 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
1301 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
1303 wstr = (void*)0xdeadbeef;
1304 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol], (void*)0xdeadbeef, 0xff, &wstr);
1305 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1306 ok(wstr == NULL, "wstr = %p\n", wstr);
1308 SET_EXPECT(QueryInterface_IHttpNegotiate);
1309 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1310 (void**)&http_negotiate_serv);
1311 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1312 CHECK_CALLED(QueryInterface_IHttpNegotiate);
1314 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1316 wstr = (void*)0xdeadbeef;
1317 SET_EXPECT(BeginningTransaction);
1318 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
1319 CHECK_CALLED(BeginningTransaction);
1320 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
1321 ok(wstr == NULL, "wstr = %p\n", wstr);
1323 IHttpNegotiate_Release(http_negotiate_serv);
1325 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
1326 (void**)&http_negotiate_serv);
1327 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
1328 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
1329 IHttpNegotiate_Release(http_negotiate_serv);
1331 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
1332 ok(hres == S_OK, "Could not get IHttpNegotiate2 interface: %08x\n", hres);
1334 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1335 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x\n", hres);
1337 IHttpNegotiate_Release(http_negotiate2);
1339 SET_EXPECT(QueryInterface_IHttpNegotiate2);
1340 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
1341 (void**)&http_negotiate2_serv);
1342 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
1343 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
1344 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
1346 SET_EXPECT(GetRootSecurityId);
1347 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1348 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
1349 CHECK_CALLED(GetRootSecurityId);
1351 IHttpNegotiate_Release(http_negotiate2_serv);
1353 SET_EXPECT(OnProgress_FINDINGRESOURCE);
1354 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
1355 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
1356 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
1358 SET_EXPECT(OnResponse);
1359 wstr = (void*)0xdeadbeef;
1360 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
1361 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
1362 CHECK_CALLED(OnResponse);
1364 IHttpNegotiate_Release(http_negotiate);
1366 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
1367 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
1369 SET_EXPECT(QueryInterface_IAuthenticate);
1370 SET_EXPECT(QueryService_IAuthenticate);
1371 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1372 (void**)&authenticate_serv);
1373 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1374 CHECK_CALLED(QueryInterface_IAuthenticate);
1375 CHECK_CALLED(QueryService_IAuthenticate);
1376 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1377 IAuthenticate_Release(authenticate_serv);
1379 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
1380 (void**)&authenticate_serv);
1381 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
1382 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
1384 IAuthenticate_Release(authenticate);
1385 IAuthenticate_Release(authenticate_serv);
1387 SET_EXPECT(OnStopBinding);
1388 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
1389 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1390 CHECK_CALLED(OnStopBinding);
1392 SET_EXPECT(QueryInterface_IInternetProtocol);
1393 SET_EXPECT(QueryService_IInternetProtocol);
1394 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
1396 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
1397 CHECK_CALLED(QueryInterface_IInternetProtocol);
1398 CHECK_CALLED(QueryService_IInternetProtocol);
1400 IServiceProvider_Release(serv_prov);
1403 static void test_RegisterBindStatusCallback(void)
1405 IBindStatusCallback *prevbsc, *clb;
1410 hres = CreateBindCtx(0, &bindctx);
1411 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
1413 SET_EXPECT(QueryInterface_IServiceProvider);
1415 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
1416 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1418 SET_EXPECT(QueryInterface_IBindStatusCallback);
1419 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
1420 prevbsc = (void*)0xdeadbeef;
1421 hres = RegisterBindStatusCallback(bindctx, &bsc, &prevbsc, 0);
1422 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1423 ok(prevbsc == &bsc, "prevbsc=%p\n", prevbsc);
1424 CHECK_CALLED(QueryInterface_IBindStatusCallback);
1425 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
1427 CHECK_CALLED(QueryInterface_IServiceProvider);
1429 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1430 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1432 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
1433 IUnknown_Release(unk);
1434 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
1435 ok(clb != &bsc, "bsc == clb\n");
1437 test_bscholder(clb);
1439 IBindStatusCallback_Release(clb);
1441 hres = RevokeBindStatusCallback(bindctx, &bsc);
1442 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1444 unk = (void*)0xdeadbeef;
1445 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
1446 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
1447 ok(unk == NULL, "unk != NULL\n");
1450 IUnknown_Release(unk);
1452 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
1453 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
1455 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
1456 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1458 hres = RevokeBindStatusCallback(bindctx, NULL);
1459 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
1461 IBindCtx_Release(bindctx);
1464 static void test_BindToStorage(int protocol, BOOL emul)
1468 LPOLESTR display_name;
1471 IBindStatusCallback *previousclb;
1472 IUnknown *unk = (IUnknown*)0x00ff00ff;
1475 test_protocol = protocol;
1476 emulate_protocol = emul;
1477 download_state = BEFORE_DOWNLOAD;
1478 stopped_binding = FALSE;
1479 data_available = FALSE;
1482 SET_EXPECT(QueryInterface_IServiceProvider);
1483 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1484 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
1485 CHECK_CALLED(QueryInterface_IServiceProvider);
1489 SET_EXPECT(QueryInterface_IServiceProvider);
1490 hres = RegisterBindStatusCallback(bctx, &bsc, &previousclb, 0);
1491 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1492 ok(previousclb == &bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
1493 CHECK_CALLED(QueryInterface_IServiceProvider);
1495 IBindStatusCallback_Release(previousclb);
1497 hres = CreateURLMoniker(NULL, urls[test_protocol], &mon);
1498 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
1500 IBindCtx_Release(bctx);
1504 if(test_protocol == FILE_TEST && INDEX_HTML[7] == '/')
1505 memmove(INDEX_HTML+7, INDEX_HTML+8, lstrlenW(INDEX_HTML+7)*sizeof(WCHAR));
1507 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
1508 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
1510 IBinding_Release(bind);
1512 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
1513 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
1514 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
1515 CoTaskMemFree(display_name);
1517 SET_EXPECT(GetBindInfo);
1518 SET_EXPECT(QueryInterface_IInternetProtocol);
1519 if(!emulate_protocol)
1520 SET_EXPECT(QueryService_IInternetProtocol);
1521 SET_EXPECT(OnStartBinding);
1522 if(emulate_protocol) {
1524 if(test_protocol == HTTP_TEST)
1525 SET_EXPECT(Terminate);
1526 SET_EXPECT(UnlockRequest);
1528 if(test_protocol == HTTP_TEST) {
1529 SET_EXPECT(QueryInterface_IHttpNegotiate);
1530 SET_EXPECT(BeginningTransaction);
1531 SET_EXPECT(QueryInterface_IHttpNegotiate2);
1532 SET_EXPECT(GetRootSecurityId);
1533 SET_EXPECT(OnProgress_FINDINGRESOURCE);
1534 SET_EXPECT(OnProgress_CONNECTING);
1536 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
1537 SET_EXPECT(OnProgress_SENDINGREQUEST);
1538 if(test_protocol == HTTP_TEST)
1539 SET_EXPECT(OnResponse);
1540 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1541 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1542 if(test_protocol == HTTP_TEST)
1543 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1544 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1545 SET_EXPECT(OnDataAvailable);
1546 SET_EXPECT(OnStopBinding);
1549 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
1550 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1552 trace( "Network unreachable, skipping tests\n" );
1555 if (!SUCCEEDED(hres)) return;
1557 if((bindf & BINDF_ASYNCHRONOUS) && !data_available) {
1558 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
1559 ok(unk == NULL, "istr should be NULL\n");
1561 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
1562 ok(unk != NULL, "unk == NULL\n");
1565 IUnknown_Release(unk);
1567 while((bindf & BINDF_ASYNCHRONOUS) &&
1568 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
1569 TranslateMessage(&msg);
1570 DispatchMessage(&msg);
1573 CHECK_CALLED(GetBindInfo);
1574 CHECK_CALLED(QueryInterface_IInternetProtocol);
1575 if(!emulate_protocol)
1576 CHECK_CALLED(QueryService_IInternetProtocol);
1577 CHECK_CALLED(OnStartBinding);
1578 if(emulate_protocol) {
1579 CHECK_CALLED(Start);
1580 if(test_protocol == HTTP_TEST)
1581 CHECK_CALLED(Terminate);
1582 CHECK_CALLED(UnlockRequest);
1584 if(test_protocol == HTTP_TEST) {
1585 CHECK_CALLED(QueryInterface_IHttpNegotiate);
1586 CHECK_CALLED(BeginningTransaction);
1587 /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
1588 * called on WinXP but not on Win98 */
1589 CLEAR_CALLED(QueryInterface_IHttpNegotiate2);
1590 CLEAR_CALLED(GetRootSecurityId);
1592 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
1593 CHECK_CALLED(OnProgress_CONNECTING);
1595 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
1596 CHECK_NOT_CALLED(OnProgress_CONNECTING);
1599 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
1600 CHECK_CALLED(OnProgress_SENDINGREQUEST);
1601 if(test_protocol == HTTP_TEST)
1602 CHECK_CALLED(OnResponse);
1603 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
1604 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1605 if(test_protocol == HTTP_TEST)
1606 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
1607 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1608 CHECK_CALLED(OnDataAvailable);
1609 CHECK_CALLED(OnStopBinding);
1612 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
1613 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
1615 if(test_protocol == HTTP_TEST)
1616 http_is_first = FALSE;
1619 static void test_BindToObject(int protocol, BOOL emul)
1623 LPOLESTR display_name;
1626 IUnknown *unk = (IUnknown*)0x00ff00ff;
1629 test_protocol = protocol;
1630 emulate_protocol = emul;
1631 download_state = BEFORE_DOWNLOAD;
1632 stopped_binding = FALSE;
1633 data_available = FALSE;
1636 SET_EXPECT(QueryInterface_IServiceProvider);
1637 hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
1638 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
1641 CHECK_CALLED(QueryInterface_IServiceProvider);
1643 hres = CreateURLMoniker(NULL, urls[test_protocol], &mon);
1644 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
1646 IBindCtx_Release(bctx);
1650 if(test_protocol == FILE_TEST && INDEX_HTML[7] == '/')
1651 memmove(INDEX_HTML+7, INDEX_HTML+8, lstrlenW(INDEX_HTML+7)*sizeof(WCHAR));
1653 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
1654 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
1656 IBinding_Release(bind);
1658 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
1659 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
1660 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
1662 SET_EXPECT(GetBindInfo);
1663 SET_EXPECT(QueryInterface_IInternetProtocol);
1664 if(!emulate_protocol)
1665 SET_EXPECT(QueryService_IInternetProtocol);
1666 SET_EXPECT(OnStartBinding);
1667 if(emulate_protocol) {
1669 SET_EXPECT(UnlockRequest);
1671 if(test_protocol == HTTP_TEST) {
1672 SET_EXPECT(QueryInterface_IHttpNegotiate);
1673 SET_EXPECT(BeginningTransaction);
1674 SET_EXPECT(QueryInterface_IHttpNegotiate2);
1675 SET_EXPECT(GetRootSecurityId);
1676 SET_EXPECT(OnProgress_FINDINGRESOURCE);
1677 SET_EXPECT(OnProgress_CONNECTING);
1679 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
1680 SET_EXPECT(OnProgress_SENDINGREQUEST);
1681 if(test_protocol == HTTP_TEST)
1682 SET_EXPECT(OnResponse);
1683 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1684 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1685 if(test_protocol == HTTP_TEST)
1686 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1687 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1688 SET_EXPECT(OnProgress_CLASSIDAVAILABLE);
1689 SET_EXPECT(OnProgress_BEGINSYNCOPERATION);
1690 SET_EXPECT(OnProgress_ENDSYNCOPERATION);
1691 SET_EXPECT(OnObjectAvailable);
1692 SET_EXPECT(OnStopBinding);
1695 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
1696 if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1698 trace( "Network unreachable, skipping tests\n" );
1701 todo_wine ok(SUCCEEDED(hres), "IMoniker_BindToObject failed with error 0x%08x\n", hres);
1702 /* no point testing the calls if binding didn't even work */
1703 if (!SUCCEEDED(hres)) return;
1705 if((bindf & BINDF_ASYNCHRONOUS)) {
1706 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
1707 ok(unk == NULL, "istr should be NULL\n");
1709 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
1710 ok(unk != NULL, "unk == NULL\n");
1713 IUnknown_Release(unk);
1715 while((bindf & BINDF_ASYNCHRONOUS) &&
1716 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
1717 TranslateMessage(&msg);
1718 DispatchMessage(&msg);
1721 CHECK_CALLED(GetBindInfo);
1722 CHECK_CALLED(QueryInterface_IInternetProtocol);
1723 if(!emulate_protocol)
1724 CHECK_CALLED(QueryService_IInternetProtocol);
1725 CHECK_CALLED(OnStartBinding);
1726 if(emulate_protocol) {
1727 CHECK_CALLED(Start);
1728 CHECK_CALLED(UnlockRequest);
1730 if(test_protocol == HTTP_TEST) {
1731 CHECK_CALLED(QueryInterface_IHttpNegotiate);
1732 CHECK_CALLED(BeginningTransaction);
1733 /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
1734 * called on WinXP but not on Win98 */
1735 CLEAR_CALLED(QueryInterface_IHttpNegotiate2);
1736 CLEAR_CALLED(GetRootSecurityId);
1738 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
1739 CHECK_CALLED(OnProgress_CONNECTING);
1741 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
1742 CHECK_NOT_CALLED(OnProgress_CONNECTING);
1745 if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
1746 CHECK_CALLED(OnProgress_SENDINGREQUEST);
1747 if(test_protocol == HTTP_TEST)
1748 CHECK_CALLED(OnResponse);
1749 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
1750 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1751 if(test_protocol == HTTP_TEST)
1752 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
1753 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1754 CHECK_CALLED(OnProgress_CLASSIDAVAILABLE);
1755 CHECK_CALLED(OnProgress_BEGINSYNCOPERATION);
1756 CHECK_CALLED(OnProgress_ENDSYNCOPERATION);
1757 CHECK_CALLED(OnObjectAvailable);
1758 CHECK_CALLED(OnStopBinding);
1761 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
1762 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
1764 if(test_protocol == HTTP_TEST)
1765 http_is_first = FALSE;
1768 static void set_file_url(void)
1772 static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
1774 memcpy(INDEX_HTML, wszFile, sizeof(wszFile));
1775 len = sizeof(wszFile)/sizeof(WCHAR);
1776 INDEX_HTML[len++] = '/';
1777 len += GetCurrentDirectoryW(sizeof(INDEX_HTML)/sizeof(WCHAR)-len, INDEX_HTML+len);
1778 INDEX_HTML[len++] = '\\';
1779 memcpy(INDEX_HTML+len, wszIndexHtml, sizeof(wszIndexHtml));
1782 static void create_file(void)
1787 static const char html_doc[] = "<HTML></HTML>";
1789 file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
1790 FILE_ATTRIBUTE_NORMAL, NULL);
1791 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
1792 if(file == INVALID_HANDLE_VALUE)
1795 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
1801 static void test_BindToStorage_fail(void)
1803 IMoniker *mon = NULL;
1804 IBindCtx *bctx = NULL;
1808 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
1809 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
1813 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1814 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1816 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
1817 ok(hres == MK_E_SYNTAX, "hres=%08x, expected INET_E_SYNTAX\n", hres);
1819 IBindCtx_Release(bctx);
1821 IMoniker_Release(mon);
1826 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
1827 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
1828 thread_id = GetCurrentThreadId();
1831 test_CreateAsyncBindCtx();
1832 test_CreateAsyncBindCtxEx();
1833 test_RegisterBindStatusCallback();
1835 trace("synchronous http test (COM not initialised)...\n");
1836 test_BindToStorage(HTTP_TEST, FALSE);
1837 test_BindToStorage_fail();
1841 trace("synchronous http test...\n");
1842 test_BindToStorage(HTTP_TEST, FALSE);
1843 test_BindToObject(HTTP_TEST, FALSE);
1845 trace("synchronous file test...\n");
1847 test_BindToStorage(FILE_TEST, FALSE);
1848 test_BindToObject(FILE_TEST, FALSE);
1849 DeleteFileW(wszIndexHtml);
1851 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
1853 trace("http test...\n");
1854 test_BindToStorage(HTTP_TEST, FALSE);
1855 test_BindToObject(HTTP_TEST, FALSE);
1857 trace("http test (short response)...\n");
1858 http_is_first = TRUE;
1859 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
1860 test_BindToStorage(HTTP_TEST, FALSE);
1861 test_BindToObject(HTTP_TEST, FALSE);
1863 trace("emulated http test...\n");
1864 test_BindToStorage(HTTP_TEST, TRUE);
1866 trace("about test...\n");
1867 test_BindToStorage(ABOUT_TEST, FALSE);
1868 test_BindToObject(ABOUT_TEST, FALSE);
1870 trace("emulated about test...\n");
1871 test_BindToStorage(ABOUT_TEST, TRUE);
1873 trace("file test...\n");
1875 test_BindToStorage(FILE_TEST, FALSE);
1876 test_BindToObject(FILE_TEST, FALSE);
1877 DeleteFileW(wszIndexHtml);
1879 trace("emulated file test...\n");
1881 test_BindToStorage(FILE_TEST, TRUE);
1883 trace("emulated its test...\n");
1884 test_BindToStorage(ITS_TEST, TRUE);
1886 trace("emulated mk test...\n");
1887 test_BindToStorage(MK_TEST, TRUE);
1889 test_BindToStorage_fail();
1891 CloseHandle(complete_event);
1892 CloseHandle(complete_event2);