mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
utc: increase coverage of picture and fill
This commit is contained in:
parent
f66ea21e9c
commit
8ed6a1a12d
2 changed files with 61 additions and 2 deletions
|
@ -124,7 +124,48 @@ TEST_CASE("Radial Filling", "[tvgFill]")
|
|||
REQUIRE(radius == 0.0f);
|
||||
}
|
||||
|
||||
TEST_CASE("Filling Dupliction", "[tvgFill]")
|
||||
TEST_CASE("Linear Filling Dupliction", "[tvgFill]")
|
||||
{
|
||||
auto fill = LinearGradient::gen();
|
||||
REQUIRE(fill);
|
||||
|
||||
//Setup
|
||||
Fill::ColorStop cs[4] = {
|
||||
{0.0f, 0, 0, 0, 0},
|
||||
{0.2f, 50, 25, 50, 25},
|
||||
{0.5f, 100, 100, 100, 125},
|
||||
{1.0f, 255, 255, 255, 255}
|
||||
};
|
||||
|
||||
REQUIRE(fill->colorStops(cs, 4) == Result::Success);
|
||||
REQUIRE(fill->spread(FillSpread::Reflect) == Result::Success);
|
||||
REQUIRE(fill->linear(-10.0f, 10.0f, 100.0f, 120.0f) == Result::Success);
|
||||
|
||||
//Duplication
|
||||
auto dup = unique_ptr<LinearGradient>(static_cast<LinearGradient*>(fill->duplicate()));
|
||||
REQUIRE(dup);
|
||||
|
||||
REQUIRE(dup->spread() == FillSpread::Reflect);
|
||||
|
||||
float x1, y1, x2, y2;
|
||||
REQUIRE(fill->linear(&x1, &y1, &x2, &y2) == Result::Success);
|
||||
REQUIRE(x1 == -10.0f);
|
||||
REQUIRE(y1 == 10.0f);
|
||||
REQUIRE(x2 == 100.0f);
|
||||
REQUIRE(y2 == 120.0f);
|
||||
|
||||
const Fill::ColorStop* cs2 = nullptr;
|
||||
REQUIRE(fill->colorStops(&cs2) == 4);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
REQUIRE(cs[i].offset == cs2[i].offset);
|
||||
REQUIRE(cs[i].r == cs2[i].r);
|
||||
REQUIRE(cs[i].g == cs2[i].g);
|
||||
REQUIRE(cs[i].b == cs2[i].b);
|
||||
};
|
||||
}
|
||||
|
||||
TEST_CASE("Radial Filling Dupliction", "[tvgFill]")
|
||||
{
|
||||
auto fill = RadialGradient::gen();
|
||||
REQUIRE(fill);
|
||||
|
@ -162,4 +203,4 @@ TEST_CASE("Filling Dupliction", "[tvgFill]")
|
|||
REQUIRE(cs[i].g == cs2[i].g);
|
||||
REQUIRE(cs[i].b == cs2[i].b);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,6 +201,23 @@ TEST_CASE("Picture Size", "[tvgPicture]")
|
|||
REQUIRE(picture->size(w, h) == Result::Success);
|
||||
}
|
||||
|
||||
TEST_CASE("Picture Duplication", "[tvgPicture]")
|
||||
{
|
||||
auto picture = Picture::gen();
|
||||
REQUIRE(picture);
|
||||
|
||||
REQUIRE(picture->load(TEST_DIR"/logo.svg") == Result::Success);
|
||||
REQUIRE(picture->size(100, 100) == Result::Success);
|
||||
|
||||
auto dup = picture->duplicate();
|
||||
REQUIRE(dup);
|
||||
|
||||
float w, h;
|
||||
REQUIRE(picture->size(&w, &h) == Result::Success);
|
||||
REQUIRE(w == 100);
|
||||
REQUIRE(h == 100);
|
||||
}
|
||||
|
||||
TEST_CASE("Load SVG file and render", "[tvgPicture]")
|
||||
{
|
||||
REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
|
||||
|
@ -287,6 +304,7 @@ TEST_CASE("Load RAW file and render", "[tvgPicture]")
|
|||
file.close();
|
||||
|
||||
REQUIRE(picture->load(data, 200, 300, false) == Result::Success);
|
||||
REQUIRE(picture->size(100, 150) == Result::Success);
|
||||
|
||||
REQUIRE(canvas->push(move(picture)) == Result::Success);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue