Add unit test 12/194012/1 accepted/tizen_5.5_unified_mobile_hotfix tizen_5.5_mobile_hotfix accepted/tizen/5.5/unified/20191031.023036 accepted/tizen/5.5/unified/mobile/hotfix/20201027.084711 accepted/tizen/unified/20181130.064935 submit/tizen/20181129.024814 submit/tizen_5.5/20191031.000004 submit/tizen_5.5_mobile_hotfix/20201026.185103 tizen_5.5.m2_release
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 28 Nov 2018 09:05:46 +0000 (18:05 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 28 Nov 2018 09:05:46 +0000 (18:05 +0900)
[Version] 0.0.4
[Profile] Common
[Issue Type] Update
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20181126.2]

Change-Id: I7f8c79b869ff37d95996eb61366a33fba328aab2
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
Makefile.am
configure.ac
packaging/libmm-display.spec
unittest/Makefile.am [new file with mode: 0644]
unittest/gtests_libmm_display.cpp [new file with mode: 0644]
unittest/gtests_libmm_display.h [new file with mode: 0644]

index 0d10595..4667b84 100644 (file)
@@ -2,6 +2,10 @@ ACLOCAL_AMFLAGS='-I m4'
 
 SUBDIRS = src
 
+if GTESTS
+SUBDIRS += unittest
+endif
+
 pcfiles = mm-display-interface.pc
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = $(pcfiles)
index 838d66e..c72f32a 100644 (file)
@@ -21,6 +21,8 @@ AC_HEADER_STDC
 AC_HEADER_TIME
 AC_PROG_GCC_TRADITIONAL
 AC_PROG_LIBTOOL
+AC_PROG_CXX
+AC_SUBST(GCC_CXXFLAGS)
 
 # Checks for libraries.
 PKG_CHECK_MODULES(GLIB, glib-2.0)
@@ -67,6 +69,7 @@ PKG_CHECK_MODULES(TIZEN_EXTENSION_CLIENT, tizen-extension-client)
 AC_SUBST(TIZEN_EXTENSION_CLIENT_CFLAGS)
 AC_SUBST(TIZEN_EXTENSION_CLIENT_LIBS)
 
+# Evas Renderer
 AC_ARG_ENABLE(evas-renderer, AC_HELP_STRING([--enable-evas-renderer], [enable evas renderer]),
 [
   case "${enableval}" in
@@ -82,6 +85,22 @@ AC_SUBST(EVAS_RENDERER_LIBS)
 fi
 AM_CONDITIONAL([TIZEN_FEATURE_EVAS_RENDERER], [test "x$TIZEN_FEATURE_EVAS_RENDERER" = "xyes"])
 
+# GTESTS
+AC_ARG_ENABLE(gtests, AC_HELP_STRING([--enable-gtests], [enable gtests]),
+[
+  case "${enableval}" in
+    yes) GTESTS=yes ;;
+    no)  GTESTS=no ;;
+    *) AC_MSG_ERROR(bad value ${enableval} for --enable-gtests) ;;
+  esac
+],[GTESTS=no])
+if test "x$GTESTS" = "xyes"; then
+PKG_CHECK_MODULES(GMOCK, gmock)
+AC_SUBST(GMOCK_CFLAGS)
+AC_SUBST(GMOCK_LIBS)
+fi
+AM_CONDITIONAL([GTESTS], [test "x$GTESTS" = "xyes"])
+
 # Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([fcntl.h memory.h stdlib.h string.h sys/time.h unistd.h])
@@ -102,6 +121,7 @@ AC_CHECK_FUNCS([memset select])
 AC_CONFIG_FILES([
 Makefile
 src/Makefile
+unittest/Makefile
 mm-display-interface.pc
 ])
 AC_OUTPUT
index 3b74978..925602c 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-display
 Summary:    Multimedia framework display library
-Version:    0.0.3
+Version:    0.0.4
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
@@ -21,6 +21,9 @@ BuildRequires:  pkgconfig(tizen-extension-client)
 %if "%{tizen_profile_name}" != "tv"
 BuildRequires:  pkgconfig(mm-evas-renderer)
 %endif
+%if "%{gtests}" == "1"
+BuildRequires:  pkgconfig(gmock)
+%endif
 
 %description
 Multimedia framework display library.
@@ -56,6 +59,9 @@ export CFLAGS+=" -D_LARGEFILE64_SOURCE -DMM_DISPLAY_LIBDIR=\\\"%{_libdir}\\\" -D
 %if "%{tizen_profile_name}" != "tv"
        --enable-evas-renderer \
 %endif
+%if "%{gtests}" == "1"
+       --enable-gtests \
+%endif
        --disable-static
 make %{?jobs:-j%jobs}
 
@@ -73,6 +79,9 @@ make %{?jobs:-j%jobs}
 %license LICENSE.APLv2
 %defattr(-,root,root,-)
 %{_libdir}/libmmfdisplay.so*
+%if "%{gtests}" == "1"
+%{_bindir}/gtests-libmm-display
+%endif
 
 %files interface
 %manifest libmm-display-interface.manifest
diff --git a/unittest/Makefile.am b/unittest/Makefile.am
new file mode 100644 (file)
index 0000000..8c3fb84
--- /dev/null
@@ -0,0 +1,18 @@
+bin_PROGRAMS = gtests-libmm-display
+
+gtests_libmm_display_SOURCES = gtests_libmm_display.cpp
+
+gtests_libmm_display_CXXFLAGS = \
+       -I$(top_srcdir)/src/include\
+       $(MM_COMMON_CFLAGS)\
+       $(MEDIA_TOOL_CFLAGS)\
+       $(GMOCK_CFLAGS)
+
+gtests_libmm_display_DEPENDENCIES = \
+       $(top_srcdir)/src/libmmfdisplay.la
+
+gtests_libmm_display_LDADD = \
+       $(GMOCK_LIBS)\
+       $(MEDIA_TOOL_LIBS)\
+       $(top_srcdir)/src/libmmfdisplay.la
+
diff --git a/unittest/gtests_libmm_display.cpp b/unittest/gtests_libmm_display.cpp
new file mode 100644 (file)
index 0000000..95f0328
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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 <mm_error.h>
+#include "gtests_libmm_display.h"
+
+using namespace std;
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+
+
+class MMDisplayTestF : public ::testing::Test {
+       protected:
+               mm_display_h handle;
+
+               void SetUp() {
+                       cout << "[SetUp]" << endl;
+                       ASSERT_EQ(mm_display_init(&handle), MM_ERROR_NONE);
+                       return;
+               }
+
+               void TearDown() {
+                       cout << "[TearDown]" << endl << endl;
+                       if (handle) {
+                               mm_display_deinit(handle);
+                               handle = NULL;
+                       }
+                       return;
+               }
+};
+
+TEST(MMDisplayTest, InitP)
+{
+       mm_display_h new_handle = NULL;
+
+       ASSERT_EQ(mm_display_init(&new_handle), MM_ERROR_NONE);
+
+       mm_display_deinit(new_handle);
+}
+
+TEST(MMDisplayTest, DeinitP)
+{
+       mm_display_h new_handle = NULL;
+
+       ASSERT_EQ(mm_display_init(&new_handle), MM_ERROR_NONE);
+
+       ASSERT_EQ(mm_display_deinit(new_handle), MM_ERROR_NONE);
+}
+
+
+int main(int argc, char **argv)
+{
+       InitGoogleTest(&argc, argv);
+
+       return RUN_ALL_TESTS();
+}
diff --git a/unittest/gtests_libmm_display.h b/unittest/gtests_libmm_display.h
new file mode 100644 (file)
index 0000000..4a51dec
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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 __MM_DISPLAY_UNITTEST_H__
+#define __MM_DISPLAY_UNITTEST_H__
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <mm_display.h>
+
+#undef LOG_TAG
+#define LOG_TAG                "GTEST_MM_DISPLAY"
+
+#endif /*__MM_DISPLAY_UNITTEST_H__*/