Commit 6d1ab7fa authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

ole32: Add more DoDragDrop tests.

parent efbd5298
...@@ -31,6 +31,40 @@ ...@@ -31,6 +31,40 @@
#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(DataObject_EnumFormatEtc);
DEFINE_EXPECT(EnumFORMATETC_Next);
DEFINE_EXPECT(EnumFORMATETC_Reset);
DEFINE_EXPECT(DataObject_QueryGetData);
DEFINE_EXPECT(DropSource_QueryContinueDrag);
DEFINE_EXPECT(DropTarget_DragEnter);
DEFINE_EXPECT(DropSource_GiveFeedback);
DEFINE_EXPECT(DropTarget_Drop);
DEFINE_EXPECT(DropTarget_DragLeave);
static int droptarget_refs; static int droptarget_refs;
/* helper macros to make tests a bit leaner */ /* helper macros to make tests a bit leaner */
...@@ -68,7 +102,9 @@ static HRESULT WINAPI DropTarget_DragEnter(IDropTarget* iface, ...@@ -68,7 +102,9 @@ static HRESULT WINAPI DropTarget_DragEnter(IDropTarget* iface,
DWORD grfKeyState, POINTL pt, DWORD grfKeyState, POINTL pt,
DWORD* pdwEffect) DWORD* pdwEffect)
{ {
return E_NOTIMPL; CHECK_EXPECT(DropTarget_DragEnter);
*pdwEffect = DROPEFFECT_COPY;
return S_OK;
} }
static HRESULT WINAPI DropTarget_DragOver(IDropTarget* iface, static HRESULT WINAPI DropTarget_DragOver(IDropTarget* iface,
...@@ -76,11 +112,14 @@ static HRESULT WINAPI DropTarget_DragOver(IDropTarget* iface, ...@@ -76,11 +112,14 @@ static HRESULT WINAPI DropTarget_DragOver(IDropTarget* iface,
POINTL pt, POINTL pt,
DWORD* pdwEffect) DWORD* pdwEffect)
{ {
return E_NOTIMPL; ok(0, "unexpected call\n");
*pdwEffect = DROPEFFECT_COPY;
return S_OK;
} }
static HRESULT WINAPI DropTarget_DragLeave(IDropTarget* iface) static HRESULT WINAPI DropTarget_DragLeave(IDropTarget* iface)
{ {
CHECK_EXPECT(DropTarget_DragLeave);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -88,7 +127,8 @@ static HRESULT WINAPI DropTarget_Drop(IDropTarget* iface, ...@@ -88,7 +127,8 @@ static HRESULT WINAPI DropTarget_Drop(IDropTarget* iface,
IDataObject* pDataObj, DWORD grfKeyState, IDataObject* pDataObj, DWORD grfKeyState,
POINTL pt, DWORD* pdwEffect) POINTL pt, DWORD* pdwEffect)
{ {
return E_NOTIMPL; CHECK_EXPECT(DropTarget_Drop);
return 0xbeefbeef;
} }
static const IDropTargetVtbl DropTarget_VTbl = static const IDropTargetVtbl DropTarget_VTbl =
...@@ -104,7 +144,6 @@ static const IDropTargetVtbl DropTarget_VTbl = ...@@ -104,7 +144,6 @@ static const IDropTargetVtbl DropTarget_VTbl =
static IDropTarget DropTarget = { &DropTarget_VTbl }; static IDropTarget DropTarget = { &DropTarget_VTbl };
/** stub IDropSource **/
static HRESULT WINAPI DropSource_QueryInterface(IDropSource *iface, REFIID riid, void **ppObj) static HRESULT WINAPI DropSource_QueryInterface(IDropSource *iface, REFIID riid, void **ppObj)
{ {
if (IsEqualIID(riid, &IID_IUnknown) || if (IsEqualIID(riid, &IID_IUnknown) ||
...@@ -132,7 +171,7 @@ static HRESULT WINAPI DropSource_QueryContinueDrag( ...@@ -132,7 +171,7 @@ static HRESULT WINAPI DropSource_QueryContinueDrag(
BOOL fEscapePressed, BOOL fEscapePressed,
DWORD grfKeyState) DWORD grfKeyState)
{ {
/* always drop */ CHECK_EXPECT(DropSource_QueryContinueDrag);
return DRAGDROP_S_DROP; return DRAGDROP_S_DROP;
} }
...@@ -140,6 +179,7 @@ static HRESULT WINAPI DropSource_GiveFeedback( ...@@ -140,6 +179,7 @@ static HRESULT WINAPI DropSource_GiveFeedback(
IDropSource *iface, IDropSource *iface,
DWORD dwEffect) DWORD dwEffect)
{ {
CHECK_EXPECT(DropSource_GiveFeedback);
return DRAGDROP_S_USEDEFAULTCURSORS; return DRAGDROP_S_USEDEFAULTCURSORS;
} }
...@@ -153,7 +193,75 @@ static const IDropSourceVtbl dropsource_vtbl = { ...@@ -153,7 +193,75 @@ static const IDropSourceVtbl dropsource_vtbl = {
static IDropSource DropSource = { &dropsource_vtbl }; static IDropSource DropSource = { &dropsource_vtbl };
/** IDataObject stub **/ static HRESULT WINAPI EnumFORMATETC_QueryInterface(IEnumFORMATETC *iface,
REFIID riid, void **ppvObj)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static ULONG WINAPI EnumFORMATETC_AddRef(IEnumFORMATETC *iface)
{
return 2;
}
static ULONG WINAPI EnumFORMATETC_Release(IEnumFORMATETC *iface)
{
return 1;
}
static BOOL formats_enumerated;
static HRESULT WINAPI EnumFORMATETC_Next(IEnumFORMATETC *iface,
ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched)
{
static FORMATETC format = { CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
CHECK_EXPECT2(EnumFORMATETC_Next);
ok(celt == 1, "celt = %d\n", celt);
ok(rgelt != NULL, "rgelt == NULL\n");
ok(pceltFetched == NULL, "pceltFetched != NULL\n");
if(formats_enumerated)
return S_FALSE;
*rgelt = format;
formats_enumerated = TRUE;
return S_OK;
}
static HRESULT WINAPI EnumFORMATETC_Skip(IEnumFORMATETC *iface, ULONG celt)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI EnumFORMATETC_Reset(IEnumFORMATETC *iface)
{
CHECK_EXPECT(EnumFORMATETC_Reset);
formats_enumerated = FALSE;
return S_OK;
}
static HRESULT WINAPI EnumFORMATETC_Clone(IEnumFORMATETC *iface,
IEnumFORMATETC **ppenum)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static const IEnumFORMATETCVtbl enumformatetc_vtbl = {
EnumFORMATETC_QueryInterface,
EnumFORMATETC_AddRef,
EnumFORMATETC_Release,
EnumFORMATETC_Next,
EnumFORMATETC_Skip,
EnumFORMATETC_Reset,
EnumFORMATETC_Clone
};
static IEnumFORMATETC EnumFORMATETC = { &enumformatetc_vtbl };
static HRESULT WINAPI DataObject_QueryInterface( static HRESULT WINAPI DataObject_QueryInterface(
IDataObject *iface, IDataObject *iface,
REFIID riid, REFIID riid,
...@@ -166,6 +274,8 @@ static HRESULT WINAPI DataObject_QueryInterface( ...@@ -166,6 +274,8 @@ static HRESULT WINAPI DataObject_QueryInterface(
IDataObject_AddRef(iface); IDataObject_AddRef(iface);
return S_OK; return S_OK;
} }
trace("DataObject_QueryInterface: %s\n", wine_dbgstr_guid(riid));
return E_NOINTERFACE; return E_NOINTERFACE;
} }
...@@ -184,6 +294,7 @@ static HRESULT WINAPI DataObject_GetData( ...@@ -184,6 +294,7 @@ static HRESULT WINAPI DataObject_GetData(
FORMATETC *pformatetcIn, FORMATETC *pformatetcIn,
STGMEDIUM *pmedium) STGMEDIUM *pmedium)
{ {
ok(0, "unexpected call\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -192,6 +303,7 @@ static HRESULT WINAPI DataObject_GetDataHere( ...@@ -192,6 +303,7 @@ static HRESULT WINAPI DataObject_GetDataHere(
FORMATETC *pformatetc, FORMATETC *pformatetc,
STGMEDIUM *pmedium) STGMEDIUM *pmedium)
{ {
ok(0, "unexpected call\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -199,6 +311,7 @@ static HRESULT WINAPI DataObject_QueryGetData( ...@@ -199,6 +311,7 @@ static HRESULT WINAPI DataObject_QueryGetData(
IDataObject *iface, IDataObject *iface,
FORMATETC *pformatetc) FORMATETC *pformatetc)
{ {
CHECK_EXPECT(DataObject_QueryGetData);
return S_OK; return S_OK;
} }
...@@ -207,6 +320,7 @@ static HRESULT WINAPI DataObject_GetCanonicalFormatEtc( ...@@ -207,6 +320,7 @@ static HRESULT WINAPI DataObject_GetCanonicalFormatEtc(
FORMATETC *pformatectIn, FORMATETC *pformatectIn,
FORMATETC *pformatetcOut) FORMATETC *pformatetcOut)
{ {
ok(0, "unexpected call\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -216,6 +330,7 @@ static HRESULT WINAPI DataObject_SetData( ...@@ -216,6 +330,7 @@ static HRESULT WINAPI DataObject_SetData(
STGMEDIUM *pmedium, STGMEDIUM *pmedium,
BOOL fRelease) BOOL fRelease)
{ {
ok(0, "unexpected call\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -224,6 +339,9 @@ static HRESULT WINAPI DataObject_EnumFormatEtc( ...@@ -224,6 +339,9 @@ static HRESULT WINAPI DataObject_EnumFormatEtc(
DWORD dwDirection, DWORD dwDirection,
IEnumFORMATETC **ppenumFormatEtc) IEnumFORMATETC **ppenumFormatEtc)
{ {
CHECK_EXPECT(DataObject_EnumFormatEtc);
*ppenumFormatEtc = &EnumFORMATETC;
formats_enumerated = FALSE;
return S_OK; return S_OK;
} }
...@@ -234,6 +352,7 @@ static HRESULT WINAPI DataObject_DAdvise( ...@@ -234,6 +352,7 @@ static HRESULT WINAPI DataObject_DAdvise(
IAdviseSink *pAdvSink, IAdviseSink *pAdvSink,
DWORD *pdwConnection) DWORD *pdwConnection)
{ {
ok(0, "unexpected call\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -241,6 +360,7 @@ static HRESULT WINAPI DataObject_DUnadvise( ...@@ -241,6 +360,7 @@ static HRESULT WINAPI DataObject_DUnadvise(
IDataObject *iface, IDataObject *iface,
DWORD dwConnection) DWORD dwConnection)
{ {
ok(0, "unexpected call\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -248,6 +368,7 @@ static HRESULT WINAPI DataObject_EnumDAdvise( ...@@ -248,6 +368,7 @@ static HRESULT WINAPI DataObject_EnumDAdvise(
IDataObject *iface, IDataObject *iface,
IEnumSTATDATA **ppenumAdvise) IEnumSTATDATA **ppenumAdvise)
{ {
ok(0, "unexpected call\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -362,9 +483,10 @@ static void test_DoDragDrop(void) ...@@ -362,9 +483,10 @@ static void test_DoDragDrop(void)
DWORD effect; DWORD effect;
HRESULT hr; HRESULT hr;
HWND hwnd; HWND hwnd;
RECT rect;
hwnd = CreateWindowA("WineOleTestClass", "Test", 0, hwnd = CreateWindowA("WineOleTestClass", "Test", 0,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL,
NULL, NULL, NULL); NULL, NULL, NULL);
ok(IsWindow(hwnd), "failed to create window\n"); ok(IsWindow(hwnd), "failed to create window\n");
...@@ -396,6 +518,47 @@ static void test_DoDragDrop(void) ...@@ -396,6 +518,47 @@ static void test_DoDragDrop(void)
hr = DoDragDrop(&DataObject, NULL, 0, &effect); hr = DoDragDrop(&DataObject, NULL, 0, &effect);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ShowWindow(hwnd, SW_SHOW);
GetWindowRect(hwnd, &rect);
ok(SetCursorPos(rect.left+50, rect.top+50), "SetCursorPos failed\n");
SET_EXPECT(DataObject_EnumFormatEtc);
SET_EXPECT(EnumFORMATETC_Next);
SET_EXPECT(EnumFORMATETC_Reset);
SET_EXPECT(DataObject_QueryGetData);
SET_EXPECT(DropSource_QueryContinueDrag);
SET_EXPECT(DropTarget_DragEnter);
SET_EXPECT(DropSource_GiveFeedback);
SET_EXPECT(DropTarget_Drop);
hr = DoDragDrop(&DataObject, &DropSource, DROPEFFECT_COPY, &effect);
ok(hr == 0xbeefbeef, "got 0x%08x\n", hr);
todo_wine CHECK_CALLED(DataObject_EnumFormatEtc);
todo_wine CHECK_CALLED(EnumFORMATETC_Next);
todo_wine CHECK_CALLED(EnumFORMATETC_Reset);
todo_wine CHECK_CALLED(DataObject_QueryGetData);
CHECK_CALLED(DropSource_QueryContinueDrag);
CHECK_CALLED(DropTarget_DragEnter);
CHECK_CALLED(DropSource_GiveFeedback);
CHECK_CALLED(DropTarget_Drop);
SET_EXPECT(DataObject_EnumFormatEtc);
SET_EXPECT(EnumFORMATETC_Next);
SET_EXPECT(EnumFORMATETC_Reset);
SET_EXPECT(DataObject_QueryGetData);
SET_EXPECT(DropSource_QueryContinueDrag);
SET_EXPECT(DropTarget_DragEnter);
SET_EXPECT(DropSource_GiveFeedback);
SET_EXPECT(DropTarget_DragLeave);
hr = DoDragDrop(&DataObject, &DropSource, 0, &effect);
ok(hr == DRAGDROP_S_DROP, "got 0x%08x\n", hr);
todo_wine CHECK_CALLED(DataObject_EnumFormatEtc);
todo_wine CHECK_CALLED(EnumFORMATETC_Next);
todo_wine CHECK_CALLED(EnumFORMATETC_Reset);
todo_wine CHECK_CALLED(DataObject_QueryGetData);
CHECK_CALLED(DropSource_QueryContinueDrag);
CHECK_CALLED(DropTarget_DragEnter);
CHECK_CALLED(DropSource_GiveFeedback);
CHECK_CALLED(DropTarget_DragLeave);
OleUninitialize(); OleUninitialize();
DestroyWindow(hwnd); DestroyWindow(hwnd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment