image asset

This commit is contained in:
2018-11-28 00:14:30 +07:00
parent ce8cea357d
commit 00b92d2d3a
9 changed files with 71 additions and 14 deletions

3
untests/bin/library/image.png Executable file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:65cbe87077ff41bd595d1e17d68240e3e18972ea0c018707d35c695d86389b0d
size 3513

View File

@@ -14,6 +14,7 @@ TEST_CASE("library"){
modules::initialize<render>(the<debug>(), the<window>());
modules::initialize<library>(url{"resources://bin/library"});
modules::initialize<asset_cache<text_asset>>(the<library>());
modules::initialize<asset_cache<image_asset>>(the<library>());
modules::initialize<asset_cache<binary_asset>>(the<library>());
{
the<debug>().register_sink<debug_console_sink>();
@@ -66,7 +67,26 @@ TEST_CASE("library"){
the<asset_cache<binary_asset>>().unload_unused_assets();
REQUIRE(the<asset_cache<binary_asset>>().asset_count() == 0);
}
{
library& l = the<library>();
auto image_res = l.load_asset<image_asset>("image.png");
REQUIRE(image_res);
REQUIRE(!image_res->content().empty());
REQUIRE(the<asset_cache<image_asset>>().find("image.png"));
REQUIRE(the<asset_cache<binary_asset>>().find("image.png"));
the<asset_cache<binary_asset>>().unload_unused_assets();
REQUIRE(the<asset_cache<image_asset>>().find("image.png"));
REQUIRE_FALSE(the<asset_cache<binary_asset>>().find("image.png"));
image_res.reset();
the<asset_cache<image_asset>>().unload_unused_assets();
REQUIRE_FALSE(the<asset_cache<image_asset>>().find("image.png"));
REQUIRE_FALSE(the<asset_cache<binary_asset>>().find("image.png"));
}
modules::shutdown<asset_cache<binary_asset>>();
modules::shutdown<asset_cache<image_asset>>();
modules::shutdown<asset_cache<text_asset>>();
modules::shutdown<library>();
modules::shutdown<render>();