Module: wine Branch: master Commit: 7b564cbf17aab7cc75bee836200fe76d87844ff5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7b564cbf17aab7cc75bee83620...
Author: Rob Shearman robertshearman@gmail.com Date: Sun Sep 28 17:27:20 2008 +0100
ole32: Create a dummy window for use in the drag and drop API tests.
As a window being registered for drag and drop is a system-global property, the tests could be affected by other processes in the system.
---
dlls/ole32/tests/dragdrop.c | 36 +++++++++++++++++++++++++++++++----- 1 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/dlls/ole32/tests/dragdrop.c b/dlls/ole32/tests/dragdrop.c index 1561066..ad10a58 100644 --- a/dlls/ole32/tests/dragdrop.c +++ b/dlls/ole32/tests/dragdrop.c @@ -108,16 +108,40 @@ static const IDropTargetVtbl DropTarget_VTbl =
static IDropTarget DropTarget = { &DropTarget_VTbl };
+static ATOM register_dummy_class(void) +{ + WNDCLASS wc = + { + 0, + DefWindowProc, + 0, + 0, + GetModuleHandle(NULL), + NULL, + LoadCursor(NULL, IDC_ARROW), + (HBRUSH)(COLOR_BTNFACE+1), + NULL, + TEXT("WineOleTestClass"), + }; + + return RegisterClass(&wc); +} + START_TEST(dragdrop) { HRESULT hr; + HWND hwnd; + + hwnd = CreateWindow(MAKEINTATOM(register_dummy_class()), "Test", 0, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, + NULL, NULL, NULL);
- hr = RegisterDragDrop(GetDesktopWindow(), &DropTarget); + hr = RegisterDragDrop(hwnd, &DropTarget); ok(hr == E_OUTOFMEMORY, "RegisterDragDrop without OLE initialized should have returned E_OUTOFMEMORY instead of 0x%08x\n", hr);
OleInitialize(NULL);
- hr = RegisterDragDrop(GetDesktopWindow(), NULL); + hr = RegisterDragDrop(hwnd, NULL); ok(hr == E_INVALIDARG, "RegisterDragDrop with NULL IDropTarget * should return E_INVALIDARG instead of 0x%08x\n", hr);
hr = RegisterDragDrop(NULL, &DropTarget); @@ -127,21 +151,23 @@ START_TEST(dragdrop) ok(hr == DRAGDROP_E_INVALIDHWND, "RegisterDragDrop with garbage hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr);
ok(droptarget_addref_called == 0, "DropTarget_AddRef shouldn't have been called\n"); - hr = RegisterDragDrop(GetDesktopWindow(), &DropTarget); + hr = RegisterDragDrop(hwnd, &DropTarget); ok_ole_success(hr, "RegisterDragDrop"); ok(droptarget_addref_called == 1, "DropTarget_AddRef should have been called once, not %d times\n", droptarget_addref_called);
- hr = RegisterDragDrop(GetDesktopWindow(), &DropTarget); + hr = RegisterDragDrop(hwnd, &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(); ok(droptarget_release_called == 0, "DropTarget_Release shouldn't have been called\n");
- hr = RevokeDragDrop(GetDesktopWindow()); + hr = RevokeDragDrop(hwnd); ok_ole_success(hr, "RevokeDragDrop"); ok(droptarget_release_called == 1, "DropTarget_Release should have been called once, not %d times\n", droptarget_release_called);
hr = RevokeDragDrop(NULL); ok(hr == DRAGDROP_E_INVALIDHWND, "RevokeDragDrop with NULL hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr); + + DestroyWindow(hwnd); }