prepare tvg v0.8 release
[platform/core/graphics/tizenvg.git] / test / testSwEngine.cpp
index 48fa7e4..4cb2250 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2021 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -67,6 +67,21 @@ TEST_CASE("Basic draw", "[tvgSwEngine]")
     REQUIRE(shape3->fill(255, 255, 255, 255) == Result::Success);
     REQUIRE(canvas->push(move(shape3)) == Result::Success);
 
+    //Dashed shape
+    auto shape4 = tvg::Shape::gen();
+    REQUIRE(shape4);
+    float dashPattern[2] = {2.5f, 5.0f};
+
+    REQUIRE(shape4->moveTo(0, 0) == Result::Success);
+    REQUIRE(shape4->lineTo(25, 25) == Result::Success);
+    REQUIRE(shape4->cubicTo(50, 50, 75, -75, 50, 100) == Result::Success);
+    REQUIRE(shape4->close() == Result::Success);
+    REQUIRE(shape4->stroke(255, 0, 0, 255) == Result::Success);
+    REQUIRE(shape4->stroke(2) == Result::Success);
+    REQUIRE(shape4->stroke(dashPattern, 2) == Result::Success);
+    REQUIRE(shape4->stroke(StrokeCap::Round) == Result::Success);
+    REQUIRE(canvas->push(move(shape4)) == Result::Success);
+
     //Draw
     REQUIRE(canvas->draw() == Result::Success);
     REQUIRE(canvas->sync() == Result::Success);
@@ -133,7 +148,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
     REQUIRE(basicPicture4->opacity(100) == Result::Success);
     REQUIRE(canvas->push(move(basicPicture4)) == Result::Success);
 
-    // Rle 
+    // Rle
     REQUIRE(basicPicture5->composite(move(rleMask), tvg::CompositeMethod::ClipPath) == Result::Success);
     REQUIRE(canvas->push(move(basicPicture5)) == Result::Success);
 
@@ -190,7 +205,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
     REQUIRE(basicPicture4->opacity(100) == Result::Success);
     REQUIRE(canvas->push(move(basicPicture4)) == Result::Success);
 
-    // Rle 
+    // Rle
     REQUIRE(basicPicture5->composite(move(rleMask), tvg::CompositeMethod::ClipPath) == Result::Success);
     REQUIRE(canvas->push(move(basicPicture5)) == Result::Success);
 
@@ -232,7 +247,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
     basicPicture6 = std::unique_ptr<Picture>(static_cast<Picture*>(basicPicture->duplicate()));
     REQUIRE(basicPicture6);
     rleMask6 = std::unique_ptr<Shape>(static_cast<Shape*>(rleMask->duplicate()));
-    REQUIRE(rleMask6); 
+    REQUIRE(rleMask6);
 
     // Rect
     REQUIRE(basicPicture->composite(move(rectMask), tvg::CompositeMethod::AlphaMask) == Result::Success);
@@ -247,7 +262,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
     REQUIRE(basicPicture4->opacity(100) == Result::Success);
     REQUIRE(canvas->push(move(basicPicture4)) == Result::Success);
 
-    // Rle 
+    // Rle
     REQUIRE(basicPicture5->composite(move(rleMask), tvg::CompositeMethod::ClipPath) == Result::Success);
     REQUIRE(canvas->push(move(basicPicture5)) == Result::Success);
 
@@ -256,6 +271,62 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
     REQUIRE(canvas->push(move(basicPicture6)) == Result::Success);
 
 
+    // Downscaled images
+    basicPicture = Picture::gen();
+    REQUIRE(basicPicture);
+    REQUIRE(basicPicture->load(TEST_DIR"/test.png") == Result::Success);
+    REQUIRE(basicPicture->scale(0.2f) == Result::Success);
+    rectMask = tvg::Shape::gen();
+    REQUIRE(rectMask);
+    REQUIRE(rectMask->appendRect(10, 10, 30, 30, 0, 0) == Result::Success);
+    rleMask = tvg::Shape::gen();
+    REQUIRE(rleMask);
+    REQUIRE(rleMask->appendRect(0, 10, 20, 30, 5, 5) == Result::Success);
+
+    // Rect images
+    basicPicture2 = std::unique_ptr<Picture>(static_cast<Picture*>(basicPicture->duplicate()));
+    REQUIRE(basicPicture2);
+    rectMask2 = std::unique_ptr<Shape>(static_cast<Shape*>(rectMask->duplicate()));
+    REQUIRE(rectMask2);
+
+    basicPicture3 = std::unique_ptr<Picture>(static_cast<Picture*>(basicPicture->duplicate()));
+    REQUIRE(basicPicture3);
+    rectMask3 = std::unique_ptr<Shape>(static_cast<Shape*>(rectMask->duplicate()));
+    REQUIRE(rectMask3);
+
+    basicPicture4 = std::unique_ptr<Picture>(static_cast<Picture*>(basicPicture->duplicate()));
+    REQUIRE(basicPicture4);
+
+    // Rle images
+    basicPicture5 = std::unique_ptr<Picture>(static_cast<Picture*>(basicPicture->duplicate()));
+    REQUIRE(basicPicture5);
+
+    basicPicture6 = std::unique_ptr<Picture>(static_cast<Picture*>(basicPicture->duplicate()));
+    REQUIRE(basicPicture6);
+    rleMask6 = std::unique_ptr<Shape>(static_cast<Shape*>(rleMask->duplicate()));
+    REQUIRE(rleMask6);
+
+    // Rect
+    REQUIRE(basicPicture->composite(move(rectMask), tvg::CompositeMethod::AlphaMask) == Result::Success);
+    REQUIRE(canvas->push(move(basicPicture)) == Result::Success);
+
+    REQUIRE(basicPicture2->composite(move(rectMask2), tvg::CompositeMethod::InvAlphaMask) == Result::Success);
+    REQUIRE(canvas->push(move(basicPicture2)) == Result::Success);
+
+    REQUIRE(basicPicture3->composite(move(rectMask3), tvg::CompositeMethod::ClipPath) == Result::Success);
+    REQUIRE(canvas->push(move(basicPicture3)) == Result::Success);
+
+    REQUIRE(basicPicture4->opacity(100) == Result::Success);
+    REQUIRE(canvas->push(move(basicPicture4)) == Result::Success);
+
+    // Rle
+    REQUIRE(basicPicture5->composite(move(rleMask), tvg::CompositeMethod::ClipPath) == Result::Success);
+    REQUIRE(canvas->push(move(basicPicture5)) == Result::Success);
+
+    REQUIRE(basicPicture6->composite(move(rleMask6), tvg::CompositeMethod::ClipPath) == Result::Success);
+    REQUIRE(basicPicture6->opacity(100) == Result::Success);
+    REQUIRE(canvas->push(move(basicPicture6)) == Result::Success);
+
     //Draw
     REQUIRE(canvas->draw() == Result::Success);
     REQUIRE(canvas->sync() == Result::Success);