mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-27 00:26:51 +00:00
test capi: Stroke Linear Gradient
This commit is contained in:
parent
23db42e41c
commit
3d672a4ea8
1 changed files with 35 additions and 1 deletions
|
@ -58,7 +58,7 @@ TEST_CASE("Linear Gradient in shape", "[capiLinearGradient]")
|
||||||
Tvg_Paint *shape = tvg_shape_new();
|
Tvg_Paint *shape = tvg_shape_new();
|
||||||
REQUIRE(shape);
|
REQUIRE(shape);
|
||||||
|
|
||||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_shape_set_linear_gradient(shape, gradient) == TVG_RESULT_SUCCESS);
|
||||||
|
|
||||||
REQUIRE(tvg_shape_set_linear_gradient(shape, NULL) == TVG_RESULT_MEMORY_CORRUPTION);
|
REQUIRE(tvg_shape_set_linear_gradient(shape, NULL) == TVG_RESULT_MEMORY_CORRUPTION);
|
||||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||||
|
@ -135,3 +135,37 @@ TEST_CASE("Linear Gradient spread", "[capiLinearGradient]")
|
||||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||||
REQUIRE(tvg_gradient_del(NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
REQUIRE(tvg_gradient_del(NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Stroke Linear Gradient", "[capiLinearGradient]")
|
||||||
|
{
|
||||||
|
Tvg_Paint *shape = tvg_shape_new();
|
||||||
|
REQUIRE(shape != NULL);
|
||||||
|
|
||||||
|
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||||
|
REQUIRE(gradient != NULL);
|
||||||
|
|
||||||
|
Tvg_Color_Stop color_stops[2] =
|
||||||
|
{
|
||||||
|
{.offset=0.0, .r=0, .g=0, .b=0, .a=255},
|
||||||
|
{.offset=1, .r=0, .g=255, .b=0, .a=255},
|
||||||
|
};
|
||||||
|
|
||||||
|
Tvg_Gradient *gradient_ret = NULL;
|
||||||
|
const Tvg_Color_Stop *color_stops_ret = NULL;
|
||||||
|
uint32_t color_stops_count_ret = 0;
|
||||||
|
|
||||||
|
REQUIRE(tvg_gradient_set_color_stops(gradient, color_stops, 2) == TVG_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
REQUIRE(tvg_shape_set_stroke_linear_gradient(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||||
|
REQUIRE(tvg_shape_set_stroke_linear_gradient(NULL, gradient) == TVG_RESULT_INVALID_ARGUMENT);
|
||||||
|
REQUIRE(tvg_shape_set_stroke_linear_gradient(shape, gradient) == TVG_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
REQUIRE(tvg_shape_get_stroke_gradient(shape, &gradient_ret) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(gradient_ret);
|
||||||
|
|
||||||
|
REQUIRE(tvg_gradient_get_color_stops(gradient_ret, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(color_stops_ret);
|
||||||
|
REQUIRE(color_stops_count_ret == 2);
|
||||||
|
|
||||||
|
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue