2004-05-03 22:07:03 +02:00
|
|
|
/*
|
|
|
|
* UrlMon URL tests
|
|
|
|
*
|
|
|
|
* Copyright 2004 Kevin Koltzau
|
2004-12-08 14:46:01 +01:00
|
|
|
* Copyright 2004 Jacek Caban
|
2004-05-03 22:07:03 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-05-03 22:07:03 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2004-08-11 21:43:45 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
2006-09-29 12:45:44 +02:00
|
|
|
#define CONST_VTABLE
|
2004-08-11 21:43:45 +02:00
|
|
|
|
2004-05-03 22:07:03 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "urlmon.h"
|
2006-09-21 11:45:32 +02:00
|
|
|
#include "wininet.h"
|
2004-05-03 22:07:03 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2005-09-16 20:46:29 +02:00
|
|
|
#define DEFINE_EXPECT(func) \
|
|
|
|
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
|
|
|
|
|
|
|
|
#define SET_EXPECT(func) \
|
|
|
|
expect_ ## func = TRUE
|
|
|
|
|
|
|
|
#define CHECK_EXPECT(func) \
|
2005-11-14 16:12:43 +01:00
|
|
|
do { \
|
2005-12-26 13:27:10 +01:00
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
2005-11-14 16:12:43 +01:00
|
|
|
expect_ ## func = FALSE; \
|
|
|
|
called_ ## func = TRUE; \
|
|
|
|
}while(0)
|
2005-09-16 20:46:29 +02:00
|
|
|
|
|
|
|
#define CHECK_EXPECT2(func) \
|
2005-11-14 16:12:43 +01:00
|
|
|
do { \
|
2005-12-26 13:27:10 +01:00
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
2005-11-14 16:12:43 +01:00
|
|
|
called_ ## func = TRUE; \
|
|
|
|
}while(0)
|
2005-09-16 20:46:29 +02:00
|
|
|
|
|
|
|
#define CHECK_CALLED(func) \
|
2005-11-14 16:12:43 +01:00
|
|
|
do { \
|
|
|
|
ok(called_ ## func, "expected " #func "\n"); \
|
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
2005-09-16 20:46:29 +02:00
|
|
|
|
|
|
|
DEFINE_EXPECT(GetBindInfo);
|
|
|
|
DEFINE_EXPECT(OnStartBinding);
|
|
|
|
DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
|
|
|
|
DEFINE_EXPECT(OnProgress_CONNECTING);
|
|
|
|
DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
|
|
|
|
DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
|
|
|
|
DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
|
|
|
|
DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
|
|
|
|
DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
|
|
|
|
DEFINE_EXPECT(OnStopBinding);
|
|
|
|
DEFINE_EXPECT(OnDataAvailable);
|
2005-11-14 16:12:43 +01:00
|
|
|
DEFINE_EXPECT(Start);
|
|
|
|
DEFINE_EXPECT(Read);
|
|
|
|
DEFINE_EXPECT(LockRequest);
|
|
|
|
DEFINE_EXPECT(Terminate);
|
|
|
|
DEFINE_EXPECT(UnlockRequest);
|
2005-09-16 20:46:29 +02:00
|
|
|
|
2004-12-08 14:46:01 +01:00
|
|
|
static const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
|
|
|
|
static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
|
2004-05-03 22:07:03 +02:00
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
static const WCHAR WINE_ABOUT_URL[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
|
|
|
|
'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
|
2005-11-14 16:12:43 +01:00
|
|
|
static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
|
2005-12-26 13:27:10 +01:00
|
|
|
static WCHAR INDEX_HTML[MAX_PATH];
|
2007-02-10 16:33:38 +01:00
|
|
|
static const WCHAR ITS_URL[] =
|
|
|
|
{'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
|
2007-02-10 16:34:41 +01:00
|
|
|
static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
|
|
|
|
't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
|
|
|
|
|
2007-02-10 16:33:38 +01:00
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2005-12-26 13:27:10 +01:00
|
|
|
static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
static BOOL stopped_binding = FALSE, emulate_protocol = FALSE;
|
|
|
|
static DWORD read = 0;
|
|
|
|
|
|
|
|
static const LPCWSTR urls[] = {
|
|
|
|
WINE_ABOUT_URL,
|
2005-12-26 13:27:10 +01:00
|
|
|
ABOUT_BLANK,
|
2007-02-10 16:33:38 +01:00
|
|
|
INDEX_HTML,
|
2007-02-10 16:34:41 +01:00
|
|
|
ITS_URL,
|
|
|
|
MK_URL
|
2005-11-14 16:12:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static enum {
|
|
|
|
HTTP_TEST,
|
2005-12-26 13:27:10 +01:00
|
|
|
ABOUT_TEST,
|
2007-02-10 16:33:38 +01:00
|
|
|
FILE_TEST,
|
2007-02-10 16:34:41 +01:00
|
|
|
ITS_TEST,
|
|
|
|
MK_TEST
|
2005-11-14 16:12:43 +01:00
|
|
|
} test_protocol;
|
2004-12-20 19:58:04 +01:00
|
|
|
|
2004-05-03 22:07:03 +02:00
|
|
|
static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IMoniker *mon1 = NULL;
|
|
|
|
IMoniker *mon2 = NULL;
|
|
|
|
|
|
|
|
hr = CreateURLMoniker(NULL, url1, &mon1);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
|
2004-05-03 22:07:03 +02:00
|
|
|
if(SUCCEEDED(hr)) {
|
|
|
|
hr = CreateURLMoniker(mon1, url2, &mon2);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
|
2004-05-03 22:07:03 +02:00
|
|
|
}
|
|
|
|
if(mon1) IMoniker_Release(mon1);
|
|
|
|
if(mon2) IMoniker_Release(mon2);
|
|
|
|
}
|
|
|
|
|
2005-06-17 12:11:37 +02:00
|
|
|
static void test_create(void)
|
2004-05-03 22:07:03 +02:00
|
|
|
{
|
|
|
|
test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
|
|
|
|
}
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
|
|
|
|
DWORD grfPI, DWORD dwReserved)
|
|
|
|
{
|
|
|
|
BINDINFO bindinfo, bi = {sizeof(bi), 0};
|
2005-12-26 13:27:10 +01:00
|
|
|
DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
|
|
|
|
WCHAR null_char = 0;
|
2005-11-14 16:12:43 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
|
|
|
|
|
|
|
|
CHECK_EXPECT(Start);
|
|
|
|
|
|
|
|
read = 0;
|
|
|
|
|
|
|
|
ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url\n");
|
|
|
|
ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
|
|
|
|
ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
|
|
|
|
ok(dwReserved == 0, "dwReserved=%d, expected 0\n", dwReserved);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
memset(&bindinfo, 0, sizeof(bindinfo));
|
|
|
|
bindinfo.cbSize = sizeof(bindinfo);
|
|
|
|
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
|
2005-12-26 13:27:10 +01:00
|
|
|
|
2007-02-10 16:34:41 +01:00
|
|
|
if(test_protocol == FILE_TEST || test_protocol == MK_TEST) {
|
2005-12-26 13:27:10 +01:00
|
|
|
ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
|
|
|
|
|BINDF_FROMURLMON),
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindf=%08x\n", bindf);
|
2005-12-26 13:27:10 +01:00
|
|
|
}else {
|
|
|
|
ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA|
|
|
|
|
BINDF_FROMURLMON|BINDF_NEEDFILE),
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindf=%08x\n", bindf);
|
2005-12-26 13:27:10 +01:00
|
|
|
}
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
ok(!memcmp(&bindinfo, &bi, sizeof(bindinfo)), "wrong bindinfo\n");
|
|
|
|
|
2007-02-10 16:34:41 +01:00
|
|
|
switch(test_protocol) {
|
|
|
|
case MK_TEST:
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
|
|
|
|
BINDSTATUS_DIRECTBIND, NULL);
|
|
|
|
ok(hres == S_OK,
|
|
|
|
"ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
case FILE_TEST:
|
|
|
|
case ITS_TEST:
|
2005-12-26 13:27:10 +01:00
|
|
|
SET_EXPECT(OnProgress_SENDINGREQUEST);
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
|
|
|
|
BINDSTATUS_SENDINGREQUEST, &null_char);
|
|
|
|
ok(hres == S_OK,
|
2006-10-07 15:30:28 +02:00
|
|
|
"ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
|
2005-12-26 13:27:10 +01:00
|
|
|
CHECK_CALLED(OnProgress_SENDINGREQUEST);
|
2007-02-10 16:34:41 +01:00
|
|
|
default:
|
|
|
|
break;
|
2007-02-10 16:33:38 +01:00
|
|
|
}
|
2005-12-26 13:27:10 +01:00
|
|
|
|
2007-02-10 16:33:38 +01:00
|
|
|
if(test_protocol == FILE_TEST) {
|
2005-12-26 13:27:10 +01:00
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
|
|
|
|
BINDSTATUS_CACHEFILENAMEAVAILABLE, &null_char);
|
|
|
|
ok(hres == S_OK,
|
2006-10-07 15:30:28 +02:00
|
|
|
"ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
|
2005-12-26 13:27:10 +01:00
|
|
|
|
|
|
|
SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
|
|
|
|
BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
|
|
|
|
ok(hres == S_OK,
|
2007-02-10 16:33:38 +01:00
|
|
|
"ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
|
2005-12-26 13:27:10 +01:00
|
|
|
CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
|
|
|
|
}else {
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
|
|
|
|
BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
|
|
|
|
ok(hres == S_OK,
|
2006-10-07 15:30:28 +02:00
|
|
|
"ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
|
2005-12-26 13:27:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(test_protocol == ABOUT_TEST)
|
|
|
|
bscf |= BSCF_DATAFULLYAVAILABLE;
|
2007-02-10 16:33:38 +01:00
|
|
|
if(test_protocol == ITS_TEST)
|
|
|
|
bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
SET_EXPECT(Read);
|
2007-02-10 16:34:41 +01:00
|
|
|
if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
|
2005-12-26 13:27:10 +01:00
|
|
|
SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
|
2005-11-14 16:12:43 +01:00
|
|
|
SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
|
|
|
|
SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
|
|
|
|
SET_EXPECT(LockRequest);
|
|
|
|
SET_EXPECT(OnDataAvailable);
|
|
|
|
SET_EXPECT(OnStopBinding);
|
|
|
|
|
2005-12-26 13:27:10 +01:00
|
|
|
hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "ReportData failed: %08x\n", hres);
|
2005-12-26 13:27:10 +01:00
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
CHECK_CALLED(Read);
|
2007-02-10 16:34:41 +01:00
|
|
|
if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
|
2005-12-26 13:27:10 +01:00
|
|
|
CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
|
2005-11-14 16:12:43 +01:00
|
|
|
CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
|
|
|
|
CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
|
|
|
|
CHECK_CALLED(LockRequest);
|
|
|
|
CHECK_CALLED(OnDataAvailable);
|
|
|
|
CHECK_CALLED(OnStopBinding);
|
|
|
|
|
2007-02-10 16:33:38 +01:00
|
|
|
if(test_protocol == ITS_TEST) {
|
|
|
|
SET_EXPECT(Read);
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
|
|
|
|
ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(Read);
|
|
|
|
}
|
|
|
|
|
2006-05-25 18:33:21 +02:00
|
|
|
SET_EXPECT(Terminate);
|
|
|
|
hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
|
2006-05-25 18:33:21 +02:00
|
|
|
CHECK_CALLED(Terminate);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
|
|
|
|
PROTOCOLDATA *pProtocolData)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(Terminate);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
|
2005-11-14 16:12:43 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
|
|
|
|
ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
|
|
|
static const char data[] = "<HTML></HTML>";
|
|
|
|
|
|
|
|
CHECK_EXPECT2(Read);
|
|
|
|
|
|
|
|
if(read) {
|
|
|
|
*pcbRead = 0;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(pv != NULL, "pv == NULL\n");
|
|
|
|
ok(cb != 0, "cb == 0\n");
|
|
|
|
ok(pcbRead != NULL, "pcbRead == NULL\n");
|
|
|
|
if(pcbRead) {
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
|
2007-02-10 16:33:38 +01:00
|
|
|
read += *pcbRead = sizeof(data)-1;
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
if(pv)
|
|
|
|
memcpy(pv, data, sizeof(data));
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
|
|
|
|
LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(LockRequest);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(UnlockRequest);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolVtbl ProtocolVtbl = {
|
|
|
|
Protocol_QueryInterface,
|
|
|
|
Protocol_AddRef,
|
|
|
|
Protocol_Release,
|
|
|
|
Protocol_Start,
|
|
|
|
Protocol_Continue,
|
|
|
|
Protocol_Abort,
|
|
|
|
Protocol_Terminate,
|
|
|
|
Protocol_Suspend,
|
|
|
|
Protocol_Resume,
|
|
|
|
Protocol_Read,
|
|
|
|
Protocol_Seek,
|
|
|
|
Protocol_LockRequest,
|
|
|
|
Protocol_UnlockRequest
|
|
|
|
};
|
|
|
|
|
|
|
|
static IInternetProtocol Protocol = { &ProtocolVtbl };
|
|
|
|
|
|
|
|
static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
|
2004-12-08 14:46:01 +01:00
|
|
|
{
|
2006-01-05 12:18:06 +01:00
|
|
|
if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
if(emulate_protocol) {
|
|
|
|
*ppv = &Protocol;
|
|
|
|
return S_OK;
|
|
|
|
}else {
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
2004-12-08 14:46:01 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI statusclb_AddRef(IBindStatusCallback *iface)
|
|
|
|
{
|
2006-01-05 12:18:06 +01:00
|
|
|
return 2;
|
2004-12-08 14:46:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI statusclb_Release(IBindStatusCallback *iface)
|
|
|
|
{
|
2006-01-05 12:18:06 +01:00
|
|
|
return 1;
|
2004-12-08 14:46:01 +01:00
|
|
|
}
|
|
|
|
|
2005-09-16 20:46:29 +02:00
|
|
|
static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved,
|
|
|
|
IBinding *pib)
|
2004-12-08 14:46:01 +01:00
|
|
|
{
|
2005-05-23 11:53:21 +02:00
|
|
|
HRESULT hres;
|
|
|
|
IMoniker *mon;
|
2004-12-20 19:58:04 +01:00
|
|
|
|
2005-09-16 20:46:29 +02:00
|
|
|
CHECK_EXPECT(OnStartBinding);
|
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
ok(pib != NULL, "pib should not be NULL\n");
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
|
|
|
|
ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
return S_OK;
|
2004-12-08 14:46:01 +01:00
|
|
|
}
|
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
|
2004-12-08 14:46:01 +01:00
|
|
|
{
|
2005-09-16 20:46:29 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2004-12-08 14:46:01 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
|
|
|
|
{
|
2005-09-16 20:46:29 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2004-12-08 14:46:01 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-09-16 20:46:29 +02:00
|
|
|
static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
|
|
|
|
ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
|
2004-12-08 14:46:01 +01:00
|
|
|
{
|
2005-09-16 20:46:29 +02:00
|
|
|
switch(ulStatusCode) {
|
|
|
|
case BINDSTATUS_FINDINGRESOURCE:
|
|
|
|
CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_CONNECTING:
|
|
|
|
CHECK_EXPECT(OnProgress_CONNECTING);
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_SENDINGREQUEST:
|
|
|
|
CHECK_EXPECT(OnProgress_SENDINGREQUEST);
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_MIMETYPEAVAILABLE:
|
|
|
|
CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_BEGINDOWNLOADDATA:
|
|
|
|
CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
|
2005-12-26 13:27:10 +01:00
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
if(szStatusText)
|
|
|
|
ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText\n");
|
2005-09-16 20:46:29 +02:00
|
|
|
break;
|
|
|
|
case BINDSTATUS_DOWNLOADINGDATA:
|
|
|
|
CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_ENDDOWNLOADDATA:
|
|
|
|
CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
|
2005-12-26 13:27:10 +01:00
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
if(szStatusText)
|
|
|
|
ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText\n");
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_CACHEFILENAMEAVAILABLE:
|
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
if(szStatusText && test_protocol == FILE_TEST)
|
|
|
|
ok(!lstrcmpW(INDEX_HTML+7, szStatusText), "wrong szStatusText\n");
|
2005-09-16 20:46:29 +02:00
|
|
|
break;
|
|
|
|
default:
|
2006-10-07 15:30:28 +02:00
|
|
|
todo_wine { ok(0, "unexpexted code %d\n", ulStatusCode); }
|
2005-09-16 20:46:29 +02:00
|
|
|
};
|
2004-12-20 19:58:04 +01:00
|
|
|
return S_OK;
|
2004-12-08 14:46:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
|
|
|
|
{
|
2005-09-16 20:46:29 +02:00
|
|
|
CHECK_EXPECT(OnStopBinding);
|
|
|
|
|
2006-09-21 11:45:32 +02:00
|
|
|
/* ignore DNS failure */
|
|
|
|
if (hresult != HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
|
|
|
|
{
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hresult), "Download failed: %08x\n", hresult);
|
2006-09-21 11:45:32 +02:00
|
|
|
ok(szError == NULL, "szError should be NULL\n");
|
|
|
|
}
|
2004-12-20 19:58:04 +01:00
|
|
|
stopped_binding = TRUE;
|
|
|
|
|
|
|
|
return S_OK;
|
2004-12-08 14:46:01 +01:00
|
|
|
}
|
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
|
2004-12-08 14:46:01 +01:00
|
|
|
{
|
2004-12-20 19:58:04 +01:00
|
|
|
DWORD cbSize;
|
|
|
|
|
2005-09-16 20:46:29 +02:00
|
|
|
CHECK_EXPECT(GetBindInfo);
|
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
*grfBINDF = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
|
|
|
|
cbSize = pbindinfo->cbSize;
|
|
|
|
memset(pbindinfo, 0, cbSize);
|
|
|
|
pbindinfo->cbSize = cbSize;
|
|
|
|
|
|
|
|
return S_OK;
|
2004-12-08 14:46:01 +01:00
|
|
|
}
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
|
|
|
|
DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
|
2004-12-08 14:46:01 +01:00
|
|
|
{
|
2004-12-20 19:58:04 +01:00
|
|
|
HRESULT hres;
|
|
|
|
DWORD readed;
|
|
|
|
BYTE buf[512];
|
2005-09-16 20:46:29 +02:00
|
|
|
|
|
|
|
CHECK_EXPECT2(OnDataAvailable);
|
|
|
|
|
2007-01-06 19:30:06 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* FIXME: Uncomment after removing BindToStorage hack. */
|
2006-05-27 22:56:20 +02:00
|
|
|
ok(pformatetc != NULL, "pformatetx == NULL\n");
|
|
|
|
if(pformatetc) {
|
|
|
|
ok(pformatetc->cfFormat == 0xc02d, "clipformat=%x\n", pformatetc->cfFormat);
|
|
|
|
ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
|
2007-01-06 19:30:06 +01:00
|
|
|
ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
|
|
|
|
ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
|
|
|
|
ok(pformatetc->tymed == TYMED_ISTREAM, "tymed=%u\n", pformatetc->tymed);
|
2006-05-27 22:56:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ok(pstgmed != NULL, "stgmeg == NULL\n");
|
|
|
|
if(pstgmed) {
|
2007-01-06 19:30:06 +01:00
|
|
|
ok(pstgmed->tymed == TYMED_ISTREAM, "tymed=%u\n", pstgmed->tymed);
|
2006-05-27 22:56:20 +02:00
|
|
|
ok(U(*pstgmed).pstm != NULL, "pstm == NULL\n");
|
|
|
|
ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
|
|
|
|
}
|
2007-01-06 19:30:06 +01:00
|
|
|
}
|
2006-05-27 22:56:20 +02:00
|
|
|
|
2006-01-05 12:18:06 +01:00
|
|
|
if(U(*pstgmed).pstm) {
|
|
|
|
do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
|
|
|
|
while(hres == S_OK);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
|
2004-12-20 19:58:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2004-12-08 14:46:01 +01:00
|
|
|
}
|
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
|
2004-12-08 14:46:01 +01:00
|
|
|
{
|
2005-09-16 20:46:29 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2004-12-08 14:46:01 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2006-01-05 12:18:06 +01:00
|
|
|
static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
|
2004-12-08 14:46:01 +01:00
|
|
|
statusclb_QueryInterface,
|
|
|
|
statusclb_AddRef,
|
|
|
|
statusclb_Release,
|
|
|
|
statusclb_OnStartBinding,
|
|
|
|
statusclb_GetPriority,
|
|
|
|
statusclb_OnLowResource,
|
|
|
|
statusclb_OnProgress,
|
|
|
|
statusclb_OnStopBinding,
|
|
|
|
statusclb_GetBindInfo,
|
|
|
|
statusclb_OnDataAvailable,
|
|
|
|
statusclb_OnObjectAvailable
|
|
|
|
};
|
|
|
|
|
2006-01-05 12:18:06 +01:00
|
|
|
static IBindStatusCallback bsc = { &BindStatusCallbackVtbl };
|
2004-12-08 14:46:01 +01:00
|
|
|
|
2005-06-17 12:11:37 +02:00
|
|
|
static void test_CreateAsyncBindCtx(void)
|
2004-12-08 14:46:01 +01:00
|
|
|
{
|
|
|
|
IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
|
|
|
|
HRESULT hres;
|
|
|
|
ULONG ref;
|
|
|
|
BIND_OPTS bindopts;
|
|
|
|
|
|
|
|
hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
|
2004-12-08 14:46:01 +01:00
|
|
|
ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
|
|
|
|
|
|
|
|
hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
|
2004-12-08 14:46:01 +01:00
|
|
|
|
2006-01-05 12:18:06 +01:00
|
|
|
hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n", hres);
|
2004-12-08 14:46:01 +01:00
|
|
|
|
2005-09-03 11:36:12 +02:00
|
|
|
bindopts.cbStruct = sizeof(bindopts);
|
2004-12-08 14:46:01 +01:00
|
|
|
hres = IBindCtx_GetBindOptions(bctx, &bindopts);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
|
2004-12-08 14:46:01 +01:00
|
|
|
ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
|
2005-09-03 11:36:12 +02:00
|
|
|
ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
|
2005-09-03 11:36:12 +02:00
|
|
|
bindopts.grfMode);
|
2004-12-08 14:46:01 +01:00
|
|
|
ok(bindopts.dwTickCountDeadline == 0,
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
|
2004-12-08 14:46:01 +01:00
|
|
|
|
|
|
|
ref = IBindCtx_Release(bctx);
|
|
|
|
ok(ref == 0, "bctx should be destroyed here\n");
|
|
|
|
}
|
|
|
|
|
2005-09-03 11:36:12 +02:00
|
|
|
static void test_CreateAsyncBindCtxEx(void)
|
|
|
|
{
|
|
|
|
IBindCtx *bctx = NULL, *bctx_arg = NULL;
|
|
|
|
BIND_OPTS bindopts;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
|
2005-09-03 11:36:12 +02:00
|
|
|
|
|
|
|
hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
|
2005-09-03 11:36:12 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
bindopts.cbStruct = sizeof(bindopts);
|
|
|
|
hres = IBindCtx_GetBindOptions(bctx, &bindopts);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
|
2005-09-03 11:36:12 +02:00
|
|
|
ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
|
2005-09-03 11:36:12 +02:00
|
|
|
ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
|
2005-09-03 11:36:12 +02:00
|
|
|
bindopts.grfMode);
|
|
|
|
ok(bindopts.dwTickCountDeadline == 0,
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
|
2005-09-03 11:36:12 +02:00
|
|
|
|
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateBindCtx(0, &bctx_arg);
|
|
|
|
hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
|
2005-09-03 11:36:12 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
bindopts.cbStruct = sizeof(bindopts);
|
|
|
|
hres = IBindCtx_GetBindOptions(bctx, &bindopts);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
|
2005-09-03 11:36:12 +02:00
|
|
|
ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
|
2005-09-03 11:36:12 +02:00
|
|
|
ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
|
2005-09-03 11:36:12 +02:00
|
|
|
bindopts.grfMode);
|
|
|
|
ok(bindopts.dwTickCountDeadline == 0,
|
2006-10-07 15:30:28 +02:00
|
|
|
"bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
|
2005-09-03 11:36:12 +02:00
|
|
|
|
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
IBindCtx_Release(bctx_arg);
|
|
|
|
|
2006-01-05 12:18:06 +01:00
|
|
|
hres = CreateAsyncBindCtxEx(NULL, 0, &bsc, NULL, &bctx, 0);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
|
2005-09-03 11:36:12 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
}
|
|
|
|
|
2007-01-12 12:31:04 +01:00
|
|
|
static void test_BindToStorage(int protocol, BOOL emul)
|
2004-12-20 19:58:04 +01:00
|
|
|
{
|
|
|
|
IMoniker *mon;
|
|
|
|
HRESULT hres;
|
|
|
|
LPOLESTR display_name;
|
|
|
|
IBindCtx *bctx;
|
|
|
|
MSG msg;
|
2006-01-05 12:18:06 +01:00
|
|
|
IBindStatusCallback *previousclb;
|
2004-12-20 19:58:04 +01:00
|
|
|
IUnknown *unk = (IUnknown*)0x00ff00ff;
|
2005-05-23 11:53:21 +02:00
|
|
|
IBinding *bind;
|
2004-12-20 19:58:04 +01:00
|
|
|
|
2007-01-12 12:31:04 +01:00
|
|
|
test_protocol = protocol;
|
|
|
|
emulate_protocol = emul;
|
|
|
|
|
2006-01-05 12:18:06 +01:00
|
|
|
hres = CreateAsyncBindCtx(0, &bsc, NULL, &bctx);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
|
2006-01-05 12:18:06 +01:00
|
|
|
if(FAILED(hres))
|
2004-12-20 19:58:04 +01:00
|
|
|
return;
|
|
|
|
|
2006-01-05 12:18:06 +01:00
|
|
|
hres = RegisterBindStatusCallback(bctx, &bsc, &previousclb, 0);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hres), "RegisterBindStatusCallback failed: %08x\n", hres);
|
2006-01-05 12:18:06 +01:00
|
|
|
ok(previousclb == &bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
|
2004-12-20 19:58:04 +01:00
|
|
|
if(previousclb)
|
|
|
|
IBindStatusCallback_Release(previousclb);
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
hres = CreateURLMoniker(NULL, urls[test_protocol], &mon);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
|
2004-12-20 19:58:04 +01:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-12-26 13:27:10 +01:00
|
|
|
if(test_protocol == FILE_TEST && INDEX_HTML[7] == '/')
|
|
|
|
memmove(INDEX_HTML+7, INDEX_HTML+8, lstrlenW(INDEX_HTML+7)*sizeof(WCHAR));
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
|
|
|
|
ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
IBinding_Release(bind);
|
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
|
2005-11-14 16:12:43 +01:00
|
|
|
ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
|
2004-12-20 19:58:04 +01:00
|
|
|
|
2005-09-16 20:46:29 +02:00
|
|
|
SET_EXPECT(GetBindInfo);
|
|
|
|
SET_EXPECT(OnStartBinding);
|
2005-11-14 16:12:43 +01:00
|
|
|
if(emulate_protocol) {
|
|
|
|
SET_EXPECT(Start);
|
|
|
|
SET_EXPECT(UnlockRequest);
|
|
|
|
}else {
|
|
|
|
if(test_protocol == HTTP_TEST) {
|
|
|
|
SET_EXPECT(OnProgress_FINDINGRESOURCE);
|
|
|
|
SET_EXPECT(OnProgress_CONNECTING);
|
|
|
|
}
|
2005-12-26 13:27:10 +01:00
|
|
|
if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
|
|
|
|
SET_EXPECT(OnProgress_SENDINGREQUEST);
|
2005-11-14 16:12:43 +01:00
|
|
|
SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
|
|
|
|
SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
|
|
|
|
if(test_protocol == HTTP_TEST)
|
|
|
|
SET_EXPECT(OnProgress_DOWNLOADINGDATA);
|
|
|
|
SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
|
2007-02-10 16:33:38 +01:00
|
|
|
SET_EXPECT(OnDataAvailable);
|
2005-11-14 16:12:43 +01:00
|
|
|
SET_EXPECT(OnStopBinding);
|
|
|
|
}
|
2005-09-16 20:46:29 +02:00
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
|
2006-09-21 11:45:32 +02:00
|
|
|
if (test_protocol == HTTP_TEST && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
|
|
|
|
{
|
|
|
|
trace( "Network unreachable, skipping tests\n" );
|
|
|
|
return;
|
|
|
|
}
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(SUCCEEDED(hres), "IMoniker_BindToStorage failed: %08x\n", hres);
|
2005-11-15 17:54:13 +01:00
|
|
|
if (!SUCCEEDED(hres)) return;
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
if(test_protocol == HTTP_TEST) {
|
|
|
|
todo_wine {
|
|
|
|
ok(unk == NULL, "istr should be NULL\n");
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
ok(unk != NULL, "unk == NULL\n");
|
2004-12-20 19:58:04 +01:00
|
|
|
}
|
|
|
|
if(unk)
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
while(!stopped_binding && GetMessage(&msg,NULL,0,0)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
|
2005-09-16 20:46:29 +02:00
|
|
|
CHECK_CALLED(GetBindInfo);
|
|
|
|
CHECK_CALLED(OnStartBinding);
|
2005-11-14 16:12:43 +01:00
|
|
|
if(emulate_protocol) {
|
|
|
|
CHECK_CALLED(Start);
|
|
|
|
CHECK_CALLED(UnlockRequest);
|
|
|
|
}else {
|
|
|
|
if(test_protocol == HTTP_TEST) {
|
|
|
|
CHECK_CALLED(OnProgress_FINDINGRESOURCE);
|
|
|
|
CHECK_CALLED(OnProgress_CONNECTING);
|
|
|
|
CHECK_CALLED(OnProgress_SENDINGREQUEST);
|
|
|
|
todo_wine { CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); }
|
|
|
|
}else {
|
|
|
|
CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
|
|
|
|
}
|
|
|
|
CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
|
|
|
|
if(test_protocol == HTTP_TEST)
|
|
|
|
CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
|
|
|
|
CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
|
2007-02-10 16:33:38 +01:00
|
|
|
CHECK_CALLED(OnDataAvailable);
|
2005-11-14 16:12:43 +01:00
|
|
|
CHECK_CALLED(OnStopBinding);
|
|
|
|
}
|
2005-09-16 20:46:29 +02:00
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
|
|
|
|
ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
|
|
|
|
}
|
|
|
|
|
2005-12-26 13:27:10 +01:00
|
|
|
static void set_file_url(void)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
|
|
|
|
|
|
|
|
memcpy(INDEX_HTML, wszFile, sizeof(wszFile));
|
|
|
|
len = sizeof(wszFile)/sizeof(WCHAR);
|
|
|
|
INDEX_HTML[len++] = '/';
|
|
|
|
len += GetCurrentDirectoryW(sizeof(INDEX_HTML)/sizeof(WCHAR)-len, INDEX_HTML+len);
|
|
|
|
INDEX_HTML[len++] = '\\';
|
|
|
|
memcpy(INDEX_HTML+len, wszIndexHtml, sizeof(wszIndexHtml));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_file(void)
|
|
|
|
{
|
|
|
|
HANDLE file;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
static const char html_doc[] = "<HTML></HTML>";
|
|
|
|
|
|
|
|
file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
|
|
|
|
if(file == INVALID_HANDLE_VALUE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
set_file_url();
|
|
|
|
}
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
static void test_BindToStorage_fail(void)
|
|
|
|
{
|
|
|
|
IMoniker *mon = NULL;
|
|
|
|
IBindCtx *bctx = NULL;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
|
2005-11-14 16:12:43 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == MK_E_SYNTAX, "hres=%08x, expected INET_E_SYNTAX\n", hres);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
|
|
|
|
2004-05-03 22:07:03 +02:00
|
|
|
START_TEST(url)
|
|
|
|
{
|
|
|
|
test_create();
|
2004-12-08 14:46:01 +01:00
|
|
|
test_CreateAsyncBindCtx();
|
2005-09-03 11:36:12 +02:00
|
|
|
test_CreateAsyncBindCtxEx();
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2005-12-26 13:27:10 +01:00
|
|
|
trace("http test...\n");
|
2007-01-12 12:31:04 +01:00
|
|
|
test_BindToStorage(HTTP_TEST, FALSE);
|
2005-12-26 13:27:10 +01:00
|
|
|
|
|
|
|
trace("about test...\n");
|
2006-05-12 18:54:54 +02:00
|
|
|
CoInitialize(NULL);
|
2007-01-12 12:31:04 +01:00
|
|
|
test_BindToStorage(ABOUT_TEST, FALSE);
|
2006-05-12 18:54:54 +02:00
|
|
|
CoUninitialize();
|
2005-12-26 13:27:10 +01:00
|
|
|
|
|
|
|
trace("emulated about test...\n");
|
2007-01-12 12:31:04 +01:00
|
|
|
test_BindToStorage(ABOUT_TEST, TRUE);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2005-12-26 13:27:10 +01:00
|
|
|
trace("file test...\n");
|
|
|
|
create_file();
|
2007-01-12 12:31:04 +01:00
|
|
|
test_BindToStorage(FILE_TEST, FALSE);
|
2005-12-26 13:27:10 +01:00
|
|
|
DeleteFileW(wszIndexHtml);
|
|
|
|
|
|
|
|
trace("emulated file test...\n");
|
|
|
|
set_file_url();
|
2007-01-12 12:31:04 +01:00
|
|
|
test_BindToStorage(FILE_TEST, TRUE);
|
2005-12-26 13:27:10 +01:00
|
|
|
|
2007-02-10 16:33:38 +01:00
|
|
|
trace("emulated its test...\n");
|
|
|
|
test_BindToStorage(ITS_TEST, TRUE);
|
|
|
|
|
2007-02-10 16:34:41 +01:00
|
|
|
trace("emulated mk test...\n");
|
|
|
|
test_BindToStorage(MK_TEST, TRUE);
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
test_BindToStorage_fail();
|
2004-05-03 22:07:03 +02:00
|
|
|
}
|