From b9cb3b1e94a16425025dd251955f57ca7da5f637 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 11 May 2016 21:29:26 +0300 Subject: Fix issues in tests after adding some asserts. --- src/gui/windowmanager_unittest.cc | 3 +++ src/resources/db/itemdb.cpp | 6 +++++ src/resources/sprite/animatedsprite_unittest.cc | 5 +++-- src/utils/chatutils_unittest.cc | 29 +++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc index ffaa00d67..200d2178c 100644 --- a/src/gui/windowmanager_unittest.cc +++ b/src/gui/windowmanager_unittest.cc @@ -20,6 +20,7 @@ #include "catch.hpp" #include "client.h" +#include "configuration.h" #include "graphicsmanager.h" #include "settings.h" @@ -73,6 +74,7 @@ TEST_CASE("Windows tests", "windowmanager") ResourceManager::init(); resourceManager->addToSearchPath("data", Append_false); resourceManager->addToSearchPath("../data", Append_false); + branding.setValue("onlineServerFile", "test/serverlistplus.xml"); mainGraphics = new SDLGraphics; imageHelper = new SDLImageHelper; userPalette = new UserPalette; @@ -142,6 +144,7 @@ TEST_CASE("Windows tests", "windowmanager") SECTION("serversDialog") { ServerInfo mCurrentServer; + settings.configDir = PhysFs::getRealDir("test/serverlistplus.xml");; ServerDialog *serverDialog = CREATEWIDGETR(ServerDialog, &mCurrentServer, settings.configDir); diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index 88b104db5..934974a5b 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -299,6 +299,12 @@ void ItemDB::load() void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum) { + if (fileName.empty()) + { + mLoaded = true; + return; + } + XML::Document doc(fileName, UseResman_true, SkipError_false); const XmlNodePtrConst rootNode = doc.rootNode(); diff --git a/src/resources/sprite/animatedsprite_unittest.cc b/src/resources/sprite/animatedsprite_unittest.cc index 917e53c10..f9b6e65a9 100644 --- a/src/resources/sprite/animatedsprite_unittest.cc +++ b/src/resources/sprite/animatedsprite_unittest.cc @@ -55,8 +55,8 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite") ResourceManager::init(); resourceManager->addToSearchPath("data", Append_false); resourceManager->addToSearchPath("../data", Append_false); - ActorSprite::load(); - + theme = new Theme; + Theme::selectSkin(); imageHelper = new SDLImageHelper(); #ifdef USE_SDL2 SDLImageHelper::setRenderer(graphicsManager.createRenderer( @@ -65,6 +65,7 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite") #else graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE); #endif + ActorSprite::load(); SECTION("basic test 1") { diff --git a/src/utils/chatutils_unittest.cc b/src/utils/chatutils_unittest.cc index 74a62c811..33c4ca286 100644 --- a/src/utils/chatutils_unittest.cc +++ b/src/utils/chatutils_unittest.cc @@ -19,19 +19,47 @@ */ #include "catch.hpp" +#include "client.h" #include "actormanager.h" +#include "graphicsmanager.h" #include "party.h" #include "being/localplayer.h" +#include "gui/theme.h" + #include "utils/chatutils.h" #include "utils/delete2.h" +#include "utils/physfstools.h" + +#include "resources/resourcemanager.h" +#include "resources/sdlimagehelper.h" #include "debug.h" TEST_CASE("chatutils replaceVars") { + client = new Client; + PHYSFS_init("manaplus"); + dirSeparator = "/"; + XML::initXML(); + SDL_Init(SDL_INIT_VIDEO); + logger = new Logger(); + ResourceManager::init(); + resourceManager->addToSearchPath("data", Append_false); + resourceManager->addToSearchPath("../data", Append_false); + theme = new Theme; + Theme::selectSkin(); + imageHelper = new SDLImageHelper(); +#ifdef USE_SDL2 + SDLImageHelper::setRenderer(graphicsManager.createRenderer( + graphicsManager.createWindow(640, 480, 0, + SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE)); +#else + graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE); +#endif + ActorSprite::load(); localPlayer = new LocalPlayer(static_cast(1), BeingTypeId_zero); actorManager = new ActorManager; @@ -198,6 +226,7 @@ TEST_CASE("chatutils replaceVars") } delete2(actorManager); + delete2(client); } TEST_CASE("chatutils textToMe") -- cgit v1.2.3-70-g09d2