mirror of
https://github.com/reactos/wine.git
synced 2025-02-11 23:27:25 +00:00
- Added test of BindToStorage.
- Added some declarations to urlmon.idl.
This commit is contained in:
parent
6c1494b19c
commit
51077d1e86
@ -3,7 +3,8 @@ TOPOBJDIR = ../../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
TESTDLL = urlmon.dll
|
||||
IMPORTS = urlmon
|
||||
IMPORTS = urlmon user32
|
||||
EXTRALIBS = -luuid
|
||||
|
||||
CTESTS = \
|
||||
generated.c \
|
||||
|
@ -29,9 +29,19 @@
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#ifdef NONAMELESSUNION
|
||||
# define U(x) (x).u
|
||||
#else
|
||||
# define U(x) (x)
|
||||
#endif
|
||||
|
||||
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'};
|
||||
|
||||
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};
|
||||
static BOOL stopped_binding = FALSE;
|
||||
|
||||
static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
|
||||
{
|
||||
HRESULT hr;
|
||||
@ -56,6 +66,8 @@ static void test_create()
|
||||
typedef struct {
|
||||
IBindStatusCallbackVtbl *lpVtbl;
|
||||
ULONG ref;
|
||||
IBinding *pbind;
|
||||
IStream *pstr;
|
||||
} statusclb;
|
||||
|
||||
static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppvObject)
|
||||
@ -80,7 +92,14 @@ static ULONG WINAPI statusclb_Release(IBindStatusCallback *iface)
|
||||
|
||||
static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
statusclb *This = (statusclb*)iface;
|
||||
|
||||
This->pbind = pib;
|
||||
ok(pib != NULL, "pib should not be NULL\n");
|
||||
if(pib)
|
||||
IBinding_AddRef(pib);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
|
||||
@ -96,23 +115,55 @@ static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallback *iface, DWORD
|
||||
static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax,
|
||||
ULONG ulStatusCode, LPCWSTR szStatusText)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
statusclb *This = (statusclb*)iface;
|
||||
|
||||
ok(SUCCEEDED(hresult), "Download failed: %08lx\n", hresult);
|
||||
ok(szError == NULL, "szError should be NULL\n");
|
||||
stopped_binding = TRUE;
|
||||
IBinding_Release(This->pbind);
|
||||
ok(This->pstr != NULL, "pstr should not be NULL here\n");
|
||||
if(This->pstr)
|
||||
IStream_Release(This->pstr);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
DWORD cbSize;
|
||||
|
||||
*grfBINDF = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
|
||||
cbSize = pbindinfo->cbSize;
|
||||
memset(pbindinfo, 0, cbSize);
|
||||
pbindinfo->cbSize = cbSize;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize,
|
||||
FORMATETC* pformatetc, STGMEDIUM* pstgmed)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
statusclb *This = (statusclb*)iface;
|
||||
HRESULT hres;
|
||||
DWORD readed;
|
||||
BYTE buf[512];
|
||||
if(!This->pstr) {
|
||||
ok(grfBSCF & BSCF_FIRSTDATANOTIFICATION, "pstr should be set when BSCF_FIRSTDATANOTIFICATION\n");
|
||||
This->pstr = U(*pstgmed).pstm;
|
||||
IStream_AddRef(This->pstr);
|
||||
ok(This->pstr != NULL, "pstr should not be NULL here\n");
|
||||
}
|
||||
|
||||
do hres = IStream_Read(This->pstr, buf, 512, &readed);
|
||||
while(hres == S_OK);
|
||||
ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08lx\n", hres);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
|
||||
@ -139,6 +190,8 @@ static IBindStatusCallback* statusclb_create()
|
||||
statusclb *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(statusclb));
|
||||
ret->lpVtbl = &statusclbVtbl;
|
||||
ret->ref = 1;
|
||||
ret->pbind = NULL;
|
||||
ret->pstr = NULL;
|
||||
return (IBindStatusCallback*)ret;
|
||||
}
|
||||
|
||||
@ -180,8 +233,67 @@ static void test_CreateAsyncBindCtx()
|
||||
ok(ref == 0, "bsc should be destroyed here\n");
|
||||
}
|
||||
|
||||
static void test_BindToStorage()
|
||||
{
|
||||
IMoniker *mon;
|
||||
HRESULT hres;
|
||||
LPOLESTR display_name;
|
||||
IBindCtx *bctx;
|
||||
MSG msg;
|
||||
IBindStatusCallback *previousclb, *sclb = statusclb_create();
|
||||
IUnknown *unk = (IUnknown*)0x00ff00ff;
|
||||
|
||||
hres = CreateAsyncBindCtx(0, sclb, NULL, &bctx);
|
||||
ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08lx\n\n", hres);
|
||||
if(FAILED(hres)) {
|
||||
IBindStatusCallback_Release(sclb);
|
||||
return;
|
||||
}
|
||||
|
||||
hres = RegisterBindStatusCallback(bctx, sclb, &previousclb, 0);
|
||||
ok(SUCCEEDED(hres), "RegisterBindStatusCallback failed: %08lx\n", hres);
|
||||
ok(previousclb == sclb, "previousclb(%p) != sclb(%p)\n", previousclb, sclb);
|
||||
if(previousclb)
|
||||
IBindStatusCallback_Release(previousclb);
|
||||
|
||||
hres = CreateURLMoniker(NULL, WINE_ABOUT_URL, &mon);
|
||||
ok(SUCCEEDED(hres), "failed to create moniker: %08lx\n", hres);
|
||||
if(FAILED(hres)) {
|
||||
IBindStatusCallback_Release(sclb);
|
||||
IBindCtx_Release(bctx);
|
||||
return;
|
||||
}
|
||||
|
||||
hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
|
||||
ok(SUCCEEDED(hres), "GetDisplayName failed %08lx\n", hres);
|
||||
ok(!lstrcmpW(display_name, WINE_ABOUT_URL), "GetDisplayName got wrong name\n");
|
||||
|
||||
hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
|
||||
ok(SUCCEEDED(hres), "IMoniker_BindToStorage failed: %08lx\n", hres);
|
||||
todo_wine {
|
||||
ok(unk == NULL, "istr should be NULL\n");
|
||||
}
|
||||
if(FAILED(hres)) {
|
||||
IBindStatusCallback_Release(sclb);
|
||||
IMoniker_Release(mon);
|
||||
return;
|
||||
}
|
||||
if(unk)
|
||||
IUnknown_Release(unk);
|
||||
|
||||
while(!stopped_binding && GetMessage(&msg,NULL,0,0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
|
||||
ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
|
||||
ok(IBindStatusCallback_Release(sclb) == 0, "scbl should be destroyed here\n");
|
||||
}
|
||||
|
||||
START_TEST(url)
|
||||
{
|
||||
test_create();
|
||||
test_CreateAsyncBindCtx();
|
||||
test_BindToStorage();
|
||||
}
|
||||
|
@ -324,6 +324,7 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
|
||||
IBindStatusCallback *pbscb;
|
||||
BINDINFO bi;
|
||||
DWORD bindf;
|
||||
IStream *pstr;
|
||||
|
||||
FIXME("(%p)->(%p,%p,%s,%p): stub\n",This,pbc,pmkToLeft,debugstr_guid(riid),ppvObject);
|
||||
if(pmkToLeft) {
|
||||
@ -339,8 +340,7 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
|
||||
We also need to implement IStream ourselves so that IStream_Read can return
|
||||
E_PENDING */
|
||||
|
||||
hres = CreateStreamOnHGlobal(0, TRUE, (IStream**)ppvObject);
|
||||
|
||||
hres = CreateStreamOnHGlobal(0, TRUE, &pstr);
|
||||
|
||||
if(SUCCEEDED(hres)) {
|
||||
TRACE("Created dummy stream...\n");
|
||||
@ -401,7 +401,6 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
|
||||
hres = IBindStatusCallback_OnProgress(pbscb, 0, 0, BINDSTATUS_SENDINGREQUEST, NULL);
|
||||
hres = E_OUTOFMEMORY; /* FIXME */
|
||||
if(HttpSendRequestW(This->hrequest, NULL, 0, NULL, 0)) {
|
||||
|
||||
len = 0;
|
||||
HttpQueryInfoW(This->hrequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &len, &lensz, NULL);
|
||||
|
||||
@ -414,7 +413,7 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
|
||||
fmt.lindex = -1;
|
||||
fmt.tymed = TYMED_ISTREAM;
|
||||
stg.tymed = TYMED_ISTREAM;
|
||||
stg.u.pstm = *(IStream**)ppvObject;
|
||||
stg.u.pstm = pstr;
|
||||
stg.pUnkForRelease = NULL;
|
||||
|
||||
while(1) {
|
||||
@ -424,9 +423,9 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
|
||||
if(InternetReadFile(This->hrequest, buf, sizeof(buf), &bufread)) {
|
||||
TRACE("read %ld bytes %s...\n", bufread, debugstr_an(buf, 10));
|
||||
if(bufread == 0) break;
|
||||
IStream_Write(*(IStream**)ppvObject, buf, bufread, &written);
|
||||
IStream_Write(pstr, buf, bufread, &written);
|
||||
total_read += bufread;
|
||||
IStream_Seek(*(IStream**)ppvObject, last_read_pos, STREAM_SEEK_SET, NULL);
|
||||
IStream_Seek(pstr, last_read_pos, STREAM_SEEK_SET, NULL);
|
||||
hres = IBindStatusCallback_OnProgress(pbscb, total_read, len, (total_read == bufread) ?
|
||||
BINDSTATUS_BEGINDOWNLOADDATA :
|
||||
BINDSTATUS_DOWNLOADINGDATA, NULL);
|
||||
@ -448,9 +447,11 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
|
||||
InternetCloseHandle(This->hrequest);
|
||||
InternetCloseHandle(This->hconnect);
|
||||
InternetCloseHandle(This->hinternet);
|
||||
IBindStatusCallback_Release(pbscb);
|
||||
}
|
||||
}
|
||||
}
|
||||
*ppvObject = (VOID*)pstr;
|
||||
return hres;
|
||||
}
|
||||
|
||||
@ -752,7 +753,7 @@ static HRESULT WINAPI URLMonikerImpl_IBinding_Abort(IBinding* iface)
|
||||
static HRESULT WINAPI URLMonikerImpl_IBinding_GetBindResult(IBinding* iface, CLSID* pclsidProtocol, DWORD* pdwResult, LPOLESTR* pszResult, DWORD* pdwReserved)
|
||||
{
|
||||
ICOM_THIS_MULTI(URLMonikerImpl, lpvtbl2, iface);
|
||||
FIXME("(%p)->(%s, %p, %p, %p): stub\n", This, debugstr_guid(pclsidProtocol), pdwResult, pszResult, pdwReserved);
|
||||
FIXME("(%p)->(%p, %p, %p, %p): stub\n", This, pclsidProtocol, pdwResult, pszResult, pdwReserved);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
@ -73,6 +73,13 @@ interface IBindStatusCallback : IUnknown
|
||||
{
|
||||
typedef [unique] IBindStatusCallback *LPBINDSTATUSCALLBACK;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BINDVERB_GET = 0x00000000,
|
||||
BINDVERB_POST = 0x00000001,
|
||||
BINDVERB_PUT = 0x00000002,
|
||||
BINDVERB_CUSTOM = 0x00000003
|
||||
} BINDVERB;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -265,6 +272,24 @@ interface IBindStatusCallback : IUnknown
|
||||
[in, iid_is(riid)] IUnknown* punk);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* IAuthenticate interface
|
||||
*/
|
||||
[
|
||||
local,
|
||||
object,
|
||||
uuid(79EAC9D0-BAf9-11CE-8C82-00AA004BA90B),
|
||||
pointer_default(unique)
|
||||
]
|
||||
interface IAuthenticate : IUnknown
|
||||
{
|
||||
typedef [unique] IAuthenticate *LPAUTHENTICATION;
|
||||
|
||||
HRESULT Authenticate(
|
||||
[out] HWND* phwnd,
|
||||
[out] LPWSTR *pszUsername,
|
||||
[out] LPWSTR *pszPassword);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* IBindHost interface
|
||||
@ -791,6 +816,7 @@ interface IInternetZoneManager : IUnknown
|
||||
cpp_quote("DEFINE_GUID(CLSID_InternetSecurityManager, 0x7b8a2d94, 0x0ac9, 0x11d1, 0x89, 0x6c, 0x00, 0xc0, 0x4f, 0xB6, 0xbf, 0xc4);")
|
||||
cpp_quote("DEFINE_GUID(CLSID_InternetZoneManager, 0x7B8A2D95, 0x0AC9, 0x11D1, 0x89, 0x6C, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4);")
|
||||
cpp_quote("DEFINE_GUID(IID_IAsyncMoniker, 0x79EAC9D3, 0xBAF9, 0x11CE, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B);")
|
||||
cpp_quote("DEFINE_GUID(IID_IAsyncBindCtx, 0x79EAC9D4, 0xBAF9, 0x11CE, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B);")
|
||||
cpp_quote("DEFINE_GUID(CLSID_StdURLMoniker, 0x79EAC9E0, 0xBAF9, 0x11CE, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B);")
|
||||
|
||||
cpp_quote("#define MK_S_ASYNCHRONOUS 0x000401E8")
|
||||
|
Loading…
x
Reference in New Issue
Block a user