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

ntoskrnl.exe/tests: Add some HidD_SetOutputReport tests.

parent d2ad6274
......@@ -290,6 +290,26 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
REPORT_SIZE(1, 1),
FEATURE(1, Data|Var|Abs),
END_COLLECTION,
USAGE_PAGE(1, HID_USAGE_PAGE_LED),
USAGE(1, HID_USAGE_LED_GREEN),
COLLECTION(1, Report),
REPORT_ID_OR_USAGE_PAGE(1, report_id, 0),
USAGE_PAGE(1, HID_USAGE_PAGE_LED),
REPORT_COUNT(1, 8),
REPORT_SIZE(1, 1),
OUTPUT(1, Cnst|Var|Abs),
END_COLLECTION,
USAGE_PAGE(1, HID_USAGE_PAGE_LED),
USAGE(1, HID_USAGE_LED_RED),
COLLECTION(1, Report),
REPORT_ID_OR_USAGE_PAGE(1, report_id, 1),
USAGE_PAGE(1, HID_USAGE_PAGE_LED),
REPORT_COUNT(1, 8),
REPORT_SIZE(1, 1),
OUTPUT(1, Cnst|Var|Abs),
END_COLLECTION,
END_COLLECTION,
};
#undef REPORT_ID_OR_USAGE_PAGE
......@@ -403,6 +423,25 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
break;
}
case IOCTL_HID_SET_OUTPUT_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);
todo_wine_if(packet->reportId != report_id)
ok(packet->reportId == report_id, "got packet report id %u\n", packet->reportId);
todo_wine_if(packet->reportBufferLen == 0 || packet->reportBufferLen == 1)
ok(packet->reportBufferLen >= expected_size, "got packet buffer len %u, expected %d or more\n",
packet->reportBufferLen, expected_size);
ok(!!packet->reportBuffer, "got packet buffer %p\n", packet->reportBuffer);
irp->IoStatus.Information = 3;
ret = STATUS_SUCCESS;
break;
}
case IOCTL_HID_GET_FEATURE:
{
HID_XFER_PACKET *packet = irp->UserBuffer;
......
......@@ -1685,8 +1685,9 @@ static void test_hidp(HANDLE file, int report_id)
.Usage = HID_USAGE_GENERIC_JOYSTICK,
.UsagePage = HID_USAGE_PAGE_GENERIC,
.InputReportByteLength = 24,
.OutputReportByteLength = 3,
.FeatureReportByteLength = 18,
.NumberLinkCollectionNodes = 8,
.NumberLinkCollectionNodes = 10,
.NumberInputButtonCaps = 13,
.NumberInputValueCaps = 7,
.NumberInputDataIndices = 43,
......@@ -1699,8 +1700,9 @@ static void test_hidp(HANDLE file, int report_id)
.Usage = HID_USAGE_GENERIC_JOYSTICK,
.UsagePage = HID_USAGE_PAGE_GENERIC,
.InputReportByteLength = 23,
.OutputReportByteLength = 2,
.FeatureReportByteLength = 17,
.NumberLinkCollectionNodes = 8,
.NumberLinkCollectionNodes = 10,
.NumberInputButtonCaps = 13,
.NumberInputValueCaps = 7,
.NumberInputDataIndices = 43,
......@@ -1842,8 +1844,8 @@ static void test_hidp(HANDLE file, int report_id)
.LinkUsage = HID_USAGE_GENERIC_JOYSTICK,
.LinkUsagePage = HID_USAGE_PAGE_GENERIC,
.CollectionType = 1,
.NumberOfChildren = 5,
.FirstChild = 7,
.NumberOfChildren = 7,
.FirstChild = 9,
},
{
.LinkUsage = HID_USAGE_GENERIC_JOYSTICK,
......@@ -2580,6 +2582,57 @@ static void test_hidp(HANDLE file, int report_id)
todo_wine ok(value == 3, "got length %u, expected 3\n", value);
memset(report, 0xcd, sizeof(report));
status = HidP_InitializeReportForID(HidP_Output, report_id, preparsed_data, report, caps.OutputReportByteLength);
ok(status == HIDP_STATUS_REPORT_DOES_NOT_EXIST, "HidP_InitializeReportForID returned %#x\n", status);
memset(report, 0, caps.OutputReportByteLength);
report[0] = report_id;
SetLastError(0xdeadbeef);
ret = HidD_SetOutputReport(file, report, 0);
todo_wine ok(!ret, "HidD_SetOutputReport succeeded\n");
todo_wine ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "HidD_SetOutputReport returned error %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = HidD_SetOutputReport(file, report, caps.OutputReportByteLength - 1);
todo_wine
ok(!ret, "HidD_SetOutputReport succeeded\n");
todo_wine
ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == ERROR_CRC),
"HidD_SetOutputReport returned error %u\n", GetLastError());
SetLastError(0xdeadbeef);
memset(buffer, 0x5a, sizeof(buffer));
ret = HidD_SetOutputReport(file, buffer, caps.OutputReportByteLength);
if (report_id || broken(!ret))
{
todo_wine
ok(!ret, "HidD_SetOutputReport succeeded, last error %u\n", GetLastError());
todo_wine
ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == ERROR_CRC),
"HidD_SetOutputReport returned error %u\n", GetLastError());
}
else
{
ok(ret, "HidD_SetOutputReport failed, last error %u\n", GetLastError());
}
SetLastError(0xdeadbeef);
ret = HidD_SetOutputReport(file, report, caps.OutputReportByteLength);
ok(ret, "HidD_SetOutputReport failed, last error %u\n", GetLastError());
value = caps.OutputReportByteLength * 2;
SetLastError(0xdeadbeef);
ret = sync_ioctl(file, IOCTL_HID_SET_OUTPUT_REPORT, NULL, 0, report, &value);
todo_wine ok(!ret, "IOCTL_HID_SET_OUTPUT_REPORT succeeded\n");
todo_wine ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "IOCTL_HID_SET_OUTPUT_REPORT returned error %u\n", GetLastError());
value = 0;
SetLastError(0xdeadbeef);
ret = sync_ioctl(file, IOCTL_HID_SET_OUTPUT_REPORT, report, caps.OutputReportByteLength * 2, NULL, &value);
ok(ret, "IOCTL_HID_SET_OUTPUT_REPORT failed, last error %u\n", GetLastError());
todo_wine ok(value == 3, "got length %u, expected 3\n", value);
HidD_FreePreparsedData(preparsed_data);
CloseHandle(file);
}
......
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