mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
common Test: Add Paint.bounds unit test
This commit is contained in:
parent
d8d754e969
commit
1bdf1c72a4
2 changed files with 70 additions and 0 deletions
|
@ -17,3 +17,17 @@ canvas_testsuite = executable('canvasTestSuite',
|
|||
)
|
||||
|
||||
test('Canvas Testsuite', canvas_testsuite)
|
||||
|
||||
paint_test_sources = [
|
||||
'testsuite.cpp',
|
||||
'test_paint.cpp',
|
||||
]
|
||||
|
||||
paint_testsuite = executable('paintTestSuite',
|
||||
paint_test_sources,
|
||||
include_directories : headers,
|
||||
override_options : override_default,
|
||||
dependencies : [gtest_dep, thorvg_lib_dep],
|
||||
)
|
||||
|
||||
test('Paint Testsuite', paint_testsuite)
|
||||
|
|
56
test/test_paint.cpp
Normal file
56
test/test_paint.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <thorvg.h>
|
||||
|
||||
class PaintTest : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() {
|
||||
auto threads = std::thread::hardware_concurrency();
|
||||
//Initialize ThorVG Engine
|
||||
if (tvg::Initializer::init(tvgEngine, threads) == tvg::Result::Success) {
|
||||
swCanvas = tvg::SwCanvas::gen();
|
||||
|
||||
scene = tvg::Scene::gen();
|
||||
|
||||
shape = tvg::Shape::gen();
|
||||
}
|
||||
}
|
||||
void TearDown() {
|
||||
|
||||
//Terminate ThorVG Engine
|
||||
tvg::Initializer::term(tvgEngine);
|
||||
}
|
||||
public:
|
||||
std::unique_ptr<tvg::SwCanvas> swCanvas;
|
||||
std::unique_ptr<tvg::Scene> scene;
|
||||
std::unique_ptr<tvg::Shape> shape;
|
||||
tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw;
|
||||
};
|
||||
|
||||
TEST_F(PaintTest, GenerateShape) {
|
||||
ASSERT_TRUE(swCanvas != nullptr);
|
||||
ASSERT_TRUE(shape != nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PaintTest, GenerateScene) {
|
||||
ASSERT_TRUE(swCanvas != nullptr);
|
||||
ASSERT_TRUE(scene != nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PaintTest, SceneBounds) {
|
||||
ASSERT_TRUE(swCanvas != nullptr);
|
||||
ASSERT_TRUE(scene != nullptr);
|
||||
|
||||
ASSERT_EQ(shape->appendRect(10.0, 20.0, 100.0, 200.0, 0, 0), tvg::Result::Success);
|
||||
|
||||
ASSERT_EQ(scene->push(std::move(shape)), tvg::Result::Success);
|
||||
|
||||
float x, y, w, h;
|
||||
ASSERT_EQ(scene->bounds(&x, &y, &w, &h), tvg::Result::Success);
|
||||
ASSERT_EQ(x, 10.0);
|
||||
ASSERT_EQ(y, 20.0);
|
||||
ASSERT_EQ(w, 100.0);
|
||||
ASSERT_EQ(h, 200.0);
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue