From e17fdbe3c6dafd7e86a1dc06a7ef602929cea8c1 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 14 May 2024 16:17:49 +0900 Subject: [PATCH] test: clean up test suites Merge two separate units: SwCanvas and SwCanvasBase. --- test/meson.build | 1 - test/resources/tag.tvg | Bin 3625 -> 3623 bytes test/testSwCanvas.cpp | 215 ++++++++++++++++++++++++++++++++++ test/testSwCanvasBase.cpp | 235 -------------------------------------- 4 files changed, 215 insertions(+), 236 deletions(-) delete mode 100644 test/testSwCanvasBase.cpp diff --git a/test/meson.build b/test/meson.build index ad473def..df5606a9 100644 --- a/test/meson.build +++ b/test/meson.build @@ -15,7 +15,6 @@ test_file = [ 'testScene.cpp', 'testShape.cpp', 'testSwCanvas.cpp', - 'testSwCanvasBase.cpp', 'testSwEngine.cpp', 'testText.cpp' ] diff --git a/test/resources/tag.tvg b/test/resources/tag.tvg index 26ef4c5ca663d397a9a7955b7ed0e97f7667823d..783a85d3456769a7ad79f7cb2a92d8ae29dde3a9 100644 GIT binary patch delta 2048 zcmV+b2> zk=zPow~x{5YJB^{KLuAD#MMGLkei133P2SAug5)m6y=fO4IrtYIYFBLbBJ#}c;OdD9RLHENUIa`$3BAm7$O6pAE$sJY|TX53auA3FyjpH0z$2TSj$g|bP0R( zVIDwG=Q=`v&`u)k{T-a_BR`sS3r`{4~F;Ry)P5C{eYVu3D} z2uIK1InM>si1;u--jo=6(c?1&d1E3zO^`PylK%96qX&c(QwKoRrREZ*uO&W0&pIGb zF?F!VhYRuf1=-CWA3C~37HXGw+XF%adEX*Fa(4;cO%@+m#77Exk52~TlZ(Fx{^P&708qD&I9VX6s}t)q3ux~*LRh(E`fqd0C9TXC+HTAH(TWUHu=w0o+_6w-R2AJ z`BrCGAmc~^>DQA6;R{3)Shxic;1Gf;yq?U^I)XqBfc~AMX7=G9KQ&gsS@+|f2 zoCO|m02&ZW3##D)g1{V;S2(h|CrDT;g7STkp8L=$0&dZ_#p}DZwTLi zLL90<0*K%TZ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 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success); + + //Try all types of paints. + REQUIRE(canvas->push(Shape::gen()) == Result::Success); + REQUIRE(canvas->push(Picture::gen()) == Result::Success); + REQUIRE(canvas->push(Scene::gen()) == Result::Success); + + //Cases by contexts. + REQUIRE(canvas->update() == Result::Success); + + REQUIRE(canvas->push(Shape::gen()) == Result::Success); + REQUIRE(canvas->push(Shape::gen()) == Result::Success); + + REQUIRE(canvas->clear() == Result::Success); + + Paint* paints[2]; + + auto p1 = Shape::gen(); + paints[0] = p1.get(); + REQUIRE(canvas->push(std::move(p1)) == Result::Success); + + //Negative case 1 + REQUIRE(canvas->push(nullptr) == Result::MemoryCorruption); + + //Negative case 2 + std::unique_ptr shape6 = nullptr; + REQUIRE(canvas->push(std::move(shape6)) == Result::MemoryCorruption); + + auto p2 = Shape::gen(); + paints[1] = p2.get(); + REQUIRE(canvas->push(std::move(p2)) == Result::Success); + REQUIRE(canvas->draw() == Result::Success); + + //Negative case 3 + REQUIRE(canvas->push(Shape::gen()) == Result::InsufficientCondition); + + //Check list of paints + auto list = canvas->paints(); + REQUIRE(list.size() == 2); + int idx = 0; + for (auto paint : list) { + REQUIRE(paints[idx] == paint); + ++idx; + } + + REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); +} + +TEST_CASE("Clear", "[tvgSwCanvas]") +{ + REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success); + + auto canvas = SwCanvas::gen(); + REQUIRE(canvas); + + auto canvas2 = SwCanvas::gen(); + REQUIRE(canvas2); + + //Try 0: Negative + REQUIRE(canvas->clear() == Result::Success); + REQUIRE(canvas->clear(false) == Result::Success); + REQUIRE(canvas->clear() == Result::Success); + + REQUIRE(canvas2->clear(false) == Result::Success); + REQUIRE(canvas2->clear() == Result::Success); + REQUIRE(canvas2->clear(false) == Result::Success); + + uint32_t buffer[100*100]; + REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success); + + uint32_t buffer2[100*100]; + REQUIRE(canvas2->target(buffer2, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success); + + //Try 1: Push -> Clear + for (int i = 0; i < 5; ++i) { + REQUIRE(canvas->push(Shape::gen()) == Result::Success); + + auto shape2 = Shape::gen(); + REQUIRE(shape2); + + REQUIRE(canvas2->push(std::move(shape2)) == Result::Success); + } + + REQUIRE(canvas->clear() == Result::Success); + REQUIRE(canvas->clear(false) == Result::Success); + + REQUIRE(canvas2->clear(false) == Result::Success); + REQUIRE(canvas2->clear() == Result::Success); + + //Try 2: Push -> Update -> Clear + for (int i = 0; i < 5; ++i) { + REQUIRE(canvas->push(Shape::gen()) == Result::Success); + + auto shape2 = Shape::gen(); + REQUIRE(shape2); + REQUIRE(canvas2->push(std::move(shape2)) == Result::Success); + } + + REQUIRE(canvas->update() == Result::Success); + REQUIRE(canvas->clear() == Result::Success); + REQUIRE(canvas->clear(false) == Result::Success); + + REQUIRE(canvas2->update() == Result::Success); + REQUIRE(canvas2->clear(false) == Result::Success); + REQUIRE(canvas2->clear() == Result::Success); + + REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); +} + +TEST_CASE("Update", "[tvgSwCanvas]") +{ + 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::ARGB8888) == Result::Success); + + REQUIRE(canvas->update() == Result::InsufficientCondition); + + REQUIRE(canvas->push(Shape::gen()) == Result::Success); + + //No pushed shape + auto shape = Shape::gen(); + REQUIRE(canvas->update(shape.get()) == Result::Success); + + //Normal case + auto ptr = shape.get(); + REQUIRE(canvas->push(std::move(shape)) == Result::Success); + REQUIRE(canvas->update(ptr) == Result::Success); + REQUIRE(canvas->update() == Result::Success); + REQUIRE(canvas->draw() == Result::Success); + REQUIRE(canvas->update() == Result::InsufficientCondition); + + REQUIRE(canvas->clear() == Result::Success); + + //Invalid shape + REQUIRE(canvas->update(ptr) == Result::InsufficientCondition); + + REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); +} + +TEST_CASE("Synchronized Drawing", "[tvgSwCanvas]") +{ + REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success); + + auto canvas = SwCanvas::gen(); + REQUIRE(canvas); + + REQUIRE(canvas->sync() == Result::InsufficientCondition); + REQUIRE(canvas->draw() == Result::InsufficientCondition); + + uint32_t buffer[100*100]; + REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success); + + REQUIRE(canvas->draw() == Result::InsufficientCondition); + REQUIRE(canvas->sync() == Result::InsufficientCondition); + + //Invalid Shape + auto shape = Shape::gen(); + REQUIRE(shape); + REQUIRE(canvas->push(std::move(shape)) == Result::Success); + + REQUIRE(canvas->draw() == Result::Success); + REQUIRE(canvas->sync() == Result::Success); + REQUIRE(canvas->clear() == Result::Success); + + auto shape2 = Shape::gen(); + REQUIRE(shape2); + REQUIRE(shape2->appendRect(0, 0, 100, 100) == Result::Success); + REQUIRE(shape2->fill(255, 255, 255, 255) == Result::Success); + + REQUIRE(canvas->push(std::move(shape2)) == Result::Success); + REQUIRE(canvas->draw() == Result::Success); + REQUIRE(canvas->sync() == Result::Success); + + REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); +} + +TEST_CASE("Asynchronized Drawing", "[tvgSwCanvas]") +{ + //Use multi-threading + REQUIRE(Initializer::init(CanvasEngine::Sw, 2) == Result::Success); + + auto canvas = SwCanvas::gen(); + REQUIRE(canvas); + + uint32_t buffer[100*100]; + REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success); + + for (int i = 0; i < 3; ++i) { + auto shape = Shape::gen(); + REQUIRE(shape); + REQUIRE(shape->appendRect(0, 0, 100, 100) == Result::Success); + REQUIRE(shape->fill(255, 255, 255, 255) == Result::Success); + + REQUIRE(canvas->push(std::move(shape)) == Result::Success); + } + + REQUIRE(canvas->draw() == Result::Success); + REQUIRE(canvas->sync() == Result::Success); + + REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); +} \ No newline at end of file diff --git a/test/testSwCanvasBase.cpp b/test/testSwCanvasBase.cpp deleted file mode 100644 index 2a1b4db2..00000000 --- a/test/testSwCanvasBase.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2021 - 2024 the ThorVG project. 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 "config.h" -#include "catch.hpp" - -using namespace tvg; - - -TEST_CASE("Pushing Paints", "[tvgSwCanvasBase]") -{ - 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::ARGB8888) == Result::Success); - - //Try all types of paints. - REQUIRE(canvas->push(Shape::gen()) == Result::Success); - REQUIRE(canvas->push(Picture::gen()) == Result::Success); - REQUIRE(canvas->push(Scene::gen()) == Result::Success); - - //Cases by contexts. - REQUIRE(canvas->update() == Result::Success); - - REQUIRE(canvas->push(Shape::gen()) == Result::Success); - REQUIRE(canvas->push(Shape::gen()) == Result::Success); - - REQUIRE(canvas->clear() == Result::Success); - - Paint* paints[2]; - - auto p1 = Shape::gen(); - paints[0] = p1.get(); - REQUIRE(canvas->push(std::move(p1)) == Result::Success); - - //Negative case 1 - REQUIRE(canvas->push(nullptr) == Result::MemoryCorruption); - - //Negative case 2 - std::unique_ptr shape6 = nullptr; - REQUIRE(canvas->push(std::move(shape6)) == Result::MemoryCorruption); - - auto p2 = Shape::gen(); - paints[1] = p2.get(); - REQUIRE(canvas->push(std::move(p2)) == Result::Success); - REQUIRE(canvas->draw() == Result::Success); - - //Negative case 3 - REQUIRE(canvas->push(Shape::gen()) == Result::InsufficientCondition); - - //Check list of paints - auto list = canvas->paints(); - REQUIRE(list.size() == 2); - int idx = 0; - for (auto paint : list) { - REQUIRE(paints[idx] == paint); - ++idx; - } - - REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); -} - -TEST_CASE("Clear", "[tvgSwCanvasBase]") -{ - REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success); - - auto canvas = SwCanvas::gen(); - REQUIRE(canvas); - auto canvas2 = SwCanvas::gen(); - REQUIRE(canvas2); - - //Try 0: Clear - REQUIRE(canvas->clear() == Result::Success); - REQUIRE(canvas->clear(false) == Result::Success); - REQUIRE(canvas->clear() == Result::Success); - - REQUIRE(canvas2->clear(false) == Result::Success); - REQUIRE(canvas2->clear() == Result::Success); - REQUIRE(canvas2->clear(false) == Result::Success); - - //Try 1: Push -> Clear - for (int i = 0; i < 5; ++i) { - REQUIRE(canvas->push(Shape::gen()) == Result::Success); - - auto shape2 = Shape::gen(); - REQUIRE(shape2); - - REQUIRE(canvas2->push(std::move(shape2)) == Result::Success); - } - - REQUIRE(canvas->clear() == Result::Success); - REQUIRE(canvas->clear(false) == Result::Success); - - REQUIRE(canvas2->clear(false) == Result::Success); - REQUIRE(canvas2->clear() == Result::Success); - - //Try 2: Push -> Update -> Clear - for (int i = 0; i < 5; ++i) { - REQUIRE(canvas->push(Shape::gen()) == Result::Success); - - auto shape2 = Shape::gen(); - REQUIRE(shape2); - REQUIRE(canvas2->push(std::move(shape2)) == Result::Success); - } - - REQUIRE(canvas->update() == Result::Success); - REQUIRE(canvas->clear() == Result::Success); - REQUIRE(canvas->clear(false) == Result::Success); - - REQUIRE(canvas2->update() == Result::Success); - REQUIRE(canvas2->clear(false) == Result::Success); - REQUIRE(canvas2->clear() == Result::Success); - - REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); -} - -TEST_CASE("Update", "[tvgSwCanvasBase]") -{ - 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::ARGB8888) == Result::Success); - - REQUIRE(canvas->update() == Result::InsufficientCondition); - - REQUIRE(canvas->push(Shape::gen()) == Result::Success); - - //No pushed shape - auto shape = Shape::gen(); - REQUIRE(canvas->update(shape.get()) == Result::Success); - - //Normal case - auto ptr = shape.get(); - REQUIRE(canvas->push(std::move(shape)) == Result::Success); - REQUIRE(canvas->update(ptr) == Result::Success); - REQUIRE(canvas->update() == Result::Success); - REQUIRE(canvas->draw() == Result::Success); - REQUIRE(canvas->update() == Result::InsufficientCondition); - - REQUIRE(canvas->clear() == Result::Success); - - //Invalid shape - REQUIRE(canvas->update(ptr) == Result::InsufficientCondition); - - REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); -} - -TEST_CASE("Synchronized Drawing", "[tvgSwCanvasBase]") -{ - REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success); - - auto canvas = SwCanvas::gen(); - REQUIRE(canvas); - - REQUIRE(canvas->sync() == Result::InsufficientCondition); - REQUIRE(canvas->draw() == Result::InsufficientCondition); - - uint32_t buffer[100*100]; - REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success); - - REQUIRE(canvas->draw() == Result::InsufficientCondition); - REQUIRE(canvas->sync() == Result::InsufficientCondition); - - //Invalid Shape - auto shape = Shape::gen(); - REQUIRE(shape); - REQUIRE(canvas->push(std::move(shape)) == Result::Success); - - REQUIRE(canvas->draw() == Result::Success); - REQUIRE(canvas->sync() == Result::Success); - REQUIRE(canvas->clear() == Result::Success); - - auto shape2 = Shape::gen(); - REQUIRE(shape2); - REQUIRE(shape2->appendRect(0, 0, 100, 100) == Result::Success); - REQUIRE(shape2->fill(255, 255, 255, 255) == Result::Success); - - REQUIRE(canvas->push(std::move(shape2)) == Result::Success); - REQUIRE(canvas->draw() == Result::Success); - REQUIRE(canvas->sync() == Result::Success); - - REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); -} - -TEST_CASE("Asynchronized Drawing", "[tvgSwCanvasBase]") -{ - //Use multi-threading - REQUIRE(Initializer::init(CanvasEngine::Sw, 2) == Result::Success); - - auto canvas = SwCanvas::gen(); - REQUIRE(canvas); - - uint32_t buffer[100*100]; - REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success); - - for (int i = 0; i < 3; ++i) { - auto shape = Shape::gen(); - REQUIRE(shape); - REQUIRE(shape->appendRect(0, 0, 100, 100) == Result::Success); - REQUIRE(shape->fill(255, 255, 255, 255) == Result::Success); - - REQUIRE(canvas->push(std::move(shape)) == Result::Success); - } - - REQUIRE(canvas->draw() == Result::Success); - REQUIRE(canvas->sync() == Result::Success); - - REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); -} \ No newline at end of file