updating usbh init with class init

This commit is contained in:
hathach
2013-02-08 12:52:46 +07:00
parent 489b98cb93
commit 5bacdc6c0f
7 changed files with 48 additions and 6 deletions
+14
View File
@@ -144,6 +144,9 @@ tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_std_request_t * cons
TEST_ASSERT_EQUAL(desc_configuration.configuration.wTotalLength, p_request->wLength);
memcpy(data, &desc_configuration, p_request->wLength);
break;
default:
return TUSB_ERROR_OSAL_TIMEOUT;
}
return TUSB_ERROR_NONE;
@@ -210,3 +213,14 @@ void test_enum_failed_get_full_config_desc(void)
usbh_enumeration_task();
}
void test_enum_parse_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(5));
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1);
// hid_install
usbh_enumeration_task();
}
+13 -2
View File
@@ -41,6 +41,7 @@
#include "mock_osal.h"
#include "mock_hcd.h"
#include "mock_usbh_hcd.h"
#include "mock_tusb_callback.h"
extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1];
tusb_handle_device_t dev_hdl;
@@ -111,18 +112,28 @@ void test_usbh_init_reporter_queue_create_failed(void)
TEST_IGNORE();
}
void class_init_expect(void)
{
hidh_init_Expect();
//TODO update more classes
}
void test_usbh_init_ok(void)
{
uint32_t dummy;
osal_queue_handle_t dummy;
usbh_device_info_t device_info_zero[TUSB_CFG_HOST_DEVICE_MAX+1];
memclr_(device_info_zero, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
hcd_init_expect();
osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE);
osal_queue_create_IgnoreAndReturn((osal_queue_handle_t)(&dummy));
osal_queue_create_IgnoreAndReturn(dummy);
class_init_expect();
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, usbh_init());
TEST_ASSERT_EQUAL_MEMORY(device_info_zero, usbh_device_info_pool, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
}