[PATCH 5/6] ntoskrnl.exe/tests: Add some HidP_GetValueCaps tests.

Rémi Bernon rbernon at codeweavers.com
Thu Jun 3 06:45:05 CDT 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/hid/hidp.c                    |  5 ++--
 dlls/ntoskrnl.exe/tests/ntoskrnl.c | 43 ++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c
index 9c7bac55abc..03c6a897248 100644
--- a/dlls/hid/hidp.c
+++ b/dlls/hid/hidp.c
@@ -474,14 +474,14 @@ NTSTATUS WINAPI HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS
                                   PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData)
 {
     PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData;
-    WINE_HID_ELEMENT *elems = HID_ELEMS(data);
+    WINE_HID_ELEMENT *elems;
     WINE_HID_REPORT *report = NULL;
     USHORT v_count = 0, r_count = 0;
     int i,j,u;
 
     TRACE("(%i, %p, %p, %p)\n", ReportType, ValueCaps, ValueCapsLength, PreparsedData);
 
-    if (data->magic != HID_MAGIC)
+    if (!data || data->magic != HID_MAGIC)
         return HIDP_STATUS_INVALID_PREPARSED_DATA;
 
     switch(ReportType)
@@ -512,6 +512,7 @@ NTSTATUS WINAPI HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS
     v_count = min(v_count, *ValueCapsLength);
 
     u = 0;
+    elems = HID_ELEMS(data);
     for (j = 0; j < r_count && u < v_count; j++)
     {
         for (i = 0; i < report[j].elementCount && u < v_count; i++)
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index ca253dae7e5..9c500885e75 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -1506,6 +1506,7 @@ static void test_hid_device(void)
     SP_DEVINFO_DATA device = {sizeof(device)};
     PHIDP_PREPARSED_DATA preparsed_data;
     HIDP_BUTTON_CAPS button_caps[16];
+    HIDP_VALUE_CAPS value_caps[16];
     BOOL ret, found = FALSE;
     OBJECT_ATTRIBUTES attr;
     UNICODE_STRING string;
@@ -1605,6 +1606,48 @@ static void test_hid_device(void)
     ok(button_caps[0].Range.DataIndexMin == 2, "unexpected button caps Range.DataIndexMin %d, expected %d\n", button_caps[0].Range.DataIndexMin, 2);
     ok(button_caps[0].Range.DataIndexMax == 9, "unexpected button caps Range.DataIndexMax %d, expected %d\n", button_caps[0].Range.DataIndexMax, 9);
 
+    count = 0;
+    status = HidP_GetValueCaps(HidP_Output, value_caps, &count, preparsed_data);
+    todo_wine ok(status == HIDP_STATUS_USAGE_NOT_FOUND, "HidP_GetValueCaps returned %#x\n", status);
+    status = HidP_GetValueCaps(HidP_Feature + 1, value_caps, &count, preparsed_data);
+    ok(status == HIDP_STATUS_INVALID_REPORT_TYPE, "HidP_GetValueCaps returned %#x\n", status);
+    status = HidP_GetValueCaps(HidP_Input, value_caps, &count, preparsed_data);
+    todo_wine ok(status == HIDP_STATUS_BUFFER_TOO_SMALL, "HidP_GetValueCaps returned %#x\n", status);
+    count = ARRAY_SIZE(value_caps);
+    status = HidP_GetValueCaps(HidP_Input, value_caps, &count, NULL);
+    ok(status == HIDP_STATUS_INVALID_PREPARSED_DATA, "HidP_GetValueCaps returned %#x\n", status);
+    status = HidP_GetValueCaps(HidP_Input, value_caps, &count, preparsed_data);
+    ok(status == HIDP_STATUS_SUCCESS, "HidP_GetValueCaps returned %#x\n", status);
+    ok(count == caps.NumberInputValueCaps, "HidP_GetValueCaps returned count %d, expected %d\n", count, caps.NumberInputButtonCaps);
+
+    ok(value_caps[0].UsagePage == HID_USAGE_PAGE_GENERIC, "unexpected value caps UsagePage %x, expected %x\n", value_caps[0].UsagePage, HID_USAGE_PAGE_GENERIC);
+    ok(value_caps[0].ReportID == 0, "unexpected value caps ReportID %d, expected %d\n", value_caps[0].ReportID, 0);
+    ok(value_caps[0].IsAlias == 0, "unexpected value caps IsAlias %d, expected %d\n", value_caps[0].IsAlias, 0);
+    todo_wine ok(value_caps[0].BitField == 2, "unexpected value caps BitField %d, expected %d\n", value_caps[0].BitField, 2);
+    ok(value_caps[0].LinkCollection == 0, "unexpected value caps LinkCollection %d, expected %d\n", value_caps[0].LinkCollection, 0);
+    ok(value_caps[0].LinkUsage == HID_USAGE_GENERIC_JOYSTICK, "unexpected value caps LinkUsage %x, expected %x\n", value_caps[0].LinkUsage, HID_USAGE_GENERIC_JOYSTICK);
+    ok(value_caps[0].LinkUsagePage == HID_USAGE_PAGE_GENERIC, "unexpected value caps LinkUsagePage %x, expected %x\n", value_caps[0].LinkUsagePage, HID_USAGE_PAGE_GENERIC);
+    ok(!value_caps[0].IsRange, "unexpected value caps IsRange %d, expected %d\n", value_caps[0].IsRange, 0);
+    ok(!value_caps[0].IsStringRange, "unexpected value caps IsStringRange %d, expected %d\n", value_caps[0].IsStringRange, 0);
+    ok(!value_caps[0].IsDesignatorRange, "unexpected value caps IsDesignatorRange %d, expected %d\n", value_caps[0].IsDesignatorRange, 0);
+    ok(value_caps[0].IsAbsolute, "unexpected value caps IsAbsolute %d, expected %d\n", value_caps[0].IsAbsolute, 1);
+    ok(value_caps[0].HasNull == 0, "unexpected value caps HasNull %d, expected %d\n", value_caps[0].HasNull, 0);
+    ok(value_caps[0].BitSize == 8, "unexpected value caps BitSize %d, expected %d\n", value_caps[0].BitSize, 8);
+    ok(value_caps[0].ReportCount == 1, "unexpected value caps ReportCount %d, expected %d\n", value_caps[0].ReportCount, 1);
+    ok(value_caps[0].UnitsExp == 0, "unexpected value caps UnitsExp %d, expected %d\n", value_caps[0].UnitsExp, 0);
+    ok(value_caps[0].Units == 0, "unexpected value caps Units %d, expected %d\n", value_caps[0].Units, 0);
+    ok(value_caps[0].LogicalMin == -128, "unexpected value caps LogicalMin %d, expected %d\n", value_caps[0].LogicalMin, -128);
+    ok(value_caps[0].LogicalMax == 127, "unexpected value caps LogicalMax %d, expected %d\n", value_caps[0].LogicalMax, 127);
+    ok(value_caps[0].PhysicalMin == 0, "unexpected value caps PhysicalMin %d, expected %d\n", value_caps[0].PhysicalMin, 0);
+    ok(value_caps[0].PhysicalMax == 0, "unexpected value caps PhysicalMax %d, expected %d\n", value_caps[0].PhysicalMax, 0);
+    todo_wine ok(value_caps[0].NotRange.Usage == HID_USAGE_GENERIC_Y, "unexpected value caps NotRange.Usage %d, expected %d\n", value_caps[0].NotRange.Usage, HID_USAGE_GENERIC_Y);
+    ok(value_caps[0].NotRange.StringIndex == 0, "unexpected value caps NotRange.StringIndex %d, expected %d\n", value_caps[0].NotRange.StringIndex, 0);
+    ok(value_caps[0].NotRange.DesignatorIndex == 0, "unexpected value caps NotRange.DesignatorIndex %d, expected %d\n", value_caps[0].NotRange.DesignatorIndex, 0);
+    ok(value_caps[0].NotRange.DataIndex == 0, "unexpected value caps NotRange.DataIndex %d, expected %d\n", value_caps[0].NotRange.DataIndex, 0);
+
+    todo_wine ok(value_caps[1].NotRange.Usage == HID_USAGE_GENERIC_X, "unexpected value caps NotRange.Usage %d, expected %d\n", value_caps[0].NotRange.Usage, HID_USAGE_GENERIC_X);
+    ok(value_caps[2].NotRange.Usage == HID_USAGE_GENERIC_HATSWITCH, "unexpected value caps NotRange.Usage %d, expected %d\n", value_caps[0].NotRange.Usage, HID_USAGE_GENERIC_HATSWITCH);
+
     HidD_FreePreparsedData(preparsed_data);
     CloseHandle(file);
 
-- 
2.31.0




More information about the wine-devel mailing list