summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-09-01 04:05:51 +0300
committerAndrei Karas <akaras@inbox.ru>2017-09-01 04:05:51 +0300
commit59d9b799fa5bf3c8ba99cc6f703b83751f1d3497 (patch)
tree16b29e2afda9f223f36e6a7d3f4659fb72d3d7e6 /src
parentb9ce7a70632f31a3a4b29841ab034dbb297b295d (diff)
downloadmv-59d9b799fa5bf3c8ba99cc6f703b83751f1d3497.tar.gz
mv-59d9b799fa5bf3c8ba99cc6f703b83751f1d3497.tar.bz2
mv-59d9b799fa5bf3c8ba99cc6f703b83751f1d3497.tar.xz
mv-59d9b799fa5bf3c8ba99cc6f703b83751f1d3497.zip
Fix unit tests after last changes in configuration.cpp
Diffstat (limited to 'src')
-rw-r--r--src/unittests/configuration.cc5
-rw-r--r--src/unittests/fs/virtfs/throw.cc25
-rw-r--r--src/unittests/gui/widgets/browserbox.cc6
-rw-r--r--src/unittests/gui/windowmanager.cc13
-rw-r--r--src/unittests/integrity.cc12
-rw-r--r--src/unittests/resources/dye/dye.cc11
-rw-r--r--src/unittests/resources/dye/dyepalette.cc6
-rw-r--r--src/unittests/resources/map/maplayer/draw.cc2
-rw-r--r--src/unittests/resources/map/maplayer/drawfringenormal.cc9
-rw-r--r--src/unittests/resources/map/maplayer/drawfringesimple.cc9
-rw-r--r--src/unittests/resources/map/maplayer/drawspeciallayer1.cc9
-rw-r--r--src/unittests/resources/map/maplayer/drawspeciallayer2.cc9
-rw-r--r--src/unittests/resources/map/speciallayer.cc10
-rw-r--r--src/unittests/resources/resourcemanager/resourcemanager.cc10
-rw-r--r--src/unittests/resources/sdlimagehelper.cc10
-rw-r--r--src/unittests/resources/sprite/animatedsprite.cc6
-rw-r--r--src/unittests/sdl.cc10
-rw-r--r--src/unittests/utils/chatutils.cc5
-rw-r--r--src/unittests/utils/translation/poparser.cc6
-rw-r--r--src/unittests/utils/xmlutils.cc27
20 files changed, 151 insertions, 49 deletions
diff --git a/src/unittests/configuration.cc b/src/unittests/configuration.cc
index 58073bbdb..cdb28eddb 100644
--- a/src/unittests/configuration.cc
+++ b/src/unittests/configuration.cc
@@ -66,11 +66,6 @@ TEST_CASE("configuration tests", "configuration")
REQUIRE(config.getValueBool(key, true) == true);
REQUIRE(config.getValue(key, -12345) == -12345);
REQUIRE(config.getValue(key, 12.345) > 12.3);
-
- REQUIRE(config.getIntValue(key) == 0);
- REQUIRE(config.getFloatValue(key) >= 0.0f);
- REQUIRE(config.getStringValue(key).empty());
- REQUIRE(config.getBoolValue(key) == false);
}
SECTION("configuration getint default")
diff --git a/src/unittests/fs/virtfs/throw.cc b/src/unittests/fs/virtfs/throw.cc
index 377230686..b15572d20 100644
--- a/src/unittests/fs/virtfs/throw.cc
+++ b/src/unittests/fs/virtfs/throw.cc
@@ -20,6 +20,10 @@
#include "unittests/unittests.h"
+#include "configmanager.h"
+#include "configuration.h"
+#include "dirs.h"
+
#include "fs/files.h"
#include "fs/virtfs/fs.h"
@@ -231,3 +235,24 @@ TEST_CASE("throw VirtFs1 unmount", "")
VirtFs::deinit();
delete2(logger);
}
+
+TEST_CASE("throw configuration tests", "configuration")
+{
+ logger = new Logger();
+
+ Dirs::initRootDir();
+ Dirs::initHomeDir();
+
+ ConfigManager::initConfiguration();
+
+ SECTION("configuration undefined")
+ {
+ const char *const key = "nonsetvalue";
+ REQUIRE_THROWS(config.getIntValue(key) == 0);
+ REQUIRE_THROWS(config.getFloatValue(key) >= 0.0f);
+ REQUIRE_THROWS(config.getStringValue(key).empty());
+ REQUIRE_THROWS(config.getBoolValue(key) == false);
+ }
+
+ delete2(logger);
+}
diff --git a/src/unittests/gui/widgets/browserbox.cc b/src/unittests/gui/widgets/browserbox.cc
index 2a72350af..7e4689707 100644
--- a/src/unittests/gui/widgets/browserbox.cc
+++ b/src/unittests/gui/widgets/browserbox.cc
@@ -65,9 +65,6 @@ TEST_CASE("BrowserBox tests", "browserbox")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
- theme = new Theme;
- Theme::selectSkin();
-
Dirs::initRootDir();
Dirs::initHomeDir();
@@ -75,6 +72,9 @@ TEST_CASE("BrowserBox tests", "browserbox")
setConfigDefaults2(config);
setBrandingDefaults(branding);
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
gui = new Gui();
gui->postInit(mainGraphics);
diff --git a/src/unittests/gui/windowmanager.cc b/src/unittests/gui/windowmanager.cc
index 9c04237a6..41e2e755b 100644
--- a/src/unittests/gui/windowmanager.cc
+++ b/src/unittests/gui/windowmanager.cc
@@ -168,8 +168,6 @@ TEST_CASE("Windows tests", "windowmanager")
userPalette = new UserPalette;
config.setValue("fontSize", 16);
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
@@ -181,8 +179,12 @@ TEST_CASE("Windows tests", "windowmanager")
ConfigManager::initConfiguration();
setConfigDefaults2(config);
setBrandingDefaults(branding);
+ setFeaturesDefaults(features);
ConfigManager::initServerConfig("nonexistserver");
+ theme = new Theme;
+ Theme::selectSkin();
+
localPlayer = new LocalPlayer(static_cast<BeingId>(1),
BeingTypeId_zero);
@@ -334,7 +336,7 @@ TEST_CASE("Windows tests", "windowmanager")
{
ConfirmDialog *dialog;
CREATEWIDGETV(dialog, ConfirmDialog,
- "", "", "", false, Modal_false, nullptr);
+ "", "", SOUND_REQUEST, false, Modal_false, nullptr);
gui->draw();
mainGraphics->updateScreen();
delete2(dialog);
@@ -850,8 +852,6 @@ TEST_CASE("WindowManager", "create windows")
#endif // USE_SDL2
config.setValue("fontSize", 16);
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
@@ -865,6 +865,9 @@ TEST_CASE("WindowManager", "create windows")
setBrandingDefaults(branding);
ConfigManager::initServerConfig("nonexistserver");
+ theme = new Theme;
+ Theme::selectSkin();
+
localPlayer = new LocalPlayer(static_cast<BeingId>(1),
BeingTypeId_zero);
diff --git a/src/unittests/integrity.cc b/src/unittests/integrity.cc
index 02682f537..a750959dc 100644
--- a/src/unittests/integrity.cc
+++ b/src/unittests/integrity.cc
@@ -20,6 +20,7 @@
#include "unittests/unittests.h"
+#include "configmanager.h"
#include "configuration.h"
#include "client.h"
#include "dirs.h"
@@ -32,7 +33,6 @@
#include "fs/virtfs/fs.h"
#include "fs/virtfs/rwops.h"
-#include "gui/gui.h"
#include "gui/userpalette.h"
#include "gui/theme.h"
@@ -137,13 +137,17 @@ TEST_CASE("integrity tests", "integrity")
#endif // USE_SDL2
userPalette = new UserPalette;
- config.setValue("fontSize", 16);
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ config.setValue("fontSize", 16);
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
const char *const name1 = "dir/hide.png";
const int size1 = 368;
diff --git a/src/unittests/resources/dye/dye.cc b/src/unittests/resources/dye/dye.cc
index 54ddd7c45..499e570ea 100644
--- a/src/unittests/resources/dye/dye.cc
+++ b/src/unittests/resources/dye/dye.cc
@@ -21,6 +21,8 @@
#include "unittests/unittests.h"
#include "client.h"
+#include "configmanager.h"
+#include "configuration.h"
#include "dirs.h"
#include "graphicsmanager.h"
@@ -28,7 +30,6 @@
#include "fs/virtfs/fs.h"
-#include "gui/gui.h"
#include "gui/userpalette.h"
#include "gui/theme.h"
@@ -1977,12 +1978,16 @@ TEST_CASE("Dye real dye", "")
#endif // USE_SDL2
userPalette = new UserPalette;
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
SECTION("B dye")
diff --git a/src/unittests/resources/dye/dyepalette.cc b/src/unittests/resources/dye/dyepalette.cc
index 54d947358..7c49f02c1 100644
--- a/src/unittests/resources/dye/dyepalette.cc
+++ b/src/unittests/resources/dye/dyepalette.cc
@@ -77,9 +77,6 @@ TEST_CASE("DyePalette tests", "")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
- theme = new Theme;
- Theme::selectSkin();
-
Dirs::initRootDir();
Dirs::initHomeDir();
@@ -87,6 +84,9 @@ TEST_CASE("DyePalette tests", "")
setConfigDefaults2(config);
setBrandingDefaults(branding);
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
gui = new Gui();
gui->postInit(mainGraphics);
diff --git a/src/unittests/resources/map/maplayer/draw.cc b/src/unittests/resources/map/maplayer/draw.cc
index ac7fba9b7..5e6cfdddf 100644
--- a/src/unittests/resources/map/maplayer/draw.cc
+++ b/src/unittests/resources/map/maplayer/draw.cc
@@ -25,8 +25,6 @@
#include "unittests/render/mockgraphics.h"
-#include "utils/delete2.h"
-
#include "resources/image/image.h"
#include "resources/map/map.h"
diff --git a/src/unittests/resources/map/maplayer/drawfringenormal.cc b/src/unittests/resources/map/maplayer/drawfringenormal.cc
index 6ab0a395c..4ec72484b 100644
--- a/src/unittests/resources/map/maplayer/drawfringenormal.cc
+++ b/src/unittests/resources/map/maplayer/drawfringenormal.cc
@@ -20,6 +20,9 @@
#include "unittests/unittests.h"
+#include "configmanager.h"
+#include "configuration.h"
+#include "dirs.h"
#include "graphicsmanager.h"
#include "being/localplayer.h"
@@ -65,6 +68,12 @@ TEST_CASE("MapLayer drawFringe normal", "")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
+ Dirs::initRootDir();
+ Dirs::initHomeDir();
+
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
theme = new Theme;
Theme::selectSkin();
diff --git a/src/unittests/resources/map/maplayer/drawfringesimple.cc b/src/unittests/resources/map/maplayer/drawfringesimple.cc
index 6a362b8aa..8c3457e8f 100644
--- a/src/unittests/resources/map/maplayer/drawfringesimple.cc
+++ b/src/unittests/resources/map/maplayer/drawfringesimple.cc
@@ -20,6 +20,9 @@
#include "unittests/unittests.h"
+#include "configmanager.h"
+#include "configuration.h"
+#include "dirs.h"
#include "graphicsmanager.h"
#include "being/localplayer.h"
@@ -62,6 +65,12 @@ TEST_CASE("MapLayer drawFringe simple", "")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
+ Dirs::initRootDir();
+ Dirs::initHomeDir();
+
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
theme = new Theme;
Theme::selectSkin();
diff --git a/src/unittests/resources/map/maplayer/drawspeciallayer1.cc b/src/unittests/resources/map/maplayer/drawspeciallayer1.cc
index 3224eb5ef..2927deb48 100644
--- a/src/unittests/resources/map/maplayer/drawspeciallayer1.cc
+++ b/src/unittests/resources/map/maplayer/drawspeciallayer1.cc
@@ -20,6 +20,9 @@
#include "unittests/unittests.h"
+#include "configmanager.h"
+#include "configuration.h"
+#include "dirs.h"
#include "graphicsmanager.h"
#include "enums/resources/map/mapitemtype.h"
@@ -59,6 +62,12 @@ TEST_CASE("MapLayer drawSpecialLayer (specialLayer)", "")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
+ Dirs::initRootDir();
+ Dirs::initHomeDir();
+
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
Map *map = nullptr;
MapLayer *layer = nullptr;
SpecialLayer *specialLayer = nullptr;
diff --git a/src/unittests/resources/map/maplayer/drawspeciallayer2.cc b/src/unittests/resources/map/maplayer/drawspeciallayer2.cc
index 0092b2019..ec101a099 100644
--- a/src/unittests/resources/map/maplayer/drawspeciallayer2.cc
+++ b/src/unittests/resources/map/maplayer/drawspeciallayer2.cc
@@ -20,6 +20,9 @@
#include "unittests/unittests.h"
+#include "configmanager.h"
+#include "configuration.h"
+#include "dirs.h"
#include "graphicsmanager.h"
#include "enums/resources/map/mapitemtype.h"
@@ -59,6 +62,12 @@ TEST_CASE("MapLayer drawSpecialLayer (tempLayer)", "")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
+ Dirs::initRootDir();
+ Dirs::initHomeDir();
+
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
Map *map = nullptr;
MapLayer *layer = nullptr;
SpecialLayer *specialLayer = nullptr;
diff --git a/src/unittests/resources/map/speciallayer.cc b/src/unittests/resources/map/speciallayer.cc
index ef9b79e48..49b50c932 100644
--- a/src/unittests/resources/map/speciallayer.cc
+++ b/src/unittests/resources/map/speciallayer.cc
@@ -21,6 +21,8 @@
#include "unittests/unittests.h"
#include "client.h"
+#include "configmanager.h"
+#include "configuration.h"
#include "dirs.h"
#include "graphicsmanager.h"
@@ -65,12 +67,16 @@ TEST_CASE("SpecialLayer updateCache", "")
#endif // USE_SDL2
userPalette = new UserPalette;
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
SpecialLayer *layer = nullptr;
diff --git a/src/unittests/resources/resourcemanager/resourcemanager.cc b/src/unittests/resources/resourcemanager/resourcemanager.cc
index d035faafb..66656558b 100644
--- a/src/unittests/resources/resourcemanager/resourcemanager.cc
+++ b/src/unittests/resources/resourcemanager/resourcemanager.cc
@@ -21,6 +21,8 @@
#include "unittests/unittests.h"
#include "client.h"
+#include "configmanager.h"
+#include "configuration.h"
#include "dirs.h"
#include "graphicsmanager.h"
@@ -110,12 +112,16 @@ TEST_CASE("resourcemanager", "resourcemanager")
#endif // USE_SDL2
userPalette = new UserPalette;
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
// ConfigManager::initConfiguration();
diff --git a/src/unittests/resources/sdlimagehelper.cc b/src/unittests/resources/sdlimagehelper.cc
index fa897c01d..e76e6f26d 100644
--- a/src/unittests/resources/sdlimagehelper.cc
+++ b/src/unittests/resources/sdlimagehelper.cc
@@ -29,6 +29,8 @@ PRAGMA48(GCC diagnostic pop)
#include "unittests/unittests.h"
#include "client.h"
+#include "configmanager.h"
+#include "configuration.h"
#include "dirs.h"
#include "graphicsmanager.h"
@@ -89,12 +91,16 @@ TEST_CASE("sdlimagehelper combineSurface", "")
#endif // USE_SDL2
userPalette = new UserPalette;
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
SECTION("empty copy1")
diff --git a/src/unittests/resources/sprite/animatedsprite.cc b/src/unittests/resources/sprite/animatedsprite.cc
index a48c21baa..0dab6d9cd 100644
--- a/src/unittests/resources/sprite/animatedsprite.cc
+++ b/src/unittests/resources/sprite/animatedsprite.cc
@@ -78,9 +78,6 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
- theme = new Theme;
- Theme::selectSkin();
-
Dirs::initRootDir();
Dirs::initHomeDir();
@@ -88,6 +85,9 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
setConfigDefaults2(config);
setBrandingDefaults(branding);
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
gui = new Gui();
gui->postInit(mainGraphics);
diff --git a/src/unittests/sdl.cc b/src/unittests/sdl.cc
index d5026a583..1d2943605 100644
--- a/src/unittests/sdl.cc
+++ b/src/unittests/sdl.cc
@@ -20,6 +20,7 @@
#include "unittests/unittests.h"
+#include "configmanager.h"
#include "configuration.h"
#include "client.h"
#include "dirs.h"
@@ -31,7 +32,6 @@
#include "fs/virtfs/fs.h"
-#include "gui/gui.h"
#include "gui/userpalette.h"
#include "gui/theme.h"
@@ -86,12 +86,16 @@ TEST_CASE("sdl tests", "sdl")
userPalette = new UserPalette;
config.setValue("fontSize", 16);
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
SECTION("sdl SDL DuplicateSurface1")
diff --git a/src/unittests/utils/chatutils.cc b/src/unittests/utils/chatutils.cc
index 88e6bdf82..f0a72af26 100644
--- a/src/unittests/utils/chatutils.cc
+++ b/src/unittests/utils/chatutils.cc
@@ -63,8 +63,6 @@ TEST_CASE("chatutils replaceVars", "")
logger = new Logger();
VirtFs::mountDirSilent("data", Append_false);
VirtFs::mountDirSilent("../data", Append_false);
- theme = new Theme;
- Theme::selectSkin();
imageHelper = new SDLImageHelper();
mainGraphics = new SDLGraphics;
@@ -84,6 +82,9 @@ TEST_CASE("chatutils replaceVars", "")
setConfigDefaults2(config);
setBrandingDefaults(branding);
+ theme = new Theme;
+ Theme::selectSkin();
+
gui = new Gui();
gui->postInit(mainGraphics);
diff --git a/src/unittests/utils/translation/poparser.cc b/src/unittests/utils/translation/poparser.cc
index b7325b1de..84c993112 100644
--- a/src/unittests/utils/translation/poparser.cc
+++ b/src/unittests/utils/translation/poparser.cc
@@ -65,9 +65,6 @@ TEST_CASE("PoParser tests", "PoParser")
graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif // USE_SDL2
- theme = new Theme;
- Theme::selectSkin();
-
Dirs::initRootDir();
Dirs::initHomeDir();
@@ -75,6 +72,9 @@ TEST_CASE("PoParser tests", "PoParser")
setConfigDefaults2(config);
setBrandingDefaults(branding);
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
gui = new Gui();
gui->postInit(mainGraphics);
diff --git a/src/unittests/utils/xmlutils.cc b/src/unittests/utils/xmlutils.cc
index 7a82a502c..bff998057 100644
--- a/src/unittests/utils/xmlutils.cc
+++ b/src/unittests/utils/xmlutils.cc
@@ -21,6 +21,8 @@
#include "unittests/unittests.h"
#include "client.h"
+#include "configmanager.h"
+#include "configuration.h"
#include "dirs.h"
#include "graphicsmanager.h"
@@ -28,7 +30,6 @@
#include "fs/virtfs/fs.h"
-#include "gui/gui.h"
#include "gui/userpalette.h"
#include "gui/theme.h"
@@ -66,12 +67,16 @@ TEST_CASE("xmlutils readXmlIntVector 1", "")
#endif // USE_SDL2
userPalette = new UserPalette;
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
STD_VECTOR<int> arr;
@@ -123,12 +128,16 @@ TEST_CASE("xmlutils readXmlStringMap 1", "")
#endif // USE_SDL2
userPalette = new UserPalette;
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
std::map<std::string, std::string> arr;
@@ -181,12 +190,16 @@ TEST_CASE("xmlutils readXmlIntMap 1", "")
#endif // USE_SDL2
userPalette = new UserPalette;
- theme = new Theme;
- Theme::selectSkin();
Dirs::initRootDir();
Dirs::initHomeDir();
+ setBrandingDefaults(branding);
+ ConfigManager::initConfiguration();
+
+ theme = new Theme;
+ Theme::selectSkin();
+
ActorSprite::load();
std::map<int32_t, int32_t> arr;