mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
test: added viewport test
This commit is contained in:
parent
e17fdbe3c6
commit
746c466df3
1 changed files with 35 additions and 1 deletions
|
@ -308,4 +308,38 @@ TEST_CASE("Asynchronized Drawing", "[tvgSwCanvas]")
|
|||
REQUIRE(canvas->sync() == Result::Success);
|
||||
|
||||
REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Viewport", "[tvgSwCanvas]")
|
||||
{
|
||||
REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
|
||||
|
||||
auto canvas = SwCanvas::gen();
|
||||
REQUIRE(canvas);
|
||||
|
||||
REQUIRE(canvas->viewport(25, 25, 100, 100) == Result::Success);
|
||||
|
||||
uint32_t buffer[100*100];
|
||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
||||
|
||||
REQUIRE(canvas->viewport(25, 25, 50, 50) == Result::Success);
|
||||
|
||||
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);
|
||||
|
||||
//Negative, not allowed
|
||||
REQUIRE(canvas->viewport(15, 25, 5, 5) == Result::InsufficientCondition);
|
||||
|
||||
REQUIRE(canvas->draw() == Result::Success);
|
||||
|
||||
//Negative, not allowed
|
||||
REQUIRE(canvas->viewport(25, 25, 10, 10) == Result::InsufficientCondition);
|
||||
|
||||
REQUIRE(canvas->sync() == Result::Success);
|
||||
|
||||
REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue