Henri Verbeet : d3d9/tests: Add a small test for IDirect3DDevice9:: SetCursorPosition().
Alexandre Julliard
julliard at winehq.org
Fri Oct 21 11:01:58 CDT 2011
Module: wine
Branch: master
Commit: 002447357c2b1feca5ef2649429fc55f70238901
URL: http://source.winehq.org/git/wine.git/?a=commit;h=002447357c2b1feca5ef2649429fc55f70238901
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Thu Oct 20 21:42:57 2011 +0200
d3d9/tests: Add a small test for IDirect3DDevice9::SetCursorPosition().
---
dlls/d3d9/tests/device.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 124 insertions(+), 0 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index affbe08..9d1da3d 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -21,6 +21,7 @@
*/
#define COBJMACROS
+#include <windowsx.h>
#include <d3d9.h>
#include "wine/test.h"
@@ -3125,6 +3126,128 @@ done:
DestroyWindow(focus_window);
}
+static const POINT *expect_pos;
+
+static LRESULT CALLBACK test_cursor_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
+{
+ if (message == WM_MOUSEMOVE)
+ {
+ if (expect_pos && expect_pos->x && expect_pos->y)
+ {
+ POINT p = {GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)};
+
+ ClientToScreen(window, &p);
+ if (expect_pos->x == p.x && expect_pos->y == p.y)
+ ++expect_pos;
+ }
+ }
+
+ return DefWindowProcA(window, message, wparam, lparam);
+}
+
+static void test_cursor_pos(void)
+{
+ IDirect3DSurface9 *cursor;
+ IDirect3DDevice9 *device;
+ WNDCLASSA wc = {0};
+ IDirect3D9 *d3d9;
+ UINT refcount;
+ HWND window;
+ HRESULT hr;
+ BOOL ret;
+
+ /* Note that we don't check for movement we're not supposed to receive.
+ * That's because it's hard to distinguish from the user accidentally
+ * moving the mouse. */
+ static const POINT points[] =
+ {
+ {50, 50},
+ {75, 75},
+ {100, 100},
+ {125, 125},
+ {150, 150},
+ {125, 125},
+ {150, 150},
+ {150, 150},
+ {0, 0},
+ };
+
+ if (!(d3d9 = pDirect3DCreate9(D3D_SDK_VERSION)))
+ {
+ skip("Failed to create IDirect3D9 object, skipping cursor tests.\n");
+ return;
+ }
+
+ wc.lpfnWndProc = test_cursor_proc;
+ wc.lpszClassName = "d3d9_test_cursor_wc";
+ ok(RegisterClassA(&wc), "Failed to register window class.\n");
+ window = CreateWindow("d3d9_test_cursor_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 320, 240, NULL, NULL, NULL, NULL);
+ ShowWindow(window, SW_SHOW);
+
+ device = create_device(d3d9, window, window, TRUE);
+ if (!device)
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 32, 32,
+ D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &cursor, NULL);
+ ok(SUCCEEDED(hr), "Failed to create cursor surface, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor);
+ ok(SUCCEEDED(hr), "Failed to set cursor properties, hr %#x.\n", hr);
+ IDirect3DSurface9_Release(cursor);
+ ret = IDirect3DDevice9_ShowCursor(device, TRUE);
+ ok(!ret, "Failed to show cursor, hr %#x.\n", ret);
+
+ flush_events();
+ expect_pos = points;
+
+ ret = SetCursorPos(50, 50);
+ ok(ret, "Failed to set cursor position.\n");
+ flush_events();
+
+ IDirect3DDevice9_SetCursorPosition(device, 75, 75, 0);
+ flush_events();
+ /* SetCursorPosition() eats duplicates. */
+ IDirect3DDevice9_SetCursorPosition(device, 75, 75, 0);
+ flush_events();
+
+ ret = SetCursorPos(100, 100);
+ ok(ret, "Failed to set cursor position.\n");
+ flush_events();
+ /* Even if the position was set with SetCursorPos(). */
+ IDirect3DDevice9_SetCursorPosition(device, 100, 100, 0);
+ flush_events();
+
+ IDirect3DDevice9_SetCursorPosition(device, 125, 125, 0);
+ flush_events();
+ ret = SetCursorPos(150, 150);
+ ok(ret, "Failed to set cursor position.\n");
+ flush_events();
+ IDirect3DDevice9_SetCursorPosition(device, 125, 125, 0);
+ flush_events();
+
+ IDirect3DDevice9_SetCursorPosition(device, 150, 150, 0);
+ flush_events();
+ /* SetCursorPos() doesn't. */
+ ret = SetCursorPos(150, 150);
+ ok(ret, "Failed to set cursor position.\n");
+ flush_events();
+
+ ok(!expect_pos->x && !expect_pos->y, "Didn't receive MOUSEMOVE %u (%d, %d).\n",
+ expect_pos - points, expect_pos->x, expect_pos->y);
+
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+done:
+ DestroyWindow(window);
+ UnregisterClassA("d3d9_test_cursor_wc", GetModuleHandleA(NULL));
+ if (d3d9)
+ IDirect3D9_Release(d3d9);
+}
+
START_TEST(device)
{
HMODULE d3d9_handle = LoadLibraryA( "d3d9.dll" );
@@ -3164,6 +3287,7 @@ START_TEST(device)
test_mipmap_levels();
test_checkdevicemultisampletype();
test_cursor();
+ test_cursor_pos();
test_reset_fullscreen();
test_reset();
test_scene();
More information about the wine-cvs
mailing list