explorerframe/tests: COM cleanup for INameSpaceTreeControlEventsImpl.
This commit is contained in:
parent
e53582fdc1
commit
d15f5722cb
@ -21,6 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
|
#define CONST_VTABLE
|
||||||
|
|
||||||
#include "shlobj.h"
|
#include "shlobj.h"
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
@ -67,25 +68,28 @@ enum { OnItemClick = 0, OnPropertyItemCommit, OnItemStateChanging, OnItemStateCh
|
|||||||
LastEvent };
|
LastEvent };
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const INameSpaceTreeControlEventsVtbl *lpVtbl;
|
INameSpaceTreeControlEvents INameSpaceTreeControlEvents_iface;
|
||||||
UINT qi_called_count; /* Keep track of calls to QueryInterface */
|
UINT qi_called_count; /* Keep track of calls to QueryInterface */
|
||||||
BOOL qi_enable_events; /* If FALSE, QueryInterface returns only E_NOINTERFACE */
|
BOOL qi_enable_events; /* If FALSE, QueryInterface returns only E_NOINTERFACE */
|
||||||
UINT count[LastEvent]; /* Keep track of calls to all On* functions. */
|
UINT count[LastEvent]; /* Keep track of calls to all On* functions. */
|
||||||
LONG ref;
|
LONG ref;
|
||||||
} INameSpaceTreeControlEventsImpl;
|
} INameSpaceTreeControlEventsImpl;
|
||||||
|
|
||||||
#define NSTCE_IMPL(iface) \
|
static inline INameSpaceTreeControlEventsImpl *impl_from_INameSpaceTreeControlEvents(INameSpaceTreeControlEvents *iface)
|
||||||
((INameSpaceTreeControlEventsImpl*)iface)
|
{
|
||||||
|
return CONTAINING_RECORD(iface, INameSpaceTreeControlEventsImpl, INameSpaceTreeControlEvents_iface);
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI NSTCEvents_fnQueryInterface(
|
static HRESULT WINAPI NSTCEvents_fnQueryInterface(
|
||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
REFIID riid,
|
REFIID riid,
|
||||||
void **ppvObject)
|
void **ppvObject)
|
||||||
{
|
{
|
||||||
NSTCE_IMPL(iface)->qi_called_count++;
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
if(NSTCE_IMPL(iface)->qi_enable_events &&
|
This->qi_called_count++;
|
||||||
IsEqualIID(riid, &IID_INameSpaceTreeControlEvents))
|
|
||||||
|
if(This->qi_enable_events && IsEqualIID(riid, &IID_INameSpaceTreeControlEvents))
|
||||||
{
|
{
|
||||||
IUnknown_AddRef(iface);
|
IUnknown_AddRef(iface);
|
||||||
*ppvObject = iface;
|
*ppvObject = iface;
|
||||||
@ -98,13 +102,17 @@ static HRESULT WINAPI NSTCEvents_fnQueryInterface(
|
|||||||
static ULONG WINAPI NSTCEvents_fnAddRef(
|
static ULONG WINAPI NSTCEvents_fnAddRef(
|
||||||
INameSpaceTreeControlEvents* iface)
|
INameSpaceTreeControlEvents* iface)
|
||||||
{
|
{
|
||||||
return InterlockedIncrement(&NSTCE_IMPL(iface)->ref);
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
|
return InterlockedIncrement(&This->ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI NSTCEvents_fnRelease(
|
static ULONG WINAPI NSTCEvents_fnRelease(
|
||||||
INameSpaceTreeControlEvents* iface)
|
INameSpaceTreeControlEvents* iface)
|
||||||
{
|
{
|
||||||
return InterlockedDecrement(&NSTCE_IMPL(iface)->ref);
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
|
return InterlockedDecrement(&This->ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI NSTCEvents_fnOnItemClick(
|
static HRESULT WINAPI NSTCEvents_fnOnItemClick(
|
||||||
@ -113,8 +121,10 @@ static HRESULT WINAPI NSTCEvents_fnOnItemClick(
|
|||||||
NSTCEHITTEST nstceHitTest,
|
NSTCEHITTEST nstceHitTest,
|
||||||
NSTCECLICKTYPE nstceClickType)
|
NSTCECLICKTYPE nstceClickType)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnItemClick]++;
|
This->count[OnItemClick]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +132,10 @@ static HRESULT WINAPI NSTCEvents_fnOnPropertyItemCommit(
|
|||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
IShellItem *psi)
|
IShellItem *psi)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnPropertyItemCommit]++;
|
This->count[OnPropertyItemCommit]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +145,10 @@ static HRESULT WINAPI NSTCEvents_fnOnItemStateChanging(
|
|||||||
NSTCITEMSTATE nstcisMask,
|
NSTCITEMSTATE nstcisMask,
|
||||||
NSTCITEMSTATE nstcisState)
|
NSTCITEMSTATE nstcisState)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnItemStateChanging]++;
|
This->count[OnItemStateChanging]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,8 +158,10 @@ static HRESULT WINAPI NSTCEvents_fnOnItemStateChanged(
|
|||||||
NSTCITEMSTATE nstcisMask,
|
NSTCITEMSTATE nstcisMask,
|
||||||
NSTCITEMSTATE nstcisState)
|
NSTCITEMSTATE nstcisState)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnItemStateChanged]++;
|
This->count[OnItemStateChanged]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +169,8 @@ static HRESULT WINAPI NSTCEvents_fnOnSelectionChanged(
|
|||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
IShellItemArray *psiaSelection)
|
IShellItemArray *psiaSelection)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psiaSelection != NULL, "IShellItemArray was NULL.\n");
|
ok(psiaSelection != NULL, "IShellItemArray was NULL.\n");
|
||||||
if(psiaSelection)
|
if(psiaSelection)
|
||||||
{
|
{
|
||||||
@ -162,7 +180,7 @@ static HRESULT WINAPI NSTCEvents_fnOnSelectionChanged(
|
|||||||
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
||||||
ok(count == 1, "Got count 0x%x\n", count);
|
ok(count == 1, "Got count 0x%x\n", count);
|
||||||
}
|
}
|
||||||
NSTCE_IMPL(iface)->count[OnSelectionChanged]++;
|
This->count[OnSelectionChanged]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +190,9 @@ static HRESULT WINAPI NSTCEvents_fnOnKeyboardInput(
|
|||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
NSTCE_IMPL(iface)->count[OnKeyboardInput]++;
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
|
This->count[OnKeyboardInput]++;
|
||||||
ok(wParam == 0x1234, "Got unexpected wParam %lx\n", wParam);
|
ok(wParam == 0x1234, "Got unexpected wParam %lx\n", wParam);
|
||||||
ok(lParam == 0x1234, "Got unexpected lParam %lx\n", lParam);
|
ok(lParam == 0x1234, "Got unexpected lParam %lx\n", lParam);
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
@ -182,8 +202,10 @@ static HRESULT WINAPI NSTCEvents_fnOnBeforeExpand(
|
|||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
IShellItem *psi)
|
IShellItem *psi)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnBeforeExpand]++;
|
This->count[OnBeforeExpand]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +213,10 @@ static HRESULT WINAPI NSTCEvents_fnOnAfterExpand(
|
|||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
IShellItem *psi)
|
IShellItem *psi)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnAfterExpand]++;
|
This->count[OnAfterExpand]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,8 +224,10 @@ static HRESULT WINAPI NSTCEvents_fnOnBeginLabelEdit(
|
|||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
IShellItem *psi)
|
IShellItem *psi)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnBeginLabelEdit]++;
|
This->count[OnBeginLabelEdit]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,8 +235,10 @@ static HRESULT WINAPI NSTCEvents_fnOnEndLabelEdit(
|
|||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
IShellItem *psi)
|
IShellItem *psi)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnEndLabelEdit]++;
|
This->count[OnEndLabelEdit]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,8 +248,10 @@ static HRESULT WINAPI NSTCEvents_fnOnGetToolTip(
|
|||||||
LPWSTR pszTip,
|
LPWSTR pszTip,
|
||||||
int cchTip)
|
int cchTip)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnGetToolTip]++;
|
This->count[OnGetToolTip]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,8 +259,10 @@ static HRESULT WINAPI NSTCEvents_fnOnBeforeItemDelete(
|
|||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
IShellItem *psi)
|
IShellItem *psi)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnBeforeItemDelete]++;
|
This->count[OnBeforeItemDelete]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,8 +271,10 @@ static HRESULT WINAPI NSTCEvents_fnOnItemAdded(
|
|||||||
IShellItem *psi,
|
IShellItem *psi,
|
||||||
BOOL fIsRoot)
|
BOOL fIsRoot)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnItemAdded]++;
|
This->count[OnItemAdded]++;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +283,10 @@ static HRESULT WINAPI NSTCEvents_fnOnItemDeleted(
|
|||||||
IShellItem *psi,
|
IShellItem *psi,
|
||||||
BOOL fIsRoot)
|
BOOL fIsRoot)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnItemDeleted]++;
|
This->count[OnItemDeleted]++;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +296,9 @@ static HRESULT WINAPI NSTCEvents_fnOnBeforeContextMenu(
|
|||||||
REFIID riid,
|
REFIID riid,
|
||||||
void **ppv)
|
void **ppv)
|
||||||
{
|
{
|
||||||
NSTCE_IMPL(iface)->count[OnBeforeContextMenu]++;
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
|
This->count[OnBeforeContextMenu]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +309,9 @@ static HRESULT WINAPI NSTCEvents_fnOnAfterContextMenu(
|
|||||||
REFIID riid,
|
REFIID riid,
|
||||||
void **ppv)
|
void **ppv)
|
||||||
{
|
{
|
||||||
NSTCE_IMPL(iface)->count[OnAfterContextMenu]++;
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
|
This->count[OnAfterContextMenu]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,8 +319,10 @@ static HRESULT WINAPI NSTCEvents_fnOnBeforeStateImageChange(
|
|||||||
INameSpaceTreeControlEvents* iface,
|
INameSpaceTreeControlEvents* iface,
|
||||||
IShellItem *psi)
|
IShellItem *psi)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnBeforeStateImageChange]++;
|
This->count[OnBeforeStateImageChange]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,8 +332,10 @@ static HRESULT WINAPI NSTCEvents_fnOnGetDefaultIconIndex(
|
|||||||
int *piDefaultIcon,
|
int *piDefaultIcon,
|
||||||
int *piOpenIcon)
|
int *piOpenIcon)
|
||||||
{
|
{
|
||||||
|
INameSpaceTreeControlEventsImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
|
||||||
|
|
||||||
ok(psi != NULL, "NULL IShellItem\n");
|
ok(psi != NULL, "NULL IShellItem\n");
|
||||||
NSTCE_IMPL(iface)->count[OnGetDefaultIconIndex]++;
|
This->count[OnGetDefaultIconIndex]++;
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,13 +362,12 @@ static const INameSpaceTreeControlEventsVtbl vt_NSTCEvents = {
|
|||||||
NSTCEvents_fnOnBeforeStateImageChange,
|
NSTCEvents_fnOnBeforeStateImageChange,
|
||||||
NSTCEvents_fnOnGetDefaultIconIndex
|
NSTCEvents_fnOnGetDefaultIconIndex
|
||||||
};
|
};
|
||||||
#undef NSTCE_IMPL
|
|
||||||
|
|
||||||
static INameSpaceTreeControlEventsImpl *create_nstc_events(void)
|
static INameSpaceTreeControlEventsImpl *create_nstc_events(void)
|
||||||
{
|
{
|
||||||
INameSpaceTreeControlEventsImpl *This;
|
INameSpaceTreeControlEventsImpl *This;
|
||||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof(INameSpaceTreeControlEventsImpl));
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(INameSpaceTreeControlEventsImpl));
|
||||||
This->lpVtbl = &vt_NSTCEvents;
|
This->INameSpaceTreeControlEvents_iface.lpVtbl = &vt_NSTCEvents;
|
||||||
This->ref = 1;
|
This->ref = 1;
|
||||||
|
|
||||||
return This;
|
return This;
|
||||||
@ -1755,10 +1798,10 @@ static void test_events(void)
|
|||||||
|
|
||||||
/* Create two instances of INameSpaceTreeControlEvents */
|
/* Create two instances of INameSpaceTreeControlEvents */
|
||||||
pnstceimpl = create_nstc_events();
|
pnstceimpl = create_nstc_events();
|
||||||
pnstce = (INameSpaceTreeControlEvents*)pnstceimpl;
|
pnstce = &pnstceimpl->INameSpaceTreeControlEvents_iface;
|
||||||
ZeroMemory(&pnstceimpl->count, sizeof(UINT)*LastEvent);
|
ZeroMemory(&pnstceimpl->count, sizeof(UINT)*LastEvent);
|
||||||
pnstceimpl2 = create_nstc_events();
|
pnstceimpl2 = create_nstc_events();
|
||||||
pnstce2 = (INameSpaceTreeControlEvents*)pnstceimpl2;
|
pnstce2 = &pnstceimpl2->INameSpaceTreeControlEvents_iface;
|
||||||
|
|
||||||
if(0)
|
if(0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user