Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/d3d9/tests/device.c | 100 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 24e0670b61..5a5183c12f 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -1742,16 +1742,30 @@ cleanup:
static void test_cursor(void) { + unsigned int adapter_idx, adapter_count, test_idx; IDirect3DSurface9 *cursor = NULL; + struct device_desc device_desc; + unsigned int width, height; IDirect3DDevice9 *device; + HRESULT expected_hr, hr; + D3DDISPLAYMODE mode; CURSORINFO info; IDirect3D9 *d3d; ULONG refcount; HCURSOR cur; HWND window; - HRESULT hr; BOOL ret;
+ static const DWORD device_flags[] = {0, CREATE_DEVICE_FULLSCREEN}; + static const SIZE cursor_sizes[] = + { + {1, 1}, + {2, 4}, + {3, 2}, + {2, 3}, + {6, 6}, + }; + window = create_window(); ok(!!window, "Failed to create a window.\n");
@@ -1812,8 +1826,92 @@ static void test_cursor(void) ok(info.flags & (CURSOR_SHOWING|CURSOR_SUPPRESSED), "The gdi cursor is hidden (%08x)\n", info.flags); ok(info.hCursor != cur, "The cursor handle is %p\n", info.hCursor);
+ /* Cursor dimensions must all be powers of two */ + for (test_idx = 0; test_idx < ARRAY_SIZE(cursor_sizes); ++test_idx) + { + width = cursor_sizes[test_idx].cx; + height = cursor_sizes[test_idx].cy; + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, D3DFMT_A8R8G8B8, + D3DPOOL_DEFAULT, &cursor, NULL); + ok(hr == D3D_OK, "Test %u: CreateOffscreenPlainSurface failed, hr %#x.\n", test_idx, hr); + hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor); + /* http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2 */ + if (width && !(width & (width - 1)) && height && !(height & (height - 1))) + expected_hr = D3D_OK; + else + expected_hr = D3DERR_INVALIDCALL; + todo_wine_if(expected_hr == D3DERR_INVALIDCALL) + ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#x, got %#x.\n", + test_idx, expected_hr, hr); + IDirect3DSurface9_Release(cursor); + } + refcount = IDirect3DDevice9_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); + + /* Cursor dimensions must not exceed adapter display mode */ + device_desc.device_window = window; + device_desc.width = 640; + device_desc.height = 480; + + adapter_count = IDirect3D9_GetAdapterCount(d3d); + for (adapter_idx = 0; adapter_idx < adapter_count; ++adapter_idx) + { + for (test_idx = 0; test_idx < ARRAY_SIZE(device_flags); ++test_idx) + { + device_desc.adapter_ordinal = adapter_idx; + device_desc.flags = device_flags[test_idx]; + if (!(device = create_device(d3d, window, &device_desc))) + { + skip("Adapter %u test %u: Failed to create a D3D device.\n", adapter_idx, test_idx); + break; + } + + hr = IDirect3D9_GetAdapterDisplayMode(d3d, adapter_idx, &mode); + ok(hr == D3D_OK, "Adapter %u test %u: GetAdapterDisplayMode failed, hr %#x.\n", + adapter_idx, test_idx, hr); + + /* Find the largest width and height that are powers of two and less than the display mode */ + width = 1; + height = 1; + while (width * 2 <= mode.Width) + width *= 2; + while (height * 2 <= mode.Height) + height *= 2; + + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height, + D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &cursor, NULL); + ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#x.\n", + adapter_idx, test_idx, hr); + hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor); + ok(hr == D3D_OK, "Adapter %u test %u: SetCursorProperties failed, hr %#x.\n", + adapter_idx, test_idx, hr); + IDirect3DSurface9_Release(cursor); + + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width * 2, height, + D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &cursor, NULL); + ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#x.\n", + adapter_idx, test_idx, hr); + hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor); + ok(hr == D3DERR_INVALIDCALL, + "Adapter %u test %u: Expect SetCursorProperties return %#x, got %#x.\n", + adapter_idx, test_idx, D3DERR_INVALIDCALL, hr); + IDirect3DSurface9_Release(cursor); + + hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, width, height * 2, + D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &cursor, NULL); + ok(hr == D3D_OK, "Adapter %u test %u: CreateOffscreenPlainSurface failed, hr %#x.\n", + adapter_idx, test_idx, hr); + hr = IDirect3DDevice9_SetCursorProperties(device, 0, 0, cursor); + ok(hr == D3DERR_INVALIDCALL, + "Adapter %u test %u: Expect SetCursorProperties return %#x, got %#x.\n", + adapter_idx, test_idx, D3DERR_INVALIDCALL, hr); + IDirect3DSurface9_Release(cursor); + + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Adapter %u: Device has %u references left.\n", adapter_idx, refcount); + } + } cleanup: IDirect3D9_Release(d3d); DestroyWindow(window);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=68434
Your paranoid android.
=== w1064v1809_2scr (32 bit report) ===
d3d9: device.c:4697: Test failed: Expected to receive message 0x1c. device.c:4059: Test failed: Expected message 0x46 for window 0x1, but didn't receive it, i=0. device.c:4103: Test failed: Expected message 0x7e for window 0, but didn't receive it, i=0. device.c:4107: Test failed: The device window is active, i=0. device.c:4112: Test failed: Got unexpected hr 0x88760869. device.c:4116: Test failed: Got unexpected screen size 1152x870. device.c:4142: Test failed: Expected message 0x46 for window 0, but didn't receive it, i=0. device.c:4151: Test failed: Got unexpected screen size 1152x870. device.c:4168: Test failed: Expected message 0x7e for window 0, but didn't receive it, i=0. device.c:4176: Test failed: Got unexpected width 1152. device.c:4177: Test failed: Got unexpected height 864. device.c:4260: Test failed: Expected message 0x7e for window 0x1, but didn't receive it, i=0. device.c:4266: Test failed: Expected IsIconic 1, got 0, i=0. device.c:4270: Test failed: Got unexpected hr 0. device.c:4278: Test failed: Expected message 0x46 for window 0x1, but didn't receive it, i=0. device.c:4313: Test failed: Expected message 0x1c for window 0x1, but didn't receive it, i=0. device.c:4323: Test failed: Got unexpected hr 0. device.c:4377: Test failed: Expected message 0x18 for window 0, but didn't receive it, i=0. device.c:4383: Test failed: Got unexpected WINDOWPOS hwnd=00000000, insertAfter=00000000, x=0, y=0, cx=0, cy=0, flags=0 device.c:4400: Test failed: Expected the device window to be visible, i=0. device.c:4059: Test failed: Expected message 0x46 for window 0x1, but didn't receive it, i=1. device.c:4103: Test failed: Expected message 0x7e for window 0, but didn't receive it, i=1. device.c:4107: Test failed: The device window is active, i=1. device.c:4112: Test failed: Got unexpected hr 0x88760869. device.c:4116: Test failed: Got unexpected screen size 1152x870. device.c:4151: Test failed: Got unexpected screen size 1152x870. device.c:4168: Test failed: Expected message 0x7e for window 0, but didn't receive it, i=1. device.c:4176: Test failed: Got unexpected width 1152. device.c:4177: Test failed: Got unexpected height 864. device.c:4260: Test failed: Expected message 0x7e for window 0x1, but didn't receive it, i=1. device.c:4270: Test failed: Got unexpected hr 0. device.c:4313: Test failed: Expected message 0x1c for window 0x1, but didn't receive it, i=1. device.c:4323: Test failed: Got unexpected hr 0. device.c:4505: Test failed: Expected foreground window 001E02B8, got 000202B0. device.c:4971: Test failed: Expected device window style 0x14cf0000, got 0x4000000, i=0. device.c:4976: Test failed: Expected device window extended style 0x108, got 0, i=0. device.c:5008: Test failed: Expected device window style 0x14cf0000, got 0x4cf0000, i=0. device.c:5013: Test failed: Expected device window extended style 0x108, got 0x100, i=0. device.c:5027: Test failed: Failed to set foreground window. device.c:5031: Test failed: Expected device window style 0x34cf0000, got 0x4000000, i=0. device.c:5035: Test failed: Expected device window extended style 0x108, got 0, i=0. device.c:5051: Test failed: Failed to set foreground window. device.c:5054: Test failed: Failed to reset device, hr 0x88760868. device.c:5027: Test failed: Failed to set foreground window. device.c:5051: Test failed: Failed to set foreground window. device.c:5054: Test failed: Failed to reset device, hr 0x88760868. device.c:11419: Test failed: Failed to set foreground window. device.c:11421: Test failed: Got unexpected hr 0. device.c:11423: Test failed: Got unexpected hr 0. device.c:11428: Test failed: Failed to set foreground window. device.c:11430: Test failed: Got unexpected hr 0. device.c:11432: Test failed: Got unexpected hr 0. device.c:11450: Test failed: Failed to set foreground window. device.c:11459: Test failed: Failed to set foreground window. device.c:11474: Test failed: Failed to set foreground window. device.c:11476: Test failed: Got unexpected hr 0. device.c:11480: Test failed: Failed to set foreground window.
=== w1064v1809_ar (32 bit report) ===
d3d9: device.c:1827: Test failed: The cursor handle is 00010019