summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-01 04:50:26 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-01 04:50:26 +0300
commit7df01a8695e46e7e8cce603782f0e16caf54169b (patch)
tree030a0125429c9605c24ad74e3d523fd900f155cd /src
parent0f172abb004bed203f8bf329e4f43eb174a8a58c (diff)
downloadplus-7df01a8695e46e7e8cce603782f0e16caf54169b.tar.gz
plus-7df01a8695e46e7e8cce603782f0e16caf54169b.tar.bz2
plus-7df01a8695e46e7e8cce603782f0e16caf54169b.tar.xz
plus-7df01a8695e46e7e8cce603782f0e16caf54169b.zip
Fix tests running without physfs.
Diffstat (limited to 'src')
-rw-r--r--src/fs/files_unittest.cc12
-rw-r--r--src/fs/virtfs/virtfs.cpp18
-rw-r--r--src/gui/widgets/browserbox_unittest.cc2
-rw-r--r--src/gui/windowmanager_unittest.cc4
-rw-r--r--src/integrity_unittest.cc16
-rw-r--r--src/resources/dye/dye_unittest.cc6
-rw-r--r--src/resources/dye/dyepalette_unittest.cc6
-rw-r--r--src/resources/map/maplayer_unittest.cc6
-rw-r--r--src/resources/map/speciallayer_unittest.cc2
-rw-r--r--src/resources/resourcemanager/resourcemanager_unittest.cc2
-rw-r--r--src/resources/sprite/animatedsprite_unittest.cc2
-rw-r--r--src/utils/chatutils_unittest.cc2
-rw-r--r--src/utils/stringutils_unittest.cc6
-rw-r--r--src/utils/translation/poparser_unittest.cc2
-rw-r--r--src/utils/xml_unittest.cc3
-rw-r--r--src/utils/xmlutils_unittest.cc25
16 files changed, 103 insertions, 11 deletions
diff --git a/src/fs/files_unittest.cc b/src/fs/files_unittest.cc
index 7b4c6ca33..69956ddb3 100644
--- a/src/fs/files_unittest.cc
+++ b/src/fs/files_unittest.cc
@@ -66,6 +66,8 @@ TEST_CASE("Files renameFile")
delete [] buf;
delete [] buf2;
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -81,6 +83,8 @@ TEST_CASE("Files existsLocal")
REQUIRE_FALSE(Files::existsLocal(VirtFs::getPath("help/about1.txt")));
REQUIRE_FALSE(Files::existsLocal(VirtFs::getPath("help1/about.txt")));
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -95,6 +99,8 @@ TEST_CASE("Files loadTextFileString")
REQUIRE(VirtFs::loadTextFileString("test/simplefile.txt") ==
"this is test \nfile.");
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -113,6 +119,8 @@ TEST_CASE("Files loadTextFile")
REQUIRE(lines[0] == "this is test ");
REQUIRE(lines[1] == "file.");
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -132,6 +140,8 @@ TEST_CASE("Files saveTextFile")
::remove((dir + "/tempfile.txt").c_str());
REQUIRE(data == "test line\ntext line2\n");
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -162,6 +172,8 @@ TEST_CASE("Files getFilesInDir")
REQUIRE(list[3] == "perserver/default/features.xml");
REQUIRE(list[4] == "perserver/default/weapons.xml");
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/fs/virtfs/virtfs.cpp b/src/fs/virtfs/virtfs.cpp
index 3d223ccba..f9fcdcf8b 100644
--- a/src/fs/virtfs/virtfs.cpp
+++ b/src/fs/virtfs/virtfs.cpp
@@ -144,23 +144,41 @@ namespace VirtFs
bool addDirToSearchPath(const std::string &restrict newDir,
const Append append)
{
+#ifdef UNITTESTS
+ return VirtFsDir::addToSearchPathSilent(newDir,
+ append,
+ SkipError_false);
+#else // UNITTESTS
return VirtFsDir::addToSearchPath(newDir, append);
+#endif // UNITTESTS
}
bool removeDirFromSearchPath(const std::string &restrict oldDir)
{
+#ifdef UNITTESTS
+ return VirtFsDir::removeFromSearchPathSilent(oldDir);
+#else // UNITTESTS
return VirtFsDir::removeFromSearchPath(oldDir);
+#endif // UNITTESTS
}
bool addZipToSearchPath(const std::string &restrict newDir,
const Append append)
{
+#ifdef UNITTESTS
+ return VirtFsZip::addToSearchPathSilent(newDir, append);
+#else // UNITTESTS
return VirtFsZip::addToSearchPath(newDir, append);
+#endif // UNITTESTS
}
bool removeZipFromSearchPath(const std::string &restrict oldDir)
{
+#ifdef UNITTESTS
+ return VirtFsZip::removeFromSearchPathSilent(oldDir);
+#else // UNITTESTS
return VirtFsZip::removeFromSearchPath(oldDir);
+#endif // UNITTESTS
}
std::string getRealDir(std::string filename)
diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc
index 4e2244a2f..0dd8af585 100644
--- a/src/gui/widgets/browserbox_unittest.cc
+++ b/src/gui/widgets/browserbox_unittest.cc
@@ -175,6 +175,8 @@ TEST_CASE("BrowserBox tests", "browserbox")
Widget::setGlobalFont(nullptr);
delete box;
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc
index 902068376..38471370d 100644
--- a/src/gui/windowmanager_unittest.cc
+++ b/src/gui/windowmanager_unittest.cc
@@ -690,6 +690,10 @@ TEST_CASE("Windows tests", "windowmanager")
delete2(inventoryHandler);
delete2(charServerHandler);
delete2(playerHandler);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
+ VirtFs::removeDirFromSearchPath("data/test");
+ VirtFs::removeDirFromSearchPath("../data/test");
delete2(logger);
// VirtFs::deinit();
diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc
index 58e22772a..73ee5cee3 100644
--- a/src/integrity_unittest.cc
+++ b/src/integrity_unittest.cc
@@ -221,7 +221,7 @@ TEST_CASE("integrity tests", "integrity")
VirtFs::addZipToSearchPath("data/test/test.zip", Append_false);
VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false);
Image *const image = Loader::getImage(
- "hide.png");
+ "dir/hide.png");
VirtFs::removeZipFromSearchPath("data/test/test.zip");
VirtFs::removeZipFromSearchPath("../data/test/test.zip");
REQUIRE(image != nullptr);
@@ -259,7 +259,11 @@ TEST_CASE("integrity tests", "integrity")
SDL_RWclose(rw);
VirtFs::removeZipFromSearchPath("data/test/test.zip");
VirtFs::removeZipFromSearchPath("../data/test/test.zip");
+ VirtFs::addDirToSearchPath("data/test", Append_true);
+ VirtFs::addDirToSearchPath("../data/test", Append_true);
REQUIRE(compareBuffers(buf) == true);
+ VirtFs::removeDirFromSearchPath("data/test");
+ VirtFs::removeDirFromSearchPath("../data/test");
}
#ifdef USE_PHYSFS
@@ -403,7 +407,11 @@ TEST_CASE("integrity tests", "integrity")
VirtFs::removeZipFromSearchPath("data/test/test.zip");
VirtFs::removeZipFromSearchPath("../data/test/test.zip");
+ VirtFs::addDirToSearchPath("data/test", Append_true);
+ VirtFs::addDirToSearchPath("../data/test", Append_true);
REQUIRE(compareBuffers(buf) == true);
+ VirtFs::removeDirFromSearchPath("data/test");
+ VirtFs::removeDirFromSearchPath("../data/test");
}
#endif // USE_PHYSFS
@@ -439,7 +447,11 @@ TEST_CASE("integrity tests", "integrity")
SDL_RWclose(rw);
VirtFs::removeZipFromSearchPath("data/test/test.zip");
VirtFs::removeZipFromSearchPath("../data/test/test.zip");
+ VirtFs::addDirToSearchPath("data/test", Append_true);
+ VirtFs::addDirToSearchPath("../data/test", Append_true);
REQUIRE(compareBuffers(buf) == true);
+ VirtFs::removeDirFromSearchPath("data/test");
+ VirtFs::removeDirFromSearchPath("../data/test");
}
SECTION("integrity Loader::getImage test 8")
@@ -498,6 +510,8 @@ TEST_CASE("integrity tests", "integrity")
delete client;
client = nullptr;
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc
index d562118b3..cc368d865 100644
--- a/src/resources/dye/dye_unittest.cc
+++ b/src/resources/dye/dye_unittest.cc
@@ -2359,6 +2359,8 @@ TEST_CASE("Dye real dye")
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
ResourceManager::init();
+ VirtFs::addDirToSearchPath("data", Append_false);
+ VirtFs::addDirToSearchPath("../data", Append_false);
VirtFs::addDirToSearchPath("data/test", Append_false);
VirtFs::addDirToSearchPath("../data/test", Append_false);
@@ -2392,6 +2394,10 @@ TEST_CASE("Dye real dye")
dyeCheck("|A:#0000FFFF,FF000050", "arrow_up_A.png");
}
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
+ VirtFs::removeDirFromSearchPath("data/test");
+ VirtFs::removeDirFromSearchPath("../data/test");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/resources/dye/dyepalette_unittest.cc b/src/resources/dye/dyepalette_unittest.cc
index 285ac22a8..7df69e952 100644
--- a/src/resources/dye/dyepalette_unittest.cc
+++ b/src/resources/dye/dyepalette_unittest.cc
@@ -60,6 +60,8 @@ TEST_CASE("DyePalette tests")
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
ResourceManager::init();
+ VirtFs::addDirToSearchPath("data", Append_false);
+ VirtFs::addDirToSearchPath("../data", Append_false);
VirtFs::addDirToSearchPath("data/test", Append_false);
VirtFs::addDirToSearchPath("../data/test", Append_false);
@@ -382,6 +384,10 @@ TEST_CASE("DyePalette tests")
REQUIRE(palette.mColors[0].value[3] == 0x77);
}
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
+ VirtFs::removeDirFromSearchPath("data/test");
+ VirtFs::removeDirFromSearchPath("../data/test");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/resources/map/maplayer_unittest.cc b/src/resources/map/maplayer_unittest.cc
index 34a0f128b..a3978b1e2 100644
--- a/src/resources/map/maplayer_unittest.cc
+++ b/src/resources/map/maplayer_unittest.cc
@@ -1994,6 +1994,8 @@ TEST_CASE("MapLayer drawSpecialLayer (specialLayer)")
delete map;
delete mock;
GraphicsManager::deleteRenderers();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
}
@@ -2351,6 +2353,8 @@ TEST_CASE("MapLayer drawSpecialLayer (tempLayer)")
delete map;
delete mock;
GraphicsManager::deleteRenderers();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
}
@@ -3236,5 +3240,7 @@ TEST_CASE("MapLayer drawFringe")
delete mock;
delete2(theme);
GraphicsManager::deleteRenderers();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
}
diff --git a/src/resources/map/speciallayer_unittest.cc b/src/resources/map/speciallayer_unittest.cc
index cf6c17120..223d05b4e 100644
--- a/src/resources/map/speciallayer_unittest.cc
+++ b/src/resources/map/speciallayer_unittest.cc
@@ -262,5 +262,7 @@ TEST_CASE("SpecialLayer updateCache")
delete layer;
resourceManager->cleanOrphans();
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
}
diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc
index 6613a42c1..fa0a07b76 100644
--- a/src/resources/resourcemanager/resourcemanager_unittest.cc
+++ b/src/resources/resourcemanager/resourcemanager_unittest.cc
@@ -660,6 +660,8 @@ TEST_CASE("resourcemanager", "resourcemanager")
delete resourceManager;
resourceManager = safeResman;
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/resources/sprite/animatedsprite_unittest.cc b/src/resources/sprite/animatedsprite_unittest.cc
index 8d31125f5..85a1c3e87 100644
--- a/src/resources/sprite/animatedsprite_unittest.cc
+++ b/src/resources/sprite/animatedsprite_unittest.cc
@@ -182,6 +182,8 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
}
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/utils/chatutils_unittest.cc b/src/utils/chatutils_unittest.cc
index fc9677c30..421798227 100644
--- a/src/utils/chatutils_unittest.cc
+++ b/src/utils/chatutils_unittest.cc
@@ -238,6 +238,8 @@ TEST_CASE("chatutils replaceVars")
delete2(actorManager);
delete2(localPlayer);
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc
index 82a15fdff..b0fdbf0de 100644
--- a/src/utils/stringutils_unittest.cc
+++ b/src/utils/stringutils_unittest.cc
@@ -1615,9 +1615,13 @@ TEST_CASE("stringuntils replaceItemLinks")
REQUIRE(str == "[[test name 1 ,test name2[] test name 1]");
}
ResourceManager::deleteInstance();
- delete2(logger);
delete_all(infos);
infos.clear();
namedInfos.clear();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
+ VirtFs::removeDirFromSearchPath("data/test");
+ VirtFs::removeDirFromSearchPath("../data/test");
+ delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/utils/translation/poparser_unittest.cc b/src/utils/translation/poparser_unittest.cc
index f8f536f88..9182bebbc 100644
--- a/src/utils/translation/poparser_unittest.cc
+++ b/src/utils/translation/poparser_unittest.cc
@@ -123,6 +123,8 @@ TEST_CASE("PoParser tests", "PoParser")
delete dict;
}
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc
index fc40f4439..f5211bcb5 100644
--- a/src/utils/xml_unittest.cc
+++ b/src/utils/xml_unittest.cc
@@ -359,6 +359,9 @@ TEST_CASE("xml doc")
}
delete2(theme);
delete2(client);
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
+
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/utils/xmlutils_unittest.cc b/src/utils/xmlutils_unittest.cc
index b3b9cba81..dff0b130c 100644
--- a/src/utils/xmlutils_unittest.cc
+++ b/src/utils/xmlutils_unittest.cc
@@ -45,6 +45,8 @@ TEST_CASE("xmlutils readXmlIntVector 1")
XML::initXML();
logger = new Logger();
ResourceManager::init();
+ VirtFs::addDirToSearchPath("data", Append_false);
+ VirtFs::addDirToSearchPath("../data", Append_false);
mainGraphics = new SDLGraphics;
imageHelper = new SDLImageHelper();
@@ -59,9 +61,6 @@ TEST_CASE("xmlutils readXmlIntVector 1")
ActorSprite::load();
- VirtFs::addDirToSearchPath("data", Append_false);
- VirtFs::addDirToSearchPath("../data", Append_false);
-
std::vector<int> arr;
readXmlIntVector("graphics/gui/browserbox.xml",
@@ -80,6 +79,8 @@ TEST_CASE("xmlutils readXmlIntVector 1")
REQUIRE(1 == arr[4]);
delete2(client);
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -91,6 +92,8 @@ TEST_CASE("xmlutils readXmlStringMap 1")
XML::initXML();
logger = new Logger();
ResourceManager::init();
+ VirtFs::addDirToSearchPath("data", Append_false);
+ VirtFs::addDirToSearchPath("../data", Append_false);
mainGraphics = new SDLGraphics;
imageHelper = new SDLImageHelper();
@@ -105,9 +108,6 @@ TEST_CASE("xmlutils readXmlStringMap 1")
ActorSprite::load();
- VirtFs::addDirToSearchPath("data", Append_false);
- VirtFs::addDirToSearchPath("../data", Append_false);
-
std::map<std::string, std::string> arr;
readXmlStringMap("graphics/sprites/manaplus_emotes.xml",
@@ -125,6 +125,8 @@ TEST_CASE("xmlutils readXmlStringMap 1")
REQUIRE(arr["Metal"] == "26");
delete2(client);
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -136,6 +138,10 @@ TEST_CASE("xmlutils readXmlIntMap 1")
XML::initXML();
logger = new Logger();
ResourceManager::init();
+ VirtFs::addDirToSearchPath("data", Append_false);
+ VirtFs::addDirToSearchPath("../data", Append_false);
+ VirtFs::addDirToSearchPath("data/test", Append_false);
+ VirtFs::addDirToSearchPath("../data/test", Append_false);
mainGraphics = new SDLGraphics;
imageHelper = new SDLImageHelper();
@@ -150,9 +156,6 @@ TEST_CASE("xmlutils readXmlIntMap 1")
ActorSprite::load();
- VirtFs::addDirToSearchPath("data/test", Append_false);
- VirtFs::addDirToSearchPath("../data/test", Append_false);
-
std::map<int32_t, int32_t> arr;
readXmlIntMap("testintmap.xml",
@@ -170,6 +173,10 @@ TEST_CASE("xmlutils readXmlIntMap 1")
REQUIRE(arr[3] == 0);
delete2(client);
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data/test");
+ VirtFs::removeDirFromSearchPath("../data/test");
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}