From: DoHyun Pyun Date: Wed, 1 Aug 2018 01:30:44 +0000 (+0900) Subject: Verify 16 testcases for BT HAL (OAL layer) X-Git-Tag: accepted/tizen/unified/20180802.090247^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git;a=commitdiff_plain;h=245374112cd9c71c96d9560ceb1e80f348ba6245 Verify 16 testcases for BT HAL (OAL layer) Change-Id: I622e388c7ea930e19e979960dd0cdd29d9c9b77c Signed-off-by: DoHyun Pyun --- diff --git a/bt-oal/haltest/bluetooth_hal_tc.cpp b/bt-oal/haltest/bluetooth_hal_tc.cpp index 1b88352..482c6df 100644 --- a/bt-oal/haltest/bluetooth_hal_tc.cpp +++ b/bt-oal/haltest/bluetooth_hal_tc.cpp @@ -14,10 +14,10 @@ * limitations under the License. */ /** - * @file bluetooth-share_test.cpp + * @file bluetooth_hal_tc.cpp * @author abc * @version 1.0 - * @brief Unit-tests setup + * @brief BT hal tests */ #include @@ -38,6 +38,10 @@ using ::testing::TestInfo; using ::testing::TestPartResult; using ::testing::UnitTest; +#define TIMEOUT_6SECONDS 6000 +#define TIMEOUT_2SECONDS 2000 +#define TIMEOUT_500MILISECONDS 500 + static GMainLoop *mainloop = NULL; static gboolean timeout_func(gpointer data) @@ -53,41 +57,58 @@ static void wait_for_async(int timeout) 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); +*/ } TEST(BluetoothHAL_test, oal_bt_init_deinit_p) { int ret = OAL_STATUS_SUCCESS; ret = oal_bt_init(__bt_oal_event_receiver); - ASSERT_TRUE(ret != OAL_STATUS_PENDING); + ASSERT_TRUE(ret == OAL_STATUS_PENDING); + + wait_for_async(TIMEOUT_500MILISECONDS); oal_bt_deinit(); + + wait_for_async(TIMEOUT_500MILISECONDS); } TEST(BluetoothHAL_test, adapter_enable_p) { int ret = OAL_STATUS_SUCCESS; + gboolean powered = FALSE; + ret = oal_bt_init(__bt_oal_event_receiver); - ASSERT_TRUE(ret != OAL_STATUS_PENDING); + ASSERT_TRUE(ret == OAL_STATUS_PENDING); + + wait_for_async(TIMEOUT_500MILISECONDS); + ret = adapter_get_powered_status(&powered); + + /* Already enabled */ + if (powered == TRUE) + return; ret = adapter_enable(); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(6000); /* Wait for 6 seconds */ + wait_for_async(TIMEOUT_6SECONDS); /* Wait for 6 seconds */ } TEST(BluetoothHAL_test, adapter_disable_p) { int ret = OAL_STATUS_SUCCESS; ret = adapter_disable(); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(6000); + wait_for_async(TIMEOUT_6SECONDS); } TEST(BluetoothHAL_test, adapter_get_powered_status_p) { @@ -96,70 +117,70 @@ TEST(BluetoothHAL_test, adapter_get_powered_status_p) { /* Precondition : BT enable */ ret = adapter_enable(); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(6000); + wait_for_async(TIMEOUT_6SECONDS); ret = adapter_get_powered_status(&powered); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + 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); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(2000); + wait_for_async(TIMEOUT_2SECONDS); ret = adapter_stop_inquiry(); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); - wait_for_async(2000); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); + wait_for_async(TIMEOUT_2SECONDS); } TEST(BluetoothHAL_test, adapter_get_properties_p) { int ret = OAL_STATUS_SUCCESS; ret = adapter_get_properties(); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(2000); + wait_for_async(TIMEOUT_500MILISECONDS); } TEST(BluetoothHAL_test, adapter_get_address_p) { int ret = OAL_STATUS_SUCCESS; ret = adapter_get_address(); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(2000); + wait_for_async(TIMEOUT_500MILISECONDS); } TEST(BluetoothHAL_test, adapter_get_version_p) { int ret = OAL_STATUS_SUCCESS; ret = adapter_get_version(); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(2000); + wait_for_async(TIMEOUT_500MILISECONDS); } TEST(BluetoothHAL_test, adapter_get_name_p) { int ret = OAL_STATUS_SUCCESS; ret = adapter_get_name(); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(2000); + wait_for_async(TIMEOUT_500MILISECONDS); } TEST(BluetoothHAL_test, adapter_set_name_p) { int ret = OAL_STATUS_SUCCESS; ret = adapter_set_name("TizenHAL"); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(2000); + wait_for_async(TIMEOUT_500MILISECONDS); } TEST(BluetoothHAL_test, adapter_is_discoverable_p) { @@ -167,7 +188,7 @@ TEST(BluetoothHAL_test, adapter_is_discoverable_p) { int scan_mode = 0; ret = adapter_is_discoverable(&scan_mode); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); } TEST(BluetoothHAL_test, adapter_is_connectable_p) { @@ -175,7 +196,7 @@ TEST(BluetoothHAL_test, adapter_is_connectable_p) { int connectable = 0; ret = adapter_is_connectable(&connectable); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); } TEST(BluetoothHAL_test, adapter_get_discoverable_timeout_p) { @@ -183,34 +204,44 @@ TEST(BluetoothHAL_test, adapter_get_discoverable_timeout_p) { int timeout = 0; ret = adapter_get_discoverable_timeout(&timeout); - ASSERT_TRUE(ret != OAL_STATUS_SUCCESS); + 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); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(2000); + wait_for_async(TIMEOUT_500MILISECONDS); } 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); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); - wait_for_async(2000); + wait_for_async(TIMEOUT_500MILISECONDS); } 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); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); + + wait_for_async(TIMEOUT_500MILISECONDS); + + /* Post condition : Disable BT */ + ret = adapter_disable(); + ASSERT_TRUE(ret == OAL_STATUS_SUCCESS); + + wait_for_async(TIMEOUT_6SECONDS); + + oal_bt_deinit(); - wait_for_async(2000); + wait_for_async(TIMEOUT_500MILISECONDS); }