summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukHyung, Kang <shine.kang@samsung.com>2019-01-28 17:54:54 +0900
committerSukHyung, Kang <shine.kang@samsung.com>2019-01-28 17:54:54 +0900
commitd73917c1e276ac417d50ef6d6a6ae1fc7617a23c (patch)
treeea31fd183cf24f5bcdd9435b8c39ae72cbbd2a83
parent033ffdc43f9d76db6e63595488efdf5d0003a694 (diff)
downloadnotification-drafts/for/tizen.tar.gz
notification-drafts/for/tizen.tar.bz2
notification-drafts/for/tizen.zip
Add unit tests for notification ex APIdrafts/for/tizen
Change-Id: Id3f1f47ac040d5b85ab2e69f70d81831ae4b87d3 Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
-rw-r--r--CMakeLists.txt1
-rw-r--r--packaging/notification.spec15
-rw-r--r--unittest/CMakeLists.txt30
-rw-r--r--unittest/src/test_main.cc37
4 files changed, 83 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f528db1..b5f63c5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ SET(LIBDIR ${LIB_INSTALL_DIR})
SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
#ADD_SUBDIRECTORY(test-app)
+ADD_SUBDIRECTORY(unittest)
SET(INIT-SRCS
./src/notification_init.c
diff --git a/packaging/notification.spec b/packaging/notification.spec
index 5c959e6..4ac60c0 100644
--- a/packaging/notification.spec
+++ b/packaging/notification.spec
@@ -22,6 +22,7 @@ BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(iniparser)
BuildRequires: pkgconfig(security-manager)
BuildRequires: pkgconfig(libsmack)
+BuildRequires: pkgconfig(gmock)
BuildRequires: cmake
Requires(post): /sbin/ldconfig
@@ -106,3 +107,17 @@ fi
%{_includedir}/notification/notification_type_internal.h
%{_libdir}/pkgconfig/notification.pc
%{_libdir}/libnotification.so
+
+
+#################################################
+# notification_ex_unittests
+#################################################
+%package -n notification_ex_unittests
+Summary: GTest for notification_ex
+Group: Development/Libraries
+
+%description -n notification_ex_unittests
+GTest for notification_ex
+
+%files -n notification_ex_unittests
+%{_bindir}/notification_ex_unittests
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
new file mode 100644
index 0000000..129c1ef
--- /dev/null
+++ b/unittest/CMakeLists.txt
@@ -0,0 +1,30 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(notification_ex_unittests CXX)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(notification_ex_unittests REQUIRED
+ dlog
+ gmock
+)
+
+FOREACH(flag ${notification_ex_unittests_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+AUX_SOURCE_DIRECTORY(src SOURCES)
+ADD_EXECUTABLE(${PROJECT_NAME}
+ ${SOURCES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${watchface-complication_unittests_LDFLAGS}
+ ${pkgs_LDFLAGS}
+ ${pkgs_LIBRARIES}
+ gmock
+)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
diff --git a/unittest/src/test_main.cc b/unittest/src/test_main.cc
new file mode 100644
index 0000000..4be05dc
--- /dev/null
+++ b/unittest/src/test_main.cc
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * 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/gtest.h>
+#include <gmock/gmock.h>
+
+int main(int argc, char** argv){
+ int ret = -1;
+ setenv("GCOV_PREFIX", "/tmp/", 1);
+ try {
+ testing::InitGoogleTest(&argc, argv);
+ } catch(...) {
+ std::cout << "Exception occurred" << std::endl;
+ }
+
+ try {
+ ret = RUN_ALL_TESTS();
+ } catch (const ::testing::internal::GoogleTestFailureException& e) {
+ ret = -1;
+ std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+ }
+
+ return ret;
+}