utc: increase coverage of picture and fill
authorMichal Maciola <m.maciola@samsung.com>
Thu, 19 Aug 2021 08:57:51 +0000 (10:57 +0200)
committerJunsuChoi <jsuya.choi@samsung.com>
Mon, 23 Aug 2021 01:21:39 +0000 (10:21 +0900)
test/testFill.cpp
test/testPicture.cpp

index c9bc189..115e051 100644 (file)
@@ -124,7 +124,48 @@ TEST_CASE("Radial Filling", "[tvgFill]")
     REQUIRE(radius == 0.0f);
 }
 
-TEST_CASE("Filling Dupliction", "[tvgFill]")
+TEST_CASE("Linear Filling Dupliction", "[tvgFill]")
+{
+    auto fill = LinearGradient::gen();
+    REQUIRE(fill);
+
+    //Setup
+    Fill::ColorStop cs[4] = {
+        {0.0f, 0, 0, 0, 0},
+        {0.2f, 50, 25, 50, 25},
+        {0.5f, 100, 100, 100, 125},
+        {1.0f, 255, 255, 255, 255}
+    };
+
+    REQUIRE(fill->colorStops(cs, 4) == Result::Success);
+    REQUIRE(fill->spread(FillSpread::Reflect) == Result::Success);
+    REQUIRE(fill->linear(-10.0f, 10.0f, 100.0f, 120.0f) == Result::Success);
+
+    //Duplication
+    auto dup = unique_ptr<LinearGradient>(static_cast<LinearGradient*>(fill->duplicate()));
+    REQUIRE(dup);
+
+    REQUIRE(dup->spread() == FillSpread::Reflect);
+
+    float x1, y1, x2, y2;
+    REQUIRE(fill->linear(&x1, &y1, &x2, &y2) == Result::Success);
+    REQUIRE(x1 == -10.0f);
+    REQUIRE(y1 == 10.0f);
+    REQUIRE(x2 == 100.0f);
+    REQUIRE(y2 == 120.0f);
+
+    const Fill::ColorStop* cs2 = nullptr;
+    REQUIRE(fill->colorStops(&cs2) == 4);
+
+    for (int i = 0; i < 4; ++i) {
+        REQUIRE(cs[i].offset == cs2[i].offset);
+        REQUIRE(cs[i].r == cs2[i].r);
+        REQUIRE(cs[i].g == cs2[i].g);
+        REQUIRE(cs[i].b == cs2[i].b);
+    };
+}
+
+TEST_CASE("Radial Filling Dupliction", "[tvgFill]")
 {
     auto fill = RadialGradient::gen();
     REQUIRE(fill);
@@ -162,4 +203,4 @@ TEST_CASE("Filling Dupliction", "[tvgFill]")
         REQUIRE(cs[i].g == cs2[i].g);
         REQUIRE(cs[i].b == cs2[i].b);
     };
-}
\ No newline at end of file
+}
index 068deeb..dd0d308 100644 (file)
@@ -201,6 +201,23 @@ TEST_CASE("Picture Size", "[tvgPicture]")
     REQUIRE(picture->size(w, h) == Result::Success);
 }
 
+TEST_CASE("Picture Duplication", "[tvgPicture]")
+{
+    auto picture = Picture::gen();
+    REQUIRE(picture);
+
+    REQUIRE(picture->load(TEST_DIR"/logo.svg") == Result::Success);
+    REQUIRE(picture->size(100, 100) == Result::Success);
+
+    auto dup = picture->duplicate();
+    REQUIRE(dup);
+
+    float w, h;
+    REQUIRE(picture->size(&w, &h) == Result::Success);
+    REQUIRE(w == 100);
+    REQUIRE(h == 100);
+}
+
 TEST_CASE("Load SVG file and render", "[tvgPicture]")
 {
     REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
@@ -287,6 +304,7 @@ TEST_CASE("Load RAW file and render", "[tvgPicture]")
     file.close();
 
     REQUIRE(picture->load(data, 200, 300, false) == Result::Success);
+    REQUIRE(picture->size(100, 150) == Result::Success);
 
     REQUIRE(canvas->push(move(picture)) == Result::Success);