ReactOS  0.4.14-dev-98-gb0d4763
HidPDescription.c File Reference
#include <kmt_test.h>
#include <hidpddi.h>
#include <debug.h>
#include "HidP.h"
Include dependency graph for HidPDescription.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 C_ASSERT (sizeof(PowerProEliteDescriptor)==148)
 
static VOID TestGetCollectionDescription (VOID)
 
NTSTATUS TestHidPDescription (IN PDEVICE_OBJECT DeviceObject, IN ULONG ControlCode, IN PVOID Buffer OPTIONAL, IN SIZE_T InLength, IN OUT PSIZE_T OutLength)
 

Variables

static UCHAR ExampleKeyboardDescriptor []
 
static UCHAR PowerProEliteDescriptor []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file HidPDescription.c.

Function Documentation

◆ C_ASSERT()

C_ASSERT ( sizeof(PowerProEliteDescriptor = =148)

◆ TestGetCollectionDescription()

static VOID TestGetCollectionDescription ( VOID  )
static

Definition at line 133 of file HidPDescription.c.

134 {
137 
138  /* Empty report descriptor */
141  0,
142  NonPagedPool,
145  ok_eq_pointer(DeviceDescription.CollectionDesc, NULL);
146  ok_eq_ulong(DeviceDescription.CollectionDescLength, 0);
148  ok_eq_ulong(DeviceDescription.ReportIDsLength, 0);
150 
151  /* Sample keyboard report descriptor from the HID spec */
154  NonPagedPool,
157  ok_eq_ulong(DeviceDescription.CollectionDescLength, 1);
158  ok_eq_ulong(DeviceDescription.ReportIDsLength, 1);
159  if (!skip(NT_SUCCESS(Status), "Parsing failure\n"))
160  {
161  if (!skip(DeviceDescription.CollectionDescLength >= 1, "No collection\n"))
162  {
163  ok_eq_uint(DeviceDescription.CollectionDesc[0].UsagePage, HID_USAGE_PAGE_GENERIC);
164  ok_eq_uint(DeviceDescription.CollectionDesc[0].Usage, HID_USAGE_GENERIC_KEYBOARD);
165  ok_eq_uint(DeviceDescription.CollectionDesc[0].CollectionNumber, 1);
166  ok_eq_uint(DeviceDescription.CollectionDesc[0].InputLength, 9);
167  ok_eq_uint(DeviceDescription.CollectionDesc[0].OutputLength, 2);
168  ok_eq_uint(DeviceDescription.CollectionDesc[0].FeatureLength, 0);
169  ok_eq_uint(DeviceDescription.CollectionDesc[0].PreparsedDataLength, 476);
170  }
171  if (!skip(DeviceDescription.ReportIDsLength >= 1, "No report IDs\n"))
172  {
173  ok_eq_uint(DeviceDescription.ReportIDs[0].ReportID, 0);
174  ok_eq_uint(DeviceDescription.ReportIDs[0].CollectionNumber, 1);
175  ok_eq_uint(DeviceDescription.ReportIDs[0].InputLength, 8);
176  ok_eq_uint(DeviceDescription.ReportIDs[0].OutputLength, 1);
177  ok_eq_uint(DeviceDescription.ReportIDs[0].FeatureLength, 0);
178  }
180  }
181 
182  /* Regression test for CORE-11538 */
184  sizeof(PowerProEliteDescriptor),
185  NonPagedPool,
188  ok_eq_ulong(DeviceDescription.CollectionDescLength, 1);
189  ok_eq_ulong(DeviceDescription.ReportIDsLength, 4);
190  if (!skip(NT_SUCCESS(Status), "Parsing failure\n"))
191  {
192  if (!skip(DeviceDescription.CollectionDescLength >= 1, "No collection\n"))
193  {
194  ok_eq_uint(DeviceDescription.CollectionDesc[0].UsagePage, HID_USAGE_PAGE_GENERIC);
195  ok_eq_uint(DeviceDescription.CollectionDesc[0].Usage, HID_USAGE_GENERIC_JOYSTICK);
196  ok_eq_uint(DeviceDescription.CollectionDesc[0].CollectionNumber, 1);
197  ok_eq_uint(DeviceDescription.CollectionDesc[0].InputLength, 49);
198  ok_eq_uint(DeviceDescription.CollectionDesc[0].OutputLength, 49);
199  ok_eq_uint(DeviceDescription.CollectionDesc[0].FeatureLength, 49);
200  ok_eq_uint(DeviceDescription.CollectionDesc[0].PreparsedDataLength, 1388);
201  }
202  if (!skip(DeviceDescription.ReportIDsLength >= 1, "No first report ID\n"))
203  {
204  ok_eq_uint(DeviceDescription.ReportIDs[0].ReportID, 1);
205  ok_eq_uint(DeviceDescription.ReportIDs[0].CollectionNumber, 1);
206  ok_eq_uint(DeviceDescription.ReportIDs[0].InputLength, 49);
207  ok_eq_uint(DeviceDescription.ReportIDs[0].OutputLength, 49);
208  ok_eq_uint(DeviceDescription.ReportIDs[0].FeatureLength, 49);
209  }
210  if (!skip(DeviceDescription.ReportIDsLength >= 2, "No second report ID\n"))
211  {
212  ok_eq_uint(DeviceDescription.ReportIDs[1].ReportID, 2);
213  ok_eq_uint(DeviceDescription.ReportIDs[1].CollectionNumber, 1);
214  ok_eq_uint(DeviceDescription.ReportIDs[1].InputLength, 0);
215  ok_eq_uint(DeviceDescription.ReportIDs[1].OutputLength, 0);
216  ok_eq_uint(DeviceDescription.ReportIDs[1].FeatureLength, 49);
217  }
218  if (!skip(DeviceDescription.ReportIDsLength >= 3, "No third report ID\n"))
219  {
220  ok_eq_uint(DeviceDescription.ReportIDs[2].ReportID, 238);
221  ok_eq_uint(DeviceDescription.ReportIDs[2].CollectionNumber, 1);
222  ok_eq_uint(DeviceDescription.ReportIDs[2].InputLength, 0);
223  ok_eq_uint(DeviceDescription.ReportIDs[2].OutputLength, 0);
224  ok_eq_uint(DeviceDescription.ReportIDs[2].FeatureLength, 49);
225  }
226  if (!skip(DeviceDescription.ReportIDsLength >= 4, "No fourth report ID\n"))
227  {
228  ok_eq_uint(DeviceDescription.ReportIDs[3].ReportID, 239);
229  ok_eq_uint(DeviceDescription.ReportIDs[3].CollectionNumber, 1);
230  ok_eq_uint(DeviceDescription.ReportIDs[3].InputLength, 0);
231  ok_eq_uint(DeviceDescription.ReportIDs[3].OutputLength, 0);
232  ok_eq_uint(DeviceDescription.ReportIDs[3].FeatureLength, 49);
233  }
235  }
236 }
#define ok_eq_ulong(value, expected)
static UCHAR ExampleKeyboardDescriptor[]
#define HID_USAGE_GENERIC_KEYBOARD
Definition: hidusage.h:36
#define ok_eq_pointer(value, expected)
NTSTATUS NTAPI HidP_GetCollectionDescription(IN PHIDP_REPORT_DESCRIPTOR ReportDesc, IN ULONG DescLength, IN POOL_TYPE PoolType, OUT PHIDP_DEVICE_DESC DeviceDescription)
Definition: hidp.c:75
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI HidP_FreeCollectionDescription(IN PHIDP_DEVICE_DESC DeviceDescription)
Definition: hidp.c:13
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ _In_ PDEVICE_DESCRIPTION DeviceDescription
Definition: iofuncs.h:1015
#define HID_USAGE_PAGE_GENERIC
Definition: hidusage.h:176
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static UCHAR PowerProEliteDescriptor[]
#define HID_USAGE_GENERIC_JOYSTICK
Definition: hidusage.h:34
#define STATUS_NO_DATA_DETECTED
Definition: udferr_usr.h:131
Status
Definition: gdiplustypes.h:24
#define skip(...)
Definition: atltest.h:64
#define ok_eq_hex(value, expected)
#define ok_eq_uint(value, expected)
Definition: kmt_test.h:239
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593

Referenced by TestHidPDescription().

◆ TestHidPDescription()

NTSTATUS TestHidPDescription ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  ControlCode,
IN PVOID Buffer  OPTIONAL,
IN SIZE_T  InLength,
IN OUT PSIZE_T  OutLength 
)

Definition at line 239 of file HidPDescription.c.

245 {
248  UNREFERENCED_PARAMETER(InLength);
249  UNREFERENCED_PARAMETER(OutLength);
250 
251  PAGED_CODE();
252 
254 
256 
257  return STATUS_SUCCESS;
258 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289
#define PAGED_CODE()
Definition: video.h:57
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
Definition: bufpool.h:45
static VOID TestGetCollectionDescription(VOID)
#define IOCTL_TEST_DESCRIPTION
Definition: HidP.h:11
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2966

Variable Documentation

◆ ExampleKeyboardDescriptor

UCHAR ExampleKeyboardDescriptor[]
static

Definition at line 16 of file HidPDescription.c.

Referenced by TestGetCollectionDescription().

◆ PowerProEliteDescriptor

UCHAR PowerProEliteDescriptor[]
static

Definition at line 51 of file HidPDescription.c.

Referenced by TestGetCollectionDescription().