Commit 7b564cbf authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

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.
parent d269a36a
...@@ -108,16 +108,40 @@ static const IDropTargetVtbl DropTarget_VTbl = ...@@ -108,16 +108,40 @@ static const IDropTargetVtbl DropTarget_VTbl =
static IDropTarget DropTarget = { &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) START_TEST(dragdrop)
{ {
HRESULT hr; 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); ok(hr == E_OUTOFMEMORY, "RegisterDragDrop without OLE initialized should have returned E_OUTOFMEMORY instead of 0x%08x\n", hr);
OleInitialize(NULL); 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); ok(hr == E_INVALIDARG, "RegisterDragDrop with NULL IDropTarget * should return E_INVALIDARG instead of 0x%08x\n", hr);
hr = RegisterDragDrop(NULL, &DropTarget); hr = RegisterDragDrop(NULL, &DropTarget);
...@@ -127,21 +151,23 @@ START_TEST(dragdrop) ...@@ -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(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"); 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_ole_success(hr, "RegisterDragDrop");
ok(droptarget_addref_called == 1, "DropTarget_AddRef should have been called once, not %d times\n", droptarget_addref_called); 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(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"); ok(droptarget_release_called == 0, "DropTarget_Release shouldn't have been called\n");
OleUninitialize(); OleUninitialize();
ok(droptarget_release_called == 0, "DropTarget_Release shouldn't have been called\n"); 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_ole_success(hr, "RevokeDragDrop");
ok(droptarget_release_called == 1, "DropTarget_Release should have been called once, not %d times\n", droptarget_release_called); ok(droptarget_release_called == 1, "DropTarget_Release should have been called once, not %d times\n", droptarget_release_called);
hr = RevokeDragDrop(NULL); hr = RevokeDragDrop(NULL);
ok(hr == DRAGDROP_E_INVALIDHWND, "RevokeDragDrop with NULL hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr); ok(hr == DRAGDROP_E_INVALIDHWND, "RevokeDragDrop with NULL hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr);
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