+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file bluetooth_hal_tc.cpp
- * @author abc
- * @version 1.0
- * @brief BT hal tests
- */
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <unistd.h>
-#include <glib.h>
-#include <system_info.h>
-
-#include "bluetooth.h"
-#include "oal-manager.h"
-#include "oal-adapter-mgr.h"
-
-using ::testing::EmptyTestEventListener;
-using ::testing::InitGoogleTest;
-using ::testing::Test;
-using ::testing::TestCase;
-using ::testing::TestEventListeners;
-using ::testing::TestInfo;
-using ::testing::TestPartResult;
-using ::testing::UnitTest;
-
-#define TIMEOUT_6SECONDS 6000
-#define TIMEOUT_2SECONDS 2000
-#define TIMEOUT_500MILISECONDS 500
-
-#define FEATURE_BT "http://tizen.org/feature/network.bluetooth"
-
-#define SKIP_NOT_SUPPORTED(bFeature) {\
- if (!bFeature) {\
- printf("Feature is not support\n");\
- return;\
- } \
-}
-
-static bool g_bFeatureBT;
-
-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);
- if (timeout_id < 0)
- return;
-
- g_main_loop_run(mainloop);
-}
-
-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);
-*/
-}
-
-static bool __check_feature_supported(char *key)
-{
- bool value = false;
- int ret = system_info_get_platform_bool(key, &value);
-
- EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
-
- return value;
-}
-
-TEST(BluetoothHAL_test, oal_bt_init_deinit_p) {
- g_bFeatureBT = __check_feature_supported((char*)FEATURE_BT);
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = oal_bt_init(__bt_oal_event_receiver);
- 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) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
- gboolean powered = FALSE;
-
- ret = oal_bt_init(__bt_oal_event_receiver);
- 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);
-
- wait_for_async(TIMEOUT_6SECONDS); /* Wait for 6 seconds */
-}
-
-TEST(BluetoothHAL_test, adapter_disable_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_disable();
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_6SECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_get_powered_status_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
- gboolean powered = FALSE;
-
- /* Precondition : BT enable */
- ret = adapter_enable();
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_6SECONDS);
-
- ret = adapter_get_powered_status(&powered);
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-}
-
-TEST(BluetoothHAL_test, adapter_start_stop_inquiry_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_start_inquiry(0);
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_2SECONDS);
-
- ret = adapter_stop_inquiry();
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
- wait_for_async(TIMEOUT_2SECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_get_properties_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_get_properties();
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_500MILISECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_get_address_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_get_address();
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_500MILISECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_get_version_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_get_version();
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_500MILISECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_get_name_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_get_name();
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_500MILISECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_set_name_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_set_name((char *)"TizenHAL");
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_500MILISECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_is_discoverable_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- 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) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- 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) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- 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) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_get_service_uuids();
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_500MILISECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_set_connectable_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_set_connectable(BT_SCAN_MODE_CONNECTABLE);
- ASSERT_TRUE(ret == OAL_STATUS_SUCCESS);
-
- wait_for_async(TIMEOUT_500MILISECONDS);
-}
-
-TEST(BluetoothHAL_test, adapter_set_discoverable_timeout_p) {
- SKIP_NOT_SUPPORTED(g_bFeatureBT);
-
- int ret = OAL_STATUS_SUCCESS;
-
- ret = adapter_set_discoverable_timeout(0);
- 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(TIMEOUT_500MILISECONDS);
-}
-
-
-int main(int argc, char **argv) {
- InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}