lottie/test: added new unit test cases for library. 58/188758/2
authorsubhransu mohanty <sub.mohanty@samsung.com>
Mon, 10 Sep 2018 05:54:15 +0000 (14:54 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Mon, 10 Sep 2018 06:17:42 +0000 (15:17 +0900)
Change-Id: I1c9d61d98a1028601a36c4e6118b7109d88b2ace

test/meson.build
test/test_lottieanimation.cpp
test/test_lottieanimation_capi.cpp [new file with mode: 0644]
test/test_vpath.cpp

index 6861208..8a83c86 100644 (file)
@@ -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,
index e69de29..ee4d8a1 100644 (file)
@@ -0,0 +1,34 @@
+#include <gtest/gtest.h>
+#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<lottie::Animation> animationInvalid;
+    std::unique_ptr<lottie::Animation> 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 (file)
index 0000000..1889621
--- /dev/null
@@ -0,0 +1,34 @@
+#include <gtest/gtest.h>
+#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);
+}
index a01b4c2..8ae7e96 100644 (file)
@@ -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());
+}