dinput8/tests: Make ret_length optional in struct hid_expect.

So that we don't have to specify it explicitely every time. Input
reports length is now enforced, and we don't mean to test the length
every time we inject input.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-09-17 09:06:23 +02:00 committed by Alexandre Julliard
parent 91d9819c95
commit e293db88a8
1 changed files with 14 additions and 10 deletions

View File

@ -225,11 +225,15 @@ static void input_queue_cleanup( struct input_queue *queue )
static BOOL input_queue_read_locked( struct input_queue *queue, IRP *irp )
{
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp );
ULONG out_size = stack->Parameters.DeviceIoControl.OutputBufferLength;
struct hid_expect *tmp = queue->pos;
if (tmp >= queue->end) return FALSE;
memcpy( irp->UserBuffer, tmp->report_buf, tmp->ret_length );
irp->IoStatus.Information = tmp->ret_length;
if (tmp >= queue->end) return FALSE;
if (tmp->ret_length) out_size = tmp->ret_length;
memcpy( irp->UserBuffer, tmp->report_buf, out_size );
irp->IoStatus.Information = out_size;
irp->IoStatus.Status = tmp->ret_status;
if (tmp < queue->end) queue->pos = tmp + 1;
@ -464,7 +468,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
"unexpected data\n" );
winetest_pop_context();
irp->IoStatus.Information = expect.ret_length;
irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
ret = expect.ret_status;
break;
}
@ -487,8 +491,8 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
winetest_pop_context();
memcpy( packet->reportBuffer, expect.report_buf, expect.ret_length );
irp->IoStatus.Information = expect.ret_length;
irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
memcpy( packet->reportBuffer, expect.report_buf, irp->IoStatus.Information );
ret = expect.ret_status;
break;
}
@ -513,7 +517,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
"unexpected data\n" );
winetest_pop_context();
irp->IoStatus.Information = expect.ret_length;
irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
ret = expect.ret_status;
break;
}
@ -536,8 +540,8 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
winetest_pop_context();
memcpy( packet->reportBuffer, expect.report_buf, expect.ret_length );
irp->IoStatus.Information = expect.ret_length;
irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
memcpy( packet->reportBuffer, expect.report_buf, irp->IoStatus.Information );
ret = expect.ret_status;
break;
}
@ -562,7 +566,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
"unexpected data\n" );
winetest_pop_context();
irp->IoStatus.Information = expect.ret_length;
irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
ret = expect.ret_status;
break;
}