--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Gilbok Lee <gilbok.lee@samsung.com>
+ *
+ * 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.
+ */
+
+#include <string.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <iostream>
+#include <system_info.h>
+#include "hal-radio.h"
+#include "hal-radio-interface.h"
+
+using namespace std;
+
+int ret;
+
+void *hal_radio;
+bool radio_supported;
+
+#define RADIO_SUPPORT_CHECK \
+do {\
+ if (!radio_supported) {\
+ cout << "RADIO NOT SUPPORTED" << endl;\
+ return;\
+ }\
+} while (0)
+
+/*
+ * main class
+ */
+class RadioHalTest : public testing::Test
+{
+ public:
+ virtual void SetUp()
+ {
+ radio_supported = false;
+
+ system_info_get_platform_bool("http://tizen.org/feature/fmradio", &radio_supported);
+ if (!radio_supported) {
+ cout << "RADIO NOT SUPPORTED" << endl;
+ return;
+ }
+
+ ret = hal_radio_get_backend(&hal_radio);
+ if (ret != HAL_RADIO_ERROR_NONE) {
+ cout << "radio hal get backend failed " << ret << endl;
+ return;
+ }
+
+ ret = hal_radio_init(hal_radio);
+ if (ret != HAL_RADIO_ERROR_NONE) {
+ cout << "radio hal init failed " << ret << endl;
+ return;
+ }
+ }
+
+ virtual void TearDown()
+ {
+ if (hal_radio) {
+ ret = hal_radio_init(hal_radio);
+ ret = hal_radio_put_backend(hal_radio);
+ hal_radio = nullptr;
+ }
+
+ return;
+ }
+};
+
+/**
+ * @testcase GetPutBackendP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Deinitializes radio HAL handle
+ * @apicovered hal_radio_get_backend, hal_radio_put_backend
+ * @passcase when hal_radio_get_backend returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_get_backend does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, GetPutBackendP)
+{
+ void *hal_handle = nullptr;
+
+ RADIO_SUPPORT_CHECK;
+
+ ret = hal_radio_get_backend(&hal_handle);
+
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+ ASSERT_NE(hal_handle, nullptr);
+
+ ret = hal_radio_put_backend(hal_handle);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+ hal_handle = nullptr;
+}
+
+/**
+ * @testcase InitP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Initializes radio HAL handle
+ * @apicovered hal_radio_init
+ * @passcase when hal_radio_init returns HAL_RADIO_ERROR_NONE and the handle "h" is not a NULL pointer
+ * @failcase when handle "h" is a NULL pointer
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, InitP)
+{
+ void *hal_handle = nullptr;
+
+ RADIO_SUPPORT_CHECK;
+
+ ret = hal_radio_get_backend(&hal_handle);
+
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+ ASSERT_NE(hal_handle, nullptr);
+
+ ret = hal_radio_init(hal_handle);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_deinit(hal_handle);
+ hal_radio_put_backend(hal_handle);
+ hal_handle = nullptr;
+}
+
+/**
+ * @testcase DeinitP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Deinitializes radio HAL handle
+ * @apicovered hal_radio_init, hal_radio_deinit
+ * @passcase when hal_radio_deinit returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_deinit does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, DeinitP)
+{
+ void *hal_handle = nullptr;
+
+ RADIO_SUPPORT_CHECK;
+
+ ret = hal_radio_get_backend(&hal_handle);
+
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+ ASSERT_NE(hal_handle, nullptr);
+
+ ret = hal_radio_init(hal_handle);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_deinit(hal_handle);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_put_backend(hal_handle);
+ hal_handle = nullptr;
+}
+
+/**
+ * @testcase PrepareDeviceP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Prepares device for device open
+ * @apicovered hal_radio_prepare
+ * @passcase when hal_radio_prepare returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_prepare does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, PrepareDeviceP)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase PrepareDeviceN
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Prepares device for device open
+ * @apicovered hal_radio_prepare
+ * @passcase when hal_radio_prepare returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_prepare does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, PrepareDeviceN)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase UnprepareDeviceP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Unprepares device for device open
+ * @apicovered hal_radio_prepare, hal_radio_unprepare
+ * @passcase when hal_radio_unprepare returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_unprepare does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, UnprepareDeviceP)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_unprepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+}
+
+/**
+ * @testcase UnprepareDeviceN
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Prepares device for device open
+ * @apicovered hal_radio_prepare, hal_radio_unprepare
+ * @passcase when hal_radio_unprepare returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_unprepare does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, UnprepareDeviceN)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_unprepare(nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase OpenDeviceP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Opens radio device
+ * @apicovered hal_radio_prepare, hal_radio_open
+ * @passcase when hal_radio_open returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_open does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, OpenDeviceP)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_close(hal_radio);
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase OpenDeviceN
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Opens radio device
+ * @apicovered hal_radio_prepare, hal_radio_open
+ * @passcase when hal_radio_open returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_open does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, OpenDeviceN)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase CloseDeviceP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Closes radio device
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_close
+ * @passcase when hal_radio_close returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_close does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, CloseDeviceP)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_close(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase CloseDeviceN
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Closes radio device
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_close
+ * @passcase when hal_radio_close returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_close does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, CloseDeviceN)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_close(nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase StartP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Starts radio
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start
+ * @passcase when hal_radio_start returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_start does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, StartP)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_stop(hal_radio);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase StartN1
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Starts radio
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start
+ * @passcase when hal_radio_start returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_start does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, StartN1)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase StartN2
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Starts radio
+ * @apicovered hal_radio_start
+ * @passcase when hal_radio_start returns HAL_RADIO_ERROR_DEVICE_NOT_OPENED
+ * @failcase when hal_radio_start does not return HAL_RADIO_ERROR_DEVICE_NOT_OPENED
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, StartN2)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_DEVICE_NOT_OPENED);
+}
+
+/**
+ * @testcase StopP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Stops radio
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start, hal_radio_stop
+ * @passcase when hal_radio_stop returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_stop does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, StopP)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_stop(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase StopN1
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Stops radio
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start, hal_radio_stop
+ * @passcase when hal_radio_stop returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_stop does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, StopN1)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_stop(nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_stop(hal_radio);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase StopN2
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Stops radio
+ * @apicovered hal_radio_stop
+ * @passcase when hal_radio_stop returns HAL_RADIO_ERROR_DEVICE_NOT_OPENED
+ * @failcase when hal_radio_stop does not return HAL_RADIO_ERROR_DEVICE_NOT_OPENED
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, StopN2)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_stop(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_DEVICE_NOT_OPENED);
+}
+
+/**
+ * @testcase SetFrequencyP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Sets radio frequency
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start, hal_radio_stop, hal_radio_set_frequency
+ * @passcase when hal_radio_set_frequency returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_set_frequency does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, SetFrequencyP)
+{
+ uint32_t freq = 95900;
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_set_frequency(hal_radio, freq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_stop(hal_radio);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase SetFrequencyN
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Sets radio frequency
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start, hal_radio_stop, hal_radio_set_frequency
+ * @passcase when hal_radio_set_frequency returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_set_frequency does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, SetFrequencyN)
+{
+ uint32_t freq = 100;
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_set_frequency(hal_radio, freq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_stop(hal_radio);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase GetFrequencyP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Gets radio frequency
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start, hal_radio_stop, hal_radio_set_frequency, hal_radio_get_frequency
+ * @passcase when hal_radio_get_frequency returns HAL_RADIO_ERROR_NONE and result is same with previous set frequecny
+ * @failcase when hal_radio_get_frequency does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, GetFrequencyP)
+{
+ uint32_t freq = 95900;
+ uint32_t getfreq = 0;
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_set_frequency(hal_radio, freq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_get_frequency(hal_radio, &getfreq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+ ASSERT_EQ(freq, getfreq);
+
+ hal_radio_stop(hal_radio);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase GetFrequencyN
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Gets radio frequency
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start, hal_radio_get_frequency
+ * @passcase when hal_radio_get_frequency returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_get_frequency does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, GetFrequencyN)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_get_frequency(hal_radio, NULL);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_stop(hal_radio);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase SeekUpP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Seeks up frequency
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_set_frequency, hal_radio_seek, hal_radio_get_frequency
+ * @passcase when hal_radio_seek returns HAL_RADIO_ERROR_NONE and the result frequency is higher than the previous set frequency.
+ * @failcase when hal_radio_seek does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, SeekUpP)
+{
+ uint32_t freq = 87500;
+ uint32_t getfreq = 0;
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_set_frequency(hal_radio, freq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_seek(hal_radio, RADIO_SEEK_DIRECTION_UP);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_get_frequency(hal_radio, &getfreq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+ ASSERT_LT(freq, getfreq);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase SeekUpP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Seeks up frequency
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_set_frequency, hal_radio_seek, hal_radio_get_frequency
+ * @passcase when hal_radio_seek returns HAL_RADIO_ERROR_NONE and the result frequency is lower than the previous set frequency.
+ * @failcase when hal_radio_seek does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, SeekDownP)
+{
+ uint32_t freq = 108000;
+ uint32_t getfreq = 0;
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_set_frequency(hal_radio, freq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_seek(hal_radio, RADIO_SEEK_DIRECTION_DOWN);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_get_frequency(hal_radio, &getfreq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+ ASSERT_GT(freq, getfreq);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase SeekN1
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Seeks up frequency
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_set_frequency, hal_radio_seek
+ * @passcase when hal_radio_seek returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_seek does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, SeekN1)
+{
+ uint32_t freq = 95900;
+
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_set_frequency(hal_radio, freq);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_seek(nullptr, RADIO_SEEK_DIRECTION_UP);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase SeekN2
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Seeks up frequency
+ * @apicovered hal_radio_seek
+ * @passcase when hal_radio_seek returns HAL_RADIO_ERROR_DEVICE_NOT_OPENED
+ * @failcase when hal_radio_seek does not return HAL_RADIO_ERROR_DEVICE_NOT_OPENED
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, SeekN2)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_seek(hal_radio, RADIO_SEEK_DIRECTION_UP);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_DEVICE_NOT_OPENED);
+}
+
+/**
+ * @testcase GetSignalStrengthP
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Positive, Gets the radio signal strength
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start, hal_radio_get_signal_strength
+ * @passcase when hal_radio_get_signal_strength returns HAL_RADIO_ERROR_NONE
+ * @failcase when hal_radio_get_signal_strength does not return HAL_RADIO_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, GetSignalStrengthP)
+{
+ int32_t getSignal = 0;
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_get_signal_strength(hal_radio, &getSignal);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ hal_radio_stop(hal_radio);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+/**
+ * @testcase GetSignalStrengthN
+ * @since_tizen 6.5
+ * @author SR(gilbok.lee)
+ * @reviewer SR(eunhae1.choi)
+ * @type auto
+ * @description Negative, Gets the radio signal strength
+ * @apicovered hal_radio_prepare, hal_radio_open, hal_radio_start, hal_radio_get_signal_strength
+ * @passcase when hal_radio_get_signal_strength returns HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @failcase when hal_radio_get_signal_strength does not return HAL_RADIO_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(RadioHalTest, GetSignalStrengthN)
+{
+ RADIO_SUPPORT_CHECK;
+
+ ASSERT_NE(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_prepare(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_open(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_start(hal_radio);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_NONE);
+
+ ret = hal_radio_get_signal_strength(hal_radio, nullptr);
+ ASSERT_EQ(ret, HAL_RADIO_ERROR_INVALID_PARAMETER);
+
+ hal_radio_stop(hal_radio);
+
+ hal_radio_close(hal_radio);
+
+ hal_radio_unprepare(hal_radio);
+}
+
+int main(int argc, char **argv)
+{
+ testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}