diff --git a/test/images/tag.svg b/test/images/tag.svg
index a4a6cdba..54e20515 100644
--- a/test/images/tag.svg
+++ b/test/images/tag.svg
@@ -20,8 +20,8 @@
-
-
+
+
diff --git a/test/images/tag.tvg b/test/images/tag.tvg
new file mode 100644
index 00000000..d1db4ca6
Binary files /dev/null and b/test/images/tag.tvg differ
diff --git a/test/images/test.tvg b/test/images/test.tvg
new file mode 100644
index 00000000..0abd9c27
Binary files /dev/null and b/test/images/test.tvg differ
diff --git a/test/meson.build b/test/meson.build
index 0cd4d457..ec4bfc95 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -4,6 +4,7 @@ test_file = [
'testMain.cpp',
'testPaint.cpp',
'testPicture.cpp',
+ 'testSavers.cpp',
'testScene.cpp',
'testShape.cpp',
'testSwCanvas.cpp',
diff --git a/test/testPicture.cpp b/test/testPicture.cpp
index dd0d308a..3ca2c6ba 100644
--- a/test/testPicture.cpp
+++ b/test/testPicture.cpp
@@ -180,6 +180,50 @@ TEST_CASE("Load JPG file from data", "[tvgPicture]")
free(data);
}
+TEST_CASE("Load TVG file from path", "[tvgPicture]")
+{
+ auto picture = Picture::gen();
+ REQUIRE(picture);
+
+ //Invalid file
+ REQUIRE(picture->load("invalid.tvg") == Result::InvalidArguments);
+
+ REQUIRE(picture->load(TEST_DIR"/tag.tvg") == Result::Success);
+
+ float w, h;
+ REQUIRE(picture->size(&w, &h) == Result::Success);
+
+ REQUIRE(w == 1000);
+ REQUIRE(h == 1000);
+}
+
+TEST_CASE("Load TVG file from data", "[tvgPicture]")
+{
+ auto picture = Picture::gen();
+ REQUIRE(picture);
+
+ //Open file
+ ifstream file(TEST_DIR"/tag.tvg");
+ REQUIRE(file.is_open());
+ auto begin = file.tellg();
+ file.seekg(0, std::ios::end);
+ auto size = file.tellg() - begin;
+ auto data = (char*)malloc(size);
+ file.seekg(0, std::ios::beg);
+ file.read(data, size);
+ file.close();
+
+ REQUIRE(picture->load(data, size, "", false) == Result::Success);
+ REQUIRE(picture->load(data, size, "tvg", true) == Result::Success);
+
+ float w, h;
+ REQUIRE(picture->size(&w, &h) == Result::Success);
+ REQUIRE(w == 1000);
+ REQUIRE(h == 1000);
+
+ free(data);
+}
+
TEST_CASE("Picture Size", "[tvgPicture]")
{
auto picture = Picture::gen();
@@ -282,6 +326,29 @@ TEST_CASE("Load JPG file and render", "[tvgPicture]")
REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
}
+TEST_CASE("Load TVG file and render", "[tvgPicture]")
+{
+ REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
+
+ auto canvas = SwCanvas::gen();
+ REQUIRE(canvas);
+
+ uint32_t buffer[1000*1000];
+ REQUIRE(canvas->target(buffer, 1000, 1000, 1000, SwCanvas::Colorspace::ABGR8888) == Result::Success);
+
+ auto pictureTag = Picture::gen();
+ REQUIRE(pictureTag);
+ REQUIRE(pictureTag->load(TEST_DIR"/tag.tvg") == Result::Success);
+ REQUIRE(canvas->push(move(pictureTag)) == Result::Success);
+
+ auto pictureTest = Picture::gen();
+ REQUIRE(pictureTest);
+ REQUIRE(pictureTest->load(TEST_DIR"/test.tvg") == Result::Success);
+ REQUIRE(canvas->push(move(pictureTest)) == Result::Success);
+
+ REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
+}
+
TEST_CASE("Load RAW file and render", "[tvgPicture]")
{
REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
diff --git a/test/testSavers.cpp b/test/testSavers.cpp
new file mode 100644
index 00000000..8577b60f
--- /dev/null
+++ b/test/testSavers.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2021 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
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include
+#include "catch.hpp"
+
+using namespace tvg;
+
+TEST_CASE("Saver Creation", "[tvgSavers]")
+{
+ auto saver = Saver::gen();
+ REQUIRE(saver);
+}
+
+TEST_CASE("Save empty shape", "[tvgSavers]")
+{
+ auto shape = Shape::gen();
+ REQUIRE(shape);
+
+ auto saver = Saver::gen();
+ REQUIRE(saver);
+
+ REQUIRE(saver->save(move(shape), TEST_DIR"/test.tvg") == Result::Unknown);
+}
+
+TEST_CASE("Save svg into tvg", "[tvgSavers]")
+{
+ REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
+
+ auto picture = Picture::gen();
+ REQUIRE(picture);
+ REQUIRE(picture->load(TEST_DIR"/tag.svg") == Result::Success);
+
+ auto saver = Saver::gen();
+ REQUIRE(saver);
+
+ REQUIRE(saver->save(move(picture), TEST_DIR"/tag.tvg") == Result::Success);
+ REQUIRE(saver->sync() == Result::Success);
+
+ REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
+}
+
+TEST_CASE("Save scene into tvg", "[tvgSavers]")
+{
+ REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
+
+ auto picture = tvg::Picture::gen();
+ REQUIRE(picture);
+ REQUIRE(picture->load(TEST_DIR"/test.png") == Result::Success);
+ REQUIRE(picture->translate(50, 0) == Result::Success);
+ REQUIRE(picture->scale(2) == Result::Success);
+
+ auto mask = tvg::Shape::gen();
+ REQUIRE(mask);
+ REQUIRE(mask->appendCircle(400, 400, 15, 15) == Result::Success);
+ REQUIRE(mask->fill(0, 0, 0, 255) == Result::Success);
+ REQUIRE(picture->composite(move(mask), tvg::CompositeMethod::InvAlphaMask) == Result::Success);
+
+ auto saver = Saver::gen();
+ REQUIRE(saver);
+ REQUIRE(saver->save(move(picture), TEST_DIR"/test.tvg") == Result::Success);
+ REQUIRE(saver->sync() == Result::Success);
+
+ REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
+}