[PATCH v2 6/6] ntoskrnl.exe/tests: Add some HidP_GetLinkCollectionNodes tests.
Rémi Bernon
rbernon at codeweavers.com
Thu Jun 3 07:55:46 CDT 2021
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/hid/hidp.c | 3 +++
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c
index c4d162695a9..fd2ac86da32 100644
--- a/dlls/hid/hidp.c
+++ b/dlls/hid/hidp.c
@@ -1002,6 +1002,9 @@ NTSTATUS WINAPI HidP_GetLinkCollectionNodes(HIDP_LINK_COLLECTION_NODE *LinkColle
TRACE("(%p, %p, %p)\n", LinkCollectionNode, LinkCollectionNodeLength, PreparsedData);
+ if (data->magic != HID_MAGIC)
+ return HIDP_STATUS_INVALID_PREPARSED_DATA;
+
if (*LinkCollectionNodeLength < data->caps.NumberLinkCollectionNodes)
return HIDP_STATUS_BUFFER_TOO_SMALL;
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index 4aa3284ad9c..cfd307aa52e 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -1584,10 +1584,12 @@ static void test_hid_device(void)
SP_DEVICE_INTERFACE_DETAIL_DATA_A *iface_detail = (void *)buffer;
SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)};
SP_DEVINFO_DATA device = {sizeof(device)};
+ HIDP_LINK_COLLECTION_NODE collections[16];
PHIDP_PREPARSED_DATA preparsed_data;
HIDP_BUTTON_CAPS button_caps[16];
HIDP_VALUE_CAPS value_caps[16];
BOOL ret, found = FALSE;
+ DWORD collection_count;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING string;
IO_STATUS_BLOCK io;
@@ -1653,6 +1655,25 @@ static void test_hid_device(void)
ok(caps.NumberFeatureValueCaps == 0, "unexpected caps NumberFeatureValueCaps %d, expected %d\n", caps.NumberFeatureValueCaps, 0);
ok(caps.NumberFeatureDataIndices == 0, "unexpected caps NumberFeatureDataIndices %d, expected %d\n", caps.NumberFeatureDataIndices, 0);
+ collection_count = 0;
+ status = HidP_GetLinkCollectionNodes(collections, &collection_count, preparsed_data);
+ ok(status == HIDP_STATUS_BUFFER_TOO_SMALL, "HidP_GetLinkCollectionNodes returned %#x\n", status);
+ collection_count = ARRAY_SIZE(collections);
+ status = HidP_GetLinkCollectionNodes(collections, &collection_count, (PHIDP_PREPARSED_DATA)buffer);
+ ok(status == HIDP_STATUS_INVALID_PREPARSED_DATA, "HidP_GetLinkCollectionNodes returned %#x\n", status);
+ status = HidP_GetLinkCollectionNodes(collections, &collection_count, preparsed_data);
+ ok(status == HIDP_STATUS_SUCCESS, "HidP_GetLinkCollectionNodes returned %#x\n", status);
+ ok(collection_count == caps.NumberLinkCollectionNodes, "HidP_GetLinkCollectionNodes returned count %d, expected %d\n", collection_count, caps.NumberLinkCollectionNodes);
+
+ ok(collections[0].LinkUsage == HID_USAGE_GENERIC_JOYSTICK, "unexpected collection LinkUsage %x, expected %x\n", collections[0].LinkUsage, HID_USAGE_GENERIC_JOYSTICK);
+ ok(collections[0].LinkUsagePage == HID_USAGE_PAGE_GENERIC, "unexpected collection LinkUsagePage %x, expected %x\n", collections[0].LinkUsagePage, HID_USAGE_PAGE_GENERIC);
+ ok(collections[0].Parent == 0, "unexpected collection Parent %d, expected %d\n", collections[0].Parent, 0);
+ ok(collections[0].NumberOfChildren == 0, "unexpected collection NumberOfChildren %d, expected %d\n", collections[0].NumberOfChildren, 0);
+ ok(collections[0].NextSibling == 0, "unexpected collection NextSibling %d, expected %d\n", collections[0].NextSibling, 0);
+ ok(collections[0].FirstChild == 0, "unexpected collection FirstChild %d, expected %d\n", collections[0].FirstChild, 0);
+ ok(collections[0].CollectionType == 1, "unexpected collection CollectionType %d, expected %d\n", collections[0].CollectionType, 1);
+ ok(collections[0].IsAlias == 0, "unexpected collection IsAlias %d, expected %d\n", collections[0].IsAlias, 0);
+
count = 0;
status = HidP_GetButtonCaps(HidP_Output, button_caps, &count, preparsed_data);
todo_wine ok(status == HIDP_STATUS_USAGE_NOT_FOUND, "HidP_GetButtonCaps returned %#x\n", status);
--
2.31.0
More information about the wine-devel
mailing list