From aa284e431e4c132d03c0e293b2ceb61197bb92d4 Mon Sep 17 00:00:00 2001 From: SeokHoon LEE Date: Mon, 26 Nov 2018 16:32:33 +0900 Subject: [PATCH] Adding initial structure for unittest Change-Id: Ib8b8b1681b824b39ab54aeafd95b6fbae24faebe Signed-off-by: SeokHoon LEE --- configure.ac | 20 +++++++++++++ packaging/gst-plugins-tizen.spec | 17 ++++++++++- wfdmanager/Makefile.am | 3 ++ wfdmanager/unittest/Makefile.am | 16 ++++++++++ wfdmanager/unittest/gtest_wfdmanager.cpp | 51 ++++++++++++++++++++++++++++++++ wfdmanager/unittest/gtest_wfdmanager.h | 26 ++++++++++++++++ 6 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 wfdmanager/unittest/Makefile.am create mode 100644 wfdmanager/unittest/gtest_wfdmanager.cpp create mode 100644 wfdmanager/unittest/gtest_wfdmanager.h diff --git a/configure.ac b/configure.ac index 021fc8f..df2c8a2 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,8 @@ AC_PROG_CC AC_PROG_CXX AC_PROG_LIBTOOL +AC_SUBST(GCC_CXXFLAGS) + dnl decide on error flags AS_COMPILER_FLAG(-Wall, GST_WALL="yes", GST_WALL="no") @@ -460,6 +462,23 @@ AC_SUBST(CAMERA_HAL_INTERFACE_CFLAGS) AC_SUBST(CAMERA_HAL_INTERFACE_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_OUTPUT( Makefile common/Makefile @@ -477,6 +496,7 @@ audioeq/src/Makefile fimcconvert/Makefile fimcconvert/src/Makefile wfdmanager/Makefile +wfdmanager/unittest/Makefile wfdmanager/wfdbase/Makefile wfdtsdemux/Makefile waylandsrc/Makefile diff --git a/packaging/gst-plugins-tizen.spec b/packaging/gst-plugins-tizen.spec index 8349f9f..5d41a28 100644 --- a/packaging/gst-plugins-tizen.spec +++ b/packaging/gst-plugins-tizen.spec @@ -9,7 +9,7 @@ Name: gst-plugins-tizen Version: 1.0.0 Summary: GStreamer tizen plugins (common) -Release: 60 +Release: 61 Group: Multimedia/Framework Url: http://gstreamer.freedesktop.org/ License: LGPL-2.1+ @@ -44,6 +44,9 @@ BuildRequires: pkgconfig(wayland-client) >= 1.0.0 BuildRequires: pkgconfig(wayland-tbm-client) BuildRequires: pkgconfig(tizen-extension-client) %endif +%if 0%{?gtests:1} +BuildRequires: pkgconfig(gmock) +%endif # for tizencamerasrc #BuildRequires: pkgconfig(camera-hal-interface) @@ -82,6 +85,9 @@ export CFLAGS="$CFLAGS_DEFAULT -DTIZEN_FEATURE_PRODUCT_TM1" ./autogen.sh --disable-static %configure \ +%if 0%{?gtests:1} + --enable-tests \ +%endif --disable-drmdecryptor\ --enable-ext-wfdtizenmanager\ --enable-ext-alfec\ @@ -107,6 +113,9 @@ export CFLAGS="$CFLAGS_DEFAULT" ./autogen.sh --disable-static %configure \ +%if 0%{?gtests:1} + --enable-tests \ +%endif --disable-drmdecryptor\ --enable-ext-wfdtizenmanager\ --enable-ext-alfec\ @@ -167,6 +176,9 @@ esac %license COPYING %{_libdir}/gstreamer-%{gst_branch}/*.so.tm1 %{_libdir}/libgstwfdbase.so*.tm1 +%if 0%{?gtests:1} +%{_bindir}/gtest* +%endif %endif %endif @@ -180,4 +192,7 @@ esac %exclude %{_libdir}/gstreamer-%{gst_branch}/*.so.tm1 %exclude %{_libdir}/libgstwfdbase.so*.tm1 %endif +%if 0%{?gtests:1} +%{_bindir}/gtest* +%endif diff --git a/wfdmanager/Makefile.am b/wfdmanager/Makefile.am index 8886a06..a2046c0 100755 --- a/wfdmanager/Makefile.am +++ b/wfdmanager/Makefile.am @@ -1,4 +1,7 @@ SUBDIRS = wfdbase +if IS_TESTS +SUBDIRS += unittest +endif plugin_LTLIBRARIES = libgstwfdmanager.la diff --git a/wfdmanager/unittest/Makefile.am b/wfdmanager/unittest/Makefile.am new file mode 100644 index 0000000..29cdf4d --- /dev/null +++ b/wfdmanager/unittest/Makefile.am @@ -0,0 +1,16 @@ +bin_PROGRAMS = gtest-wfdmanager + +gtest_wfdmanager_SOURCES = gtest_wfdmanager.cpp + +gtest_wfdmanager_CXXFLAGS = \ + -I$(top_srcdir)/wfdmanager/wfdbase \ + $(MMCOMMON_CFLAGS) \ + $(GTESTS_CFLAGS) \ + $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) + +gtest_wfdmanager_LDADD = \ + $(top_builddir)/wfdmanager/wfdbase/libgstwfdbase.la \ + -lgstrtp-@GST_MAJORMINOR@ -lgstrtsp-@GST_MAJORMINOR@ \ + $(MMCOMMON_LIBS) \ + $(GTESTS_LIBS) \ + $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) diff --git a/wfdmanager/unittest/gtest_wfdmanager.cpp b/wfdmanager/unittest/gtest_wfdmanager.cpp new file mode 100644 index 0000000..7f72909 --- /dev/null +++ b/wfdmanager/unittest/gtest_wfdmanager.cpp @@ -0,0 +1,51 @@ +/* + * 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_wfdmanager.h" +#include "gstwfdsinkmessage.h" + +using ::testing::InitGoogleTest; +using ::testing::Test; +using ::testing::TestCase; + +class wfdmanager_Test : public ::testing::Test { + protected: + void SetUp() { + std::cout << "SetUp()" << std::endl; + } + + void TearDown() { + std::cout << "TearDown()" << std::endl; + } +}; + +TEST(wfdmanager_Test, _wfd_message_new_p1) +{ + GstWFDResult wfd_res; + GstWFDMessage *msg; + + wfd_res = gst_wfd_message_new(&msg); + + EXPECT_EQ(wfd_res, GST_WFD_OK); +} + +int main(int argc, char **argv) +{ + InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/wfdmanager/unittest/gtest_wfdmanager.h b/wfdmanager/unittest/gtest_wfdmanager.h new file mode 100644 index 0000000..3bfb654 --- /dev/null +++ b/wfdmanager/unittest/gtest_wfdmanager.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 __WFDMANAGER_UNITTEST_H__ +#define __WFDMANAGER_UNITTEST_H__ + +#include +#include + +#undef LOG_TAG +#define LOG_TAG "GTEST_WFDMANAGER" + +#endif /*__WFDMANAGER_UNITTEST_H__*/ -- 2.7.4