diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-01-05 17:00:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-01-05 17:00:02 +0300 |
commit | 855387d2d795c9471587cc7ddf2c66bb676d698e (patch) | |
tree | 3dbb1260c219312f36893dfae52f5cd40760aeb5 /src/utils | |
parent | 9fefb2942865846ccb7dbdac4ebd4515b8c851a2 (diff) | |
download | plus-855387d2d795c9471587cc7ddf2c66bb676d698e.tar.gz plus-855387d2d795c9471587cc7ddf2c66bb676d698e.tar.bz2 plus-855387d2d795c9471587cc7ddf2c66bb676d698e.tar.xz plus-855387d2d795c9471587cc7ddf2c66bb676d698e.zip |
Fix different issues in unit tests.
Fix crash with some compilers flags.
Clean window container to null after it was removed.
Init and deinit physfs globally.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/chatutils_unittest.cc | 8 | ||||
-rw-r--r-- | src/utils/files_unittest.cc | 6 | ||||
-rw-r--r-- | src/utils/stringutils_unittest.cc | 5 | ||||
-rw-r--r-- | src/utils/translation/poparser_unittest.cc | 19 | ||||
-rw-r--r-- | src/utils/xml_unittest.cc | 7 | ||||
-rw-r--r-- | src/utils/xmlutils_unittest.cc | 3 |
6 files changed, 31 insertions, 17 deletions
diff --git a/src/utils/chatutils_unittest.cc b/src/utils/chatutils_unittest.cc index 2077bfe5e..374bf3125 100644 --- a/src/utils/chatutils_unittest.cc +++ b/src/utils/chatutils_unittest.cc @@ -27,12 +27,15 @@ #include "being/localplayer.h" +#include "gui/gui.h" #include "gui/theme.h" #include "utils/chatutils.h" #include "utils/delete2.h" #include "utils/physfstools.h" +#include "render/sdlgraphics.h" + #include "resources/sdlimagehelper.h" #include "resources/resourcemanager/resourcemanager.h" @@ -46,7 +49,6 @@ TEST_CASE("chatutils replaceVars") { client = new Client; - PHYSFS_init("manaplus"); dirSeparator = "/"; XML::initXML(); SDL_Init(SDL_INIT_VIDEO); @@ -57,6 +59,10 @@ TEST_CASE("chatutils replaceVars") theme = new Theme; Theme::selectSkin(); imageHelper = new SDLImageHelper(); + mainGraphics = new SDLGraphics; + + gui = new Gui(); + gui->postInit(mainGraphics); #ifdef USE_SDL2 SDLImageHelper::setRenderer(graphicsManager.createRenderer( graphicsManager.createWindow(640, 480, 0, diff --git a/src/utils/files_unittest.cc b/src/utils/files_unittest.cc index 77a7017f6..d0d4fdb1e 100644 --- a/src/utils/files_unittest.cc +++ b/src/utils/files_unittest.cc @@ -31,7 +31,6 @@ TEST_CASE("Files renameFile") { - PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); ResourceManager::init(); @@ -69,7 +68,6 @@ TEST_CASE("Files renameFile") TEST_CASE("Files existsLocal") { - PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); ResourceManager::init(); @@ -84,7 +82,6 @@ TEST_CASE("Files existsLocal") TEST_CASE("Files loadTextFileString") { - PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); ResourceManager::init(); @@ -98,7 +95,6 @@ TEST_CASE("Files loadTextFileString") TEST_CASE("Files loadTextFile") { - PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); ResourceManager::init(); @@ -116,7 +112,6 @@ TEST_CASE("Files loadTextFile") TEST_CASE("Files saveTextFile") { - PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); ResourceManager::init(); @@ -135,7 +130,6 @@ TEST_CASE("Files saveTextFile") TEST_CASE("Files getFilesInDir") { - PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); ResourceManager::init(); diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc index 481289087..1cc6049f5 100644 --- a/src/utils/stringutils_unittest.cc +++ b/src/utils/stringutils_unittest.cc @@ -19,6 +19,7 @@ */ #include "catch.hpp" +#include "configuration.h" #include "logger.h" #include "utils/physfstools.h" @@ -623,15 +624,17 @@ TEST_CASE("stringuntils escapeString") TEST_CASE("stringuntils replaceItemLinks") { - PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); ResourceManager::init(); resourceManager->addToSearchPath("data", Append_false); resourceManager->addToSearchPath("../data", Append_false); + resourceManager->addToSearchPath("data/test", Append_false); + resourceManager->addToSearchPath("../data/test", Append_false); ItemDB::NamedItemInfos &namedInfos = ItemDB::getNamedItemInfosTest(); ItemDB::ItemInfos &infos = ItemDB::getItemInfosTest(); + paths.setDefaultValues(getPathsDefaults()); ItemInfo *info = new ItemInfo; info->setId(123456); info->setName("test name 1"); diff --git a/src/utils/translation/poparser_unittest.cc b/src/utils/translation/poparser_unittest.cc index 9a138c67c..77cb4c22d 100644 --- a/src/utils/translation/poparser_unittest.cc +++ b/src/utils/translation/poparser_unittest.cc @@ -25,17 +25,22 @@ #include "being/actorsprite.h" +#include "gui/gui.h" +#include "gui/theme.h" + +#include "utils/delete2.h" +#include "utils/env.h" +#include "utils/physfstools.h" + #include "utils/translation/podict.h" #include "utils/translation/poparser.h" +#include "render/sdlgraphics.h" + #include "resources/sdlimagehelper.h" #include "resources/resourcemanager/resourcemanager.h" -#include "utils/delete2.h" -#include "utils/env.h" -#include "utils/physfstools.h" - #include "debug.h" TEST_CASE("PoParser tests", "PoParser") @@ -43,13 +48,13 @@ TEST_CASE("PoParser tests", "PoParser") setEnv("SDL_VIDEODRIVER", "dummy"); client = new Client; - PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); ResourceManager::init(); resourceManager->addToSearchPath("data", Append_false); resourceManager->addToSearchPath("../data", Append_false); + mainGraphics = new SDLGraphics; imageHelper = new SDLImageHelper(); #ifdef USE_SDL2 SDLImageHelper::setRenderer(graphicsManager.createRenderer( @@ -60,7 +65,11 @@ TEST_CASE("PoParser tests", "PoParser") graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE); #endif // USE_SDL2 + theme = new Theme; + Theme::selectSkin(); ActorSprite::load(); + gui = new Gui(); + gui->postInit(mainGraphics); SECTION("PoParser empty") { diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc index 52f234d12..40876e0d2 100644 --- a/src/utils/xml_unittest.cc +++ b/src/utils/xml_unittest.cc @@ -24,12 +24,15 @@ #include "being/actorsprite.h" +#include "gui/gui.h" #include "gui/theme.h" #include "utils/delete2.h" #include "utils/env.h" #include "utils/physfstools.h" +#include "render/sdlgraphics.h" + #include "resources/sdlimagehelper.h" #include "resources/resourcemanager/resourcemanager.h" @@ -41,13 +44,13 @@ TEST_CASE("xml doc") setEnv("SDL_VIDEODRIVER", "dummy"); client = new Client; - PHYSFS_init("manaplus"); dirSeparator = "/"; XML::initXML(); logger = new Logger(); ResourceManager::init(); resourceManager->addToSearchPath("data", Append_false); resourceManager->addToSearchPath("../data", Append_false); + mainGraphics = new SDLGraphics; imageHelper = new SDLImageHelper(); #ifdef USE_SDL2 SDLImageHelper::setRenderer(graphicsManager.createRenderer( @@ -62,6 +65,8 @@ TEST_CASE("xml doc") Theme::selectSkin(); const char *const tempXmlName = "tempxml.xml"; ActorSprite::load(); + gui = new Gui(); + gui->postInit(mainGraphics); SECTION("load1") { diff --git a/src/utils/xmlutils_unittest.cc b/src/utils/xmlutils_unittest.cc index 5603bf5a8..ebd964262 100644 --- a/src/utils/xmlutils_unittest.cc +++ b/src/utils/xmlutils_unittest.cc @@ -34,7 +34,6 @@ TEST_CASE("xmlutils readXmlIntVector 1") { client = new Client; - PHYSFS_init("manaplus"); dirSeparator = "/"; XML::initXML(); logger = new Logger(); @@ -65,7 +64,6 @@ TEST_CASE("xmlutils readXmlIntVector 1") TEST_CASE("xmlutils readXmlStringMap 1") { client = new Client; - PHYSFS_init("manaplus"); dirSeparator = "/"; XML::initXML(); logger = new Logger(); @@ -95,7 +93,6 @@ TEST_CASE("xmlutils readXmlStringMap 1") TEST_CASE("xmlutils readXmlIntMap 1") { client = new Client; - PHYSFS_init("manaplus"); dirSeparator = "/"; XML::initXML(); logger = new Logger(); |