2 * Copyright (c) 2021 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 TEST_CASE("Scene Creation", "[tvgScene]")
30 auto scene = Scene::gen();
33 REQUIRE(scene->identifier() == Scene::identifier());
34 REQUIRE(scene->identifier() != Shape::identifier());
35 REQUIRE(scene->identifier() != Picture::identifier());
38 TEST_CASE("Pushing Paints Into Scene", "[tvgScene]")
40 auto scene = Scene::gen();
44 REQUIRE(scene->push(move(Shape::gen())) == Result::Success);
45 REQUIRE(scene->push(move(Picture::gen())) == Result::Success);
46 REQUIRE(scene->push(move(Scene::gen())) == Result::Success);
48 //Pushing Null Pointer
49 REQUIRE(scene->push(nullptr) == Result::MemoryCorruption);
51 //Pushing Invalid Paint
52 std::unique_ptr<Shape> shape = nullptr;
53 REQUIRE(scene->push(move(shape)) == Result::MemoryCorruption);
56 TEST_CASE("Scene Memory Reservation", "[tvgScene]")
58 auto scene = Scene::gen();
61 //Check Growth / Reduction
62 REQUIRE(scene->reserve(10) == Result::Success);
63 REQUIRE(scene->reserve(1000) == Result::Success);
64 REQUIRE(scene->reserve(100) == Result::Success);
65 REQUIRE(scene->reserve(0) == Result::Success);
68 TEST_CASE("Scene Clear", "[tvgScene]")
70 auto scene = Scene::gen();
73 REQUIRE(scene->push(move(Shape::gen())) == Result::Success);
74 REQUIRE(scene->clear() == Result::Success);
77 TEST_CASE("Scene Clear And Reuse Shape", "[tvgScene]")
79 REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
81 auto canvas = SwCanvas::gen();
84 auto scene = Scene::gen();
86 Scene *pScene = scene.get();
88 auto shape = Shape::gen();
90 Shape* pShape = shape.get();
92 REQUIRE(scene->push(move(shape)) == Result::Success);
93 REQUIRE(canvas->push(move(scene)) == Result::Success);
94 REQUIRE(canvas->update() == Result::Success);
96 //No deallocate shape.
97 REQUIRE(pScene->clear(false) == Result::Success);
100 REQUIRE(pScene->push(std::unique_ptr<Shape>(pShape)) == Result::Success);
102 REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);