summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-01-05 17:00:02 +0300
committerAndrei Karas <akaras@inbox.ru>2017-01-05 17:00:02 +0300
commit855387d2d795c9471587cc7ddf2c66bb676d698e (patch)
tree3dbb1260c219312f36893dfae52f5cd40760aeb5 /src/resources
parent9fefb2942865846ccb7dbdac4ebd4515b8c851a2 (diff)
downloadmv-855387d2d795c9471587cc7ddf2c66bb676d698e.tar.gz
mv-855387d2d795c9471587cc7ddf2c66bb676d698e.tar.bz2
mv-855387d2d795c9471587cc7ddf2c66bb676d698e.tar.xz
mv-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/resources')
-rw-r--r--src/resources/dye/dye_unittest.cc1
-rw-r--r--src/resources/dye/dyepalette_unittest.cc11
-rw-r--r--src/resources/resourcemanager/resourcemanager_unittest.cc1
-rw-r--r--src/resources/sprite/animatedsprite_unittest.cc12
4 files changed, 19 insertions, 6 deletions
diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc
index ff79fea52..370800675 100644
--- a/src/resources/dye/dye_unittest.cc
+++ b/src/resources/dye/dye_unittest.cc
@@ -2354,7 +2354,6 @@ TEST_CASE("Dye real dye")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- PHYSFS_init("manaplus");
dirSeparator = "/";
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
diff --git a/src/resources/dye/dyepalette_unittest.cc b/src/resources/dye/dyepalette_unittest.cc
index 7e652e43f..5296abb33 100644
--- a/src/resources/dye/dyepalette_unittest.cc
+++ b/src/resources/dye/dyepalette_unittest.cc
@@ -27,6 +27,11 @@
#include "being/actorsprite.h"
+#include "gui/gui.h"
+#include "gui/theme.h"
+
+#include "render/sdlgraphics.h"
+
#include "resources/sdlimagehelper.h"
#include "resources/db/palettedb.h"
@@ -50,7 +55,6 @@ TEST_CASE("DyePalette tests")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- PHYSFS_init("manaplus");
dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
@@ -59,6 +63,7 @@ TEST_CASE("DyePalette tests")
resourceManager->addToSearchPath("data/test", Append_false);
resourceManager->addToSearchPath("../data/test", Append_false);
+ mainGraphics = new SDLGraphics;
imageHelper = new SDLImageHelper();
#ifdef USE_SDL2
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
@@ -69,7 +74,11 @@ TEST_CASE("DyePalette tests")
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);
paths.setDefaultValues(getPathsDefaults());
PaletteDB::load();
diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc
index a8b1becc1..2019f20d8 100644
--- a/src/resources/resourcemanager/resourcemanager_unittest.cc
+++ b/src/resources/resourcemanager/resourcemanager_unittest.cc
@@ -88,7 +88,6 @@ TEST_CASE("resourcemanager", "resourcemanager")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- PHYSFS_init("manaplus");
dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
diff --git a/src/resources/sprite/animatedsprite_unittest.cc b/src/resources/sprite/animatedsprite_unittest.cc
index bf151308c..a46fad9b0 100644
--- a/src/resources/sprite/animatedsprite_unittest.cc
+++ b/src/resources/sprite/animatedsprite_unittest.cc
@@ -28,8 +28,11 @@
#include "being/actorsprite.h"
+#include "gui/gui.h"
#include "gui/theme.h"
+#include "render/sdlgraphics.h"
+
#include "resources/sdlimagehelper.h"
#include "resources/animation/animation.h"
@@ -52,7 +55,6 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
initRand();
client = new Client;
- PHYSFS_init("manaplus");
dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
@@ -60,8 +62,7 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
ResourceManager::init();
resourceManager->addToSearchPath("data", Append_false);
resourceManager->addToSearchPath("../data", Append_false);
- theme = new Theme;
- Theme::selectSkin();
+ mainGraphics = new SDLGraphics;
imageHelper = new SDLImageHelper();
#ifdef USE_SDL2
SDLImageHelper::setRenderer(graphicsManager.createRenderer(
@@ -72,7 +73,11 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
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("basic test 1")
{
@@ -92,6 +97,7 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
REQUIRE(10 == sprite->getFrameTime());
REQUIRE(0 == sprite->getFrameIndex());
delete sprite;
+ logger->log("test4");
}
SECTION("basic test 2")