summaryrefslogtreecommitdiff
path: root/tests/test
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-04-07 14:44:53 +0700
committerhathach <[email protected]>2013-04-07 14:44:53 +0700
commit3d8a4ef8c8b8d6778e2bea47e709822bb6a358b5 (patch)
tree55a2c1f720250bb584f8b70193bd7e72024434ee /tests/test
parent27f860db9ffd46bb8cb43046f9203f510a554d7c (diff)
remove hcd_port_reset before set address in enumeration
add test & implement tusbh_hid_mouse_is_supported
Diffstat (limited to 'tests/test')
-rw-r--r--tests/test/host/hid/test_hidh_keyboard.c3
-rw-r--r--tests/test/host/hid/test_hidh_mouse.c31
-rw-r--r--tests/test/host/usbh/test_enum_task.c12
3 files changed, 39 insertions, 7 deletions
diff --git a/tests/test/host/hid/test_hidh_keyboard.c b/tests/test/host/hid/test_hidh_keyboard.c
index a3ef34542..56ba9dfbd 100644
--- a/tests/test/host/hid/test_hidh_keyboard.c
+++ b/tests/test/host/hid/test_hidh_keyboard.c
@@ -60,9 +60,10 @@ tusb_keyboard_report_t sample_key[2] =
};
uint8_t dev_addr;
-tusb_keyboard_report_t report;
hidh_interface_info_t *p_hidh_kbd;
+tusb_keyboard_report_t report;
+
tusb_descriptor_interface_t const *p_kbd_interface_desc = &desc_configuration.keyboard_interface;
tusb_descriptor_endpoint_t const *p_kdb_endpoint_desc = &desc_configuration.keyboard_endpoint;
diff --git a/tests/test/host/hid/test_hidh_mouse.c b/tests/test/host/hid/test_hidh_mouse.c
index e1e0d8fa0..b2086b9ad 100644
--- a/tests/test/host/hid/test_hidh_mouse.c
+++ b/tests/test/host/hid/test_hidh_mouse.c
@@ -46,9 +46,23 @@
#include "descriptor_test.h"
extern hidh_interface_info_t mouse_data[TUSB_CFG_HOST_DEVICE_MAX];
+hidh_interface_info_t *p_hidh_mouse;
+uint8_t dev_addr;
void setUp(void)
{
+ hidh_init();
+
+ dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1;
+
+ p_hidh_mouse = &mouse_data[dev_addr-1];
+
+ p_hidh_mouse->report_size = sizeof(tusb_mouse_report_t);
+ p_hidh_mouse->pipe_hdl = (pipe_handle_t) {
+ .dev_addr = dev_addr,
+ .xfer_type = TUSB_XFER_INTERRUPT,
+ .index = 1
+ };
}
void tearDown(void)
@@ -63,7 +77,24 @@ void test_mouse_init(void)
TEST_ASSERT_MEM_ZERO(mouse_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
}
+void test_mouse_is_supported_fail_unplug(void)
+{
+ tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_UNPLUG);
+ TEST_ASSERT_FALSE( tusbh_hid_mouse_is_supported(dev_addr) );
+}
+
+void test_mouse_is_supported_fail_not_opened(void)
+{
+ hidh_init();
+ tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
+ TEST_ASSERT_FALSE( tusbh_hid_mouse_is_supported(dev_addr) );
+}
+void test_mouse_is_supported_ok(void)
+{
+ tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
+ TEST_ASSERT_TRUE( tusbh_hid_mouse_is_supported(dev_addr) );
+}
diff --git a/tests/test/host/usbh/test_enum_task.c b/tests/test/host/usbh/test_enum_task.c
index f942af74c..d0b757ad7 100644
--- a/tests/test/host/usbh/test_enum_task.c
+++ b/tests/test/host/usbh/test_enum_task.c
@@ -179,7 +179,7 @@ void test_addr0_failed_dev_desc(void)
void test_addr0_failed_set_address(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(1));
- hcd_port_reset_Expect( usbh_devices[0].core_id );
+// hcd_port_reset_Expect( usbh_devices[0].core_id );
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task();
@@ -191,7 +191,7 @@ void test_addr0_failed_set_address(void)
void test_enum_failed_get_full_dev_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(2));
- hcd_port_reset_Expect( usbh_devices[0].core_id );
+// hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
@@ -211,7 +211,7 @@ void test_enum_failed_get_full_dev_desc(void)
void test_enum_failed_get_9byte_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(3));
- hcd_port_reset_Expect( usbh_devices[0].core_id );
+// hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
@@ -228,7 +228,7 @@ void test_enum_failed_get_9byte_config_desc(void)
void test_enum_failed_get_full_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(4));
- hcd_port_reset_Expect( usbh_devices[0].core_id );
+// hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
@@ -246,7 +246,7 @@ void class_install_expect(void)
void test_enum_parse_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(5));
- hcd_port_reset_Expect( usbh_devices[0].core_id );
+// hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
@@ -262,7 +262,7 @@ void test_enum_parse_config_desc(void)
void test_enum_set_configure(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(6));
- hcd_port_reset_Expect( usbh_devices[0].core_id );
+// hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);