hlink: Added HlinkResolveMonikerForData tests.

This commit is contained in:
Jacek Caban 2008-01-29 00:22:35 +01:00 committed by Alexandre Julliard
parent 9d6cf488b6
commit 5a03ea8914
1 changed files with 396 additions and 2 deletions

View File

@ -2,7 +2,7 @@
* Implementation of hyperlinking (hlink.dll) * Implementation of hyperlinking (hlink.dll)
* *
* Copyright 2006 Mike McCormack * Copyright 2006 Mike McCormack
* Copyright 2007 Jacek Caban for CodeWeavers * Copyright 2007-2008 Jacek Caban for CodeWeavers
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -28,6 +28,34 @@
#include "wine/test.h" #include "wine/test.h"
#define DEFINE_EXPECT(func) \
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
#define SET_EXPECT(func) \
expect_ ## func = TRUE
#define CHECK_EXPECT2(func) \
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define CHECK_EXPECT(func) \
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)
#define CHECK_CALLED(func) \
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
DEFINE_EXPECT(IsSystemMoniker);
DEFINE_EXPECT(BindToStorage);
DEFINE_EXPECT(GetDisplayName);
static const char *debugstr_w(LPCWSTR str) static const char *debugstr_w(LPCWSTR str)
{ {
static char buf[1024]; static char buf[1024];
@ -37,6 +65,18 @@ static const char *debugstr_w(LPCWSTR str)
return buf; return buf;
} }
static const char *debugstr_guid(REFIID riid)
{
static char buf[50];
sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
riid->Data4[5], riid->Data4[6], riid->Data4[7]);
return buf;
}
static void test_HlinkIsShortcut(void) static void test_HlinkIsShortcut(void)
{ {
int i; int i;
@ -292,7 +332,7 @@ static void test_persist(void)
hr = HlinkCreateFromString(url, NULL, NULL, NULL, hr = HlinkCreateFromString(url, NULL, NULL, NULL,
0, NULL, &IID_IHlink, (LPVOID*) &lnk); 0, NULL, &IID_IHlink, (LPVOID*) &lnk);
ok(hr == S_OK, "IHlinCreateFromString failed with error 0x%08x\n", hr); ok(hr == S_OK, "IHlinkCreateFromString failed with error 0x%08x\n", hr);
if (!lnk) { if (!lnk) {
skip("Can't create lnk, skipping test_persist. Was wineprefixcreate run properly?\n"); skip("Can't create lnk, skipping test_persist. Was wineprefixcreate run properly?\n");
return; return;
@ -511,6 +551,359 @@ static void test_HlinkParseDisplayName(void)
IBindCtx_Release(bctx); IBindCtx_Release(bctx);
} }
static IBindCtx *_bctx;
static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
{
ok(0, "unexpected call\n");
return E_NOINTERFACE;
}
static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
{
return 2;
}
static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
{
return 1;
}
static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
REFGUID guidService, REFIID riid, void **ppv)
{
ok(0, "unexpected service %s\n", debugstr_guid(guidService));
return E_NOINTERFACE;
}
static IServiceProviderVtbl ServiceProviderVtbl = {
ServiceProvider_QueryInterface,
ServiceProvider_AddRef,
ServiceProvider_Release,
ServiceProvider_QueryService
};
static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
{
*ppv = NULL;
if(IsEqualGUID(riid, &IID_IServiceProvider)) {
*ppv = &ServiceProvider;
return S_OK;
}
ok(0, "unexpected interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
{
return 2;
}
static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
{
return 1;
}
static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved,
IBinding *pib)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF,
DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
BindStatusCallback_QueryInterface,
BindStatusCallback_AddRef,
BindStatusCallback_Release,
BindStatusCallback_OnStartBinding,
BindStatusCallback_GetPriority,
BindStatusCallback_OnLowResource,
BindStatusCallback_OnProgress,
BindStatusCallback_OnStopBinding,
BindStatusCallback_GetBindInfo,
BindStatusCallback_OnDataAvailable,
BindStatusCallback_OnObjectAvailable
};
static IBindStatusCallback BindStatusCallback = { &BindStatusCallbackVtbl };
static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
{
*ppv = NULL;
ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
{
return 2;
}
static ULONG WINAPI Moniker_Release(IMoniker *iface)
{
return 1;
}
static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
REFIID riidResult, void **ppvResult)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
REFIID riid, void **ppv)
{
IUnknown *unk;
HRESULT hres;
static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
CHECK_EXPECT(BindToStorage);
ok(pbc == _bctx, "pbc != _bctx\n");
ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
ok(ppv != NULL, "ppv == NULL\n");
ok(*ppv == NULL, "*ppv=%p\n", *ppv);
hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk);
ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
ok(unk != NULL, "unk == NULL\n");
IUnknown_Release(unk);
return S_OK;
}
static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
IMoniker *pmkNewlyRunning)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
IMoniker *pmkToLeft, FILETIME *pFileTime)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
IMoniker **ppmkPrefix)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
IMoniker **pmkRelPath)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
{
static const WCHAR winehq_urlW[] =
{'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};
CHECK_EXPECT(GetDisplayName);
ok(pbc != NULL, "pbc == NULL\n");
ok(pbc != _bctx, "pbc == _bctx\n");
ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
*ppszDisplayName = CoTaskMemAlloc(sizeof(winehq_urlW));
memcpy(*ppszDisplayName, winehq_urlW, sizeof(winehq_urlW));
return S_OK;
}
static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
{
CHECK_EXPECT2(IsSystemMoniker);
*pdwMksys = MKSYS_URLMONIKER;
return S_OK;
}
static IMonikerVtbl MonikerVtbl = {
Moniker_QueryInterface,
Moniker_AddRef,
Moniker_Release,
Moniker_GetClassID,
Moniker_IsDirty,
Moniker_Load,
Moniker_Save,
Moniker_GetSizeMax,
Moniker_BindToObject,
Moniker_BindToStorage,
Moniker_Reduce,
Moniker_ComposeWith,
Moniker_Enum,
Moniker_IsEqual,
Moniker_Hash,
Moniker_IsRunning,
Moniker_GetTimeOfLastChange,
Moniker_Inverse,
Moniker_CommonPrefixWith,
Moniker_RelativePathTo,
Moniker_GetDisplayName,
Moniker_ParseDisplayName,
Moniker_IsSystemMoniker
};
static IMoniker Moniker = { &MonikerVtbl };
static void test_HlinkResolveMonikerForData(void)
{
IBindCtx *bctx;
HRESULT hres;
CreateBindCtx(0, &bctx);
_bctx = bctx;
SET_EXPECT(IsSystemMoniker);
SET_EXPECT(GetDisplayName);
SET_EXPECT(BindToStorage);
hres = HlinkResolveMonikerForData(&Moniker, 0, bctx, 0, NULL, &BindStatusCallback, NULL);
ok(hres == S_OK, "HlinkResolveMonikerForData failed: %08x\n", hres);
CHECK_CALLED(IsSystemMoniker);
CHECK_CALLED(GetDisplayName);
CHECK_CALLED(BindToStorage);
IBindCtx_Release(bctx);
}
START_TEST(hlink) START_TEST(hlink)
{ {
CoInitialize(NULL); CoInitialize(NULL);
@ -521,6 +914,7 @@ START_TEST(hlink)
test_special_reference(); test_special_reference();
test_HlinkCreateExtensionServices(); test_HlinkCreateExtensionServices();
test_HlinkParseDisplayName(); test_HlinkParseDisplayName();
test_HlinkResolveMonikerForData();
CoUninitialize(); CoUninitialize();
} }