mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
test: ++coverage of Canvas::paints(), Scene::paints()
This commit is contained in:
parent
075e3e6b2a
commit
90c9810b97
4 changed files with 42 additions and 7 deletions
Binary file not shown.
Binary file not shown.
|
@ -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> 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]")
|
||||
|
|
|
@ -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<Shape> 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue