2013-04-22 17:49:28 +03:00
|
|
|
enable_testing()
|
2017-07-09 18:31:21 +02:00
|
|
|
|
|
|
|
set(googleTest_Dir ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
|
2017-08-15 20:17:00 +02:00
|
|
|
if(EXISTS ${googleTest_Dir})
|
2017-08-12 20:58:09 +02:00
|
|
|
set(GTestSrc ${googleTest_Dir}/googletest)
|
|
|
|
set(GMockSrc ${googleTest_Dir}/googlemock)
|
2017-08-15 20:17:00 +02:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "No googletest src dir found!")
|
|
|
|
endif()
|
2017-07-09 18:31:21 +02:00
|
|
|
include_directories(${GTestSrc} ${GTestSrc}/include ${GMockSrc} ${GMockSrc}/include)
|
2016-08-12 08:38:26 +02:00
|
|
|
include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/test)
|
2017-07-02 00:53:50 +02:00
|
|
|
include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
|
2013-04-22 17:49:28 +03:00
|
|
|
|
|
|
|
set(test_SRCS
|
2017-07-04 13:29:50 +02:00
|
|
|
StdInc.cpp
|
|
|
|
main.cpp
|
|
|
|
CMemoryBufferTest.cpp
|
|
|
|
CVcmiTestConfig.cpp
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2017-07-04 13:29:50 +02:00
|
|
|
battle/BattleHexTest.cpp
|
2017-07-20 06:08:49 +02:00
|
|
|
battle/CBattleInfoCallbackTest.cpp
|
2017-07-04 13:29:50 +02:00
|
|
|
battle/CHealthTest.cpp
|
2017-07-20 06:08:49 +02:00
|
|
|
battle/CUnitStateTest.cpp
|
|
|
|
battle/CUnitStateMagicTest.cpp
|
|
|
|
battle/battle_UnitTest.cpp
|
|
|
|
|
|
|
|
game/CGameStateTest.cpp
|
2017-07-04 13:29:50 +02:00
|
|
|
|
|
|
|
map/CMapEditManagerTest.cpp
|
|
|
|
map/CMapFormatTest.cpp
|
|
|
|
map/MapComparer.cpp
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
spells/TargetConditionTest.cpp
|
|
|
|
|
|
|
|
spells/effects/EffectFixture.cpp
|
|
|
|
spells/effects/CatapultTest.cpp
|
|
|
|
spells/effects/CloneTest.cpp
|
|
|
|
spells/effects/DamageTest.cpp
|
|
|
|
spells/effects/DispelTest.cpp
|
|
|
|
spells/effects/HealTest.cpp
|
|
|
|
spells/effects/SacrificeTest.cpp
|
|
|
|
spells/effects/SummonTest.cpp
|
|
|
|
spells/effects/TeleportTest.cpp
|
|
|
|
spells/effects/TimedTest.cpp
|
|
|
|
|
|
|
|
spells/targetConditions/AbsoluteSpellConditionTest.cpp
|
|
|
|
spells/targetConditions/AbsoluteLevelConditionTest.cpp
|
|
|
|
spells/targetConditions/BonusConditionTest.cpp
|
|
|
|
spells/targetConditions/CreatureConditionTest.cpp
|
|
|
|
spells/targetConditions/ElementalConditionTest.cpp
|
|
|
|
spells/targetConditions/HealthValueConditionTest.cpp
|
|
|
|
spells/targetConditions/ImmunityNegationConditionTest.cpp
|
|
|
|
spells/targetConditions/NormalLevelConditionTest.cpp
|
|
|
|
spells/targetConditions/NormalSpellConditionTest.cpp
|
|
|
|
spells/targetConditions/ReceptiveFeatureConditionTest.cpp
|
|
|
|
spells/targetConditions/SpellEffectConditionTest.cpp
|
|
|
|
spells/targetConditions/TargetConditionItemFixture.cpp
|
|
|
|
|
|
|
|
mock/mock_IGameCallback.cpp
|
|
|
|
mock/mock_MapService.cpp
|
|
|
|
mock/mock_BonusBearer.cpp
|
2017-06-29 01:03:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
set(test_HEADERS
|
2017-07-04 13:29:50 +02:00
|
|
|
StdInc.h
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2017-07-04 13:29:50 +02:00
|
|
|
CVcmiTestConfig.h
|
|
|
|
map/MapComparer.h
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
spells/effects/EffectFixture.h
|
|
|
|
|
|
|
|
spells/targetConditions/TargetConditionItemFixture.h
|
|
|
|
|
|
|
|
mock/mock_BonusBearer.h
|
|
|
|
mock/mock_IGameCallback.h
|
|
|
|
mock/mock_MapService.h
|
|
|
|
mock/mock_BonusBearer.h
|
2013-04-22 17:49:28 +03:00
|
|
|
)
|
|
|
|
|
2017-08-15 20:17:00 +02:00
|
|
|
assign_source_group(${test_SRCS} ${test_HEADERS})
|
|
|
|
|
2017-07-18 21:04:57 +02:00
|
|
|
set(mock_HEADERS
|
2017-07-20 06:08:49 +02:00
|
|
|
mock/mock_battle_IBattleState.h
|
|
|
|
mock/mock_battle_Unit.h
|
|
|
|
mock/mock_UnitInfo.h
|
|
|
|
mock/mock_UnitEnvironment.h
|
|
|
|
mock/mock_spells_Mechanics.h
|
|
|
|
mock/mock_spells_Problem.h
|
|
|
|
mock/mock_spells_Spell.h
|
|
|
|
mock/mock_vstd_RNG.h
|
2017-07-18 21:04:57 +02:00
|
|
|
)
|
2017-08-15 20:17:00 +02:00
|
|
|
|
2017-08-07 18:43:32 +02:00
|
|
|
add_subdirectory_with_folder("3rdparty" googletest EXCLUDE_FROM_ALL)
|
2017-07-09 18:31:21 +02:00
|
|
|
|
2017-07-18 21:04:57 +02:00
|
|
|
add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS} ${GTestSrc}/src/gtest-all.cc ${GMockSrc}/src/gmock-all.cc)
|
2017-07-09 18:31:21 +02:00
|
|
|
target_link_libraries(vcmitest vcmi ${RT_LIB} ${DL_LIB})
|
2013-04-22 17:49:28 +03:00
|
|
|
add_test(vcmitest vcmitest)
|
|
|
|
|
2017-07-04 22:46:49 +02:00
|
|
|
vcmi_set_output_dir(vcmitest "")
|
|
|
|
|
2014-02-05 23:25:36 +03:00
|
|
|
set_target_properties(vcmitest PROPERTIES ${PCH_PROPERTIES})
|
|
|
|
cotire(vcmitest)
|
2014-02-01 16:37:26 +03:00
|
|
|
|
2013-04-25 19:09:48 +03:00
|
|
|
# Files to copy to the build directory
|
2013-04-22 17:49:28 +03:00
|
|
|
set(vcmitest_FILES
|
2016-11-13 12:38:42 +02:00
|
|
|
testdata/TerrainViewTest.h3m
|
|
|
|
testdata/terrainViewMappings.json
|
|
|
|
testdata/ObjectPropertyTest/header.json
|
|
|
|
testdata/ObjectPropertyTest/objects.json
|
|
|
|
testdata/ObjectPropertyTest/surface_terrain.json
|
|
|
|
testdata/ObjectPropertyTest/underground_terrain.json
|
2013-04-22 17:49:28 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
foreach(file ${vcmitest_FILES})
|
2017-08-11 04:31:23 +02:00
|
|
|
add_custom_command(TARGET vcmitest POST_BUILD
|
2017-08-15 20:17:00 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${file}" ${CMAKE_CURRENT_BINARY_DIR}
|
2017-07-04 13:29:50 +02:00
|
|
|
)
|
2013-04-22 17:49:28 +03:00
|
|
|
endforeach()
|
2017-07-20 06:08:49 +02:00
|
|
|
|