ReactOS 0.4.16-dev-336-gb667d82
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,
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 */
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);
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 */
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);
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}
static UCHAR PowerProEliteDescriptor[]
static UCHAR ExampleKeyboardDescriptor[]
#define ok_eq_pointer(value, expected)
Definition: apitest.h:59
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok_eq_uint(value, expected)
Definition: apitest.h:61
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI HidP_GetCollectionDescription(IN PHIDP_REPORT_DESCRIPTOR ReportDesc, IN ULONG DescLength, IN POOL_TYPE PoolType, OUT PHIDP_DEVICE_DESC DeviceDescription)
Definition: hidp.c:61
VOID NTAPI HidP_FreeCollectionDescription(IN PHIDP_DEVICE_DESC DeviceDescription)
Definition: hidp.c:13
#define HID_USAGE_PAGE_GENERIC
Definition: hidusage.h:176
#define HID_USAGE_GENERIC_KEYBOARD
Definition: hidusage.h:36
#define HID_USAGE_GENERIC_JOYSTICK
Definition: hidusage.h:34
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NO_DATA_DETECTED
Definition: udferr_usr.h:131
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432

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 PAGED_CODE()
static VOID TestGetCollectionDescription(VOID)
#define IOCTL_TEST_DESCRIPTION
Definition: HidP.h:11
Definition: bufpool.h:45
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3304

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().