From: subhransu mohanty Date: Mon, 10 Sep 2018 05:54:15 +0000 (+0900) Subject: lottie/test: added new unit test cases for library. X-Git-Tag: submit/tizen/20180917.042405~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F188758%2F2;p=platform%2Fcore%2Fuifw%2Flottie-player.git lottie/test: added new unit test cases for library. Change-Id: I1c9d61d98a1028601a36c4e6118b7109d88b2ace --- diff --git a/test/meson.build b/test/meson.build index 6861208..8a83c86 100644 --- a/test/meson.build +++ b/test/meson.build @@ -14,6 +14,7 @@ test('Vector Testsuite', vector_testsuite) animation_test_sources = files('testsuite.cpp') animation_test_sources += files('test_lottieanimation.cpp') +animation_test_sources += files('test_lottieanimation_capi.cpp') animation_testsuite = executable('animationTestSuite', animation_test_sources, diff --git a/test/test_lottieanimation.cpp b/test/test_lottieanimation.cpp index e69de29..ee4d8a1 100644 --- a/test/test_lottieanimation.cpp +++ b/test/test_lottieanimation.cpp @@ -0,0 +1,34 @@ +#include +#include "lottieanimation.h" + +class AnimationTest : public ::testing::Test { +public: + void SetUp() + { + animationInvalid = lottie::Animation::loadFromFile("wrong_file.json"); + std::string filePath = DEMO_DIR; + filePath +="mask.json"; + animation = lottie::Animation::loadFromFile(filePath); + + } + void TearDown() + { + + } +public: + std::unique_ptr animationInvalid; + std::unique_ptr animation; +}; + +TEST_F(AnimationTest, loadFromFile_N) { + ASSERT_FALSE(animationInvalid); +} + +TEST_F(AnimationTest, loadFromFile) { + ASSERT_TRUE(animation); + ASSERT_EQ(animation->totalFrame(), 29); + size_t width, height; + animation->size(width, height); + ASSERT_EQ(width, 500); + ASSERT_EQ(height, 500); +} diff --git a/test/test_lottieanimation_capi.cpp b/test/test_lottieanimation_capi.cpp new file mode 100644 index 0000000..1889621 --- /dev/null +++ b/test/test_lottieanimation_capi.cpp @@ -0,0 +1,34 @@ +#include +#include "lottieanimation_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), 29); + size_t width, height; + lottie_animation_get_size(animation, &width, &height); + ASSERT_EQ(width, 500); + ASSERT_EQ(height, 500); +} diff --git a/test/test_vpath.cpp b/test/test_vpath.cpp index a01b4c2..8ae7e96 100644 --- a/test/test_vpath.cpp +++ b/test/test_vpath.cpp @@ -12,7 +12,11 @@ public: 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() { @@ -27,7 +31,11 @@ public: VPath pathOval; VPath pathOvalCircle; VPath pathCircle; + VPath pathCircleZeroRadius; VPath pathPolygon; + VPath pathPolystar; + VPath pathPolygonZero; + VPath pathPolystarZero; }; TEST_F(VPathTest, emptyPath) { @@ -139,9 +147,43 @@ TEST_F(VPathTest, addCircle) { 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()); +}