diff options
| author | hathach <[email protected]> | 2013-03-26 13:45:14 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-03-26 13:45:14 +0700 |
| commit | 205a21ff045087214afebd593134ed325138e6fd (patch) | |
| tree | 21576692a0c2688274e4215b298fc5e81a216598 /tests/test | |
| parent | 3c767e9f44ff6e430f85f7fae7c38ee8aca3b6e2 (diff) | |
add code for hidh close
refractor the full configure descriptor parsing in enum task
Diffstat (limited to 'tests/test')
| -rw-r--r-- | tests/test/host/hid/test_hid_host.c | 15 | ||||
| -rw-r--r-- | tests/test/host/hid/test_hidh_keyboard.c | 14 |
2 files changed, 21 insertions, 8 deletions
diff --git a/tests/test/host/hid/test_hid_host.c b/tests/test/host/hid/test_hid_host.c index 0b40d9c5b..8c53fa083 100644 --- a/tests/test/host/hid/test_hid_host.c +++ b/tests/test/host/hid/test_hid_host.c @@ -40,6 +40,7 @@ #include "tusb_option.h" #include "errors.h" #include "binary.h" +#include "type_helper.h" #include "descriptor_test.h" #include "mock_osal.h" @@ -49,6 +50,9 @@ #include "hid_host.h" uint8_t dev_addr; +pipe_handle_t pipe_hdl; + +extern hidh_keyboard_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; tusb_descriptor_interface_t const *p_kbd_interface_desc = &desc_configuration.keyboard_interface; tusb_hid_descriptor_hid_t const *p_kbh_hid_desc = &desc_configuration.keyboard_hid; @@ -57,6 +61,7 @@ tusb_descriptor_endpoint_t const *p_kdb_endpoint_desc = &desc_configuration.ke void setUp(void) { dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1; + pipe_hdl = (pipe_handle_t) {.dev_addr = dev_addr, .xfer_type = TUSB_XFER_INTERRUPT, .index = 2}; } void tearDown(void) @@ -66,7 +71,7 @@ void tearDown(void) void test_hidh_open_ok(void) { uint16_t length=0; - pipe_handle_t pipe_hdl = {.dev_addr = dev_addr, .xfer_type = TUSB_XFER_INTERRUPT, .index = 2}; + // TODO expect get HID report descriptor hcd_pipe_open_IgnoreAndReturn( pipe_hdl ); @@ -80,9 +85,15 @@ void test_hidh_open_ok(void) void test_hidh_close(void) { - TEST_IGNORE(); + keyboard_data[dev_addr-1].pipe_hdl = pipe_hdl; + keyboard_data[dev_addr-1].report_size = 8; + + hcd_pipe_close_ExpectAndReturn(pipe_hdl, TUSB_ERROR_NONE); + //------------- Code Under TEST -------------// hidh_close(dev_addr); + + TEST_ASSERT_MEM_ZERO(&keyboard_data[dev_addr-1], sizeof(hidh_keyboard_info_t)); } void test_hihd_isr(void) diff --git a/tests/test/host/hid/test_hidh_keyboard.c b/tests/test/host/hid/test_hidh_keyboard.c index b124ade00..fc4531765 100644 --- a/tests/test/host/hid/test_hidh_keyboard.c +++ b/tests/test/host/hid/test_hidh_keyboard.c @@ -109,11 +109,18 @@ void test_keyboard_is_supported_fail_not_opened(void) TEST_ASSERT_FALSE( tusbh_hid_keyboard_is_supported(dev_addr) ); } +void test_keyboard_is_supported_ok(void) +{ + tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); + TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_supported(dev_addr) ); +} + void test_keyboard_open_ok(void) { uint16_t length=0; pipe_handle_t pipe_hdl = {.dev_addr = dev_addr, .xfer_type = TUSB_XFER_INTERRUPT, .index = 2}; - memclr_(p_hidh_kbd, sizeof(hidh_keyboard_info_t)); + + hidh_init(); hcd_pipe_open_ExpectAndReturn(dev_addr, p_kdb_endpoint_desc, TUSB_CLASS_HID, pipe_hdl); @@ -129,11 +136,6 @@ void test_keyboard_open_ok(void) TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_supported(dev_addr) ); } -void test_keyboard_close(void) -{ - -} - //--------------------------------------------------------------------+ // keyboard_get //--------------------------------------------------------------------+ |
