[PATCH 1/4] dinput/tests: Prove that GetDeviceData() does nothing.
Zebediah Figura (she/her)
zfigura at codeweavers.com
Fri Jul 23 11:35:46 CDT 2021
On 7/23/21 10:37 AM, Arkadiusz Hiler wrote:
> Signed-off-by: Arkadiusz Hiler <ahiler at codeweavers.com>
> ---
> dlls/dinput/tests/mouse.c | 42 ++++++++++++++++++++++++---------------
> 1 file changed, 26 insertions(+), 16 deletions(-)
>
> diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c
> index 69051bb2a34..2d4699bb9a0 100644
> --- a/dlls/dinput/tests/mouse.c
> +++ b/dlls/dinput/tests/mouse.c
> @@ -106,7 +106,7 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd)
> DIMOUSESTATE m_state;
> HWND hwnd2;
> DIPROPDWORD di_op;
> - DIDEVICEOBJECTDATA mouse_state;
> + DIDEVICEOBJECTDATA mouse_state[30];
> DWORD cnt;
> int i;
>
> @@ -159,16 +159,20 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd)
> ok(hr == S_OK, "Acquire() failed: %08x\n", hr);
>
> mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0);
> - cnt = 1;
> - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
> - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
> + cnt = ARRAY_SIZE(mouse_state);
> + mouse_state[0].dwTimeStamp = 0xdeadbeef;
> + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
> + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
> + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
Any reason not to make this three separate ok calls?
>
> mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0);
> hr = IDirectInputDevice_Unacquire(pMouse);
> ok(hr == S_OK, "Failed: %08x\n", hr);
> - cnt = 1;
> - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
> - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
> + cnt = ARRAY_SIZE(mouse_state);
> + mouse_state[0].dwTimeStamp = 0xdeadbeef;
> + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
> + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
> + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
>
> hr = IDirectInputDevice_Acquire(pMouse);
> ok(hr == S_OK, "Failed: %08x\n", hr);
> @@ -178,20 +182,26 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd)
>
> hr = IDirectInputDevice_Acquire(pMouse);
> ok(hr == S_OK, "Failed: %08x\n", hr);
> - cnt = 1;
> - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
> - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
> + cnt = ARRAY_SIZE(mouse_state);
> + mouse_state[0].dwTimeStamp = 0xdeadbeef;
> + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
> + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
> + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
>
> /* Check for buffer overflow */
> for (i = 0; i < 6; i++)
> mouse_event(MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0);
>
> - cnt = 1;
> - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
> - ok(hr == DI_OK, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
> - cnt = 1;
> - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
> - ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt);
> + cnt = ARRAY_SIZE(mouse_state);
> + mouse_state[0].dwTimeStamp = 0xdeadbeef;
> + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
> + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
> + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
> + cnt = ARRAY_SIZE(mouse_state);
> + mouse_state[0].dwTimeStamp = 0xdeadbeef;
> + hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state[0]), mouse_state, &cnt, 0);
> + todo_wine ok(hr == S_OK && cnt == ARRAY_SIZE(mouse_state) && mouse_state[0].dwTimeStamp == 0xdeadbeef,
> + "GetDeviceData() failed: %08x cnt: %d, timestamp: %d\n", hr, cnt, mouse_state[0].dwTimeStamp);
>
> /* Check for granularity property using BYOFFSET */
> memset(&di_op, 0, sizeof(di_op));
>
More information about the wine-devel
mailing list