diff options
Diffstat (limited to 'test')
38 files changed, 518 insertions, 915 deletions
diff --git a/test/cbot/CBot_console/CBotConsole.cpp b/test/cbot/CBot_console/CBotConsole.cpp index e9209d3..1b0b185 100644 --- a/test/cbot/CBot_console/CBotConsole.cpp +++ b/test/cbot/CBot_console/CBotConsole.cpp @@ -1,4 +1,22 @@ /* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ +/* * CBotConsole.cpp * * Created on: 08-08-2012 diff --git a/test/cbot/CBot_console/CBotConsole.h b/test/cbot/CBot_console/CBotConsole.h index ac87911..83556f5 100644 --- a/test/cbot/CBot_console/CBotConsole.h +++ b/test/cbot/CBot_console/CBotConsole.h @@ -1,4 +1,22 @@ /* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ +/* * CBotConsole.h * * Created on: 08-08-2012 diff --git a/test/cbot/CBot_console/CBotDoc.cpp b/test/cbot/CBot_console/CBotDoc.cpp index 1c694c9..5871fb5 100644 --- a/test/cbot/CBot_console/CBotDoc.cpp +++ b/test/cbot/CBot_console/CBotDoc.cpp @@ -1,4 +1,22 @@ /* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ +/* * CBotDoc.cpp * * Created on: 08-08-2012 diff --git a/test/cbot/CBot_console/CBotDoc.h b/test/cbot/CBot_console/CBotDoc.h index 82af7b0..5f58ed5 100644 --- a/test/cbot/CBot_console/CBotDoc.h +++ b/test/cbot/CBot_console/CBotDoc.h @@ -1,4 +1,22 @@ /* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ +/* * CBotDoc.h * * Created on: 08-08-2012 diff --git a/test/cbot/CBot_console/CClass.cpp b/test/cbot/CBot_console/CClass.cpp index 9b7c842..ec6cd8f 100644 --- a/test/cbot/CBot_console/CClass.cpp +++ b/test/cbot/CBot_console/CClass.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "CClass.h" #include "routines.cpp" diff --git a/test/cbot/CBot_console/CClass.h b/test/cbot/CBot_console/CClass.h index da2c46c..187d090 100644 --- a/test/cbot/CBot_console/CClass.h +++ b/test/cbot/CBot_console/CClass.h @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #pragma once #include <CBot/CBot.h> diff --git a/test/cbot/CBot_console/main.cpp b/test/cbot/CBot_console/main.cpp index a2d3668..98c8c18 100644 --- a/test/cbot/CBot_console/main.cpp +++ b/test/cbot/CBot_console/main.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "CClass.h" #include "CBotDoc.h" #include <iostream> diff --git a/test/cbot/CBot_console/routines.cpp b/test/cbot/CBot_console/routines.cpp index 8b8a1d4..a967305 100644 --- a/test/cbot/CBot_console/routines.cpp +++ b/test/cbot/CBot_console/routines.cpp @@ -1,18 +1,21 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see http://www.gnu.org/licenses/. +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ //////////////////////////////////////////////////////////////////// // routine show() diff --git a/test/envs/CMakeLists.txt b/test/envs/CMakeLists.txt index 374c39f..3d535f3 100644 --- a/test/envs/CMakeLists.txt +++ b/test/envs/CMakeLists.txt @@ -1,2 +1,3 @@ # OpenGL tests -add_subdirectory(opengl) +# TODO: fix dependency on resource manager and re-enable +#add_subdirectory(opengl) diff --git a/test/envs/opengl/light_test.cpp b/test/envs/opengl/light_test.cpp index 5c5af7c..7f1c652 100644 --- a/test/envs/opengl/light_test.cpp +++ b/test/envs/opengl/light_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "app/system.h" #include "common/config.h" diff --git a/test/envs/opengl/model_test.cpp b/test/envs/opengl/model_test.cpp index fa4042c..006b16e 100644 --- a/test/envs/opengl/model_test.cpp +++ b/test/envs/opengl/model_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "app/system.h" #include "common/config.h" diff --git a/test/envs/opengl/texture_test.cpp b/test/envs/opengl/texture_test.cpp index 5c27b43..0a0575b 100644 --- a/test/envs/opengl/texture_test.cpp +++ b/test/envs/opengl/texture_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "common/config.h" #include "common/logger.h" #include "common/image.h" diff --git a/test/envs/opengl/transform_test.cpp b/test/envs/opengl/transform_test.cpp index 99ec9f0..9536740 100644 --- a/test/envs/opengl/transform_test.cpp +++ b/test/envs/opengl/transform_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "app/system.h" #include "common/config.h" diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index bdb5a67..cd745c3 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -1,170 +1,3 @@ -set(SRC_DIR ${colobot_SOURCE_DIR}/src) - -# Additional libraries per platform -if(MXE) # MXE requires special treatment - set(PLATFORM_LIBS ${MXE_LIBS}) -elseif(PLATFORM_WINDOWS) - # because it isn't included in standard linking libraries - set(PLATFORM_LIBS "-lintl") -elseif(PLATFORM_GNU) - set(PLATFORM_LIBS "-lX11") -elseif(PLATFORM_LINUX) - # for clock_gettime - set(PLATFORM_LIBS "-lrt -lX11") -elseif(PLATFORM_MACOSX) - find_library(LIBINTL_LIBRARY NAMES intl libintl ) - set(PLATFORM_LIBS ${LIBINTL_LIBRARY} ${X11_X11_LIB}) -endif() - - -# Configure file -configure_file(${SRC_DIR}/common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h) - -# Code sources -set(COLOBOT_SOURCES -${SRC_DIR}/app/app.cpp -${SRC_DIR}/app/gamedata.cpp -${SRC_DIR}/app/pausemanager.cpp -${SRC_DIR}/app/system.cpp -${SRC_DIR}/app/${SYSTEM_CPP_MODULE} -${SRC_DIR}/app/system_other.cpp -${SRC_DIR}/common/event.cpp -${SRC_DIR}/common/image.cpp -${SRC_DIR}/common/iman.cpp -${SRC_DIR}/common/logger.cpp -${SRC_DIR}/common/misc.cpp -${SRC_DIR}/common/profile.cpp -${SRC_DIR}/common/restext.cpp -${SRC_DIR}/common/stringutils.cpp -${SRC_DIR}/graphics/core/color.cpp -${SRC_DIR}/graphics/engine/camera.cpp -${SRC_DIR}/graphics/engine/cloud.cpp -${SRC_DIR}/graphics/engine/engine.cpp -${SRC_DIR}/graphics/engine/lightman.cpp -${SRC_DIR}/graphics/engine/lightning.cpp -${SRC_DIR}/graphics/engine/modelfile.cpp -${SRC_DIR}/graphics/engine/modelmanager.cpp -${SRC_DIR}/graphics/engine/particle.cpp -${SRC_DIR}/graphics/engine/planet.cpp -${SRC_DIR}/graphics/engine/pyro.cpp -${SRC_DIR}/graphics/engine/terrain.cpp -${SRC_DIR}/graphics/engine/text.cpp -${SRC_DIR}/graphics/engine/water.cpp -${SRC_DIR}/graphics/opengl/gldevice.cpp -${SRC_DIR}/object/auto/auto.cpp -${SRC_DIR}/object/auto/autobase.cpp -${SRC_DIR}/object/auto/autoconvert.cpp -${SRC_DIR}/object/auto/autoderrick.cpp -${SRC_DIR}/object/auto/autodestroyer.cpp -${SRC_DIR}/object/auto/autoegg.cpp -${SRC_DIR}/object/auto/autoenergy.cpp -${SRC_DIR}/object/auto/autofactory.cpp -${SRC_DIR}/object/auto/autoflag.cpp -${SRC_DIR}/object/auto/autohuston.cpp -${SRC_DIR}/object/auto/autoinfo.cpp -${SRC_DIR}/object/auto/autojostle.cpp -${SRC_DIR}/object/auto/autokid.cpp -${SRC_DIR}/object/auto/autolabo.cpp -${SRC_DIR}/object/auto/automush.cpp -${SRC_DIR}/object/auto/autonest.cpp -${SRC_DIR}/object/auto/autonuclear.cpp -${SRC_DIR}/object/auto/autopara.cpp -${SRC_DIR}/object/auto/autoportico.cpp -${SRC_DIR}/object/auto/autoradar.cpp -${SRC_DIR}/object/auto/autorepair.cpp -${SRC_DIR}/object/auto/autoresearch.cpp -${SRC_DIR}/object/auto/autoroot.cpp -${SRC_DIR}/object/auto/autosafe.cpp -${SRC_DIR}/object/auto/autostation.cpp -${SRC_DIR}/object/auto/autotower.cpp -${SRC_DIR}/object/brain.cpp -${SRC_DIR}/object/mainmovie.cpp -${SRC_DIR}/object/motion/motion.cpp -${SRC_DIR}/object/motion/motionant.cpp -${SRC_DIR}/object/motion/motionbee.cpp -${SRC_DIR}/object/motion/motionhuman.cpp -${SRC_DIR}/object/motion/motionmother.cpp -${SRC_DIR}/object/motion/motionspider.cpp -${SRC_DIR}/object/motion/motiontoto.cpp -${SRC_DIR}/object/motion/motionvehicle.cpp -${SRC_DIR}/object/motion/motionworm.cpp -${SRC_DIR}/object/motion/motiondummy.cpp -${SRC_DIR}/object/object.cpp -${SRC_DIR}/object/objman.cpp -${SRC_DIR}/object/robotmain.cpp -${SRC_DIR}/object/task/task.cpp -${SRC_DIR}/object/task/taskadvance.cpp -${SRC_DIR}/object/task/taskbuild.cpp -${SRC_DIR}/object/task/taskfire.cpp -${SRC_DIR}/object/task/taskfireant.cpp -${SRC_DIR}/object/task/taskflag.cpp -${SRC_DIR}/object/task/taskgoto.cpp -${SRC_DIR}/object/task/taskgungoal.cpp -${SRC_DIR}/object/task/taskinfo.cpp -${SRC_DIR}/object/task/taskmanager.cpp -${SRC_DIR}/object/task/taskmanip.cpp -${SRC_DIR}/object/task/taskpen.cpp -${SRC_DIR}/object/task/taskrecover.cpp -${SRC_DIR}/object/task/taskreset.cpp -${SRC_DIR}/object/task/tasksearch.cpp -${SRC_DIR}/object/task/taskshield.cpp -${SRC_DIR}/object/task/taskspiderexplo.cpp -${SRC_DIR}/object/task/tasktake.cpp -${SRC_DIR}/object/task/taskterraform.cpp -${SRC_DIR}/object/task/taskturn.cpp -${SRC_DIR}/object/task/taskwait.cpp -${SRC_DIR}/physics/physics.cpp -${SRC_DIR}/script/cbottoken.cpp -${SRC_DIR}/script/cmdtoken.cpp -${SRC_DIR}/script/script.cpp -${SRC_DIR}/sound/sound.cpp -${SRC_DIR}/ui/button.cpp -${SRC_DIR}/ui/check.cpp -${SRC_DIR}/ui/color.cpp -${SRC_DIR}/ui/compass.cpp -${SRC_DIR}/ui/control.cpp -${SRC_DIR}/ui/displayinfo.cpp -${SRC_DIR}/ui/displaytext.cpp -${SRC_DIR}/ui/edit.cpp -${SRC_DIR}/ui/editvalue.cpp -${SRC_DIR}/ui/gauge.cpp -${SRC_DIR}/ui/group.cpp -${SRC_DIR}/ui/image.cpp -${SRC_DIR}/ui/interface.cpp -${SRC_DIR}/ui/key.cpp -${SRC_DIR}/ui/label.cpp -${SRC_DIR}/ui/list.cpp -${SRC_DIR}/ui/maindialog.cpp -${SRC_DIR}/ui/mainmap.cpp -${SRC_DIR}/ui/mainshort.cpp -${SRC_DIR}/ui/map.cpp -${SRC_DIR}/ui/scroll.cpp -${SRC_DIR}/ui/shortcut.cpp -${SRC_DIR}/ui/slider.cpp -${SRC_DIR}/ui/studio.cpp -${SRC_DIR}/ui/target.cpp -${SRC_DIR}/ui/window.cpp -) - -set(OPENAL_SOURCES "") - -if(OPENAL_SOUND) - set(OPENAL_SOURCES - ${SRC_DIR}/sound/oalsound/alsound.cpp - ${SRC_DIR}/sound/oalsound/buffer.cpp - ${SRC_DIR}/sound/oalsound/channel.cpp - ) -endif() - -# Optional libraries -set(OPTIONAL_LIBS "") - -if(OPENAL_SOUND) - set(OPTIONAL_LIBS ${OPENAL_LIBRARY}) - set(OPTIONAL_INCLUDES ${OPENAL_INCLUDE_DIR}) -endif() - - # Platform-dependent tests if(PLATFORM_WINDOWS) set(PLATFORM_TESTS app/system_windows_test.cpp) @@ -172,67 +5,58 @@ elseif(PLATFORM_LINUX) set(PLATFORM_TESTS app/system_linux_test.cpp) endif() -# Tests +# Sources set(UT_SOURCES -main.cpp -app/app_test.cpp -graphics/engine/lightman_test.cpp -math/func_test.cpp -math/geometry_test.cpp -math/matrix_test.cpp -math/vector_test.cpp -${PLATFORM_TESTS} + main.cpp + app/app_test.cpp + common/profile_test.cpp + graphics/engine/lightman_test.cpp + math/func_test.cpp + math/geometry_test.cpp + math/matrix_test.cpp + math/vector_test.cpp + ${PLATFORM_TESTS} ) -# Local +# Includes include_directories( -. -common -math -${SRC_DIR} -${CMAKE_CURRENT_BINARY_DIR} + common + math + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${COLOBOT_LOCAL_INCLUDES} ) -# System include_directories( -SYSTEM -${GTEST_INCLUDE_DIR} -${GMOCK_INCLUDE_DIR} -${SDL_INCLUDE_DIR} -${SDLIMAGE_INCLUDE_DIR} -${SDLTTF_INCLUDE_DIR} -${PNG_INCLUDE_DIRS} -${GLEW_INCLUDE_PATH} -${Boost_INCLUDE_DIRS} -${OPTIONAL_INCLUDE_DIRS} -${LIBSNDFILE_INCLUDE_DIR} -${CLIPBOARD_INCLUDE_DIR} -${LOCALENAME_INCLUDE_DIR} + SYSTEM + ${GTEST_INCLUDE_DIR} + ${GMOCK_INCLUDE_DIR} + ${COLOBOT_SYSTEM_INCLUDES} ) +# Libraries set(LIBS -gtest -gmock -CBot -clipboard -localename -${SDL_LIBRARY} -${SDLIMAGE_LIBRARY} -${SDLTTF_LIBRARY} -${OPENGL_LIBRARY} -${PNG_LIBRARIES} -${GLEW_LIBRARY} -${Boost_LIBRARIES} -${OPTIONAL_LIBS} -${PLATFORM_LIBS} -${LIBSNDFILE_LIBRARY} + gtest + gmock + colobotbase + ${COLOBOT_LIBS} ) -add_executable(colobot_ut ${COLOBOT_SOURCES} ${UT_SOURCES} ${OPENAL_SOURCES}) -target_link_libraries(colobot_ut ${LIBS}) +# Test files -add_test(colobot_ut ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/colobot_ut) +set(TEST_FILES + common/colobot.ini +) -# TODO: change the unit cases to independent automated tests to be included in colobot_ut -add_subdirectory(common) -add_subdirectory(ui) +file(COPY ${TEST_FILES} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +# Targets + +add_executable(colobot_ut ${UT_SOURCES}) +target_link_libraries(colobot_ut ${LIBS}) + +add_test( + NAME colobot_ut + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/colobot_ut + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} +) diff --git a/test/unit/app/app_test.cpp b/test/unit/app/app_test.cpp index b517d7d..fff08a5 100644 --- a/test/unit/app/app_test.cpp +++ b/test/unit/app/app_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "app/app.h" #if defined(PLATFORM_WINDOWS) diff --git a/test/unit/app/system_linux_test.cpp b/test/unit/app/system_linux_test.cpp index b0a05ca..7b734c6 100644 --- a/test/unit/app/system_linux_test.cpp +++ b/test/unit/app/system_linux_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "app/system.h" #include "app/system_linux.h" diff --git a/test/unit/app/system_mock.h b/test/unit/app/system_mock.h index 470a4e1..2f2c464 100644 --- a/test/unit/app/system_mock.h +++ b/test/unit/app/system_mock.h @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #pragma once #include "app/system.h" diff --git a/test/unit/app/system_windows_test.cpp b/test/unit/app/system_windows_test.cpp index 79f8c7f..cfba1ae 100644 --- a/test/unit/app/system_windows_test.cpp +++ b/test/unit/app/system_windows_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "app/system.h" #include "app/system_windows.h" diff --git a/test/unit/common/CMakeLists.txt b/test/unit/common/CMakeLists.txt deleted file mode 100644 index cf37961..0000000 --- a/test/unit/common/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set(SRC_DIR ${colobot_SOURCE_DIR}/src) - -include_directories( -${SRC_DIR} -${GTEST_INCLUDE_DIR} -) - -add_executable(image_test ${SRC_DIR}/common/image.cpp image_test.cpp) -target_link_libraries(image_test ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${PNG_LIBRARIES}) -add_test(NAME image_test - COMMAND ${CMAKE_BINARY_DIR}/image_test ${CMAKE_SOURCE_DIR}/test/envs/opengl/tex1.png ${CMAKE_BINARY_DIR}/tex1_test.png) - -file(COPY colobot.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -add_executable(profile_test ${SRC_DIR}/common/profile.cpp ${SRC_DIR}/common/logger.cpp profile_test.cpp) -set_target_properties(profile_test PROPERTIES COMPILE_DEFINITIONS "DEV_BUILD=1") -target_link_libraries(profile_test gtest ${Boost_LIBRARIES}) - -add_test(NAME profile_test - COMMAND ${CMAKE_BINARY_DIR}/profile_test - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/test/unit/common/image_test.cpp b/test/unit/common/image_test.cpp deleted file mode 100644 index 2b20a17..0000000 --- a/test/unit/common/image_test.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "common/image.h" - -#include <SDL.h> -#include <stdio.h> - -/* For now, just a simple test: loading a file from image - * and saving it to another in PNG. */ - -int main(int argc, char *argv[]) -{ - if (argc != 3) - { - printf("Usage: %s in_image out_image\n", argv[0]); - return 0; - } - - CImage image; - - if (! image.Load(argv[1])) - { - std::string err = image.GetError(); - printf("Error loading '%s': %s\n", argv[1], err.c_str()); - return 1; - } - Gfx::Color color; - std::string str; - - color = image.GetPixel(Math::IntPoint(0, 0)); - str = color.ToString(); - printf("pixel @ (0,0): %s\n", str.c_str()); - - color = image.GetPixel(Math::IntPoint(0, 1)); - str = color.ToString(); - printf("pixel @ (0,1): %s\n", str.c_str()); - - color = image.GetPixel(Math::IntPoint(1, 0)); - str = color.ToString(); - printf("pixel @ (1,0): %s\n", str.c_str()); - - color = image.GetPixel(Math::IntPoint(1, 1)); - str = color.ToString(); - printf("pixel @ (1,1): %s\n", str.c_str()); - - image.SetPixel(Math::IntPoint(0, 0), Gfx::Color(0.1f, 0.2f, 0.3f, 0.0f)); - image.SetPixel(Math::IntPoint(1, 0), Gfx::Color(0.3f, 0.2f, 0.1f, 1.0f)); - image.SetPixel(Math::IntPoint(0, 1), Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)); - image.SetPixel(Math::IntPoint(1, 1), Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f)); - - if (! image.SavePNG(argv[2])) - { - std::string err = image.GetError(); - printf("Error saving PNG '%s': %s\n", argv[2], err.c_str()); - return 2; - } - - return 0; -} diff --git a/test/unit/common/profile_test.cpp b/test/unit/common/profile_test.cpp index dabcba6..d85017b 100644 --- a/test/unit/common/profile_test.cpp +++ b/test/unit/common/profile_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "common/profile.h" #include "common/logger.h" #include "app/system.h" @@ -11,34 +29,28 @@ class CProfileTest : public testing::Test { protected: - CLogger m_logger; CProfile m_profile; - }; TEST_F(CProfileTest, ReadTest) { - ASSERT_TRUE(m_profile.InitCurrentDirectory()); // load colobot.ini file + m_profile.SetUseCurrentDirectory(true); + + ASSERT_TRUE(m_profile.Init()); // load colobot.ini file std::string result; - ASSERT_TRUE(m_profile.GetLocalProfileString("test_string", "string_value", result)); + ASSERT_TRUE(m_profile.GetStringProperty("test_string", "string_value", result)); ASSERT_STREQ("Hello world", result.c_str()); int int_value; - ASSERT_TRUE(m_profile.GetLocalProfileInt("test_int", "int_value", int_value)); + ASSERT_TRUE(m_profile.GetIntProperty("test_int", "int_value", int_value)); ASSERT_EQ(42, int_value); float float_value; - ASSERT_TRUE(m_profile.GetLocalProfileFloat("test_float", "float_value", float_value)); + ASSERT_TRUE(m_profile.GetFloatProperty("test_float", "float_value", float_value)); ASSERT_FLOAT_EQ(1.5, float_value); std::vector<std::string> list; - list = m_profile.GetLocalProfileSection("test_multi", "entry"); + list = m_profile.GetSection("test_multi", "entry"); ASSERT_EQ(5u, list.size()); } - -int main(int argc, char *argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/unit/graphics/core/device_mock.h b/test/unit/graphics/core/device_mock.h index 498239f..5ab0b7d 100644 --- a/test/unit/graphics/core/device_mock.h +++ b/test/unit/graphics/core/device_mock.h @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #pragma once #include "graphics/core/device.h" @@ -21,11 +39,8 @@ public: MOCK_METHOD0(Clear, void()); MOCK_METHOD2(SetTransform, void(Gfx::TransformType type, const Math::Matrix &matrix)); - MOCK_METHOD1(GetTransform, const Math::Matrix& (Gfx::TransformType type)); - MOCK_METHOD2(MultiplyTransform, void(Gfx::TransformType type, const Math::Matrix &matrix)); MOCK_METHOD1(SetMaterial, void(const Gfx::Material &material)); - MOCK_METHOD0(GetMaterial, const Gfx::Material&()); MOCK_METHOD0(GetMaxLightCount, int()); @@ -33,7 +48,6 @@ public: MOCK_METHOD1(GetLight, const Gfx::Light&(int index)); MOCK_METHOD2(SetLightEnabled, void(int index, bool enabled)); - MOCK_METHOD1(GetLightEnabled, bool(int index)); MOCK_METHOD2(CreateTexture, Gfx::Texture(CImage *image, const Gfx::TextureCreateParams ¶ms)); MOCK_METHOD2(CreateTexture, Gfx::Texture(ImageData *data, const Gfx::TextureCreateParams ¶ms)); @@ -45,13 +59,10 @@ public: MOCK_METHOD2(SetTexture, void(int index, const Gfx::Texture &texture)); MOCK_METHOD2(SetTexture, void(int index, unsigned int textureId)); - MOCK_METHOD1(GetTexture, Gfx::Texture(int index)); MOCK_METHOD2(SetTextureEnabled, void(int index, bool enabled)); - MOCK_METHOD1(GetTextureEnabled, bool(int index)); MOCK_METHOD2(SetTextureStageParams, void(int index, const Gfx::TextureStageParams ¶ms)); - MOCK_METHOD1(GetTextureStageParams, Gfx::TextureStageParams(int index)); MOCK_METHOD3(SetTextureStageWrap, void(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT)); @@ -77,34 +88,24 @@ public: MOCK_METHOD1(GetRenderState, bool(Gfx::RenderState state)); MOCK_METHOD1(SetDepthTestFunc, void(Gfx::CompFunc func)); - MOCK_METHOD0(GetDepthTestFunc, Gfx::CompFunc()); MOCK_METHOD1(SetDepthBias, void(float factor)); - MOCK_METHOD0(GetDepthBias, float()); MOCK_METHOD2(SetAlphaTestFunc, void(Gfx::CompFunc func, float refValue)); - MOCK_METHOD2(GetAlphaTestFunc, void(Gfx::CompFunc &func, float &refValue)); MOCK_METHOD2(SetBlendFunc, void(Gfx::BlendFunc srcBlend, Gfx::BlendFunc dstBlend)); - MOCK_METHOD2(GetBlendFunc, void(Gfx::BlendFunc &srcBlend, Gfx::BlendFunc &dstBlend)); MOCK_METHOD1(SetClearColor, void(const Gfx::Color &color)); - MOCK_METHOD0(GetClearColor, Gfx::Color()); MOCK_METHOD1(SetGlobalAmbient, void(const Gfx::Color &color)); - MOCK_METHOD0(GetGlobalAmbient, Gfx::Color()); MOCK_METHOD5(SetFogParams, void(Gfx::FogMode mode, const Gfx::Color &color, float start, float end, float density)); - MOCK_METHOD5(GetFogParams, void(Gfx::FogMode &mode, Gfx::Color &color, float &start, float &end, float &density)); MOCK_METHOD1(SetCullMode, void(Gfx::CullMode mode)); - MOCK_METHOD0(GetCullMode, Gfx::CullMode()); MOCK_METHOD1(SetShadeModel, void(Gfx::ShadeModel model)); - MOCK_METHOD0(GetShadeModel, Gfx::ShadeModel()); MOCK_METHOD1(SetFillMode, void(Gfx::FillMode mode)); - MOCK_METHOD0(GetFillMode, Gfx::FillMode()); MOCK_CONST_METHOD0(GetFrameBufferPixels, void*()); }; diff --git a/test/unit/graphics/engine/engine_mock.h b/test/unit/graphics/engine/engine_mock.h index 1a15eca..72ceddb 100644 --- a/test/unit/graphics/engine/engine_mock.h +++ b/test/unit/graphics/engine/engine_mock.h @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "graphics/engine/engine.h" #include <gmock/gmock.h> diff --git a/test/unit/graphics/engine/lightman_test.cpp b/test/unit/graphics/engine/lightman_test.cpp index e2dc785..d493afb 100644 --- a/test/unit/graphics/engine/lightman_test.cpp +++ b/test/unit/graphics/engine/lightman_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "graphics/engine/lightman.h" #include "app/system_mock.h" diff --git a/test/unit/graphics/engine/modelfile_test.cpp b/test/unit/graphics/engine/modelfile_test.cpp index 0598e84..ba95d04 100644 --- a/test/unit/graphics/engine/modelfile_test.cpp +++ b/test/unit/graphics/engine/modelfile_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "graphics/engine/modelfile.h" #include "math/func.h" diff --git a/test/unit/main.cpp b/test/unit/main.cpp index 7d08f58..f136ebc 100644 --- a/test/unit/main.cpp +++ b/test/unit/main.cpp @@ -1,18 +1,21 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2012, Polish Portal of Colobot (PPC) -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see http://www.gnu.org/licenses/. +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #include "common/logger.h" diff --git a/test/unit/math/func_test.cpp b/test/unit/math/func_test.cpp index 57f1347..aa06f9e 100644 --- a/test/unit/math/func_test.cpp +++ b/test/unit/math/func_test.cpp @@ -1,4 +1,22 @@ /* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ +/* Unit tests for math functions. */ diff --git a/test/unit/math/geometry_test.cpp b/test/unit/math/geometry_test.cpp index 581ef89..49caaa4 100644 --- a/test/unit/math/geometry_test.cpp +++ b/test/unit/math/geometry_test.cpp @@ -1,3 +1,21 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ /* Unit tests for functions in geometry.h */ #include "math/func.h" diff --git a/test/unit/math/matrix_test.cpp b/test/unit/math/matrix_test.cpp index 7693a85..3b67d69 100644 --- a/test/unit/math/matrix_test.cpp +++ b/test/unit/math/matrix_test.cpp @@ -1,4 +1,22 @@ /* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ +/* Unit tests for Matrix struct Test data was randomly generated and the expected results diff --git a/test/unit/math/vector_test.cpp b/test/unit/math/vector_test.cpp index 6fe30be..f8a8b10 100644 --- a/test/unit/math/vector_test.cpp +++ b/test/unit/math/vector_test.cpp @@ -1,4 +1,22 @@ /* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ +/* Unit tests for Vector struct Test data was randomly generated and the expected results diff --git a/test/unit/ui/CMakeLists.txt b/test/unit/ui/CMakeLists.txt deleted file mode 100644 index 7f7b2f8..0000000 --- a/test/unit/ui/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -set(SRC_DIR ${colobot_SOURCE_DIR}/src) - -include_directories( -. -${SRC_DIR} -${GTEST_INCLUDE_DIR} -${GMOCK_INCLUDE_DIR} -${CLIPBOARD_INCLUDE_DIR} -) - -# Platform-dependent implementation of CSystemUtils -if(PLATFORM_WINDOWS) -elseif(PLATFORM_MACOSX) - set(ADDITIONAL_LIB "${X11_X11_LIB}") -else() - set(ADDITIONAL_LIB "-lX11") -endif() - -add_executable(edit_test -${SRC_DIR}/app/gamedata.cpp -${SRC_DIR}/app/system.cpp -${SRC_DIR}/app/${SYSTEM_CPP_MODULE} -${SRC_DIR}/app/system_other.cpp -${SRC_DIR}/common/event.cpp -${SRC_DIR}/common/logger.cpp -${SRC_DIR}/common/misc.cpp -${SRC_DIR}/common/profile.cpp -${SRC_DIR}/common/iman.cpp -${SRC_DIR}/common/stringutils.cpp -${SRC_DIR}/graphics/engine/text.cpp -${SRC_DIR}/ui/button.cpp -${SRC_DIR}/ui/control.cpp -${SRC_DIR}/ui/edit.cpp -${SRC_DIR}/ui/scroll.cpp -stubs/app_stub.cpp -stubs/engine_stub.cpp -stubs/particle_stub.cpp -stubs/restext_stub.cpp -stubs/robotmain_stub.cpp -edit_test.cpp) - -target_link_libraries(edit_test gtest gmock clipboard ${SDL_LIBRARY} ${SDLTTF_LIBRARY} ${Boost_LIBRARIES} ${ADDITIONAL_LIB}) - - - -add_test(edit_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/edit_test) diff --git a/test/unit/ui/edit_test.cpp b/test/unit/ui/edit_test.cpp deleted file mode 100644 index 34af013..0000000 --- a/test/unit/ui/edit_test.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "app/app.h" -#include "app/gamedata.h" - -#include "ui/edit.h" - -#include "mocks/text_mock.h" - -#include <fstream> - -#include <gtest/gtest.h> -#include <gmock/gmock.h> - -class CEditTest : public testing::Test -{ -public: - CEditTest() - : m_robotMain(nullptr) - , m_gameData(nullptr) - , m_engine(nullptr) - , m_edit(nullptr) - {} - - virtual void SetUp() - { - m_robotMain = new CRobotMain(&m_app, false); - - m_gameData = new CGameData(); - - m_engine = new Gfx::CEngine(nullptr); - - m_edit = new Ui::CEdit; - } - - virtual void TearDown() - { - delete m_edit; - m_edit = nullptr; - delete m_engine; - m_engine = nullptr; - delete m_gameData; - m_gameData = nullptr; - delete m_robotMain; - m_robotMain = nullptr; - } - virtual ~CEditTest() - { - - }; - -protected: - CApplication m_app; - CRobotMain* m_robotMain; - CGameData * m_gameData; - Gfx::CEngine * m_engine; - Ui::CEdit * m_edit; - CLogger m_logger; -}; - -using ::testing::_; -using ::testing::An; -using ::testing::Return; - -TEST_F(CEditTest, WriteTest) -{ - ASSERT_TRUE(true); - CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText()); - EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f)); - EXPECT_CALL(*text, GetStringWidth(An<const std::string&>(), _, _, _)).WillOnce(Return(1.0f)); - std::string filename = "test.file"; - m_edit->SetMaxChar(Ui::EDITSTUDIOMAX); - m_edit->SetAutoIndent(true); - std::string inputScript = "{\ntext1\ntext2\n\ntext3\n{\ntext4\n}\n}"; - std::string expectedScript = "{\r\n\ttext1\r\n\ttext2\r\n\t\r\n\ttext3\r\n\t{\r\n\t\ttext4\r\n\t}\r\n}"; - m_edit->SetText(inputScript.c_str(), true); - GetLogger()->Info("Writing text \n"); - m_edit->WriteText("script.txt"); - - std::fstream scriptFile; - - scriptFile.open("script.txt", std::ios_base::binary | std::ios_base::in); - std::string outputScript((std::istreambuf_iterator<char>(scriptFile)), std::istreambuf_iterator<char>()); - ASSERT_STREQ(expectedScript.c_str(), outputScript.c_str()); -} - -int main(int argc, char *argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - diff --git a/test/unit/ui/mocks/text_mock.h b/test/unit/ui/mocks/text_mock.h deleted file mode 100644 index b9af6d3..0000000 --- a/test/unit/ui/mocks/text_mock.h +++ /dev/null @@ -1,35 +0,0 @@ -#include "common/logger.h" - -#include "graphics/engine/text.h" - -#include <gmock/gmock.h> - -class CTextMock : public Gfx::CText -{ -public: - CTextMock(Gfx::CEngine* engine) : CText(engine) - { - } - - virtual ~CTextMock() - { - }; - - MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char ch, - Gfx::FontType type, - float size, - float offset)); - MOCK_METHOD4(GetStringWidth, float(const std::string &text, - std::vector<Gfx::FontMetaChar>::iterator format, - std::vector<Gfx::FontMetaChar>::iterator end, - float size)); - MOCK_METHOD3(GetStringWidth, float(std::string text, - Gfx::FontType font, - float size)); - MOCK_METHOD4(GetStringWidth, float(Gfx::UTF8Char ch, - Gfx::FontType font, - float size, - float offset)); - -}; - diff --git a/test/unit/ui/stubs/app_stub.cpp b/test/unit/ui/stubs/app_stub.cpp deleted file mode 100644 index 95430d8..0000000 --- a/test/unit/ui/stubs/app_stub.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "app/app.h" - -#include "graphics/opengl/gldevice.h" - -template<> CApplication* CSingleton<CApplication>::m_instance = nullptr; - -namespace Gfx { - -GLDeviceConfig::GLDeviceConfig() -{ -} - -} /* Gfx */ - - -CApplication::CApplication() -{ -} - -CApplication::~CApplication() -{ -} - -CSoundInterface* CApplication::GetSound() -{ - return nullptr; -} - -CEventQueue* CApplication::GetEventQueue() -{ - return nullptr; -} - -Event CApplication::CreateUpdateEvent() -{ - return Event(EVENT_NULL); -} - -char CApplication::GetLanguageChar() const -{ - return 'E'; -} diff --git a/test/unit/ui/stubs/engine_stub.cpp b/test/unit/ui/stubs/engine_stub.cpp deleted file mode 100644 index 0a2777c..0000000 --- a/test/unit/ui/stubs/engine_stub.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "graphics/engine/engine.h" -#include "graphics/engine/text.h" - -#include "mocks/text_mock.h" - -template<> Gfx::CEngine* CSingleton<Gfx::CEngine>::m_instance = nullptr; - -namespace Gfx { - -CEngine::CEngine(CApplication* app) : - m_app(app) -{ - m_text = new CTextMock(this); - m_text->Create(); -} - -CEngine::~CEngine() -{ - delete m_text; - m_text = nullptr; -} - -CParticle* CEngine::GetParticle() -{ - return nullptr; -} - -Math::Point CEngine::WindowToInterfaceSize(Math::IntPoint size) -{ - return Math::Point(size.x, size.y); -} - -void CEngine::SetState(int state, const Color& color) -{ - if (state == m_lastState && color == m_lastColor) - return; - - m_lastState = state; - m_lastColor = color; -} - -Math::IntPoint CEngine::GetWindowSize() -{ - return m_size; -} - -void CEngine::AddStatisticTriangle(int count) -{ - m_statisticTriangle += count; -} - -void CEngine::SetMouseType(EngineMouseType type) -{ - m_mouseType = type; -} - -bool CEngine::SetTexture(const std::string& /* name */, int /* stage */) -{ - return true; -} - -CText* CEngine::GetText() -{ - return m_text; -} - -CDevice* CEngine::GetDevice() -{ - return m_device; -} - -int CEngine::GetEditIndentValue() -{ - return m_editIndentValue; -} - -void CEngine::DeleteTexture(const std::string& /* texName */) -{ -} - -Texture CEngine::LoadTexture(const std::string& /* name */) -{ - Texture texture; - return texture; -} - -Math::Vector CEngine::GetEyePt() -{ - return Math::Vector(); -} - -Math::Vector CEngine::GetLookatPt() -{ - return Math::Vector(); -} - -bool CEngine::GetPause() -{ - return false; -} - - -} /* Gfx */ - diff --git a/test/unit/ui/stubs/particle_stub.cpp b/test/unit/ui/stubs/particle_stub.cpp deleted file mode 100644 index 34cf973..0000000 --- a/test/unit/ui/stubs/particle_stub.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "graphics/engine/particle.h" - -#include "common/logger.h" - - -// Graphics module namespace -namespace Gfx { - - -CParticle::CParticle(CEngine* /*engine*/) -{ -} - -CParticle::~CParticle() -{ -} - -void CParticle::SetDevice(CDevice* /*device*/) -{ -} - -void CParticle::FlushParticle() -{ -} - -void CParticle::FlushParticle(int /*sheet*/) -{ -} - -int CParticle::CreateParticle(Math::Vector /*pos*/, Math::Vector /*speed*/, Math::Point /*dim*/, - ParticleType /*type*/, float /*duration*/, float /*mass*/, - float /*windSensitivity*/, int /*sheet*/) -{ - return 0; -} - -int CParticle::CreateFrag(Math::Vector /*pos*/, Math::Vector /*speed*/, EngineTriangle */*triangle*/, - ParticleType /*type*/, float /*duration*/, float /*mass*/, - float /*windSensitivity*/, int /*sheet*/) -{ - return 0; -} - -int CParticle::CreatePart(Math::Vector /*pos*/, Math::Vector /*speed*/, ParticleType /*type*/, - float /*duration*/, float /*mass*/, float /*weight*/, - float /*windSensitivity*/, int /*sheet*/) -{ - return 0; -} - -int CParticle::CreateRay(Math::Vector /*pos*/, Math::Vector /*goal*/, ParticleType /*type*/, Math::Point /*dim*/, - float /*duration*/, int /*sheet*/) -{ - return 0; -} - -int CParticle::CreateTrack(Math::Vector /*pos*/, Math::Vector /*speed*/, Math::Point /*dim*/, ParticleType /*type*/, - float /*duration*/, float /*mass*/, float /*length*/, float /*width*/) -{ - return 0; -} - -void CParticle::CreateWheelTrace(const Math::Vector &/*p1*/, const Math::Vector &/*p2*/, const Math::Vector &/*p3*/, - const Math::Vector &/*p4*/, ParticleType /*type*/) -{ -} - -void CParticle::DeleteParticle(ParticleType /*type*/) -{ -} - -void CParticle::DeleteParticle(int /*channel*/) -{ -} - -void CParticle::SetObjectLink(int /*channel*/, CObject */*object*/) -{ -} - -void CParticle::SetObjectFather(int /*channel*/, CObject */*object*/) -{ -} - -void CParticle::SetPosition(int /*channel*/, Math::Vector /*pos*/) -{ -} - -void CParticle::SetDimension(int /*channel*/, Math::Point /*dim*/) -{ -} - -void CParticle::SetZoom(int /*channel*/, float /*zoom*/) -{ -} - -void CParticle::SetAngle(int /*channel*/, float /*angle*/) -{ -} - -void CParticle::SetIntensity(int /*channel*/, float /*intensity*/) -{ -} - -void CParticle::SetParam(int /*channel*/, Math::Vector /*pos*/, Math::Point /*dim*/, float /*zoom*/, float /*angle*/, float /*intensity*/) -{ -} - -void CParticle::SetPhase(int /*channel*/, ParticlePhase /*phase*/, float /*duration*/) -{ -} - -bool CParticle::GetPosition(int /*channel*/, Math::Vector &/*pos*/) -{ - return true; -} - -Color CParticle::GetFogColor(Math::Vector /*pos*/) -{ - return Color(); -} - -void CParticle::SetFrameUpdate(int /*sheet*/, bool /*update*/) -{ -} - -void CParticle::FrameParticle(float /*rTime*/) -{ -} - -void CParticle::DrawParticle(int /*sheet*/) -{ -} - -bool CParticle::WriteWheelTrace(const char */*filename*/, int /*width*/, int /*height*/, Math::Vector /*dl*/, Math::Vector /*ur*/) -{ - return true; -} - -void CParticle::DeleteRank(int /*rank*/) -{ -} - -bool CParticle::CheckChannel(int &/*channel*/) -{ - return true; -} - -void CParticle::DrawParticleTriangle(int /*i*/) -{ -} - -void CParticle::DrawParticleNorm(int /*i*/) -{ -} - -void CParticle::DrawParticleFlat(int /*i*/) -{ -} - -void CParticle::DrawParticleFog(int /*i*/) -{ -} - -void CParticle::DrawParticleRay(int /*i*/) -{ -} - -void CParticle::DrawParticleSphere(int /*i*/) -{ -} - -void CParticle::DrawParticleCylinder(int /*i*/) -{ -} - -void CParticle::DrawParticleWheel(int /*i*/) -{ -} - -CObject* CParticle::SearchObjectGun(Math::Vector /*old*/, Math::Vector /*pos*/, ParticleType /*type*/, CObject */*father*/) -{ - return nullptr; -} - -CObject* CParticle::SearchObjectRay(Math::Vector /*pos*/, Math::Vector /*goal*/, ParticleType /*type*/, CObject */*father*/) -{ - return nullptr; -} - -void CParticle::Play(Sound /*sound*/, Math::Vector /*pos*/, float /*amplitude*/) -{ -} - -bool CParticle::TrackMove(int /*i*/, Math::Vector /*pos*/, float /*progress*/) -{ - return true; -} - -void CParticle::TrackDraw(int /*i*/, ParticleType /*type*/) -{ -} - - -} // namespace Gfx - diff --git a/test/unit/ui/stubs/restext_stub.cpp b/test/unit/ui/stubs/restext_stub.cpp deleted file mode 100644 index fa47da6..0000000 --- a/test/unit/ui/stubs/restext_stub.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "common/restext.h" - -bool GetResource(ResType /* type */, int /* num */, std::string& /* text */) -{ - return true; -} - -bool SearchKey(const char * /* cmd */, InputSlot & /* key */) -{ - return true; -} - diff --git a/test/unit/ui/stubs/robotmain_stub.cpp b/test/unit/ui/stubs/robotmain_stub.cpp deleted file mode 100644 index 692f67f..0000000 --- a/test/unit/ui/stubs/robotmain_stub.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "object/robotmain.h" - - -template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr; - -CRobotMain::CRobotMain(CApplication* app, bool loadProfile) -{ -} - -CRobotMain::~CRobotMain() -{ -} - -bool CRobotMain::GetGlint() -{ - return false; -} - -const InputBinding& CRobotMain::GetInputBinding(InputSlot slot) -{ - unsigned int index = static_cast<unsigned int>(slot); - assert(index >= 0 && index < INPUT_SLOT_MAX); - return m_inputBindings[index]; -} - |