Add initial structure for unittest 16/193516/2
authorHyunil <hyunil46.park@samsung.com>
Wed, 21 Nov 2018 10:37:41 +0000 (19:37 +0900)
committerHyunil <hyunil46.park@samsung.com>
Wed, 21 Nov 2018 10:45:31 +0000 (19:45 +0900)
Change-Id: Ie28dd53fc81f744a04dbc0f61431158abba73b76
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
Makefile.am
configure.ac
packaging/libmm-evas-renderer.spec
unittest/Makefile.am [new file with mode: 0644]
unittest/libmm_evas_renderer_unittest.cpp [new file with mode: 0644]
unittest/libmm_evas_renderer_unittest.h [new file with mode: 0644]

index b9b8ac7abf5d1d13b03acb3915e5e86bf38facec..224cacc373a673a457d6e110c0e78ebe3da122d0 100644 (file)
@@ -1,6 +1,10 @@
 ACLOCAL_AMFLAGS='-I m4'
 SUBDIRS = src
 
+if IS_TESTS
+SUBDIRS += unittest
+endif
+
 pcfiles = mm-evas-renderer.pc
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = $(pcfiles)
index 855fcad4bc876559502a315eeea064b6d76ba654..cf3a7e6e4f4447b7bc08aa226319b0adcbdf8e45 100644 (file)
@@ -11,6 +11,7 @@ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
 # Checks for programs.
 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 AC_PROG_CC
+AC_PROG_CXX
 AM_PROG_CC_C_O
 AC_C_CONST
 dnl AC_FUNC_MALLOC
@@ -25,6 +26,8 @@ AC_HEADER_TIME
 AC_PROG_GCC_TRADITIONAL
 AC_PROG_LIBTOOL
 
+AC_SUBST(GCC_CXXFLAGS)
+
 PKG_CHECK_MODULES(MMCOMMON, mm-common)
 AC_SUBST(MMCOMMON_CFLAGS)
 AC_SUBST(MMCOMMON_LIBS)
@@ -57,6 +60,23 @@ AC_SUBST(ECORE_LIBS)
 AC_HEADER_STDC
 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h syslog.h unistd.h])
 
+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)
+])
+
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
 AC_C_CONST
@@ -74,6 +94,7 @@ AC_CHECK_FUNCS([memset])
 AC_CONFIG_FILES([
 Makefile
 src/Makefile
+unittest/Makefile
 mm-evas-renderer.pc
 ])
 AC_OUTPUT
index 8dc6e669aa7e5af032652d670ae586966ef0c3ea..49255a81f179975080a8e0df65af6ff7f941082c 100644 (file)
@@ -16,6 +16,9 @@ BuildRequires:  pkgconfig(ecore)
 BuildRequires:  pkgconfig(evas)
 BuildRequires:  pkgconfig(capi-media-tool)
 BuildRequires:  pkgconfig(libtbm)
+%if 0%{?gtests:1}
+BuildRequires:  pkgconfig(gmock)
+%endif
 
 %description
 Multimedia Framework Evas Renderer Library files.
@@ -38,7 +41,10 @@ cp %{SOURCE1001} .
 export CFLAGS+=" -DTIZEN_DEBUG"
 ./autogen.sh
 %configure \
-    --disable-static
+%if 0%{?gtests:1}
+       --enable-tests \
+%endif
+       --disable-static
 make %{?jobs:-j%jobs}
 
 %install
@@ -53,6 +59,9 @@ make %{?jobs:-j%jobs}
 %license LICENSE.Apache-2.0
 %defattr(-,root,root,-)
 %{_libdir}/*.so.*
+%if 0%{?gtests:1}
+%{_bindir}/gtest-libmm-evas-renderer
+%endif
 
 %files devel
 %manifest %{name}.manifest
diff --git a/unittest/Makefile.am b/unittest/Makefile.am
new file mode 100644 (file)
index 0000000..ce8cbb6
--- /dev/null
@@ -0,0 +1,31 @@
+# Unit tests
+bin_PROGRAMS = gtest-libmm-evas-renderer
+
+gtest_libmm_evas_renderer_SOURCES  = libmm_evas_renderer_unittest.cpp
+
+gtest_libmm_evas_renderer_CXXFLAGS =  -I$(top_srcdir)/src/include \
+                       $(MMCOMMON_CFLAGS) \
+                       $(MEDIAPACKET_CFLAGS) \
+                       $(DLOG_CFLAGS) \
+                       $(EVAS_CFLAGS) \
+                       $(ECORE_CFLAGS) \
+                       $(ELEMENTARY_CFLAGS) \
+                       $(GLIB_CFLAGS) \
+                       $(TBM_CFLAGS) \
+                       $(GTESTS_CFLAGS) \
+                       -Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-cpp
+
+gtest_libmm_evas_renderer_DEPENDENCIES = $(top_srcdir)/src/.libs/libmmfevasrenderer.la
+
+gtest_libmm_evas_renderer_LDADD = \
+                       $(GST_LIBS) \
+                       $(MMCOMMON_LIBS) \
+                       $(MEDIAPACKET_LIBS) \
+                       $(DLOG_LIBS) \
+                       $(EVAS_LIBS) \
+                       $(ECORE_LIBS) \
+                       $(ELEMENTARY_LIBS) \
+                       $(GLIB_LIBS) \
+                       $(TBM_LIBS)     \
+                       $(GTESTS_LIBS) \
+                       $(top_srcdir)/src/.libs/libmmfevasrenderer.la
diff --git a/unittest/libmm_evas_renderer_unittest.cpp b/unittest/libmm_evas_renderer_unittest.cpp
new file mode 100644 (file)
index 0000000..9602979
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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 "libmm_evas_renderer_unittest.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+class libmm_evas_renderer_Test : public ::testing::Test {
+       protected:
+               void SetUp() {
+                       std::cout << "SetUp()" << std::endl;
+               }
+
+               void TearDown() {
+                       std::cout << "TearDown()" << std::endl;
+               }
+};
+
+TEST_F(libmm_evas_renderer_Test, mm_evas_renderer_create_p)
+{
+
+}
+
+TEST_F(libmm_evas_renderer_Test, mm_evas_renderer_create_n)
+{
+
+}
+
+gint main(gint argc, gchar **argv)
+{
+       InitGoogleTest(&argc, argv);
+
+       return RUN_ALL_TESTS();
+}
diff --git a/unittest/libmm_evas_renderer_unittest.h b/unittest/libmm_evas_renderer_unittest.h
new file mode 100644 (file)
index 0000000..bc8be51
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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_EVAS_RENDERER_UNITTEST_H__
+#define __LIB_MM_EVAS_RENDERER_UNITTEST_H__
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <mm_evas_renderer.h>
+#include <mm_evas_renderer_private.h>
+#include <mm_error.h>
+#undef LOG_TAG
+#define LOG_TAG                "GTEST_LIB_MM_EVAS_RENDERER"
+
+#endif /*__LIB_MM_EVAS_RENDERER_UNITTEST_H__*/