Rob Shearman : ole32: Add tests for drag and drop functions.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Apr 5 06:42:54 CDT 2007
Module: wine
Branch: master
Commit: db4972f1fb2af57baaf435a701d627257dd07ea0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=db4972f1fb2af57baaf435a701d627257dd07ea0
Author: Rob Shearman <rob at codeweavers.com>
Date: Thu Apr 5 11:31:51 2007 +0100
ole32: Add tests for drag and drop functions.
---
dlls/ole32/tests/Makefile.in | 1 +
dlls/ole32/tests/dragdrop.c | 157 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 158 insertions(+), 0 deletions(-)
diff --git a/dlls/ole32/tests/Makefile.in b/dlls/ole32/tests/Makefile.in
index ef01690..a0e811d 100644
--- a/dlls/ole32/tests/Makefile.in
+++ b/dlls/ole32/tests/Makefile.in
@@ -9,6 +9,7 @@ EXTRALIBS = -luuid
CTESTS = \
clipboard.c \
compobj.c \
+ dragdrop.c \
errorinfo.c \
hglobalstream.c \
marshal.c \
diff --git a/dlls/ole32/tests/dragdrop.c b/dlls/ole32/tests/dragdrop.c
new file mode 100644
index 0000000..2193f0f
--- /dev/null
+++ b/dlls/ole32/tests/dragdrop.c
@@ -0,0 +1,157 @@
+/*
+ * Drag and Drop Tests
+ *
+ * Copyright 2007 Robert Shearman
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define _WIN32_DCOM
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+
+#include "wine/test.h"
+
+/* functions that are not present on all versions of Windows */
+HRESULT (WINAPI * pCoInitializeEx)(LPVOID lpReserved, DWORD dwCoInit);
+
+static int droptarget_addref_called;
+static int droptarget_release_called;
+
+/* helper macros to make tests a bit leaner */
+#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
+
+static HRESULT WINAPI DropTarget_QueryInterface(IDropTarget* iface, REFIID riid,
+ void** ppvObject)
+{
+ trace("DropTarget_QueryInterface\n");
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IDropTarget))
+ {
+ IUnknown_AddRef(iface);
+ *ppvObject = iface;
+ return S_OK;
+ }
+ *ppvObject = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DropTarget_AddRef(IDropTarget* iface)
+{
+ droptarget_addref_called++;
+ return 2;
+}
+
+static ULONG WINAPI DropTarget_Release(IDropTarget* iface)
+{
+ droptarget_release_called++;
+ return 1;
+}
+
+static HRESULT WINAPI DropTarget_DragEnter(IDropTarget* iface,
+ IDataObject* pDataObj,
+ DWORD grfKeyState, POINTL pt,
+ DWORD* pdwEffect)
+{
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI DropTarget_DragOver(IDropTarget* iface,
+ DWORD grfKeyState,
+ POINTL pt,
+ DWORD* pdwEffect)
+{
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI DropTarget_DragLeave(IDropTarget* iface)
+{
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI DropTarget_Drop(IDropTarget* iface,
+ IDataObject* pDataObj, DWORD grfKeyState,
+ POINTL pt, DWORD* pdwEffect)
+{
+ return E_NOTIMPL;
+}
+
+static const IDropTargetVtbl DropTarget_VTbl =
+{
+ DropTarget_QueryInterface,
+ DropTarget_AddRef,
+ DropTarget_Release,
+ DropTarget_DragEnter,
+ DropTarget_DragOver,
+ DropTarget_DragLeave,
+ DropTarget_Drop
+};
+
+static IDropTarget DropTarget = { &DropTarget_VTbl };
+
+START_TEST(dragdrop)
+{
+ HRESULT hr;
+
+ hr = RegisterDragDrop(GetDesktopWindow(), &DropTarget);
+ todo_wine
+ ok(hr == CO_E_NOTINITIALIZED, "RegisterDragDrop without OLE initialized should have returned CO_E_NOTINITIALIZED instead of 0x%08x\n", hr);
+
+ OleInitialize(NULL);
+
+ hr = RegisterDragDrop(GetDesktopWindow(), NULL);
+ ok(hr == E_INVALIDARG, "RegisterDragDrop with NULL IDropTarget * should return E_INVALIDARG instead of 0x%08x\n", hr);
+
+ hr = RegisterDragDrop(NULL, &DropTarget);
+ todo_wine
+ ok(hr == DRAGDROP_E_INVALIDHWND, "RegisterDragDrop with NULL hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr);
+
+ hr = RegisterDragDrop((HWND)0xdeadbeef, &DropTarget);
+ todo_wine
+ ok(hr == DRAGDROP_E_INVALIDHWND, "RegisterDragDrop with garbage hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr);
+
+ todo_wine
+ ok(droptarget_addref_called == 0, "DropTarget_AddRef shouldn't have been called\n");
+ hr = RegisterDragDrop(GetDesktopWindow(), &DropTarget);
+ todo_wine
+ ok_ole_success(hr, "RegisterDragDrop");
+ todo_wine
+ ok(droptarget_addref_called == 1, "DropTarget_AddRef should have been called once, not %d times\n", droptarget_addref_called);
+
+ hr = RegisterDragDrop(GetDesktopWindow(), &DropTarget);
+ ok(hr == DRAGDROP_E_ALREADYREGISTERED, "RegisterDragDrop with already registered hwnd should return DRAGDROP_E_ALREADYREGISTERED instead of 0x%08x\n", hr);
+
+ ok(droptarget_release_called == 0, "DropTarget_Release shouldn't have been called\n");
+ OleUninitialize();
+ todo_wine
+ ok(droptarget_release_called == 0, "DropTarget_Release shouldn't have been called\n");
+
+ hr = RevokeDragDrop(GetDesktopWindow());
+ todo_wine
+ ok_ole_success(hr, "RevokeDragDrop");
+ todo_wine
+ ok(droptarget_release_called == 1, "DropTarget_Release should have been called once, not %d times\n", droptarget_release_called);
+
+ hr = RevokeDragDrop(NULL);
+ todo_wine
+ ok(hr == DRAGDROP_E_INVALIDHWND, "RevokeDragDrop with NULL hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr);
+}
More information about the wine-cvs
mailing list