mirror of
https://gitlab.com/splashmapper/splash.git
synced 2026-02-12 06:50:49 +01:00
67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
#include <filesystem>
|
|
#include <stdlib.h>
|
|
#include <string>
|
|
|
|
#include <doctest.h>
|
|
|
|
#include "./config.h"
|
|
#include "./core/constants.h"
|
|
#include "./core/factory.h"
|
|
#include "./image/image.h"
|
|
#include "./image/image_ffmpeg.h"
|
|
#include "./utils/osutils.h"
|
|
|
|
using namespace Splash;
|
|
namespace fs = std::filesystem;
|
|
|
|
/*************/
|
|
TEST_CASE("Testing Factory subtype evaluation")
|
|
{
|
|
auto factory = Factory();
|
|
CHECK(factory.isSubtype<Image>("image_ffmpeg"));
|
|
}
|
|
|
|
/*************/
|
|
TEST_CASE("Testing Factory default values")
|
|
{
|
|
if (!Utils::ensureConfigurationHomeExists())
|
|
return;
|
|
|
|
const auto filename = Utils::cleanPath(Utils::getHomeConfigurationPath() + "/" + Constants::DEFAULTS_FILENAME);
|
|
const std::string defaultFile = "./data/splashrc.json";
|
|
|
|
const bool defaultExists = fs::exists(filename);
|
|
if (defaultExists)
|
|
fs::rename(filename, filename + ".tmp");
|
|
|
|
fs::copy(defaultFile, filename);
|
|
|
|
auto factory = Factory();
|
|
auto defaults = factory.getDefaults();
|
|
REQUIRE_NE(defaults.find("image"), defaults.end());
|
|
auto imageDefaultsIt = defaults.find("image");
|
|
CHECK_NE(imageDefaultsIt->second.find("flip"), imageDefaultsIt->second.end());
|
|
|
|
if (defaultExists)
|
|
fs::rename(filename + ".tmp", filename);
|
|
}
|
|
|
|
/*************/
|
|
TEST_CASE("Testing Factory getters")
|
|
{
|
|
auto factory = Factory();
|
|
auto types = factory.getObjectTypes();
|
|
CHECK(!types.empty());
|
|
CHECK(!factory.getObjectsOfCategory(GraphObject::Category::MISC).empty());
|
|
CHECK(!factory.getObjectsOfCategory(GraphObject::Category::IMAGE).empty());
|
|
CHECK(!factory.getObjectsOfCategory(GraphObject::Category::MESH).empty());
|
|
CHECK(!factory.getObjectsOfCategory(GraphObject::Category::TEXTURE).empty());
|
|
|
|
for (const auto& type : types)
|
|
{
|
|
CHECK(!factory.getShortDescription(type).empty());
|
|
CHECK(!factory.getDescription(type).empty());
|
|
CHECK(factory.isCreatable(type));
|
|
}
|
|
}
|