summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilbok Lee <gilbok.lee@samsung.com>2018-11-21 14:33:54 +0900
committerGilbok Lee <gilbok.lee@samsung.com>2018-11-23 15:35:10 +0900
commit1fe51fdf428abc272015be4b5ac9a46dfdb1a52d (patch)
treecdfb96a749f8aceb68e5aa98fdc66ab095278195
parentc49703247bd61eecae2d7cb0139c0f5fc4e0e44b (diff)
downloadlibmm-radio-1fe51fdf428abc272015be4b5ac9a46dfdb1a52d.tar.gz
libmm-radio-1fe51fdf428abc272015be4b5ac9a46dfdb1a52d.tar.bz2
libmm-radio-1fe51fdf428abc272015be4b5ac9a46dfdb1a52d.zip
Adding initial structure for unittest
Change-Id: Iea696f0087069093152f77e4fc7c48b007400f9a
-rw-r--r--Makefile.am8
-rwxr-xr-xautogen.sh1
-rwxr-xr-xconfigure.ac27
-rw-r--r--[-rwxr-xr-x]packaging/libmm-radio.spec12
-rw-r--r--unittest/Makefile.am36
-rwxr-xr-xunittest/gtest_libmm-radio.cpp98
-rw-r--r--unittest/gtest_libmm-radio.h26
7 files changed, 195 insertions, 13 deletions
diff --git a/Makefile.am b/Makefile.am
index c9ea877..3231f35 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,9 @@
-ACLOCAL_AMFLAGS='-I m4'
+ACLOCAL_AMFLAGS='-I m4'
SUBDIRS = src
+if IS_TESTS
+SUBDIRS += unittest
+endif
pcfiles = mm-radio.pc
@@ -8,5 +11,4 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pcfiles)
-EXTRA_DIST = $(pcfiles)
-
+EXTRA_DIST = $(pcfiles)
diff --git a/autogen.sh b/autogen.sh
index 828897e..b73dd97 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -4,4 +4,3 @@ libtoolize
autoheader
autoconf
automake --add-missing --copy --foreign
-
diff --git a/configure.ac b/configure.ac
index ace5364..1faaf9f 100755
--- a/configure.ac
+++ b/configure.ac
@@ -12,6 +12,7 @@ AC_PROG_LIBTOOL
m4_pattern_allow([AM_PROG_AR])
AM_PROG_AR
AC_PROG_CC
+AC_PROG_CXX
# Checks for libraries.
@@ -67,13 +68,11 @@ if test "x$ENABLE_EMULATOR" == "xyes"; then
fi
AC_ARG_ENABLE(sound-vstream, AC_HELP_STRING([--enable-sound-vstream], [using sound virtual stream]),
-[
- case "${enableval}" in
- yes) ENABLE_SOUND_VSTREAM=yes ;;
- no) ENABLE_SOUND_VSTREAM=no ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-sound-vstream) ;;
- esac
- ],[ENABLE_SOUND_VSTREAM=no])
+[case "${enableval}" in
+ yes) ENABLE_SOUND_VSTREAM=yes ;;
+ no) ENABLE_SOUND_VSTREAM=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-sound-vstream) ;;
+esac], [ENABLE_SOUND_VSTREAM=no])
AM_CONDITIONAL(ENABLE_SOUND_VSTREAM, test "x$ENABLE_SOUND_VSTREAM" = "xyes")
if test "x$ENABLE_SOUND_VSTREAM" == "xyes"; then
@@ -82,10 +81,24 @@ if test "x$ENABLE_SOUND_VSTREAM" == "xyes"; then
AC_SUBST(SOUNDMGR_LIBS)
fi
+AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [unittest build]),
+[case "${enableval}" in
+ yes) IS_TESTS=yes ;;
+ no) IS_TESTS=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
+esac], [IS_TESTS=no])
+AM_CONDITIONAL([IS_TESTS], [test "x$IS_TESTS" = "xyes"])
+
+AS_IF([test "x$enable_tests" = "xyes"], [
+ PKG_CHECK_MODULES(GTESTS, gmock)
+ AC_SUBST(GTESTS_CFLAGS)
+ AC_SUBST(GTESTS_LIBS)
+])
AC_CONFIG_FILES([
Makefile
src/Makefile
+ unittest/Makefile
mm-radio.pc
])
AC_OUTPUT
diff --git a/packaging/libmm-radio.spec b/packaging/libmm-radio.spec
index 5cad65a..86b5065 100755..100644
--- a/packaging/libmm-radio.spec
+++ b/packaging/libmm-radio.spec
@@ -1,6 +1,6 @@
Name: libmm-radio
Summary: Multimedia Framework Radio Library
-Version: 0.2.43
+Version: 0.2.44
Release: 0
Group: System/Libraries
License: Apache-2.0
@@ -16,6 +16,9 @@ BuildRequires: pkgconfig(gstreamer-1.0)
BuildRequires: pkgconfig(gstreamer-plugins-base-1.0)
%endif
BuildRequires: pkgconfig(mm-resource-manager)
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
%description
Description: Multimedia Framework Radio Library
@@ -46,6 +49,9 @@ export CFLAGS+=" -DPATH_LIBDIR=\\\"%{_libdir}\\\""
%ifnarch %{arm}
--enable-emulator \
%endif
+%if 0%{?gtests:1}
+--enable-tests \
+%endif
--enable-sound-vstream \
--disable-static --prefix=%{_prefix}
@@ -66,6 +72,9 @@ rm -rf %{buildroot}
%defattr(-,root,root,-)
%{_libdir}/libmmfradio.so.*
%license LICENSE.Apache-2.0
+%if 0%{?gtests:1}
+%{_bindir}/gtest_libmm_radio
+%endif
%files devel
%manifest %{name}.manifest
@@ -73,4 +82,3 @@ rm -rf %{buildroot}
%{_libdir}/libmmfradio.so
%{_libdir}/pkgconfig/mm-radio.pc
%{_includedir}/mmf/mm_radio.h
-
diff --git a/unittest/Makefile.am b/unittest/Makefile.am
new file mode 100644
index 0000000..841d81f
--- /dev/null
+++ b/unittest/Makefile.am
@@ -0,0 +1,36 @@
+# Unit tests
+bin_PROGRAMS = gtest_libmm_radio
+
+gtest_libmm_radio_SOURCES = gtest_libmm-radio.cpp
+
+gtest_libmm_radio_CXXFLAGS = -I$(top_srcdir)/src/include \
+ $(GTHREAD_CFLAGS) \
+ $(MMCOMMON_CFLAGS) \
+ $(MM_RESOURCE_MANAGER_CFLAGS) \
+ $(DLOG_CFLAGS) \
+ $(GTESTS_CFLAGS) \
+ -Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-cpp
+
+gtest_libmm_radio_DEPENDENCIES = $(top_srcdir)/src/.libs/libmmfradio.la
+
+gtest_libmm_radio_LDADD = $(GTHREAD_LIBS) \
+ $(MMCOMMON_LIBS) \
+ $(MM_RESOURCE_MANAGER_LIBS) \
+ $(DLOG_LIBS) \
+ $(GTESTS_LIBS) \
+ $(top_srcdir)/src/.libs/libmmfradio.la
+
+if ENABLE_EMULATOR
+gtest_libmm_radio_CXXFLAGS += $(GST_CFLAGS) \
+ $(GSTAPP_CFLAGS)
+
+gtest_libmm_radio_LDADD += $(GST_LIBS) \
+ $(GSTAPP_LIBS)
+endif
+
+if ENABLE_SOUND_VSTREAM
+gtest_libmm_radio_CXXFLAGS += $(SOUNDMGR_CFLAGS) \
+ -DTIZEN_FEATURE_SOUND_VSTREAM
+
+gtest_libmm_radio_LDADD += $(SOUNDMGR_LIBS)
+endif
diff --git a/unittest/gtest_libmm-radio.cpp b/unittest/gtest_libmm-radio.cpp
new file mode 100755
index 0000000..8c1e147
--- /dev/null
+++ b/unittest/gtest_libmm-radio.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2018 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.
+ */
+
+
+#include "gtest_libmm-radio.h"
+#include "mm_error.h"
+#include "mm_radio.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+using namespace std;
+
+int ret;
+MMHandleType hradio;
+
+static int _message_callback(int message, void *pParam, void *user_param)
+{
+ MMMessageParamType* param = (MMMessageParamType*)pParam;
+
+ cout << "incomming message :" << message << endl;
+
+ switch(message)
+ {
+ case MM_MESSAGE_STATE_CHANGED:
+ cout << "MM_MESSAGE_STATE_CHANGED: current : " << param->state.current
+ << "old : " << param->state.previous << endl;
+ break;
+ case MM_MESSAGE_RADIO_SCAN_START:
+ cout << "MM_MESSAGE_RADIO_SCAN_START" << endl;
+ break;
+ case MM_MESSAGE_RADIO_SCAN_INFO:
+ cout << "MM_MESSAGE_RADIO_SCAN_INFO : freq : " << param->radio_scan.frequency
+ << endl;
+ break;
+ case MM_MESSAGE_RADIO_SCAN_STOP:
+ cout << "MM_MESSAGE_RADIO_SCAN_STOP" << endl;
+ break;
+ case MM_MESSAGE_RADIO_SCAN_FINISH:
+ cout << "MM_MESSAGE_RADIO_SCAN_FINISHED" << endl;
+ break;
+ case MM_MESSAGE_RADIO_SEEK_START:
+ cout << "MM_MESSAGE_RADIO_SEEK_START" << endl;
+ break;
+ case MM_MESSAGE_RADIO_SEEK_FINISH:
+ cout << "MM_MESSAGE_RADIO_SEEK_FINISHED : freq : " << param->radio_scan.frequency
+ << endl;
+ break;
+ default:
+ cout << "ERROR : unknown message received!" << endl;
+ break;
+ }
+
+ return 0;
+}
+
+class MMRadioTest : public ::testing::Test {
+ protected:
+ void SetUp() {
+ ret = mm_radio_create(&hradio);
+ ASSERT_EQ(ret, MM_ERROR_NONE) << "[FAILED] mm_radio_create";
+
+ ret = mm_radio_set_message_callback(hradio, _message_callback, &hradio);
+ ASSERT_EQ(ret, MM_ERROR_NONE) << "[FAILED] mm_radio_set_message_callback";
+ }
+
+ void TearDown() {
+ ret = mm_radio_destroy(hradio);
+ ASSERT_EQ(ret, MM_ERROR_NONE) << "[FAILED] mm_radio_destroy";
+ return;
+ }
+};
+
+TEST_F(MMRadioTest, mmradio_create_test)
+{
+ ASSERT_EQ(ret, MM_ERROR_NONE) << "[FAILED] mm_radio_create";
+}
+
+int main(int argc, char **argv)
+{
+ InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
diff --git a/unittest/gtest_libmm-radio.h b/unittest/gtest_libmm-radio.h
new file mode 100644
index 0000000..0d17f4e
--- /dev/null
+++ b/unittest/gtest_libmm-radio.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2018 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.
+ */
+
+#ifndef __LIB_MM_RADIO_UNITTEST_H__
+#define __LIB_MM_RADIO_UNITTEST_H__
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#undef LOG_TAG
+#define LOG_TAG "GTEST_LIBMM_RADIO"
+
+#endif /*__LIB_MM_RADIO_UNITTEST_H__*/