atl100: Added AtlAdvise implementation.

This commit is contained in:
Jacek Caban 2013-01-03 11:45:44 +01:00 committed by Alexandre Julliard
parent ded419707a
commit e57b22b960
3 changed files with 148 additions and 4 deletions

View File

@ -41,10 +41,26 @@ static ICatRegister *catreg;
/***********************************************************************
* AtlAdvise [atl100.@]
*/
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, LPDWORD pdw)
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, DWORD *pdw)
{
FIXME("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw);
return E_FAIL;
IConnectionPointContainer *container;
IConnectionPoint *cp;
HRESULT hres;
TRACE("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw);
hres = IUnknown_QueryInterface(pUnkCP, &IID_IConnectionPointContainer, (void**)&container);
if(FAILED(hres))
return hres;
hres = IConnectionPointContainer_FindConnectionPoint(container, iid, &cp);
IConnectionPointContainer_Release(container);
if(FAILED(hres))
return hres;
hres = IConnectionPoint_Advise(cp, pUnk, pdw);
IConnectionPoint_Release(cp);
return hres;
}
/***********************************************************************

View File

@ -1,5 +1,5 @@
TESTDLL = atl100.dll
IMPORTS = atl100 oleaut32 ole32 advapi32
IMPORTS = uuid atl100 oleaut32 ole32 advapi32
EXTRADEFS = -D_ATL_VER=_ATL_VER_100
C_SRCS = \

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#define COBJMACROS
#define CONST_VTABLE
#include <atlbase.h>
@ -207,6 +208,132 @@ static void test_typelib(void)
ITypeLib_Release(typelib);
}
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
*ppv = iface;
return S_OK;
}
ok(0, "unexpected call\n");
return E_NOINTERFACE;
}
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
{
return 2;
}
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
{
return 1;
}
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
IConnectionPointContainer **ppCPC)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
DWORD *pdwCookie)
{
ok(pUnkSink == (IUnknown*)0xdead0000, "pUnkSink = %p\n", pUnkSink);
*pdwCookie = 0xdeadbeef;
return S_OK;
}
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
IEnumConnections **ppEnum)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static const IConnectionPointVtbl ConnectionPointVtbl =
{
ConnectionPoint_QueryInterface,
ConnectionPoint_AddRef,
ConnectionPoint_Release,
ConnectionPoint_GetConnectionInterface,
ConnectionPoint_GetConnectionPointContainer,
ConnectionPoint_Advise,
ConnectionPoint_Unadvise,
ConnectionPoint_EnumConnections
};
static IConnectionPoint ConnectionPoint = { &ConnectionPointVtbl };
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
*ppv = iface;
return S_OK;
}
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
{
return 2;
}
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
{
return 1;
}
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
IEnumConnectionPoints **ppEnum)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
REFIID riid, IConnectionPoint **ppCP)
{
ok(IsEqualGUID(riid, &CLSID_Test), "unexpected riid\n");
*ppCP = &ConnectionPoint;
return S_OK;
}
static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
ConnectionPointContainer_QueryInterface,
ConnectionPointContainer_AddRef,
ConnectionPointContainer_Release,
ConnectionPointContainer_EnumConnectionPoints,
ConnectionPointContainer_FindConnectionPoint
};
static IConnectionPointContainer ConnectionPointContainer = { &ConnectionPointContainerVtbl };
static void test_cp(void)
{
DWORD cookie = 0;
HRESULT hres;
hres = AtlAdvise((IUnknown*)&ConnectionPointContainer, (IUnknown*)0xdead0000, &CLSID_Test, &cookie);
ok(hres == S_OK, "AtlAdvise failed: %08x\n", hres);
ok(cookie == 0xdeadbeef, "cookie = %x\n", cookie);
}
START_TEST(atl)
{
CoInitialize(NULL);
@ -214,6 +341,7 @@ START_TEST(atl)
test_winmodule();
test_regcat();
test_typelib();
test_cp();
CoUninitialize();
}