summaryrefslogtreecommitdiff
path: root/test/test-assetFactory.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 18:03:34 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 18:03:34 +0100
commit5776a36b454fac04617313da011d7aa2b0e834d3 (patch)
tree1eb96d07e9a17a51e5763f397fc003f762cd2e75 /test/test-assetFactory.cpp
parentMerge branch 'model-factory-textures' (diff)
parentAdd an asset template and use it to define all the foliage assets in the plan... (diff)
downloadilt-5776a36b454fac04617313da011d7aa2b0e834d3.tar.bz2
ilt-5776a36b454fac04617313da011d7aa2b0e834d3.tar.xz
ilt-5776a36b454fac04617313da011d7aa2b0e834d3.zip
Merge branch 'assimp'
Diffstat (limited to 'test/test-assetFactory.cpp')
-rw-r--r--test/test-assetFactory.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp
index 54168aa..3d79213 100644
--- a/test/test-assetFactory.cpp
+++ b/test/test-assetFactory.cpp
@@ -8,6 +8,8 @@
#include "assetFactory/assetFactory.h"
#include "assetFactory/object.h"
#include "assetFactory/texturePacker.h"
+#include "game/scenary/foliage.h"
+#include "game/scenary/plant.h"
#include "game/vehicles/railVehicle.h"
#include "game/vehicles/railVehicleClass.h"
#include "gfx/gl/sceneRenderer.h"
@@ -30,7 +32,7 @@ public:
glDisable(GL_DEBUG_OUTPUT);
auto outpath = (TMP / boost::unit_test::framework::current_test_case().full_name()).replace_extension(".tga");
std::filesystem::create_directories(outpath.parent_path());
- Texture::save(outImage, size, outpath.c_str());
+ Texture::save(outImage, outpath.c_str());
}
void
content(const SceneShader & shader) const override
@@ -96,8 +98,30 @@ BOOST_AUTO_TEST_CASE(brush47xml, *boost::unit_test::timeout(5))
render();
}
+
+BOOST_AUTO_TEST_CASE(foliage, *boost::unit_test::timeout(5))
+{
+ auto mf = AssetFactory::loadXML(RESDIR "/foliage.xml");
+ BOOST_REQUIRE(mf);
+ auto tree_01_1 = mf->assets.at("Tree-01-1");
+ BOOST_REQUIRE(tree_01_1);
+ auto tree_01_1_f = std::dynamic_pointer_cast<Foliage>(tree_01_1);
+ BOOST_REQUIRE(tree_01_1_f);
+
+ auto plant = std::make_shared<Plant>(tree_01_1_f, Location {{-2, 2, 0}, {}});
+ objects.objects.push_back(plant);
+
+ render(5);
+}
BOOST_AUTO_TEST_SUITE_END();
+BOOST_AUTO_TEST_CASE(loadall)
+{
+ const auto assets = AssetFactory::loadAll(RESDIR);
+ BOOST_CHECK(assets.at("brush-47"));
+ BOOST_CHECK(assets.at("Tree-01-1"));
+}
+
template<typename T> using InOut = std::tuple<T, T>;
BOOST_DATA_TEST_CASE(normalizeColourName,
boost::unit_test::data::make<InOut<std::string>>({
@@ -157,7 +181,7 @@ BOOST_AUTO_TEST_CASE(texturePacker_many, *boost::unit_test::timeout(5))
BOOST_CHECK_EQUAL(totalSize, TexturePacker::area(result.second));
}
-BOOST_AUTO_TEST_CASE(texturePacker_many_random, *boost::unit_test::timeout(5))
+BOOST_AUTO_TEST_CASE(texturePacker_many_random, *boost::unit_test::timeout(15))
{
std::vector<TexturePacker::Image> images(2048);
std::mt19937 gen(std::random_device {}());