init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
allhaileris
2026-02-16 15:50:16 +03:00
commit afb81b8278
13816 changed files with 3689732 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
project(rlottie_tests CXX)
find_package(GTest REQUIRED)
add_definitions(-DDEMO_DIR="${CMAKE_SOURCE_DIR}/example/resource/")
link_libraries(GTest::GTest GTest::Main)
add_executable(vectorTestSuite testsuite.cpp test_vrect.cpp test_vpath.cpp
${CMAKE_SOURCE_DIR}/src/vector/vbezier.cpp
${CMAKE_SOURCE_DIR}/src/vector/vdebug.cpp
${CMAKE_SOURCE_DIR}/src/vector/vmatrix.cpp
${CMAKE_SOURCE_DIR}/src/vector/vpath.cpp
${CMAKE_SOURCE_DIR}/src/vector/pixman/vregion.cpp)
target_include_directories(vectorTestSuite PRIVATE ${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src/vector ${CMAKE_SOURCE_DIR}/src/vector/pixman)
gtest_add_tests(vectorTestSuite "" AUTO)
add_executable(animationTestSuite testsuite.cpp
test_lottieanimation.cpp test_lottieanimation_capi.cpp)
target_include_directories(animationTestSuite PRIVATE ${CMAKE_SOURCE_DIR}/inc)
target_link_libraries(animationTestSuite PRIVATE rlottie)
gtest_add_tests(animationTestSuite "" AUTO)

View File

@@ -0,0 +1,36 @@
override_default = ['warning_level=2', 'werror=false']
gtest_dep = dependency('gtest')
vector_test_sources = [
'testsuite.cpp',
'test_vrect.cpp',
'test_vpath.cpp',
]
vector_testsuite = executable('vectorTestSuite',
vector_test_sources,
include_directories : inc,
override_options : override_default,
dependencies : [gtest_dep, rlottie_lib_dep],
)
test('Vector Testsuite', vector_testsuite)
animation_test_sources = [
'testsuite.cpp',
'test_lottieanimation.cpp',
'test_lottieanimation_capi.cpp'
]
animation_testsuite = executable('animationTestSuite',
animation_test_sources,
include_directories : inc,
override_options : override_default,
link_with : rlottie_lib,
dependencies : gtest_dep,
)
test('Animation Testsuite', animation_testsuite)

View File

@@ -0,0 +1,34 @@
#include <gtest/gtest.h>
#include "rlottie.h"
class AnimationTest : public ::testing::Test {
public:
void SetUp()
{
animationInvalid = rlottie::Animation::loadFromFile("wrong_file.json");
std::string filePath = DEMO_DIR;
filePath +="mask.json";
animation = rlottie::Animation::loadFromFile(filePath);
}
void TearDown()
{
}
public:
std::unique_ptr<rlottie::Animation> animationInvalid;
std::unique_ptr<rlottie::Animation> animation;
};
TEST_F(AnimationTest, loadFromFile_N) {
ASSERT_FALSE(animationInvalid);
}
TEST_F(AnimationTest, loadFromFile) {
ASSERT_TRUE(animation != nullptr);
ASSERT_EQ(animation->totalFrame(), 30);
size_t width, height;
animation->size(width, height);
ASSERT_EQ(width, 500);
ASSERT_EQ(height, 500);
}

View File

@@ -0,0 +1,34 @@
#include <gtest/gtest.h>
#include "rlottie_capi.h"
class AnimationCApiTest : public ::testing::Test {
public:
void SetUp()
{
animationInvalid = lottie_animation_from_file("wrong_file.json");
std::string filePath = DEMO_DIR;
filePath +="mask.json";
animation = lottie_animation_from_file(filePath.c_str());
}
void TearDown()
{
if (animation) lottie_animation_destroy(animation);
}
public:
Lottie_Animation *animationInvalid;
Lottie_Animation *animation;
};
TEST_F(AnimationCApiTest, loadFromFile_N) {
ASSERT_FALSE(animationInvalid);
}
TEST_F(AnimationCApiTest, loadFromFile) {
ASSERT_TRUE(animation);
ASSERT_EQ(lottie_animation_get_totalframe(animation), 30);
size_t width, height;
lottie_animation_get_size(animation, &width, &height);
ASSERT_EQ(width, 500);
ASSERT_EQ(height, 500);
}

View File

@@ -0,0 +1,190 @@
#include <gtest/gtest.h>
#include "vpath.h"
class VPathTest : public ::testing::Test {
public:
void SetUp()
{
pathRect.addRect({-10, -20, 100, 100});
pathRoundRect.addRoundRect({0, 0, 100, 100}, 5, 5);
pathRoundRectZeroCorner.addRoundRect({0, 0, 100, 100}, 0, 0);
pathRoundRectHalfCircle.addRoundRect({0, 0, 100, 100}, 60, 60);
pathOval.addOval({0,0,100,50});
pathOvalCircle.addOval({0,0,100,100});
pathCircle.addCircle(0, 0, 100);
pathCircleZeroRadius.addCircle(10, 10, 0);
pathPolygon.addPolygon(10, 50, 5, 0, 0, 0);
pathPolystar.addPolystar(10, 50, 100, 7, 14, 0, 0, 0);
pathPolygonZero.addPolygon(10, 50, 0, 0, 0, 0);
pathPolystarZero.addPolystar(10, 50, 100, 0, 0, 0, 0, 0);
}
void TearDown()
{
}
public:
VPath pathEmpty;
VPath pathRect;
VPath pathRoundRect;
VPath pathRoundRectZeroCorner;
VPath pathRoundRectHalfCircle;
VPath pathOval;
VPath pathOvalCircle;
VPath pathCircle;
VPath pathCircleZeroRadius;
VPath pathPolygon;
VPath pathPolystar;
VPath pathPolygonZero;
VPath pathPolystarZero;
};
TEST_F(VPathTest, emptyPath) {
ASSERT_EQ(sizeof(pathEmpty), sizeof(void *));
ASSERT_TRUE(pathEmpty.empty());
ASSERT_FALSE(pathEmpty.segments());
ASSERT_EQ(pathEmpty.segments() , 0);
ASSERT_EQ(pathEmpty.elements().size() , 0);
ASSERT_EQ(pathEmpty.elements().capacity() , pathEmpty.elements().size());
ASSERT_EQ(pathEmpty.points().size() , 0);
ASSERT_EQ(pathEmpty.points().capacity() , pathEmpty.points().size());
}
TEST_F(VPathTest, reset) {
pathRect.reset();
ASSERT_TRUE(pathRect.empty());
ASSERT_EQ(pathRect.segments() , 0);
ASSERT_GE(pathRect.points().capacity(), 1);
ASSERT_GE(pathRect.elements().capacity(), 1);
}
TEST_F(VPathTest, reserve) {
pathEmpty.reserve(10, 10);
ASSERT_EQ(pathEmpty.points().capacity(), 10);
ASSERT_GE(pathEmpty.elements().capacity(), 10);
ASSERT_EQ(pathEmpty.segments() , 0);
ASSERT_EQ(pathEmpty.points().size(), 0);
ASSERT_GE(pathEmpty.elements().size(), 0);
}
TEST_F(VPathTest, clone) {
VPath pathClone;
pathClone.clone(pathOval);
ASSERT_TRUE(pathClone.unique());
ASSERT_EQ(pathClone.segments(), pathOval.segments());
ASSERT_EQ(pathClone.points().size(), pathOval.points().size());
ASSERT_NE(pathClone.points().data(), pathOval.points().data());
ASSERT_EQ(pathClone.elements().size(), pathOval.elements().size());
ASSERT_NE(pathClone.elements().data(), pathOval.elements().data());
}
TEST_F(VPathTest, copyOnWrite) {
VPath pathCopy;
pathCopy = pathOval;
ASSERT_EQ(pathCopy.segments(), pathOval.segments());
ASSERT_EQ(pathCopy.points().size(), pathOval.points().size());
ASSERT_EQ(pathCopy.points().data(), pathOval.points().data());
ASSERT_EQ(pathCopy.elements().size(), pathOval.elements().size());
ASSERT_EQ(pathCopy.elements().data(), pathOval.elements().data());
}
TEST_F(VPathTest, addRect) {
ASSERT_FALSE(pathRect.empty());
ASSERT_EQ(pathRect.segments() , 1);
ASSERT_EQ(pathRect.elements().capacity() , pathRect.elements().size());
ASSERT_EQ(pathRect.points().capacity() , pathRect.points().size());
}
TEST_F(VPathTest, addRect_N) {
pathEmpty.addRect({});
ASSERT_TRUE(pathEmpty.empty());
ASSERT_EQ(pathEmpty.segments() , 0);
}
TEST_F(VPathTest, addRoundRect) {
ASSERT_FALSE(pathRoundRect.empty());
ASSERT_EQ(pathRoundRect.segments() , 1);
ASSERT_EQ(pathRoundRect.elements().capacity() , pathRoundRect.elements().size());
ASSERT_EQ(pathRoundRect.points().capacity() , pathRoundRect.points().size());
}
TEST_F(VPathTest, addRoundRectZeoCorner) {
ASSERT_FALSE(pathRoundRectZeroCorner.empty());
ASSERT_EQ(pathRoundRectZeroCorner.segments() , 1);
ASSERT_EQ(pathRoundRectZeroCorner.elements().size() , pathRect.elements().size());
ASSERT_EQ(pathRoundRectZeroCorner.elements().capacity() , pathRoundRectZeroCorner.elements().size());
ASSERT_EQ(pathRoundRectZeroCorner.points().size() , pathRect.points().size());
ASSERT_EQ(pathRoundRectZeroCorner.points().capacity() , pathRoundRectZeroCorner.points().size());
}
TEST_F(VPathTest, addRoundRectHalfCircle) {
ASSERT_FALSE(pathRoundRectHalfCircle.empty());
ASSERT_EQ(pathRoundRectHalfCircle.segments() , 1);
ASSERT_EQ(pathRoundRectHalfCircle.elements().capacity() , pathRoundRectHalfCircle.elements().size());
ASSERT_EQ(pathRoundRectHalfCircle.points().capacity() , pathRoundRectHalfCircle.points().size());
}
TEST_F(VPathTest, addOval) {
ASSERT_FALSE(pathOval.empty());
ASSERT_EQ(pathOval.segments() , 1);
ASSERT_EQ(pathOval.elements().capacity() , pathOval.elements().size());
ASSERT_EQ(pathOval.points().capacity() , pathOval.points().size());
}
TEST_F(VPathTest, addOvalCircle) {
ASSERT_FALSE(pathOvalCircle.empty());
ASSERT_EQ(pathOvalCircle.segments() , 1);
ASSERT_EQ(pathOvalCircle.elements().size() , pathOval.elements().size());
ASSERT_EQ(pathOvalCircle.elements().capacity() , pathOvalCircle.elements().size());
ASSERT_EQ(pathOvalCircle.points().size() , pathOval.points().size());
ASSERT_EQ(pathOvalCircle.points().capacity() , pathOvalCircle.points().size());
}
TEST_F(VPathTest, addCircle) {
ASSERT_FALSE(pathCircle.empty());
ASSERT_EQ(pathCircle.segments() , 1);
ASSERT_EQ(pathCircle.elements().size() , pathOval.elements().size());
ASSERT_EQ(pathCircle.elements().capacity() , pathCircle.elements().size());
ASSERT_EQ(pathCircle.points().size() , pathOval.points().size());
ASSERT_EQ(pathCircle.points().capacity() , pathCircle.points().size());
}
TEST_F(VPathTest, addCircleZeroRadius) {
ASSERT_TRUE(pathCircleZeroRadius.empty());
ASSERT_EQ(pathCircleZeroRadius.segments() , 0);
}
TEST_F(VPathTest, length) {
ASSERT_EQ(pathRect.length(), 400);
}
TEST_F(VPathTest, lengthEmptyPath) {
ASSERT_EQ(pathEmpty.length(), 0);
}
TEST_F(VPathTest, addPolygon) {
ASSERT_FALSE(pathPolygon.empty());
ASSERT_EQ(pathPolygon.segments() , 1);
ASSERT_EQ(pathPolygon.elements().size() , pathPolygon.elements().capacity());
ASSERT_EQ(pathPolygon.points().size() , pathPolygon.points().capacity());
}
TEST_F(VPathTest, addPolygonZeroRoundness) {
ASSERT_FALSE(pathPolygonZero.empty());
ASSERT_EQ(pathPolygonZero.segments() , 1);
ASSERT_EQ(pathPolygonZero.elements().size() , pathPolygonZero.elements().capacity());
ASSERT_EQ(pathPolygonZero.points().size() , pathPolygonZero.points().capacity());
}
TEST_F(VPathTest, addPolystar) {
ASSERT_FALSE(pathPolystar.empty());
ASSERT_EQ(pathPolystar.segments() , 1);
ASSERT_EQ(pathPolystar.elements().size() , pathPolystar.elements().capacity());
ASSERT_EQ(pathPolystar.points().size() , pathPolystar.points().capacity());
}
TEST_F(VPathTest, addPolystarZeroRoundness) {
ASSERT_FALSE(pathPolystarZero.empty());
ASSERT_EQ(pathPolystarZero.segments() , 1);
ASSERT_EQ(pathPolystarZero.elements().size() , pathPolystarZero.elements().capacity());
ASSERT_EQ(pathPolystarZero.points().size() , pathPolystarZero.points().capacity());
}

View File

@@ -0,0 +1,58 @@
#include <gtest/gtest.h>
#include "vrect.h"
class VRectFTest : public ::testing::Test {
public:
void SetUp()
{
conersionRect = rect;
}
void TearDown()
{
}
public:
VRectF Empty;
VRectF illigal{0, 0, -100, 200};
VRectF conersionRect;
VRect rect{0, 0, 100, 100};
};
class VRectTest : public ::testing::Test {
public:
void SetUp()
{
conersionRect = rect;
}
void TearDown()
{
}
public:
VRect Empty;
VRect illigal{0, 0, -100, 200};
VRect conersionRect;
VRectF rect{0, 0, 100.5, 100};
};
TEST_F(VRectFTest, construct) {
VRectF r1{0, 0, 100, 100};
VRectF r2{0, 0, 100.0, 100};
VRectF r3 = {0, 0, 100, 100};
VRectF r4 = {0, 0, 100.0, 100};
VRectF r6(0, 0, 100, 100);
VRectF r7(0, 0, 100.0, 100);
ASSERT_TRUE(Empty.empty());
ASSERT_TRUE(illigal.empty());
}
TEST_F(VRectTest, construct) {
VRect r1{0, 0, 100, 100};
VRect r2{0, 0, 10, 100};
VRect r3 = {0, 0, 100, 100};
VRect r4 = {0, 0, 10, 100};
VRect r6(0, 0, 100, 100);
VRect r7(0, 0, 10, 100);
ASSERT_TRUE(Empty.empty());
ASSERT_TRUE(illigal.empty());
}

View File

@@ -0,0 +1,120 @@
#include <gtest/gtest.h>
#include"vregion.h"
#include"vdebug.h"
#include"vpoint.h"
class VRegionTest : public ::testing::Test {
public:
VRegionTest():rgn1(-10, -10, 20, 20)
{
}
void SetUp()
{
rect1 = VRect(-10, -10, 20, 20);
rect2 = VRect(-15, 5, 10, 10);
rgn2 += rect2;
rgn3 = rgn1;
}
void TearDown()
{
}
public:
VRegion emptyRgn;
VRegion rgn1;
VRegion rgn2;
VRegion rgn3;
VRect rect1;
VRect rect2;
VRect rect3;
};
TEST_F(VRegionTest, constructor) {
ASSERT_EQ(rgn1.rectCount() , 1);
ASSERT_TRUE(rgn1.rectAt(0) == rect1);
ASSERT_TRUE(rgn1==rgn3);
ASSERT_TRUE(rgn1!=rgn2);
}
TEST_F(VRegionTest, moveSemantics) {
// move assignment
rgn1 = rect1;
VRegion tmp;
tmp = std::move(rgn1);
ASSERT_TRUE(rgn1.empty());
// move construction
rgn1 = rect1;
VRegion mvrgn = std::move(rgn1);
ASSERT_TRUE(rgn1.empty());
ASSERT_TRUE(mvrgn == rect1);
}
TEST_F(VRegionTest, isEmpty) {
ASSERT_TRUE(emptyRgn.empty());
ASSERT_TRUE(emptyRgn == VRegion());
ASSERT_TRUE(emptyRgn.rectCount() == 0);
ASSERT_TRUE(emptyRgn.boundingRect() == VRect());
}
TEST_F(VRegionTest, boundingRect) {
{
VRect rect;
VRegion region(rect);
ASSERT_TRUE(region.boundingRect() == rect);
}
{
VRect rect(10, -20, 30, 40);
VRegion region(rect);
ASSERT_TRUE(region.boundingRect() == rect);
}
{
VRect rect(15,25,10,10);
VRegion region(rect);
ASSERT_TRUE(region.boundingRect() == rect);
}
}
TEST_F(VRegionTest, swap) {
VRegion r1(VRect(0, 0,10,10));
VRegion r2(VRect(10,10,10,10));
std::swap(r1 ,r2);
ASSERT_TRUE(r1.rectAt(0) == VRect(10,10,10,10));
ASSERT_TRUE(r2.rectAt(0) == VRect(0, 0,10,10));
}
TEST_F(VRegionTest, substracted) {
VRegion r1(VRect(0, 0,20,20));
VRegion r2 = r1.subtracted(VRect(5,5,5,5));
VRegion expected;
expected += VRect(0,0,20,5);
expected += VRect(0,5,5,5);
expected += VRect(10,5,10,5);
expected += VRect(0,10,20,10);
ASSERT_TRUE(r2.rectCount() == expected.rectCount());
ASSERT_TRUE(r2 == expected);
r2 += VRect(5,5,5,5);
ASSERT_TRUE(r2 == r1);
}
TEST_F(VRegionTest, translate) {
VRegion r1(VRect(0, 0,20,20));
VPoint offset(10,10);
VRegion r2 = r1.translated(offset);
r1.translate(offset);
ASSERT_TRUE(r2 == r2);
}
TEST_F(VRegionTest, intersects) {
VRegion r1(VRect(0, 0,20,20));
VRegion r2(VRect(20, 20,10,10));
ASSERT_FALSE(r1.intersects(r2));
r2 += VRect(5, 0,20,20);
ASSERT_TRUE(r1.intersects(r2));
}
TEST_F(VRegionTest, contains) {
VRegion r1(VRect(0, 0,20,20));
ASSERT_TRUE(r1.contains(VRect(5,5,10,10)));
ASSERT_FALSE(r1.contains(VRect(11,5,10,10)));
}

View File

@@ -0,0 +1,6 @@
#include <gtest/gtest.h>
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}