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.
This commit is contained in:
Rob Shearman 2008-09-28 17:27:20 +01:00 committed by Alexandre Julliard
parent d269a36a81
commit 7b564cbf17
1 changed files with 31 additions and 5 deletions

View File

@ -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;
hr = RegisterDragDrop(GetDesktopWindow(), &DropTarget);
hwnd = CreateWindow(MAKEINTATOM(register_dummy_class()), "Test", 0,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
NULL, NULL, NULL);
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);
}