diff options
author | Gilbok Lee <gilbok.lee@samsung.com> | 2018-07-16 16:54:12 +0900 |
---|---|---|
committer | Gilbok Lee <gilbok.lee@samsung.com> | 2018-08-14 15:18:35 +0900 |
commit | d06767768203168895ae22481b4090121924feb3 (patch) | |
tree | 575845ae9f991a3087232787075537f9343c3d0f | |
parent | 9a6c00f33f08e36fe2d2c060abefd4931261d222 (diff) | |
download | mm-hal-interface-d06767768203168895ae22481b4090121924feb3.tar.gz mm-hal-interface-d06767768203168895ae22481b4090121924feb3.tar.bz2 mm-hal-interface-d06767768203168895ae22481b4090121924feb3.zip |
[radio/haltest] Update tizen radio and add radio hal test
1. Modify tizen radio (Remove/Add error type and modify description)
2. Make radio hal test
[Version] 0.0.12
[Profile] Common
[Issue Type] Add features
Change-Id: I04d3e2873a1d5ee14290a1d68cb8fc05008d896e
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | include/radio/radio_hal_interface.h | 61 | ||||
-rw-r--r-- | include/radio/tizen-radio.h | 93 | ||||
-rw-r--r-- | mm-hal-interface-radio.manifest | 5 | ||||
-rw-r--r-- | packaging/mm-hal-interface.spec | 39 | ||||
-rw-r--r-- | radio-hal-interface.pc.in | 11 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/radio/Makefile.am | 6 | ||||
-rw-r--r-- | src/radio/radio_hal_interface.c | 317 | ||||
-rw-r--r-- | testcase/Makefile.am | 3 | ||||
-rw-r--r-- | testcase/radio/Makefile.am | 20 | ||||
-rw-r--r-- | testcase/radio/radio_haltests.cpp | 1395 |
13 files changed, 1929 insertions, 30 deletions
diff --git a/Makefile.am b/Makefile.am index f149a4d..a00a6d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ SUBDIRS = src testcase -pcfiles = camera-hal-interface.pc +pcfiles = camera-hal-interface.pc \ + radio-hal-interface.pc pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = $(pcfiles) EXTRA_DIST = $(pcfiles) diff --git a/configure.ac b/configure.ac index c476c63..0c305a9 100644 --- a/configure.ac +++ b/configure.ac @@ -35,9 +35,12 @@ AC_CONFIG_FILES([ Makefile src/Makefile src/camera/Makefile +src/radio/Makefile testcase/Makefile testcase/camera/Makefile +testcase/radio/Makefile camera-hal-interface.pc +radio-hal-interface.pc ]) AC_OUTPUT diff --git a/include/radio/radio_hal_interface.h b/include/radio/radio_hal_interface.h new file mode 100644 index 0000000..cb4a1d0 --- /dev/null +++ b/include/radio/radio_hal_interface.h @@ -0,0 +1,61 @@ +/* + * radio_hal_interface.h + * + * Copyright (c) 2000 - 2016 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. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include "tizen-radio.h" + +typedef enum _seek_direction_type { + SEEK_DIRECTION_UP, /**< Seek upward */ + SEEK_DIRECTION_DOWN /**< Seek downward */ +} seek_direction_type_t; + +typedef struct _radio_hal_interface { + void *dl_handle; + void *rh_handle; + radio_interface_t intf; +} radio_hal_interface; + +int radio_hal_interface_init(radio_hal_interface **handle); +int radio_hal_interface_deinit(radio_hal_interface *handle); +int radio_hal_open(radio_hal_interface *handle); +int radio_hal_prepare(radio_hal_interface *handle); +int radio_hal_unprepare(radio_hal_interface *handle); +int radio_hal_close(radio_hal_interface *handle); +int radio_hal_start(radio_hal_interface *handle); +int radio_hal_stop(radio_hal_interface *handle); +int radio_hal_seek(radio_hal_interface *handle, seek_direction_type_t direction); +int radio_hal_get_frequency(radio_hal_interface *handle, uint32_t *frequency); +int radio_hal_set_frequency(radio_hal_interface *handle, uint32_t frequency); +int radio_hal_get_signal_strength(radio_hal_interface *handle, int32_t *strength); +int radio_hal_mute(radio_hal_interface *handle); +int radio_hal_unmute(radio_hal_interface *handle); +int radio_hal_set_volume(radio_hal_interface *handle, float volume); +int radio_hal_get_volume(radio_hal_interface *handle, float *volume); +int radio_hal_set_media_volume(radio_hal_interface *handle, uint32_t level); + + +#ifdef __cplusplus +} +#endif diff --git a/include/radio/tizen-radio.h b/include/radio/tizen-radio.h index 8f6ce17..bae4851 100644 --- a/include/radio/tizen-radio.h +++ b/include/radio/tizen-radio.h @@ -44,7 +44,6 @@ extern "C" { typedef enum radio_error { RADIO_ERROR_NONE, RADIO_ERROR_INVALID_PARAMETER, - RADIO_ERROR_INVALID_STATE, RADIO_ERROR_INVALID_OPERATION, RADIO_ERROR_PERMISSION_DENIED, RADIO_ERROR_NOT_SUPPORTED, @@ -52,9 +51,9 @@ typedef enum radio_error { RADIO_ERROR_DEVICE_NOT_PREPARED, RADIO_ERROR_DEVICE_NOT_OPENED, RADIO_ERROR_DEVICE_NOT_FOUND, - RADIO_ERROR_DEVICE_NOT_SUPPORTED, RADIO_ERROR_NO_ANTENNA, RADIO_ERROR_INTERNAL, + RADIO_ERROR_NOT_IMPLEMENTED, RADIO_ERROR_UNKNOWN } radio_error_t; @@ -82,25 +81,29 @@ typedef struct radio_interface { radio_error_t (*set_frequency)(void *radio_handle, uint32_t frequency); radio_error_t (*mute)(void *radio_handle); radio_error_t (*unmute)(void *radio_handle); - radio_error_t (*get_signal_strength)(void *radio_handle, uint32_t *strength); + radio_error_t (*get_signal_strength)(void *radio_handle, int32_t *strength); + radio_error_t (*get_volume)(void *radio_handle, float *volume); + radio_error_t (*set_volume)(void *radio_handle, float volume); + radio_error_t (*set_media_volume)(void *radio_handle, uint32_t level); } radio_interface_t; /** * @brief Initializes new handle of radio HAL. * @since_tizen 3.0 - * @param[out] radio_handle A newly returned handle to the radio HAL + * @param[out] radio_handle A newly returned the radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RADIO_ERROR_OUT_OF_MEMORY Out of memory + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @see radio_deinit() */ radio_error_t radio_init(void **radio_handle); /** - * @brief Deinitializes handle of camera HAL. + * @brief Deinitializes handle of radio HAL. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter @@ -111,11 +114,11 @@ radio_error_t radio_deinit(void *radio_handle); /** * @brief Prepare the device of radio. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @see radio_unprepare() */ radio_error_t radio_prepare(void *radio_handle); @@ -123,10 +126,11 @@ radio_error_t radio_prepare(void *radio_handle); /** * @brief Unprepare the device of radio. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @see radio_prepare() */ radio_error_t radio_unprepare(void *radio_handle); @@ -134,12 +138,12 @@ radio_error_t radio_unprepare(void *radio_handle); /** * @brief Opens the device of radio. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RADIO_ERROR_DEVICE_NOT_FOUND Failed to find radio device - * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @retval #RADIO_ERROR_PERMISSION_DENIED The access to the resources can not be granted. * @retval #RADIO_ERROR_DEVICE_NOT_PREPARED Not prepared the radio device * @see radio_close() @@ -149,10 +153,12 @@ radio_error_t radio_open(void *radio_handle); /** * @brief Closes the device of radio. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened. + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @see radio_open() */ radio_error_t radio_close(void *radio_handle); @@ -160,10 +166,11 @@ radio_error_t radio_close(void *radio_handle); /** * @brief Starts the device of radio. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened. * @see radio_stop() */ radio_error_t radio_start(void *radio_handle); @@ -171,10 +178,11 @@ radio_error_t radio_start(void *radio_handle); /** * @brief Stops the device of radio. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened. * @see radio_start() */ radio_error_t radio_stop(void *radio_handle); @@ -182,7 +190,7 @@ radio_error_t radio_stop(void *radio_handle); /** * @brief Seeks (up or down) the effective frequency of the radio. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @param[in] direction The seek direction type (up or down) * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful @@ -195,12 +203,11 @@ radio_error_t radio_seek(void *radio_handle, radio_seek_direction_type_t directi /** * @brief Gets the radio frequency. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL - * @param[out] frequency The current frequency (khz) + * @param[in] radio_handle The radio HAL handle + * @param[out] frequency The current frequency (kHz) * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation */ radio_error_t radio_get_frequency(void *radio_handle, uint32_t *frequency); @@ -208,12 +215,11 @@ radio_error_t radio_get_frequency(void *radio_handle, uint32_t *frequency); /** * @brief Sets the radio frequency. * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL - * @param[in] frequency The frequency to set (khz) + * @param[in] radio_handle The radio HAL handle + * @param[in] frequency The frequency to set (kHz) * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation */ radio_error_t radio_set_frequency(void *radio_handle, uint32_t frequency); @@ -221,7 +227,7 @@ radio_error_t radio_set_frequency(void *radio_handle, uint32_t frequency); /** * @brief Sets the radio's mute * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter @@ -232,7 +238,7 @@ radio_error_t radio_mute(void *radio_handle); /** * @brief Unsets the radio's mute * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter @@ -243,14 +249,51 @@ radio_error_t radio_unmute(void *radio_handle); /** * @brief Gets the current signal strength of the radio * @since_tizen 3.0 - * @param[in] radio_handle The handle to the radio HAL + * @param[in] radio_handle The radio HAL handle * @param[out] strength The current signal strength (dBm) * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation */ -radio_error_t radio_get_signal_strength(void *radio_handle, uint32_t *strength); +radio_error_t radio_get_signal_strength(void *radio_handle, int32_t *strength); + +/** + * @brief Gets the radio's current volume. + * @since_tizen 3.0 + * @param[in] radio_handle The radio HAL handle + * @param[out] volume The current radio volume (0.0 ~ 1.0) + * @return @c 0 on success, otherwise a negative error value + * @retval #RADIO_ERROR_NONE Successful + * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation + */ +radio_error_t radio_get_volume(void *radio_handle, float *volume); + +/** + * @brief Sets the current radio's volume. + * @since_tizen 3.0 + * @param[in] radio_handle The radio HAL handle + * @param[in] volume The radio volume to set (0.0 ~ 1.0) + * @return @c 0 on success, otherwise a negative error value + * @retval #RADIO_ERROR_NONE Successful + * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation + */ +radio_error_t radio_set_volume(void *radio_handle, float volume); + +/** + * @brief Sets the current media volume level(system media volume). + * @since_tizen 3.0 + * @param[in] radio_handle The radio HAL handle + * @param[in] level The media volume level to set + * @return @c 0 on success, otherwise a negative error value + * @retval #RADIO_ERROR_NONE Successful + * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation + */ +radio_error_t radio_set_media_volume(void *radio_handle, uint32_t level); + /** * @} diff --git a/mm-hal-interface-radio.manifest b/mm-hal-interface-radio.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/mm-hal-interface-radio.manifest @@ -0,0 +1,5 @@ +<manifest> + <request> + <domain name="_" /> + </request> +</manifest> diff --git a/packaging/mm-hal-interface.spec b/packaging/mm-hal-interface.spec index 35d3c67..3c054f6 100644 --- a/packaging/mm-hal-interface.spec +++ b/packaging/mm-hal-interface.spec @@ -1,7 +1,7 @@ Name: mm-hal-interface Summary: Multimedia HAL Interface -Version: 0.0.11 -Release: 2 +Version: 0.0.12 +Release: 1 Group: Multimedia/Development License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -24,12 +24,22 @@ Version: %{version} %description camera Multimedia framework hardware abstraction layer interface library for camera. +%package radio +Summary: Multimedia framework hardware abstraction layer interface library for radio +Group: Multimedia/Libraries +Version: %{version} + +%description radio +Multimedia framework hardware abstraction layer interface library for radio. + + %package devel Summary: Multimedia framework hardware abstraction layer interface development package Group: libdevel Version: %{version} Requires: %{name}-camera = %{version}-%{release} +Requires: %{name}-radio = %{version}-%{release} %description devel Multimedia framework hardware abstraction layer interface development package. @@ -44,11 +54,21 @@ Version: %{version} gtest for camera HAL APIs. +%package -n radio-haltests +Summary: gtest for radio HAL APIs +Group: Development/Tools +Version: %{version} + +%description -n radio-haltests +gtest for radio HAL APIs. + + %prep %setup -q %build export CFLAGS+=" -D_LARGEFILE64_SOURCE" +export CFLAGS+=" -DPATH_LIBDIR=\\\"%{_libdir}\\\"" ./autogen.sh %configure --disable-static make %{?jobs:-j%jobs} @@ -66,12 +86,21 @@ install -m 644 include/radio/*.h %{buildroot}%{_includedir} %post -n camera-haltests -p /sbin/ldconfig %postun -n camera-haltests -p /sbin/ldconfig +%post -n radio-haltests -p /sbin/ldconfig +%postun -n radio-haltests -p /sbin/ldconfig + %files camera %manifest mm-hal-interface-camera.manifest %license LICENSE.APLv2 %defattr(-,root,root,-) %{_libdir}/libcamera*.so.* +%files radio +%manifest mm-hal-interface-radio.manifest +%license LICENSE.APLv2 +%defattr(-,root,root,-) +%{_libdir}/libradio*.so.* + %files devel %defattr(-,root,root,-) %{_includedir}/*.h @@ -83,3 +112,9 @@ install -m 644 include/radio/*.h %{buildroot}%{_includedir} %license LICENSE.APLv2 %defattr(-,root,root,-) %{_bindir}/camera_* + +%files -n radio-haltests +%manifest mm-haltests.manifest +%license LICENSE.APLv2 +%defattr(-,root,root,-) +%{_bindir}/radio_* diff --git a/radio-hal-interface.pc.in b/radio-hal-interface.pc.in new file mode 100644 index 0000000..47e3035 --- /dev/null +++ b/radio-hal-interface.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: radio-hal-interface +Description: Multimedia Framework Radio HAL Interface library +Requires: glib-2.0 dlog +Version: $VERSION +Libs: -L${libdir} -lradio_hal_interface +Cflags: -I${includedir}/ diff --git a/src/Makefile.am b/src/Makefile.am index ac1b359..1d5c729 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,3 @@ -SUBDIRS = camera +SUBDIRS = camera \ + radio diff --git a/src/radio/Makefile.am b/src/radio/Makefile.am new file mode 100644 index 0000000..fca1177 --- /dev/null +++ b/src/radio/Makefile.am @@ -0,0 +1,6 @@ +lib_LTLIBRARIES = libradio_hal_interface.la + +libradio_hal_interface_la_SOURCES = radio_hal_interface.c +libradio_hal_interface_la_CFLAGS = $(DLOG_CFLAGS) -I$(srcdir)/../../include/radio +libradio_hal_interface_la_LIBADD = $(DLOG_LIBS) -ldl + diff --git a/src/radio/radio_hal_interface.c b/src/radio/radio_hal_interface.c new file mode 100644 index 0000000..b4f683b --- /dev/null +++ b/src/radio/radio_hal_interface.c @@ -0,0 +1,317 @@ +/* + * radio_hal_interface.c + * + * Copyright (c) 2016 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. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <dlfcn.h> +#include <dlog.h> + +#include "radio_hal_interface.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif /* LOG_TAG */ + +#define LOG_TAG "RADIO_HAL_INTF" + +#define LIB_TIZEN_RADIO PATH_LIBDIR"/libtizen-radio.so" + +#define RADIO_INTF_CHECK_ARG(x_radio) \ +do { \ + if (!x_radio) { \ + LOGE("argument is NULL\n"); \ + return RADIO_ERROR_INVALID_PARAMETER; \ + } \ +} while (0) + +int radio_hal_interface_init(radio_hal_interface **handle) +{ + radio_hal_interface *h = NULL; + int ret = RADIO_ERROR_NONE; + h = (radio_hal_interface *)malloc(sizeof(radio_hal_interface)); + + if (!h) { + LOGE("cannot allocate memory for radio_hal interface"); + return RADIO_ERROR_OUT_OF_MEMORY; + } + + h->dl_handle = dlopen(LIB_TIZEN_RADIO, RTLD_NOW); + + if (h->dl_handle) { + h->intf.init = dlsym(h->dl_handle, "radio_init"); + h->intf.deinit = dlsym(h->dl_handle, "radio_deinit"); + h->intf.prepare = dlsym(h->dl_handle, "radio_prepare"); + h->intf.unprepare = dlsym(h->dl_handle, "radio_unprepare"); + h->intf.open = dlsym(h->dl_handle, "radio_open"); + h->intf.close = dlsym(h->dl_handle, "radio_close"); + h->intf.start = dlsym(h->dl_handle, "radio_start"); + h->intf.stop = dlsym(h->dl_handle, "radio_stop"); + h->intf.seek = dlsym(h->dl_handle, "radio_seek"); + h->intf.get_frequency = dlsym(h->dl_handle, "radio_get_frequency"); + h->intf.set_frequency = dlsym(h->dl_handle, "radio_set_frequency"); + h->intf.mute = dlsym(h->dl_handle, "radio_mute"); + h->intf.unmute = dlsym(h->dl_handle, "radio_unmute"); + h->intf.get_signal_strength = dlsym(h->dl_handle, "radio_get_signal_strength"); + h->intf.get_volume = dlsym(h->dl_handle, "radio_get_volume"); + h->intf.set_volume = dlsym(h->dl_handle, "radio_set_volume"); + h->intf.set_media_volume = dlsym(h->dl_handle, "radio_set_media_volume"); + + if (h->intf.init == NULL || h->intf.deinit == NULL) { + LOGE("could not get mandatory funtion"); + goto FAIL; + } + + ret = h->intf.init(&h->rh_handle); + if (ret != RADIO_ERROR_NONE) { + LOGE("radio_hal init failed %d", ret); + goto FAIL; + } + + } else { + LOGE("open radio hal_interface failed : %s", dlerror()); + ret = RADIO_ERROR_INTERNAL; + goto FAIL; + } + + *handle = h; + + LOGD("open radio_hal interface"); + + return ret; +FAIL: + if (h) { + if (h->dl_handle) + dlclose(h->dl_handle); + free(h); + } + + return ret; +} + +int radio_hal_interface_deinit(radio_hal_interface *handle) +{ + int ret = RADIO_ERROR_NONE; + RADIO_INTF_CHECK_ARG(handle); + + if (handle->dl_handle) { + ret = handle->intf.deinit(handle->rh_handle); + if (ret != RADIO_ERROR_NONE) + return ret; + + handle->rh_handle = NULL; + + LOGD("close radio_hal interface"); + dlclose(handle->dl_handle); + handle->dl_handle = NULL; + } + + free(handle); + handle = NULL; + + return ret; +} + +int radio_hal_open(radio_hal_interface *handle) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.open) { + LOGW("radio_hal open is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.open(handle->rh_handle); +} + +int radio_hal_prepare(radio_hal_interface *handle) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.prepare) { + LOGW("radio_hal prepare is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.prepare(handle->rh_handle); +} + +int radio_hal_unprepare(radio_hal_interface *handle) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.unprepare) { + LOGW("radio_hal unprepare is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.unprepare(handle->rh_handle); +} + + +int radio_hal_close(radio_hal_interface *handle) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.close) { + LOGW("radio_hal close is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.close(handle->rh_handle); +} + +int radio_hal_start(radio_hal_interface *handle) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.start) { + LOGW("radio_hal start is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.start(handle->rh_handle); +} + +int radio_hal_stop(radio_hal_interface *handle) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.stop) { + LOGW("radio_hal stop is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.stop(handle->rh_handle); +} + + +int radio_hal_seek(radio_hal_interface *handle, seek_direction_type_t direction) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.seek) { + LOGW("radio_hal seek is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.seek(handle->rh_handle, (radio_seek_direction_type_t)direction); +} + +int radio_hal_get_frequency(radio_hal_interface *handle, uint32_t *frequency) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.get_frequency) { + LOGW("radio_hal get_frequency is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.get_frequency(handle->rh_handle, frequency); +} + +int radio_hal_set_frequency(radio_hal_interface *handle, uint32_t frequency) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.set_frequency) { + LOGW("radio_hal set_frequency is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.set_frequency(handle->rh_handle, frequency); +} + +int radio_hal_get_signal_strength(radio_hal_interface *handle, int32_t *strength) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.get_signal_strength) { + LOGW("radio_hal get_signal_strength is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.get_signal_strength(handle->rh_handle, strength); +} + +int radio_hal_mute(radio_hal_interface *handle) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.mute) { + LOGW("radio_hal mute is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.mute(handle->rh_handle); +} + +int radio_hal_unmute(radio_hal_interface *handle) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.unmute) { + LOGW("radio_hal unmute is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.unmute(handle->rh_handle); +} + +int radio_hal_set_volume(radio_hal_interface *handle, float volume) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.set_volume) { + LOGW("radio_hal set_volume is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.set_volume(handle->rh_handle, volume); +} + +int radio_hal_get_volume(radio_hal_interface *handle, float *volume) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.get_volume) { + LOGW("radio_hal get_volume is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.get_volume(handle->rh_handle, volume); +} + +int radio_hal_set_media_volume(radio_hal_interface *handle, uint32_t level) +{ + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.set_media_volume) { + LOGW("radio_hal set_media_volume is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; + } + + return handle->intf.set_media_volume(handle->rh_handle, level); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + diff --git a/testcase/Makefile.am b/testcase/Makefile.am index ac1b359..1d5c729 100644 --- a/testcase/Makefile.am +++ b/testcase/Makefile.am @@ -1,2 +1,3 @@ -SUBDIRS = camera +SUBDIRS = camera \ + radio diff --git a/testcase/radio/Makefile.am b/testcase/radio/Makefile.am new file mode 100644 index 0000000..e1c6a29 --- /dev/null +++ b/testcase/radio/Makefile.am @@ -0,0 +1,20 @@ +# with gtest +bin_PROGRAMS = radio_haltests + +radio_haltests_SOURCES = \ + radio_haltests.cpp + +radio_haltests_CPPFLAGS = \ + $(GLIB_CFLAGS)\ + $(DLOG_CFLAGS)\ + $(SYSTEM_INFO_CFLAGS)\ + -I$(srcdir)/../../include/radio + +radio_haltests_LDADD = \ + -ldl\ + -lgtest\ + $(top_builddir)/src/radio/libradio_hal_interface.la\ + $(GLIB_LIBS)\ + $(DLOG_LIBS)\ + $(SYSTEM_INFO_LIBS) + diff --git a/testcase/radio/radio_haltests.cpp b/testcase/radio/radio_haltests.cpp new file mode 100644 index 0000000..0a88213 --- /dev/null +++ b/testcase/radio/radio_haltests.cpp @@ -0,0 +1,1395 @@ +/* + * Copyright (c) 2018 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 <glib.h> +#include <string.h> +#include <gtest/gtest.h> +#include <unistd.h> +#include <iostream> +#include <system_info.h> +#include <radio_hal_interface.h> + +using namespace std; + +int ret; + +radio_hal_interface *h; + +GMutex msg_cb_lock; +GCond msg_cb_cond; + +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); + + ret = radio_hal_interface_init(&h); + if (ret != RADIO_ERROR_NONE) { + cout << "radio hal init failed " << ret << endl; + return; + } + + return; + } + + virtual void TearDown() + { + if (h) { + ret = radio_hal_interface_deinit(h); + h = nullptr; + } + + return; + } +}; + +/** + * @testcase InitP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Initializes radio HAL handle + * @apicovered radio_init + * @passcase when radio_init returns 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) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); +} + +/** + * @testcase DeinitP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Deinitializes radio HAL handle + * @apicovered radio_init, radio_deinit + * @passcase when radio_dedeinit returns RADIO_ERROR_NONE + * @failcase when radio_init does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, DeinitP) +{ + radio_hal_interface *hal_handle = nullptr; + + RADIO_SUPPORT_CHECK; + + ret = radio_hal_interface_init(&hal_handle); + + EXPECT_EQ(ret, RADIO_ERROR_NONE); + EXPECT_NE(hal_handle, nullptr); + + ret = radio_hal_interface_deinit(hal_handle); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + hal_handle = nullptr; +} + +/** + * @testcase PrepareDeviceP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Prepares device for device open + * @apicovered radio_prepare + * @passcase when radio_prepare returns RADIO_ERROR_NONE + * @failcase when radio_prepare does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, PrepareDeviceP) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_unprepare(h); +} + +/** + * @testcase PrepareDeviceN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Prepares device for device open + * @apicovered radio_prepare + * @passcase when radio_prepare returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_prepare does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, PrepareDeviceN) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(nullptr); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase UnprepareDeviceP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Unprepares device for device open + * @apicovered radio_prepare, radio_unprepare + * @passcase when radio_unprepare returns RADIO_ERROR_NONE + * @failcase when radio_unprepare does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, UnprepareDeviceP) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_unprepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); +} + +/** + * @testcase UnprepareDeviceN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Prepares device for device open + * @apicovered radio_prepare, radio_unprepare + * @passcase when radio_unprepare returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_unprepare does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, UnprepareDeviceN) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_unprepare(nullptr); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_unprepare(h); +} + +/** + * @testcase OpenDeviceP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Opens radio device + * @apicovered radio_prepare, radio_open + * @passcase when radio_open returns RADIO_ERROR_NONE + * @failcase when radio_open does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, OpenDeviceP) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_close(h); + radio_hal_unprepare(h); +} + +/** + * @testcase OpenDeviceN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Opens radio device + * @apicovered radio_prepare, radio_open + * @passcase when radio_open returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_open does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, OpenDeviceN) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(nullptr); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_unprepare(h); +} + +/** + * @testcase CloseDeviceP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Closes radio device + * @apicovered radio_prepare, radio_open, radio_close + * @passcase when radio_close returns RADIO_ERROR_NONE + * @failcase when radio_close does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, CloseDeviceP) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_close(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_unprepare(h); +} + +/** + * @testcase CloseDeviceN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Closes radio device + * @apicovered radio_prepare, radio_open, radio_close + * @passcase when radio_close returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_close does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, CloseDeviceN) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_close(nullptr); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase StartP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Starts radio + * @apicovered radio_prepare, radio_open, radio_start + * @passcase when radio_start returns RADIO_ERROR_NONE + * @failcase when radio_start does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, StartP) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase StartN1 + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Starts radio + * @apicovered radio_prepare, radio_open, radio_start + * @passcase when radio_start returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_start does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, StartN1) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(nullptr); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase StartN2 + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Starts radio + * @apicovered radio_start + * @passcase when radio_start returns RADIO_ERROR_DEVICE_NOT_OPENED + * @failcase when radio_start does not return RADIO_ERROR_DEVICE_NOT_OPENED + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, StartN2) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_DEVICE_NOT_OPENED); +} + +/** + * @testcase StopP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Stops radio + * @apicovered radio_prepare, radio_open, radio_start, radio_stop + * @passcase when radio_stop returns RADIO_ERROR_NONE + * @failcase when radio_stop does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, StopP) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_stop(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase StopN1 + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Stops radio + * @apicovered radio_prepare, radio_open, radio_start, radio_stop + * @passcase when radio_stop returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_stop does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, StopN1) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_stop(nullptr); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase StopN2 + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Stops radio + * @apicovered radio_stop + * @passcase when radio_stop returns RADIO_ERROR_DEVICE_NOT_OPENED + * @failcase when radio_stop does not return RADIO_ERROR_DEVICE_NOT_OPENED + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, StopN2) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_stop(h); + EXPECT_EQ(ret, RADIO_ERROR_DEVICE_NOT_OPENED); +} + +/** + * @testcase SetFrequencyP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Sets radio frequency + * @apicovered radio_prepare, radio_open, radio_start, radio_stop, radio_set_frequency + * @passcase when radio_set_frequency returns RADIO_ERROR_NONE + * @failcase when radio_set_frequency does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SetFrequencyP) +{ + uint32_t freq = 95900; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SetFrequencyN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Sets radio frequency + * @apicovered radio_prepare, radio_open, radio_start, radio_stop, radio_set_frequency + * @passcase when radio_set_frequency returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_set_frequency does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SetFrequencyN) +{ + uint32_t freq = 100; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase GetFrequencyP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Gets radio frequency + * @apicovered radio_prepare, radio_open, radio_start, radio_stop, radio_set_frequency, radio_get_frequency + * @passcase when radio_get_frequency returns RADIO_ERROR_NONE and result is same with previous set frequecny + * @failcase when radio_get_frequency does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, GetFrequencyP) +{ + uint32_t freq = 95900; + uint32_t getfreq = 0; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_get_frequency(h, &getfreq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + EXPECT_EQ(freq, getfreq); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase GetFrequencyN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Gets radio frequency + * @apicovered radio_prepare, radio_open, radio_start, radio_get_frequency + * @passcase when radio_get_frequency returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_get_frequency does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, GetFrequencyN) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_get_frequency(h, NULL); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SeekUpP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Seeks up frequency + * @apicovered radio_prepare, radio_open, radio_set_frequency, radio_seek, radio_get_frequency + * @passcase when radio_seek returns RADIO_ERROR_NONE and the result frequency is higher than the previous set frequency. + * @failcase when radio_seek does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SeekUpP) +{ + uint32_t freq = 87500; + uint32_t getfreq = 0; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_seek(h, SEEK_DIRECTION_UP); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_get_frequency(h, &getfreq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + EXPECT_LT(freq, getfreq); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SeekUpP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Seeks up frequency + * @apicovered radio_prepare, radio_open, radio_set_frequency, radio_seek, radio_get_frequency + * @passcase when radio_seek returns RADIO_ERROR_NONE and the result frequency is lower than the previous set frequency. + * @failcase when radio_seek does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SeekDownP) +{ + uint32_t freq = 108000; + uint32_t getfreq = 0; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_seek(h, SEEK_DIRECTION_DOWN); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_get_frequency(h, &getfreq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + EXPECT_GT(freq, getfreq); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SeekN1 + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Seeks up frequency + * @apicovered radio_prepare, radio_open, radio_set_frequency, radio_seek + * @passcase when radio_seek returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_seek does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SeekN) +{ + uint32_t freq = 95900; + + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_seek(nullptr, SEEK_DIRECTION_UP); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SeekN2 + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Seeks up frequency + * @apicovered radio_seek + * @passcase when radio_seek returns RADIO_ERROR_DEVICE_NOT_OPENED + * @failcase when radio_seek does not return RADIO_ERROR_DEVICE_NOT_OPENED + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SeekN2) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_seek(h, SEEK_DIRECTION_UP); + EXPECT_EQ(ret, RADIO_ERROR_DEVICE_NOT_OPENED); +} + +/** + * @testcase MuteP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Mutes radio + * @apicovered radio_prepare, radio_open, radio_set_frequency, radio_mute + * @passcase when radio_mute returns RADIO_ERROR_NONE + * @failcase when radio_mute does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, MuteP) +{ + uint32_t freq = 95900; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_mute(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase MuteP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Mutes radio + * @apicovered radio_prepare, radio_open, radio_set_frequency, radio_mute + * @passcase when radio_mute returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_mute does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, MuteN) +{ + uint32_t freq = 95900; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_mute(nullptr); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase UnMuteP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Unmutes radio + * @apicovered radio_prepare, radio_open, radio_set_frequency, radio_unmute + * @passcase when radio_seek returns RADIO_ERROR_NONE + * @failcase when radio_seek does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, UnMuteP) +{ + uint32_t freq = 95900; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_unmute(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase UnMuteN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Unmutes radio + * @apicovered radio_prepare, radio_open, radio_set_frequency, radio_unmute + * @passcase when radio_unmute returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_unmute does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, UnMuteN) +{ + uint32_t freq = 95900; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_unmute(NULL); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase GetSignalStrengthP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Gets the radio signal strength + * @apicovered radio_prepare, radio_open, radio_start, radio_get_signal_strength + * @passcase when radio_get_signal_strength returns RADIO_ERROR_NONE + * @failcase when radio_get_signal_strength does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, GetSignalStrengthP) +{ + int32_t getSignal = 0; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_get_signal_strength(h, &getSignal); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase GetSignalStrengthN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Gets the radio signal strength + * @apicovered radio_prepare, radio_open, radio_start, radio_get_signal_strength + * @passcase when radio_get_signal_strength returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_get_signal_strength does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, GetSignalStrengthN) +{ + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_get_signal_strength(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SetVolumeP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Sets the radio volume + * @apicovered radio_prepare, radio_open, radio_start, radio_set_freqeuncy, radio_set_volume + * @passcase when radio_set_volume returns RADIO_ERROR_NONE + * @failcase when radio_set_volume does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SetVolumeP) +{ + uint32_t freq = 95900; + float vol = 0.5; + + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_volume(h, vol); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SetVolumeN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Sets the radio volume + * @apicovered radio_prepare, radio_open, radio_start, radio_set_freqeuncy, radio_set_volume + * @passcase when radio_set_volume returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_set_volume does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SetVolumeN) +{ + uint32_t freq = 95900; + float vol = 0.5; + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_volume(nullptr, vol); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase GetVolumeP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Gets the radio volume + * @apicovered radio_prepare, radio_open, radio_start, radio_set_freqeuncy, radio_set_volume, radio_get_volume + * @passcase when radio_set_volume returns RADIO_ERROR_NONE and result is same with previous set volume + * @failcase when radio_set_volume does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, GetVolumeP) +{ + uint32_t freq = 95900; + float vol = 0.5; + float getVol = 0; + + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_volume(h, vol); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_get_volume(h, &getVol); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + EXPECT_EQ(vol, getVol); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase GetVolumeP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Negative, Gets the radio volume + * @apicovered radio_prepare, radio_open, radio_start, radio_set_freqeuncy, radio_set_volume, radio_get_volume + * @passcase when radio_set_volume returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_set_volume does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, GetVolumeN) +{ + uint32_t freq = 95900; + float getVol = 0; + + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_get_volume(nullptr, &getVol); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SetMediaVolumeP + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Sets the media volume in radio + * @apicovered radio_prepare, radio_open, radio_start, radio_set_freqeuncy, radio_set_media_volume + * @passcase when radio_set_volume returns RADIO_ERROR_NONE + * @failcase when radio_set_volume does not return RADIO_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SetMediaVolumeP) +{ + uint32_t freq = 95900; + int level = 5; + + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_media_volume(h, level); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +/** + * @testcase SetMediaVolumeN + * @sizen_tizen 5.0 + * @author SR(gilbok.lee) + * @reviewer SR(eunhae1.choi) + * @type auto + * @description Positive, Sets the media volume in radio + * @apicovered radio_prepare, radio_open, radio_start, radio_set_freqeuncy, radio_set_media_volume + * @passcase when radio_set_volume returns RADIO_ERROR_INVALID_PARAMETER + * @failcase when radio_set_volume does not return RADIO_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(RadioHalTest, SetMediaVolumeN) +{ + uint32_t freq = 95900; + int level = 5; + + RADIO_SUPPORT_CHECK; + + EXPECT_NE(h, nullptr); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_prepare(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_open(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_start(h); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_frequency(h, freq); + EXPECT_EQ(ret, RADIO_ERROR_NONE); + + ret = radio_hal_set_media_volume(nullptr, level); + EXPECT_EQ(ret, RADIO_ERROR_INVALID_PARAMETER); + + radio_hal_stop(h); + + radio_hal_close(h); + + radio_hal_unprepare(h); +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} |