summaryrefslogtreecommitdiff
path: root/tests/test
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-26 16:39:25 +0700
committerhathach <[email protected]>2013-03-26 16:39:25 +0700
commitac905a8d09598067c53ff32835a2d70797d970be (patch)
tree2ea02bce7ac3f4174dc99f4a22e56abb1c109595 /tests/test
parent0b08dc7724a67f09be16fad3d6702ce0d7566f03 (diff)
rename pipe_status_t to tusb_interface_status_t
add tusbh_hid_keyboard_status & test code
Diffstat (limited to 'tests/test')
-rw-r--r--tests/test/host/hid/test_hidh_keyboard.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test/host/hid/test_hidh_keyboard.c b/tests/test/host/hid/test_hidh_keyboard.c
index fc4531765..101cc0bb9 100644
--- a/tests/test/host/hid/test_hidh_keyboard.c
+++ b/tests/test/host/hid/test_hidh_keyboard.c
@@ -97,7 +97,6 @@ void test_keyboard_init(void)
void test_keyboard_is_supported_fail_unplug(void)
{
- hidh_init();
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_UNPLUG);
TEST_ASSERT_FALSE( tusbh_hid_keyboard_is_supported(dev_addr) );
}
@@ -134,6 +133,7 @@ void test_keyboard_open_ok(void)
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_supported(dev_addr) );
+ TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, p_hidh_kbd->status);
}
//--------------------------------------------------------------------+
@@ -166,12 +166,24 @@ void test_keyboard_get_report_xfer_failed()
TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_hid_keyboard_get_report(dev_addr, 0, &report));
}
+void test_keyboard_get_report_xfer_failed_busy()
+{
+ tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
+ p_hidh_kbd->status = TUSB_INTERFACE_STATUS_BUSY;
+ TEST_ASSERT_EQUAL(TUSB_ERROR_INTERFACE_IS_BUSY, tusbh_hid_keyboard_get_report(dev_addr, 0, &report));
+}
+
void test_keyboard_get_ok()
{
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
+ TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_keyboard_status(dev_addr, 0));
+
+ tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
hcd_pipe_xfer_ExpectAndReturn(p_hidh_kbd->pipe_hdl, (uint8_t*) &report, p_hidh_kbd->report_size, true, TUSB_ERROR_NONE);
//------------- Code Under TEST -------------//
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_hid_keyboard_get_report(dev_addr, 0, &report));
-}
+ tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
+ TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_keyboard_status(dev_addr, 0));
+}