From 2e860afedf4f5877e76e1bb0e2b0354c4fde2f1f Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Tue, 31 Jul 2018 17:23:43 +0900 Subject: [PATCH] Add HAL testcases for oal adapater Change-Id: Iffacb93377869fca5fb66e80e605f8bbbc1b367b Signed-off-by: DoHyun Pyun --- bt-oal/haltest/CMakeLists.txt | 1 + bt-oal/haltest/bluetooth_hal_tc.cpp | 165 ++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) diff --git a/bt-oal/haltest/CMakeLists.txt b/bt-oal/haltest/CMakeLists.txt index 43936cd..c7e9493 100644 --- a/bt-oal/haltest/CMakeLists.txt +++ b/bt-oal/haltest/CMakeLists.txt @@ -22,6 +22,7 @@ INCLUDE_DIRECTORIES(/usr/include) INCLUDE_DIRECTORIES(/usr/include/db-util) INCLUDE_DIRECTORIES(/usr/include/glib-2.0) INCLUDE_DIRECTORIES(/usr/lib/glib-2.0/include/) +INCLUDE_DIRECTORIES(/usr/lib64/glib-2.0/include/) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/hardware) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common) diff --git a/bt-oal/haltest/bluetooth_hal_tc.cpp b/bt-oal/haltest/bluetooth_hal_tc.cpp index 001c555..1b88352 100644 --- a/bt-oal/haltest/bluetooth_hal_tc.cpp +++ b/bt-oal/haltest/bluetooth_hal_tc.cpp @@ -25,7 +25,9 @@ #include #include +#include "bluetooth.h" #include "oal-manager.h" +#include "oal-adapter-mgr.h" using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; @@ -36,6 +38,24 @@ using ::testing::TestInfo; using ::testing::TestPartResult; using ::testing::UnitTest; +static GMainLoop *mainloop = NULL; + +static gboolean timeout_func(gpointer data) +{ + g_main_loop_quit((GMainLoop *)data); + return FALSE; +} + +static void wait_for_async(int timeout) +{ + int timeout_id = 0; + mainloop = g_main_loop_new(NULL, FALSE); + + timeout_id = g_timeout_add(timeout, timeout_func, mainloop); + g_main_loop_run(mainloop); + g_source_remove(timeout_id); +} + static void __bt_oal_event_receiver(int event_type, gpointer event_data, gsize len) { printf("event_type: [%d], data size: [%d]\n", event_type, len); @@ -49,6 +69,151 @@ TEST(BluetoothHAL_test, oal_bt_init_deinit_p) { oal_bt_deinit(); } +TEST(BluetoothHAL_test, adapter_enable_p) { + int ret = OAL_STATUS_SUCCESS; + ret = oal_bt_init(__bt_oal_event_receiver); + ASSERT_TRUE(ret != OAL_STATUS_PENDING); + + + ret = adapter_enable(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(6000); /* Wait for 6 seconds */ +} + +TEST(BluetoothHAL_test, adapter_disable_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_disable(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(6000); +} + +TEST(BluetoothHAL_test, adapter_get_powered_status_p) { + int ret = OAL_STATUS_SUCCESS; + gboolean powered = FALSE; + + /* Precondition : BT enable */ + ret = adapter_enable(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(6000); + + ret = adapter_get_powered_status(&powered); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); +} + +TEST(BluetoothHAL_test, adapter_start_stop_inquiry_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_start_inquiry(0); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); + + ret = adapter_stop_inquiry(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + wait_for_async(2000); +} + +TEST(BluetoothHAL_test, adapter_get_properties_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_get_properties(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); +} + +TEST(BluetoothHAL_test, adapter_get_address_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_get_address(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); +} + +TEST(BluetoothHAL_test, adapter_get_version_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_get_version(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); +} + +TEST(BluetoothHAL_test, adapter_get_name_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_get_name(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); +} + +TEST(BluetoothHAL_test, adapter_set_name_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_set_name("TizenHAL"); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); +} + +TEST(BluetoothHAL_test, adapter_is_discoverable_p) { + int ret = OAL_STATUS_SUCCESS; + int scan_mode = 0; + + ret = adapter_is_discoverable(&scan_mode); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); +} + +TEST(BluetoothHAL_test, adapter_is_connectable_p) { + int ret = OAL_STATUS_SUCCESS; + int connectable = 0; + + ret = adapter_is_connectable(&connectable); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); +} + +TEST(BluetoothHAL_test, adapter_get_discoverable_timeout_p) { + int ret = OAL_STATUS_SUCCESS; + int timeout = 0; + + ret = adapter_get_discoverable_timeout(&timeout); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); +} + +TEST(BluetoothHAL_test, adapter_get_service_uuids_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_get_service_uuids(); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); +} + +TEST(BluetoothHAL_test, adapter_set_connectable_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_set_connectable(BT_SCAN_MODE_CONNECTABLE); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); +} + +TEST(BluetoothHAL_test, adapter_set_discoverable_timeout_p) { + int ret = OAL_STATUS_SUCCESS; + + ret = adapter_set_discoverable_timeout(0); + ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + + wait_for_async(2000); +} + + int main(int argc, char **argv) { InitGoogleTest(&argc, argv); -- 2.7.4