CVcmiTestConfig.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * CVcmiTestConfig.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "CVcmiTestConfig.h"
  12. #include "../lib/logging/CBasicLogConfigurator.h"
  13. #include "../lib/VCMIDirs.h"
  14. #include "../lib/GameLibrary.h"
  15. #include "../lib/logging/CLogger.h"
  16. #include "../lib/CConfigHandler.h"
  17. #include "../lib/filesystem/Filesystem.h"
  18. #include "../lib/filesystem/CFilesystemLoader.h"
  19. #include "../lib/filesystem/AdapterLoaders.h"
  20. void CVcmiTestConfig::SetUp()
  21. {
  22. LIBRARY = new GameLibrary;
  23. LIBRARY->initializeFilesystem(false);
  24. LIBRARY->initializeLibrary();
  25. /* TEST_DATA_DIR may be wrong, if yes below test don't run,
  26. find your test data folder in your build and change TEST_DATA_DIR for it*/
  27. const std::string TEST_DATA_DIR = "test/testdata/";
  28. auto path = boost::filesystem::current_path();
  29. path+= "/" + TEST_DATA_DIR;
  30. if(boost::filesystem::exists(path)){
  31. auto loader = std::make_unique<CFilesystemLoader>("test/", TEST_DATA_DIR);
  32. dynamic_cast<CFilesystemList*>(CResourceHandler::get("core"))->addLoader(std::move(loader), false);
  33. loader = std::make_unique<CFilesystemLoader>("scripts/test/erm/", TEST_DATA_DIR+"erm/");
  34. dynamic_cast<CFilesystemList*>(CResourceHandler::get("core"))->addLoader(std::move(loader), false);
  35. loader = std::make_unique<CFilesystemLoader>("scripts/test/lua/", TEST_DATA_DIR+"lua/");
  36. dynamic_cast<CFilesystemList*>(CResourceHandler::get("core"))->addLoader(std::move(loader), false);
  37. }
  38. }
  39. void CVcmiTestConfig::TearDown()
  40. {
  41. std::cout << "Ending global test tear-down." << std::endl;
  42. }