diff --git a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c index f25d0f198..44cea9ab1 100644 --- a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c +++ b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c @@ -75,7 +75,9 @@ void setUp(void) ehci_controller_init(); helper_usbh_init_expect(); + helper_class_init_expect(); usbh_init(); + helper_usbh_device_emulate(dev_addr, hub_addr, hub_port, hostid, TUSB_SPEED_HIGH); regs = get_operational_register(hostid); diff --git a/tests/test/host/host_helper.h b/tests/test/host/host_helper.h index 502cd3288..f4fdf62d4 100644 --- a/tests/test/host/host_helper.h +++ b/tests/test/host/host_helper.h @@ -39,18 +39,25 @@ #include "host/usbh.h" #include "host/usbh_hcd.h" -static inline void class_init_expect(void) +static inline void helper_class_init_expect(void) { hidh_init_Expect(); //TODO update more classes } +static inline void helper_class_close_expect(uint8_t dev_addr) +{ + hidh_close_Expect(dev_addr); + //TODO update more classes +} + + + static inline void helper_usbh_init_expect(void) { osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234); osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); osal_queue_create_IgnoreAndReturn( (osal_queue_handle_t) 0x4566 ); - class_init_expect(); } static inline void helper_usbh_device_emulate(uint8_t dev_addr, uint8_t hub_addr, uint8_t hub_port, uint8_t hostid, tusb_speed_t speed) diff --git a/tests/test/host/usbh/test_usbh.c b/tests/test/host/usbh/test_usbh.c index c1ff1007b..b72fd2966 100644 --- a/tests/test/host/usbh/test_usbh.c +++ b/tests/test/host/usbh/test_usbh.c @@ -49,6 +49,7 @@ #include "mock_tusb_callback.h" #include "mock_hid_host.h" +#include "host_helper.h" uint8_t dev_addr; void setUp(void) @@ -103,22 +104,12 @@ void test_usbh_init_enum_queue_create_failed(void) TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_QUEUE_FAILED, usbh_init()); } -void class_init_expect(void) -{ - hidh_init_Expect(); - - //TODO update more classes -} - void test_usbh_init_ok(void) { hcd_init_ExpectAndReturn(TUSB_ERROR_NONE); - osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234); - osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); - osal_queue_create_IgnoreAndReturn( (osal_queue_handle_t) 0x4566 ); - - class_init_expect(); + helper_usbh_init_expect(); + helper_class_init_expect(); //------------- code under test -------------// TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, usbh_init()); @@ -129,11 +120,6 @@ void test_usbh_init_ok(void) } } -void class_close_expect(void) -{ - hidh_close_Expect(1); -} - // device is not mounted before, even the control pipe is not open, do nothing void test_usbh_device_unplugged_isr_device_not_previously_mounted(void) { @@ -157,7 +143,7 @@ void test_usbh_device_unplugged_isr(void) usbh_devices[dev_addr].hub_port = 0; usbh_devices[dev_addr].flag_supported_class = TUSB_CLASS_FLAG_HID; - class_close_expect(); + helper_class_close_expect(dev_addr); hcd_pipe_control_close_ExpectAndReturn(dev_addr, TUSB_ERROR_NONE); //------------- Code Under Test -------------//