aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodney Dawes <rodney.dawes@canonical.com>2017-02-02 14:53:15 -0500
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:38:27 +0200
commit5b555e5b0d23aa429d26795183a63653ef440c77 (patch)
tree9c6e6fa864a414cbe61b4d99a07c8c0ee8cbba65
parent5b5755d1c4f3fc9823e98be43c18201740393679 (diff)
downloadayatana-indicator-datetime-5b555e5b0d23aa429d26795183a63653ef440c77.tar.gz
ayatana-indicator-datetime-5b555e5b0d23aa429d26795183a63653ef440c77.tar.bz2
ayatana-indicator-datetime-5b555e5b0d23aa429d26795183a63653ef440c77.zip
Switch to using gmock module from cmake-extras.
-rw-r--r--CMakeLists.txt9
-rw-r--r--m4/gtest.m463
-rw-r--r--tests/CMakeLists.txt15
3 files changed, 5 insertions, 82 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 57ac0ce..1aebdf3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,15 +124,6 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
# testing & coverage
if (${ENABLE_TESTS})
pkg_check_modules (DBUSTEST REQUIRED dbustest-1>=14.04.0)
-
- if (EXISTS /usr/src/googletest/src)
- set (GTEST_SOURCE_DIR /usr/src/googletest/src)
- else ()
- set (GTEST_SOURCE_DIR /usr/src/gtest/src)
- endif ()
-
- set (GTEST_INCLUDE_DIR ${GTEST_SOURCE_DIR}/..)
- set (GTEST_LIBS -lpthread)
enable_testing ()
if (${ENABLE_COVERAGE})
include(GCov)
diff --git a/m4/gtest.m4 b/m4/gtest.m4
deleted file mode 100644
index 2de334c..0000000
--- a/m4/gtest.m4
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (C) 2012 Canonical, Ltd.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-# Checks whether the gtest source is available on the system. Allows for
-# adjusting the include and source path. Sets have_gtest=yes if the source is
-# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and
-# source location respectively.
-AC_DEFUN([CHECK_GTEST],
-[
- AC_ARG_WITH([gtest-include-path],
- [AS_HELP_STRING([--with-gtest-include-path],
- [location of the Google test headers])],
- [GTEST_CPPFLAGS="-I$withval"])
-
- AC_ARG_WITH([gtest-source-path],
- [AS_HELP_STRING([--with-gtest-source-path],
- [location of the Google test sources, defaults to /usr/src/gtest])],
- [GTEST_SOURCE="$withval"],
- [GTEST_SOURCE="/usr/src/gtest"])
-
- GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
-
- AC_LANG_PUSH([C++])
-
- tmp_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS"
-
- AC_CHECK_HEADER([gtest/gtest.h])
-
- CPPFLAGS="$tmp_CPPFLAGS"
-
- AC_LANG_POP
-
- AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
- [$GTEST_SOURCE/src/gtest_main.cc],
- [have_gtest_source=yes],
- [have_gtest_source=no])
-
- AS_IF([test "x$ac_cv_header_gtest_gtest_h" = xyes -a \
- "x$have_gtest_source" = xyes],
- [have_gtest=yes]
- [AC_SUBST(GTEST_CPPFLAGS)]
- [AC_SUBST(GTEST_SOURCE)],
- [have_gtest=no])
-]) # CHECK_GTEST
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 3bc6777..4eefbdc 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,9 +1,4 @@
-# build libgtest
-add_library (gtest STATIC
- ${GTEST_SOURCE_DIR}/gtest-all.cc
- ${GTEST_SOURCE_DIR}/gtest_main.cc)
-set_target_properties (gtest PROPERTIES INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GTEST_INCLUDE_DIR})
-set_target_properties (gtest PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -w")
+find_package(GMock REQUIRED)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ${COMPILE_FLAGS}")
@@ -44,7 +39,7 @@ function(add_test_by_name name)
set (TEST_NAME ${name})
add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)
add_test (${TEST_NAME} ${TEST_NAME})
- target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})
+ target_link_libraries (${TEST_NAME} indicatordatetimeservice ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
endfunction()
add_test_by_name(test-datetime)
if(HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS)
@@ -70,7 +65,7 @@ add_test_by_name(test-utils)
if(HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS)
set (TEST_NAME manual-test-snap)
add_executable (${TEST_NAME} ${TEST_NAME}.cpp)
- target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})
+ target_link_libraries (${TEST_NAME} indicatordatetimeservice ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
endif()
##
@@ -84,7 +79,7 @@ function(add_eds_ics_test_by_name name)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.ics.in"
"${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.ics")
add_executable(${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)
- target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})
+ target_link_libraries (${TEST_NAME} indicatordatetimeservice ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
add_test (${TEST_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/run-eds-ics-test.sh
${DBUS_RUNNER} # arg1: dbus-test-runner exec
@@ -112,7 +107,7 @@ add_eds_ics_test_by_name(test-eds-ics-repeating-events-with-individual-change)
# set (TEST_NAME ${name})
# add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)
# add_test (${TEST_NAME} ${TEST_NAME})
-# target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${SERVICE_DEPS_LIBRARIES} ${DBUSTEST_LIBRARIES} ${GTEST_LIBS})
+# target_link_libraries (${TEST_NAME} indicatordatetimeservice ${SERVICE_DEPS_LIBRARIES} ${DBUSTEST_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
#endfunction()
#add_dbusmock_test_by_name(test-timezone-geoclue)
#add_dbusmock_test_by_name(test-timezones)