From 13abe0e9e171e400d759ae1279d5d6170c9ef816 Mon Sep 17 00:00:00 2001 From: mbanth Date: Thu, 27 May 2021 12:26:57 +0100 Subject: [PATCH] Update unit tests for explicit reset --- tests/xua_unit_tests/src/test_hid.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/xua_unit_tests/src/test_hid.c b/tests/xua_unit_tests/src/test_hid.c index 7dee6fcf..d528462f 100644 --- a/tests/xua_unit_tests/src/test_hid.c +++ b/tests/xua_unit_tests/src/test_hid.c @@ -26,6 +26,11 @@ static unsigned construct_usage_header( unsigned size ) return header; } +void setUp( void ) +{ + hidResetReportDescriptor(); +} + // Basic report descriptor tests void test_unprepared_hidGetReportDescriptor( void ) { @@ -40,6 +45,23 @@ void test_prepared_hidGetReportDescriptor( void ) TEST_ASSERT_NOT_NULL( reportDescPtr ); } +void test_reset_unprepared_hidGetReportDescriptor( void ) +{ + hidPrepareReportDescriptor(); + hidResetReportDescriptor(); + unsigned char* reportDescPtr = hidGetReportDescriptor(); + TEST_ASSERT_NULL( reportDescPtr ); +} + +void test_reset_prepared_hidGetReportDescriptor( void ) +{ + hidPrepareReportDescriptor(); + hidResetReportDescriptor(); + hidPrepareReportDescriptor(); + unsigned char* reportDescPtr = hidGetReportDescriptor(); + TEST_ASSERT_NOT_NULL( reportDescPtr ); +} + // Configurable and non-configurable item tests void test_configurable_item_hidSetReportItem( void ) { @@ -276,6 +298,7 @@ void test_modification_without_subsequent_preparation( void ) const unsigned char data[ 1 ] = { LOUDNESS_CONTROL }; const unsigned char header = construct_usage_header( sizeof data / sizeof( unsigned char )); + hidResetReportDescriptor(); unsigned retVal = hidSetReportItem( byte, bit, header, data ); TEST_ASSERT_EQUAL_UINT( HID_STATUS_GOOD, retVal ); @@ -294,6 +317,7 @@ void test_modification_with_subsequent_preparation( void ) const unsigned char data[ 1 ] = { LOUDNESS_CONTROL }; const unsigned char header = construct_usage_header( sizeof data / sizeof( unsigned char )); + hidResetReportDescriptor(); unsigned retVal = hidSetReportItem( byte, bit, header, data ); TEST_ASSERT_EQUAL_UINT( HID_STATUS_GOOD, retVal );