From 7a8f96894c97da8861b30da89e0a375181f8fd37 Mon Sep 17 00:00:00 2001 From: Michal Maciola Date: Wed, 18 Aug 2021 15:56:59 +0200 Subject: [PATCH] utc: increase coverage up --- test/images/tag.svg | 10 +++++++--- test/testPicture.cpp | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/test/images/tag.svg b/test/images/tag.svg index 4533376..4d3542a 100644 --- a/test/images/tag.svg +++ b/test/images/tag.svg @@ -1,6 +1,6 @@ - + @@ -20,16 +20,20 @@ + + + + - + - + diff --git a/test/testPicture.cpp b/test/testPicture.cpp index 53b48f4..6be9189 100644 --- a/test/testPicture.cpp +++ b/test/testPicture.cpp @@ -208,8 +208,8 @@ TEST_CASE("Load SVG file and render", "[tvgPicture]") auto canvas = SwCanvas::gen(); REQUIRE(canvas); - uint32_t buffer[100*100]; - REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success); + uint32_t buffer[1000*1000]; + REQUIRE(canvas->target(buffer, 1000, 1000, 1000, SwCanvas::Colorspace::ABGR8888) == Result::Success); auto picture = Picture::gen(); REQUIRE(picture); @@ -260,3 +260,33 @@ TEST_CASE("Load JPG file and render", "[tvgPicture]") REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); } + +TEST_CASE("Load RAW file and render", "[tvgPicture]") +{ + REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success); + + auto canvas = SwCanvas::gen(); + REQUIRE(canvas); + + uint32_t buffer[100*100]; + REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success); + + auto picture = Picture::gen(); + REQUIRE(picture); + + string path(TEST_DIR"/rawimage_200x300.raw"); + + ifstream file(path); + if (!file.is_open()) return; + auto data = (uint32_t*)malloc(sizeof(uint32_t) * (200*300)); + file.read(reinterpret_cast(data), sizeof (uint32_t) * 200 * 300); + file.close(); + + REQUIRE(picture->load(data, 200, 300, false) == Result::Success); + + REQUIRE(canvas->push(move(picture)) == Result::Success); + + REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); + + free(data); +} -- 2.7.4