test: coverage enhancement

+ Accessor::id()
+ Picture::paint()
This commit is contained in:
Hermet Park 2024-08-06 11:08:32 +09:00 committed by Hermet Park
parent 92303e91b4
commit 19b21852e3
3 changed files with 10041 additions and 3 deletions

File diff suppressed because one or more lines are too long

View file

@ -58,19 +58,27 @@ TEST_CASE("Set", "[tvgAccessor]")
REQUIRE(accessor->set(picture.get(), nullptr, nullptr) == Result::InvalidArguments);
//Case 2
Shape* ret = nullptr;
auto f = [](const tvg::Paint* paint, void* data) -> bool
{
if (paint->type() == Type::Shape) {
auto shape = (tvg::Shape*) paint;
uint8_t r, g, b;
shape->fillColor(&r, &g, &b);
if (r == 37 && g == 47 && b == 53)
if (r == 37 && g == 47 && b == 53) {
shape->fill(0, 0, 255);
shape->id = Accessor::id("TestAccessor");
*static_cast<Shape**>(data) = shape;
return false;
}
}
return true;
};
REQUIRE(accessor->set(picture.get(), f, nullptr) == Result::Success);
REQUIRE(accessor->set(picture.get(), f, &ret) == Result::Success);
REQUIRE((ret && ret->id == Accessor::id("TestAccessor")));
REQUIRE(Initializer::term() == Result::Success);
}

View file

@ -115,6 +115,13 @@ TEST_CASE("Animation Lottie2", "[tvgAnimation]")
REQUIRE(picture->load(TEST_DIR"/test2.json") == Result::Success);
//Find specific paint nodes
REQUIRE(!picture->paint(Accessor::id("test1")));
REQUIRE(!picture->paint(Accessor::id("abcd")));
REQUIRE(!picture->paint(Accessor::id("abcd")));
REQUIRE(picture->paint(Accessor::id("bar")));
REQUIRE(picture->paint(Accessor::id("pad1")));
REQUIRE(animation->frame(20.0f) == Result::Success);
REQUIRE(Initializer::term() == Result::Success);