summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-26 02:02:54 +0700
committerhathach <[email protected]>2013-03-26 02:02:54 +0700
commit086a8e4a2dbd78dc42a6359c40e1920c9b93a701 (patch)
tree8f84a2563c448f02c57165ed486cab5c5615fbbf /tests
parentff03b452d9097c8fc40bebe115f6d5979aa6ed08 (diff)
add flag_supported_class to usbh_devices
remove all ATTR_WEAK in init,open,isr,close driver functions of USBH-CLASS API - prefer testing
Diffstat (limited to 'tests')
-rw-r--r--tests/test/host/ehci/test_ehci_usbh_hcd_integration.c2
-rw-r--r--tests/test/host/hid/test_hid_host.c (renamed from tests/test/host/hid/test_hidh.c)42
-rw-r--r--tests/test/host/hid/test_hidh_keyboard.c2
-rw-r--r--tests/test/host/test_enum_task.c1
4 files changed, 34 insertions, 13 deletions
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 b1417c388..ee640fff2 100644
--- a/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c
+++ b/tests/test/host/ehci/test_ehci_usbh_hcd_integration.c
@@ -42,6 +42,8 @@
#include "hal.h"
#include "mock_osal.h"
+#include "mock_hid_host.h"
+
#include "hcd.h"
#include "usbh_hcd.h"
#include "usbh.h"
diff --git a/tests/test/host/hid/test_hidh.c b/tests/test/host/hid/test_hid_host.c
index 412b5d820..3a398257c 100644
--- a/tests/test/host/hid/test_hidh.c
+++ b/tests/test/host/hid/test_hid_host.c
@@ -37,44 +37,62 @@
#include "stdlib.h"
#include "unity.h"
-#include "common/common.h"
+#include "tusb_option.h"
#include "errors.h"
-#include "hid_host.h"
+#include "binary.h"
+#include "descriptor_test.h"
#include "mock_osal.h"
#include "mock_hcd.h"
#include "mock_usbh.h"
#include "mock_hid_host_keyboard.h"
-
+#include "hid_host.h"
uint8_t dev_addr;
-uint8_t instance_num;
+
+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;
+tusb_descriptor_endpoint_t const *p_kdb_endpoint_desc = &desc_configuration.keyboard_endpoint;
void setUp(void)
{
- instance_num = 0;
-// dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1;
+ dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1;
}
void tearDown(void)
{
}
-void test_hidh_init(void)
+void test_hidh_init_ok(void)
{
- hidh_keyboard_init_Expect();
+// hidh_keyboard_init_Expect();
+ // TODO mouse, generic expect
//------------- Code Under TEST -------------//
- if (!hidh_init)
- TEST_IGNORE();
+// hidh_init();
+}
+void test_hidh_open_ok(void)
+{
+ uint16_t length=0;
+//
+// hidh_keyboard_open_subtask_ExpectAndReturn(dev_addr, p_kbd_interface_desc, &length, TUSB_ERROR_NONE);
+//
+ //------------- Code Under TEST -------------//
+// hidh_open_subtask(dev_addr, (uint8_t*) p_kbd_interface_desc, &length);
+
+// TEST_ASSERT_EQUAL(sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t),
+// length);
}
void test_hidh_close(void)
{
- if (!hidh_close)
- TEST_IGNORE();
+ hidh_keyboard_init_Ignore();
+ hidh_keyboard_close_Expect(dev_addr);
+
+ //------------- Code Under TEST -------------//
+// hidh_close(dev_addr);
}
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 d63a5eedb..528f146e2 100644
--- a/tests/test/host/hid/test_hidh_keyboard.c
+++ b/tests/test/host/hid/test_hidh_keyboard.c
@@ -126,7 +126,7 @@ void test_keyboard_open_ok(void)
TEST_ASSERT_PIPE_HANDLE(pipe_hdl, p_hidh_kbd->pipe_hdl);
TEST_ASSERT_EQUAL(8, p_hidh_kbd->report_size);
TEST_ASSERT_EQUAL(sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t),
- length);
+ length);
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_supported(dev_addr) );
diff --git a/tests/test/host/test_enum_task.c b/tests/test/host/test_enum_task.c
index f407e84df..70dc8d398 100644
--- a/tests/test/host/test_enum_task.c
+++ b/tests/test/host/test_enum_task.c
@@ -256,6 +256,7 @@ void test_enum_parse_config_desc(void)
usbh_enumeration_task();
TEST_ASSERT_EQUAL(desc_configuration.configuration.bNumInterfaces, usbh_devices[1].interface_count);
+ TEST_ASSERT_EQUAL(TUSB_CLASS_FLAG_HID, usbh_devices[1].flag_supported_class); // TODO change later
}
void test_enum_set_configure(void)