summaryrefslogtreecommitdiff
path: root/src/gui
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/gui
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/gui')
-rw-r--r--src/gui/gui.cpp1
-rw-r--r--src/gui/widgets/browserbox_unittest.cc26
-rw-r--r--src/gui/windowmanager_unittest.cc9
3 files changed, 31 insertions, 5 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 7a9e0e29e..fd3f8bd2a 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -279,6 +279,7 @@ Gui::~Gui()
Widget *top = mTop;
if (Widget::widgetExists(mTop))
setTop(nullptr);
+ Window::setWindowContainer(nullptr);
delete top;
delete2(mGuiFont);
diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc
index 665d6de3f..c58f274e0 100644
--- a/src/gui/widgets/browserbox_unittest.cc
+++ b/src/gui/widgets/browserbox_unittest.cc
@@ -20,13 +20,20 @@
#include "catch.hpp"
#include "client.h"
+#include "graphicsmanager.h"
#include "being/actorsprite.h"
+#include "gui/gui.h"
+
#include "gui/fonts/font.h"
#include "gui/widgets/browserbox.h"
+#include "render/sdlgraphics.h"
+
+#include "resources/sdlimagehelper.h"
+
#include "resources/resourcemanager/resourcemanager.h"
#include "resources/sdlimagehelper.h"
@@ -41,16 +48,31 @@ extern const char *dirSeparator;
TEST_CASE("BrowserBox tests", "browserbox")
{
- PHYSFS_init("manaplus");
dirSeparator = "/";
client = new Client;
logger = new Logger();
imageHelper = new SDLImageHelper();
- theme = new Theme;
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(
+ graphicsManager.createWindow(640, 480, 0,
+ SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
+#else // USE_SDL2
+
+ 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);
+
Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/"
"ttf-dejavu/DejaVuSans-Oblique.ttf", 18));
BrowserBox *const box = new BrowserBox(nullptr,
diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc
index 0f8c5bc15..048d23550 100644
--- a/src/gui/windowmanager_unittest.cc
+++ b/src/gui/windowmanager_unittest.cc
@@ -127,7 +127,6 @@ TEST_CASE("Windows tests", "windowmanager")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- PHYSFS_init("manaplus");
dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
@@ -138,6 +137,9 @@ TEST_CASE("Windows tests", "windowmanager")
resourceManager->cleanOrphans(true);
resourceManager->addToSearchPath("data", Append_false);
resourceManager->addToSearchPath("../data", Append_false);
+ resourceManager->addToSearchPath("data/test", Append_false);
+ resourceManager->addToSearchPath("../data/test", Append_false);
+ paths.setDefaultValues(getPathsDefaults());
branding.setValue("onlineServerFile", "test/serverlistplus.xml");
mainGraphics = new SDLGraphics;
imageHelper = new SDLImageHelper;
@@ -150,10 +152,11 @@ TEST_CASE("Windows tests", "windowmanager")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
- ActorSprite::load();
userPalette = new UserPalette;
- theme = new Theme;
config.setValue("fontSize", 16);
+ theme = new Theme;
+ Theme::selectSkin();
+ ActorSprite::load();
gui = new Gui();
gui->postInit(mainGraphics);
touchManager.init();