Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com ---
v3: use todo_wine only where applicable
supersedes 210321
dlls/dinput/tests/mouse.c | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index 69051bb2a34..d4ffcf4853b 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,22 @@ 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); + ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr); + todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt); + todo_wine ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", mouse_state[0].dwTimeStamp);
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); + ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr); + todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt); + todo_wine ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", mouse_state[0].dwTimeStamp);
hr = IDirectInputDevice_Acquire(pMouse); ok(hr == S_OK, "Failed: %08x\n", hr); @@ -178,20 +184,29 @@ 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); + ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr); + todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt); + todo_wine ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", 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); + ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr); + todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt); + todo_wine ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", 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); + ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr); + todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt); + ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", mouse_state[0].dwTimeStamp);
/* Check for granularity property using BYOFFSET */ memset(&di_op, 0, sizeof(di_op));
On 7/27/21 4:49 PM, Arkadiusz Hiler wrote:
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com
v3: use todo_wine only where applicable
supersedes 210321
dlls/dinput/tests/mouse.c | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index 69051bb2a34..d4ffcf4853b 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,22 @@ 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);
ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr);
todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt);
todo_wine ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", mouse_state[0].dwTimeStamp);
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);
ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr);
todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt);
todo_wine ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", mouse_state[0].dwTimeStamp);
hr = IDirectInputDevice_Acquire(pMouse); ok(hr == S_OK, "Failed: %08x\n", hr);
@@ -178,20 +184,29 @@ 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);
ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr);
todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt);
todo_wine ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", 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);
ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr);
todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt);
todo_wine ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", 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);
ok(hr == S_OK, "GetDeviceData() failed: %08x\n", hr);
todo_wine ok(cnt == ARRAY_SIZE(mouse_state), "GetDeviceData() unexpected cnt: %d\n", cnt);
ok(mouse_state[0].dwTimeStamp == 0xdeadbeef, "GetDeviceData() overwrote the timestamp: %d\n", mouse_state[0].dwTimeStamp);
/* Check for granularity property using BYOFFSET */ memset(&di_op, 0, sizeof(di_op));
AFAICS the function does nothing with dinput <= 7, but only when used with DIDEVICEOBJECTDATA struct. It works as expected in the following cases:
* dinput >= 8 with size == sizeof(DIDEVICEOBJECTDATA) * dinput <= 7 with size == sizeof(DIDEVICEOBJECTDATA_DX3)
The function fails with E_INVALIDARG with dinput >= 8 when called with sizeof(DIDEVICEOBJECTDATA_DX3).
I think a few simple tests should validate that (with a test in dinput8/device), but then the tests should instead use the appropriate sizes and check that the event data can be read.
Cheers,