Commit d9d982df authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

ntoskrnl.exe/tests: Add some IOCTL_HID_WRITE_REPORT tests.

parent 881b2d65
......@@ -502,6 +502,33 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
break;
}
case IOCTL_HID_WRITE_REPORT:
{
HID_XFER_PACKET *packet = irp->UserBuffer;
ULONG expected_size = 2;
todo_wine
ok(in_size == sizeof(*packet), "got input size %u\n", in_size);
todo_wine
ok(!out_size, "got output size %u\n", out_size);
ok(packet->reportBufferLen >= expected_size, "got report size %u\n", packet->reportBufferLen);
if (report_id)
{
todo_wine_if(packet->reportBuffer[0] == 0xa5)
ok(packet->reportBuffer[0] == report_id, "got report id %x\n", packet->reportBuffer[0]);
}
else
{
todo_wine
ok(packet->reportBuffer[0] == 0xcd, "got first byte %x\n", packet->reportBuffer[0]);
}
irp->IoStatus.Information = 3;
ret = STATUS_SUCCESS;
break;
}
case IOCTL_HID_GET_INPUT_REPORT:
{
HID_XFER_PACKET *packet = irp->UserBuffer;
......
......@@ -2633,6 +2633,47 @@ static void test_hidp(HANDLE file, int report_id)
todo_wine ok(value == 3, "got length %u, expected 3\n", value);
SetLastError(0xdeadbeef);
ret = WriteFile(file, report, 0, &value, NULL);
ok(!ret, "WriteFile succeeded\n");
ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "WriteFile returned error %u\n", GetLastError());
ok(value == 0, "WriteFile returned %x\n", value);
SetLastError(0xdeadbeef);
ret = WriteFile(file, report, caps.OutputReportByteLength - 1, &value, NULL);
ok(!ret, "WriteFile succeeded\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INVALID_USER_BUFFER,
"WriteFile returned error %u\n", GetLastError());
ok(value == 0, "WriteFile returned %x\n", value);
memset(report, 0xcd, sizeof(report));
report[0] = 0xa5;
SetLastError(0xdeadbeef);
ret = WriteFile(file, report, caps.OutputReportByteLength * 2, &value, NULL);
if (report_id || broken(!ret) /* w7u */)
{
todo_wine
ok(!ret, "WriteFile succeeded\n");
todo_wine
ok(GetLastError() == ERROR_INVALID_PARAMETER, "WriteFile returned error %u\n", GetLastError());
todo_wine
ok(value == 0, "WriteFile wrote %u\n", value);
SetLastError(0xdeadbeef);
report[0] = report_id;
ret = WriteFile(file, report, caps.OutputReportByteLength, &value, NULL);
}
if (report_id)
{
ok(ret, "WriteFile failed, last error %u\n", GetLastError());
ok(value == 2, "WriteFile wrote %u\n", value);
}
else
{
ok(ret, "WriteFile failed, last error %u\n", GetLastError());
todo_wine ok(value == 3, "WriteFile wrote %u\n", value);
}
HidD_FreePreparsedData(preparsed_data);
CloseHandle(file);
}
......@@ -2680,7 +2721,7 @@ static void test_hid_device(DWORD report_id, DWORD polled)
todo_wine ok(found, "didn't find device\n");
file = CreateFileA(iface_detail->DevicePath, FILE_READ_ACCESS,
file = CreateFileA(iface_detail->DevicePath, FILE_READ_ACCESS | FILE_WRITE_ACCESS,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment