- Implemented CreateAsyncBindCtx.

- Added test.
This commit is contained in:
Jacek Caban 2004-12-08 13:46:01 +00:00 committed by Alexandre Julliard
parent 0e9f423b17
commit 7af955a198
2 changed files with 162 additions and 5 deletions

View File

@ -2,6 +2,7 @@
* UrlMon URL tests
*
* Copyright 2004 Kevin Koltzau
* Copyright 2004 Jacek Caban
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -28,8 +29,8 @@
#include "wine/test.h"
const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
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 void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
{
@ -52,7 +53,135 @@ static void test_create()
test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
}
typedef struct {
IBindStatusCallbackVtbl *lpVtbl;
ULONG ref;
} statusclb;
static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppvObject)
{
return E_NOINTERFACE;
}
static ULONG WINAPI statusclb_AddRef(IBindStatusCallback *iface)
{
return InterlockedIncrement(&((statusclb*)iface)->ref);
}
static ULONG WINAPI statusclb_Release(IBindStatusCallback *iface)
{
statusclb *This = (statusclb*)iface;
ULONG ref;
ref = InterlockedDecrement(&This->ref);
if(!ref)
HeapFree(GetProcessHeap(), 0, This);
return ref;
}
static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallback *iface,DWORD dwReserved, IBinding * pib)
{
return E_NOTIMPL;
}
static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallback *iface, LONG * pnPriority)
{
return E_NOTIMPL;
}
static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
{
return E_NOTIMPL;
}
static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax,
ULONG ulStatusCode, LPCWSTR szStatusText)
{
return E_NOTIMPL;
}
static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
{
return E_NOTIMPL;
}
static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO * pbindinfo)
{
return E_NOTIMPL;
}
static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize,
FORMATETC* pformatetc, STGMEDIUM* pstgmed)
{
return E_NOTIMPL;
}
static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown* punk)
{
return E_NOTIMPL;
}
static IBindStatusCallbackVtbl statusclbVtbl = {
statusclb_QueryInterface,
statusclb_AddRef,
statusclb_Release,
statusclb_OnStartBinding,
statusclb_GetPriority,
statusclb_OnLowResource,
statusclb_OnProgress,
statusclb_OnStopBinding,
statusclb_GetBindInfo,
statusclb_OnDataAvailable,
statusclb_OnObjectAvailable
};
static IBindStatusCallback* statusclb_create()
{
statusclb *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(statusclb));
ret->lpVtbl = &statusclbVtbl;
ret->ref = 1;
return (IBindStatusCallback*)ret;
}
static void test_CreateAsyncBindCtx()
{
IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
HRESULT hres;
ULONG ref;
BIND_OPTS bindopts;
IBindStatusCallback *bsc = statusclb_create();
hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08lx\n", hres);
ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08lx\n", hres);
hres = CreateAsyncBindCtx(0, bsc, NULL, &bctx);
ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08lx\n", hres);
if(FAILED(hres)) {
IBindStatusCallback_Release(bsc);
return;
}
bindopts.cbStruct = 16;
hres = IBindCtx_GetBindOptions(bctx, &bindopts);
ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08lx\n", hres);
ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
"bindopts.grfFlags = %08lx, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
ok(bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
"bindopts.grfMode = %08lx, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n", bindopts.grfMode);
ok(bindopts.dwTickCountDeadline == 0,
"bindopts.dwTickCountDeadline = %08lx, expected: 0\n", bindopts.dwTickCountDeadline);
ref = IBindCtx_Release(bctx);
ok(ref == 0, "bctx should be destroyed here\n");
ref = IBindStatusCallback_Release(bsc);
ok(ref == 0, "bsc should be destroyed here\n");
}
START_TEST(url)
{
test_create();
test_CreateAsyncBindCtx();
}

View File

@ -882,8 +882,36 @@ static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeft
HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
IEnumFORMATETC *format, IBindCtx **pbind)
{
FIXME("stub.\n");
return E_INVALIDARG;
HRESULT hres;
BIND_OPTS bindopts;
IBindCtx *bctx;
TRACE("(%08lx %p %p %p)\n", reserved, callback, format, pbind);
if(!callback)
return E_INVALIDARG;
if(format)
FIXME("format is not supported yet\n");
hres = CreateBindCtx(0, &bctx);
if(FAILED(hres))
return hres;
bindopts.cbStruct = sizeof(BIND_OPTS);
bindopts.grfFlags = BIND_MAYBOTHERUSER;
bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
bindopts.dwTickCountDeadline = 0;
IBindCtx_SetBindOptions(bctx, &bindopts);
hres = IBindCtx_RegisterObjectParam(bctx, (LPOLESTR)BSCBHolder, (IUnknown*)callback);
if(FAILED(hres)) {
IBindCtx_Release(bctx);
return hres;
}
*pbind = bctx;
return S_OK;
}
/***********************************************************************
* CreateAsyncBindCtxEx (URLMON.@)
@ -892,7 +920,7 @@ HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
*
* FIXME
* Not implemented.
*/
*/
HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options,
IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx** pbind,
DWORD reserved)