CVcmiTestConfig.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. preinitDLL(true);
  23. loadDLLClasses(true);
  24. /* TEST_DATA_DIR may be wrong, if yes below test don't run,
  25. find your test data folder in your build and change TEST_DATA_DIR for it*/
  26. const std::string TEST_DATA_DIR = "test/testdata/";
  27. auto path = boost::filesystem::current_path();
  28. path+= "/" + TEST_DATA_DIR;
  29. if(boost::filesystem::exists(path)){
  30. auto loader = new CFilesystemLoader("test/", TEST_DATA_DIR);
  31. dynamic_cast<CFilesystemList*>(CResourceHandler::get("core"))->addLoader(loader, false);
  32. loader = new CFilesystemLoader("scripts/test/erm/", TEST_DATA_DIR+"erm/");
  33. dynamic_cast<CFilesystemList*>(CResourceHandler::get("core"))->addLoader(loader, false);
  34. loader = new CFilesystemLoader("scripts/test/lua/", TEST_DATA_DIR+"lua/");
  35. dynamic_cast<CFilesystemList*>(CResourceHandler::get("core"))->addLoader(loader, false);
  36. }
  37. }
  38. void CVcmiTestConfig::TearDown()
  39. {
  40. std::cout << "Ending global test tear-down." << std::endl;
  41. }