test: added gif save test

Skipped capi tests this time, since it has no saver api now.
This commit is contained in:
Hermet Park 2023-11-17 15:54:14 +09:00 committed by Hermet Park
parent 25513b591a
commit ab35ab2171
3 changed files with 52 additions and 0 deletions

View file

@ -101,4 +101,14 @@ TEST_CASE("Synchronize a Saver", "[capiSaver]")
REQUIRE(tvg_saver_del(saver) == TVG_RESULT_SUCCESS);
}
#endif
#ifdef THORVG_GIF_SAVER_SUPPORT
TEST_CASE("Save a lottie into gif", "[capiSavers]")
{
//TODO: GIF Save Test
}
#endif

Binary file not shown.

View file

@ -97,4 +97,46 @@ TEST_CASE("Save scene into tvg", "[tvgSavers]")
free(data);
}
#endif
#ifdef THORVG_GIF_SAVER_SUPPORT
TEST_CASE("Save a lottie into gif", "[tvgSavers]")
{
REQUIRE(Initializer::init(0) == Result::Success);
auto animation = Animation::gen();
REQUIRE(animation);
auto picture = animation->picture();
REQUIRE(picture);
REQUIRE(picture->load(TEST_DIR"/test.json") == Result::Success);
REQUIRE(picture->size(100, 100) == Result::Success);
auto saver = Saver::gen();
REQUIRE(saver);
REQUIRE(saver->save(std::move(animation), TEST_DIR"/test.gif") == Result::Success);
REQUIRE(saver->sync() == Result::Success);
//with a background
auto animation2 = Animation::gen();
REQUIRE(animation2);
auto picture2 = animation2->picture();
REQUIRE(picture2);
REQUIRE(picture2->load(TEST_DIR"/test.json") == Result::Success);
REQUIRE(picture2->size(100, 100) == Result::Success);
auto bg = Shape::gen();
REQUIRE(bg->fill(255, 255, 255) == Result::Success);
REQUIRE(bg->appendRect(0, 0, 100, 100) == Result::Success);
REQUIRE(saver->background(std::move(bg)) == Result::Success);
REQUIRE(saver->save(std::move(animation2), TEST_DIR"/test.gif") == Result::Success);
REQUIRE(saver->sync() == Result::Success);
REQUIRE(Initializer::term() == Result::Success);
}
#endif