[PATCH 6/6] ntoskrnl.exe/tests: Add some HidP_GetLinkCollectionNodes tests.
Rémi Bernon
rbernon at codeweavers.com
Thu Jun 3 06:45:06 CDT 2021
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/hid/hidp.c | 6 +++++-
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 21 +++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c
index 03c6a897248..94ff7ab3cd3 100644
--- a/dlls/hid/hidp.c
+++ b/dlls/hid/hidp.c
@@ -999,14 +999,18 @@ NTSTATUS WINAPI HidP_GetLinkCollectionNodes(HIDP_LINK_COLLECTION_NODE *LinkColle
ULONG *LinkCollectionNodeLength, PHIDP_PREPARSED_DATA PreparsedData)
{
WINE_HIDP_PREPARSED_DATA *data = (WINE_HIDP_PREPARSED_DATA*)PreparsedData;
- WINE_HID_LINK_COLLECTION_NODE *nodes = HID_NODES(data);
+ WINE_HID_LINK_COLLECTION_NODE *nodes;
ULONG i;
TRACE("(%p, %p, %p)\n", LinkCollectionNode, LinkCollectionNodeLength, PreparsedData);
+ if (!data || data->magic != HID_MAGIC)
+ return HIDP_STATUS_INVALID_PREPARSED_DATA;
+
if (*LinkCollectionNodeLength < data->caps.NumberLinkCollectionNodes)
return HIDP_STATUS_BUFFER_TOO_SMALL;
+ nodes = HID_NODES(data);
for (i = 0; i < data->caps.NumberLinkCollectionNodes; ++i)
{
LinkCollectionNode[i].LinkUsage = nodes[i].LinkUsage;
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index 9c500885e75..b27ac091cae 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -1504,10 +1504,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;
@@ -1572,6 +1574,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, NULL);
+ 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