mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-06 14:07:38 +03:00
Merge branch 'develop'
Conflicts: CMakeLists.txt cmake/CLangFormat.cmake snapcraft.yaml src/CMakeLists.txt src/core/Database.cpp src/core/Database.h src/core/Tools.cpp src/crypto/CryptoHash.h src/crypto/ssh/ASN1Key.h src/crypto/ssh/OpenSSHKey.cpp src/format/Kdbx4Reader.cpp src/gui/DatabaseTabWidget.cpp src/gui/DatabaseTabWidget.h src/gui/DatabaseWidget.cpp src/gui/DatabaseWidget.h src/gui/DetailsWidget.cpp src/gui/DetailsWidget.ui src/gui/EditWidgetProperties.cpp src/gui/EntryPreviewWidget.cpp src/gui/EntryPreviewWidget.ui src/gui/FileDialog.cpp src/gui/dbsettings/DatabaseSettingsDialog.cpp src/gui/dbsettings/DatabaseSettingsDialog.h src/gui/group/EditGroupWidget.cpp src/gui/group/EditGroupWidget.h src/sshagent/ASN1Key.h src/sshagent/OpenSSHKey.cpp src/sshagent/SSHAgent.cpp tests/CMakeLists.txt
This commit is contained in:
commit
9e2be34897
421 changed files with 18208 additions and 12907 deletions
tests
|
@ -1,3 +1,4 @@
|
|||
# Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
|
||||
# Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
@ -13,7 +14,11 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/../src)
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../src)
|
||||
|
||||
add_definitions(-DQT_TEST_LIB)
|
||||
|
||||
|
@ -21,99 +26,98 @@ set(KEEPASSX_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
|||
configure_file(config-keepassx-tests.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx-tests.h)
|
||||
|
||||
macro(parse_arguments prefix arg_names option_names)
|
||||
set(DEFAULT_ARGS)
|
||||
foreach(arg_name ${arg_names})
|
||||
set(${prefix}_${arg_name})
|
||||
endforeach(arg_name)
|
||||
foreach(option ${option_names})
|
||||
set(${prefix}_${option} FALSE)
|
||||
endforeach(option)
|
||||
set(DEFAULT_ARGS)
|
||||
foreach(arg_name ${arg_names})
|
||||
set(${prefix}_${arg_name})
|
||||
endforeach(arg_name)
|
||||
foreach(option ${option_names})
|
||||
set(${prefix}_${option} FALSE)
|
||||
endforeach(option)
|
||||
|
||||
set(current_arg_name DEFAULT_ARGS)
|
||||
set(current_arg_list)
|
||||
foreach(arg ${ARGN})
|
||||
set(larg_names ${arg_names})
|
||||
list(FIND larg_names "${arg}" is_arg_name)
|
||||
if(is_arg_name GREATER -1)
|
||||
set(${prefix}_${current_arg_name} ${current_arg_list})
|
||||
set(current_arg_name ${arg})
|
||||
set(current_arg_list)
|
||||
else()
|
||||
set(loption_names ${option_names})
|
||||
list(FIND loption_names "${arg}" is_option)
|
||||
if(is_option GREATER -1)
|
||||
set(${prefix}_${arg} TRUE)
|
||||
else(is_option GREATER -1)
|
||||
set(current_arg_list ${current_arg_list} ${arg})
|
||||
endif()
|
||||
endif()
|
||||
endforeach(arg)
|
||||
set(${prefix}_${current_arg_name} ${current_arg_list})
|
||||
set(current_arg_name DEFAULT_ARGS)
|
||||
set(current_arg_list)
|
||||
foreach(arg ${ARGN})
|
||||
set(larg_names ${arg_names})
|
||||
list(FIND larg_names "${arg}" is_arg_name)
|
||||
if(is_arg_name GREATER -1)
|
||||
set(${prefix}_${current_arg_name} ${current_arg_list})
|
||||
set(current_arg_name ${arg})
|
||||
set(current_arg_list)
|
||||
else()
|
||||
set(loption_names ${option_names})
|
||||
list(FIND loption_names "${arg}" is_option)
|
||||
if(is_option GREATER -1)
|
||||
set(${prefix}_${arg} TRUE)
|
||||
else(is_option GREATER -1)
|
||||
set(current_arg_list ${current_arg_list} ${arg})
|
||||
endif()
|
||||
endif()
|
||||
endforeach(arg)
|
||||
set(${prefix}_${current_arg_name} ${current_arg_list})
|
||||
endmacro(parse_arguments)
|
||||
|
||||
macro(add_unit_test)
|
||||
parse_arguments(TEST "NAME;SOURCES;LIBS" "" ${ARGN})
|
||||
set(_test_NAME ${TEST_NAME})
|
||||
set(_srcList ${TEST_SOURCES})
|
||||
add_executable(${_test_NAME} ${_srcList})
|
||||
target_link_libraries(${_test_NAME} ${TEST_LIBS})
|
||||
parse_arguments(TEST "NAME;SOURCES;LIBS" "" ${ARGN})
|
||||
set(_test_NAME ${TEST_NAME})
|
||||
set(_srcList ${TEST_SOURCES})
|
||||
add_executable(${_test_NAME} ${_srcList})
|
||||
target_link_libraries(${_test_NAME} ${TEST_LIBS})
|
||||
|
||||
if(NOT TEST_OUTPUT)
|
||||
set(TEST_OUTPUT plaintext)
|
||||
endif(NOT TEST_OUTPUT)
|
||||
set(TEST_OUTPUT ${TEST_OUTPUT} CACHE STRING "The output to generate when running the QTest unit tests")
|
||||
if(NOT TEST_OUTPUT)
|
||||
set(TEST_OUTPUT plaintext)
|
||||
endif(NOT TEST_OUTPUT)
|
||||
set(TEST_OUTPUT ${TEST_OUTPUT} CACHE STRING "The output to generate when running the QTest unit tests")
|
||||
|
||||
if(KDE4_TEST_OUTPUT STREQUAL "xml")
|
||||
add_test(${_test_NAME} ${_test_NAME} -xml -o ${_test_NAME}.tml)
|
||||
else(KDE4_TEST_OUTPUT STREQUAL "xml")
|
||||
add_test(${_test_NAME} ${_test_NAME})
|
||||
endif(KDE4_TEST_OUTPUT STREQUAL "xml")
|
||||
if(KDE4_TEST_OUTPUT STREQUAL "xml")
|
||||
add_test(${_test_NAME} ${_test_NAME} -xml -o ${_test_NAME}.tml)
|
||||
else(KDE4_TEST_OUTPUT STREQUAL "xml")
|
||||
add_test(${_test_NAME} ${_test_NAME})
|
||||
endif(KDE4_TEST_OUTPUT STREQUAL "xml")
|
||||
|
||||
if(NOT MSVC_IDE) #not needed for the ide
|
||||
# if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests
|
||||
if(NOT WITH_TESTS)
|
||||
get_directory_property(_buildtestsAdded BUILDTESTS_ADDED)
|
||||
if(NOT _buildtestsAdded)
|
||||
add_custom_target(buildtests)
|
||||
set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE)
|
||||
endif()
|
||||
add_dependencies(buildtests ${_test_NAME})
|
||||
if(NOT MSVC_IDE) #not needed for the ide
|
||||
# if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests
|
||||
if(NOT WITH_TESTS)
|
||||
get_directory_property(_buildtestsAdded BUILDTESTS_ADDED)
|
||||
if(NOT _buildtestsAdded)
|
||||
add_custom_target(buildtests)
|
||||
set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE)
|
||||
endif()
|
||||
add_dependencies(buildtests ${_test_NAME})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro(add_unit_test)
|
||||
|
||||
set(TEST_LIBRARIES
|
||||
keepassx_core
|
||||
${keepasshttp_LIB}
|
||||
${autotype_LIB}
|
||||
Qt5::Core
|
||||
Qt5::Concurrent
|
||||
Qt5::Widgets
|
||||
Qt5::Test
|
||||
${GCRYPT_LIBRARIES}
|
||||
${GPGERROR_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
)
|
||||
keepassx_core
|
||||
${keepasshttp_LIB}
|
||||
${autotype_LIB}
|
||||
Qt5::Core
|
||||
Qt5::Concurrent
|
||||
Qt5::Widgets
|
||||
Qt5::Test
|
||||
${GCRYPT_LIBRARIES}
|
||||
${GPGERROR_LIBRARIES}
|
||||
${ZLIB_LIBRARIES})
|
||||
|
||||
set(testsupport_SOURCES TestGlobal.h modeltest.cpp FailDevice.cpp stub/TestClock.cpp stub/TestRandom.cpp)
|
||||
set(testsupport_SOURCES TestGlobal.h modeltest.cpp FailDevice.cpp mock/MockClock.cpp util/TemporaryFile.cpp stub/TestRandom.cpp)
|
||||
add_library(testsupport STATIC ${testsupport_SOURCES})
|
||||
target_link_libraries(testsupport Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Test)
|
||||
|
||||
if(YUBIKEY_FOUND)
|
||||
set(TEST_LIBRARIES ${TEST_LIBRARIES} ${YUBIKEY_LIBRARIES})
|
||||
set(TEST_LIBRARIES ${TEST_LIBRARIES} ${YUBIKEY_LIBRARIES})
|
||||
endif()
|
||||
|
||||
add_unit_test(NAME testgroup SOURCES TestGroup.cpp
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testkdbx2 SOURCES TestKdbx2.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testkdbx3 SOURCES TestKeePass2Format.cpp FailDevice.cpp TestKdbx3.cpp
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testkdbx4 SOURCES TestKeePass2Format.cpp FailDevice.cpp mock/MockChallengeResponseKey.cpp TestKdbx4.cpp
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testkeys SOURCES TestKeys.cpp mock/MockChallengeResponseKey.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
|
@ -132,7 +136,7 @@ add_unit_test(NAME testsymmetriccipher SOURCES TestSymmetricCipher.cpp
|
|||
|
||||
if(WITH_XC_KEESHARE)
|
||||
add_unit_test(NAME testsignature SOURCES TestSignature.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
endif()
|
||||
|
||||
add_unit_test(NAME testhashedblockstream SOURCES TestHashedBlockStream.cpp
|
||||
|
@ -142,7 +146,7 @@ add_unit_test(NAME testkeepass2randomstream SOURCES TestKeePass2RandomStream.cpp
|
|||
LIBS ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testmodified SOURCES TestModified.cpp
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testdeletedobjects SOURCES TestDeletedObjects.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
|
@ -154,21 +158,24 @@ add_unit_test(NAME testwildcardmatcher SOURCES TestWildcardMatcher.cpp
|
|||
LIBS ${TEST_LIBRARIES})
|
||||
|
||||
if(WITH_XC_AUTOTYPE)
|
||||
add_unit_test(NAME testautotype SOURCES TestAutoType.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
set_target_properties(testautotype PROPERTIES ENABLE_EXPORTS ON)
|
||||
add_unit_test(NAME testautotype SOURCES TestAutoType.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
set_target_properties(testautotype PROPERTIES ENABLE_EXPORTS ON)
|
||||
endif()
|
||||
|
||||
if(WITH_XC_CRYPTO_SSH)
|
||||
add_unit_test(NAME testopensshkey SOURCES TestOpenSSHKey.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
add_unit_test(NAME testopensshkey SOURCES TestOpenSSHKey.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
endif()
|
||||
|
||||
add_unit_test(NAME testentry SOURCES TestEntry.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testmerge SOURCES TestMerge.cpp
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testpasswordgenerator SOURCES TestPasswordGenerator.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testtotp SOURCES TestTotp.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
|
@ -203,6 +210,11 @@ add_unit_test(NAME testdatabase SOURCES TestDatabase.cpp
|
|||
add_unit_test(NAME testtools SOURCES TestTools.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
|
||||
|
||||
if(WITH_GUI_TESTS)
|
||||
add_subdirectory(gui)
|
||||
# CLI clip tests need X environment on Linux
|
||||
add_unit_test(NAME testcli SOURCES TestCli.cpp
|
||||
LIBS testsupport cli ${TEST_LIBRARIES})
|
||||
|
||||
add_subdirectory(gui)
|
||||
endif(WITH_GUI_TESTS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue