From 90c9810b9709af0ffcdb22926c49c143cb20d400 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 13 Jun 2023 15:33:01 +0900 Subject: [PATCH] test: ++coverage of Canvas::paints(), Scene::paints() --- test/images/tag.tvg | Bin 3410 -> 3410 bytes test/images/test.tvg | Bin 191768 -> 191768 bytes test/testScene.cpp | 25 ++++++++++++++++++++++--- test/testSwCanvasBase.cpp | 24 ++++++++++++++++++++---- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/test/images/tag.tvg b/test/images/tag.tvg index db99276102e5840d8b11df0c1226178e9dbc4bd1..0ce8f0a64f2fe962dcbea695112ab95fe224fed7 100644 GIT binary patch delta 19 acmca4bxDdVBqP5l%-z7i&|o8%2QL6a-v#af delta 19 acmca4bxDdVBqP5l%-z7iz+@wr2QL6a?FI1w diff --git a/test/images/test.tvg b/test/images/test.tvg index 22b10cef6ff24e777fbbf138c9d68a2bb19b79da..7f46de367d2e9994fb09327be0285e74a73960a0 100644 GIT binary patch delta 27 icmbPni+jc`Zmy7w{Gu>-0|P^YMy^&a#;sgTd~X4YDG1j9 delta 27 icmbPni+jc`Zmy7w{Gu>-0|Nt-My^&a#;sgTd~X4YNeJ2i diff --git a/test/testScene.cpp b/test/testScene.cpp index 82456791..34144e1a 100644 --- a/test/testScene.cpp +++ b/test/testScene.cpp @@ -41,10 +41,20 @@ TEST_CASE("Pushing Paints Into Scene", "[tvgScene]") auto scene = Scene::gen(); REQUIRE(scene); + Paint* paints[3]; + //Pushing Paints - REQUIRE(scene->push(Shape::gen()) == Result::Success); - REQUIRE(scene->push(Picture::gen()) == Result::Success); - REQUIRE(scene->push(Scene::gen()) == Result::Success); + auto p1 = Shape::gen(); + paints[0] = p1.get(); + REQUIRE(scene->push(std::move(p1)) == Result::Success); + + auto p2 = Picture::gen(); + paints[1] = p2.get(); + REQUIRE(scene->push(std::move(p2)) == Result::Success); + + auto p3 = Picture::gen(); + paints[2] = p3.get(); + REQUIRE(scene->push(std::move(p3)) == Result::Success); //Pushing Null Pointer REQUIRE(scene->push(nullptr) == Result::MemoryCorruption); @@ -52,6 +62,15 @@ TEST_CASE("Pushing Paints Into Scene", "[tvgScene]") //Pushing Invalid Paint std::unique_ptr shape = nullptr; REQUIRE(scene->push(std::move(shape)) == Result::MemoryCorruption); + + //Check list of paints + auto list = scene->paints(); + REQUIRE(list.size() == 3); + int idx = 0; + for (auto paint : list) { + REQUIRE(paints[idx] == paint); + ++idx; + } } TEST_CASE("Scene Clear", "[tvgScene]") diff --git a/test/testSwCanvasBase.cpp b/test/testSwCanvasBase.cpp index 6b4fde75..b2fc1130 100644 --- a/test/testSwCanvasBase.cpp +++ b/test/testSwCanvasBase.cpp @@ -50,7 +50,11 @@ TEST_CASE("Pushing Paints", "[tvgSwCanvasBase]") REQUIRE(canvas->clear() == Result::Success); - REQUIRE(canvas->push(Shape::gen()) == 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); @@ -59,11 +63,23 @@ TEST_CASE("Pushing Paints", "[tvgSwCanvasBase]") std::unique_ptr shape6 = nullptr; REQUIRE(canvas->push(std::move(shape6)) == Result::MemoryCorruption); - //Negative case 3 - REQUIRE(canvas->push(Shape::gen()) == Result::Success); + 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); } @@ -225,4 +241,4 @@ TEST_CASE("Asynchronized Drawing", "[tvgSwCanvasBase]") REQUIRE(canvas->sync() == Result::Success); REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); -} +} \ No newline at end of file