mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 06:04:03 +00:00
tests: added tests for size and composite C apis
This commit is contained in:
parent
236c777466
commit
304a351dcc
2 changed files with 30 additions and 3 deletions
|
@ -218,8 +218,16 @@ TEST_CASE("Paint Clip Path Composite Method", "[capiPaint]")
|
||||||
REQUIRE(tvg_paint_set_composite_method(paint, NULL, TVG_COMPOSITE_METHOD_NONE) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_paint_set_composite_method(paint, NULL, TVG_COMPOSITE_METHOD_NONE) == TVG_RESULT_SUCCESS);
|
||||||
REQUIRE(tvg_paint_set_composite_method(paint, target, TVG_COMPOSITE_METHOD_NONE) == TVG_RESULT_INVALID_ARGUMENT);
|
REQUIRE(tvg_paint_set_composite_method(paint, target, TVG_COMPOSITE_METHOD_NONE) == TVG_RESULT_INVALID_ARGUMENT);
|
||||||
|
|
||||||
REQUIRE(tvg_paint_set_composite_method(paint, target, TVG_COMPOSITE_METHOD_CLIP_PATH) == TVG_RESULT_SUCCESS);
|
|
||||||
REQUIRE(tvg_paint_set_composite_method(paint, NULL, TVG_COMPOSITE_METHOD_CLIP_PATH) == TVG_RESULT_INVALID_ARGUMENT);
|
REQUIRE(tvg_paint_set_composite_method(paint, NULL, TVG_COMPOSITE_METHOD_CLIP_PATH) == TVG_RESULT_INVALID_ARGUMENT);
|
||||||
|
REQUIRE(tvg_paint_set_composite_method(paint, target, TVG_COMPOSITE_METHOD_CLIP_PATH) == TVG_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
const Tvg_Paint* target2 = nullptr;
|
||||||
|
Tvg_Composite_Method method = TVG_COMPOSITE_METHOD_NONE;
|
||||||
|
REQUIRE(tvg_paint_get_composite_method(paint, NULL, &method) == TVG_RESULT_INVALID_ARGUMENT);
|
||||||
|
REQUIRE(tvg_paint_get_composite_method(paint, &target2, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||||
|
REQUIRE(tvg_paint_get_composite_method(paint, &target2, &method) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(method == TVG_COMPOSITE_METHOD_CLIP_PATH);
|
||||||
|
REQUIRE(target == target2);
|
||||||
|
|
||||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,12 @@ TEST_CASE("Load Svg file in Picture", "[capiPicture]")
|
||||||
//Load Svg file
|
//Load Svg file
|
||||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/logo.svg") == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_picture_load(picture, TEST_DIR"/logo.svg") == TVG_RESULT_SUCCESS);
|
||||||
|
|
||||||
float w, h;
|
float wNew = 500.0f, hNew = 500.0f;
|
||||||
|
float w = 0.0f, h = 0.0f;
|
||||||
|
REQUIRE(tvg_picture_set_size(picture, wNew, hNew) == TVG_RESULT_SUCCESS);
|
||||||
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(w == Approx(wNew).epsilon(0.0000001));
|
||||||
|
REQUIRE(h == Approx(hNew).epsilon(0.0000001));
|
||||||
|
|
||||||
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +69,12 @@ TEST_CASE("Load Svg Data in Picture", "[capiPicture]")
|
||||||
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
||||||
REQUIRE(w == Approx(1000).epsilon(0.0000001));
|
REQUIRE(w == Approx(1000).epsilon(0.0000001));
|
||||||
REQUIRE(h == Approx(1000).epsilon(0.0000001));
|
REQUIRE(h == Approx(1000).epsilon(0.0000001));
|
||||||
|
float wNew = 500.0f, hNew = 500.0f;
|
||||||
|
REQUIRE(tvg_picture_set_size(picture, wNew, hNew) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(w == Approx(wNew).epsilon(0.0000001));
|
||||||
|
REQUIRE(h == Approx(hNew).epsilon(0.0000001));
|
||||||
|
|
||||||
|
|
||||||
//Verify Position
|
//Verify Position
|
||||||
float x, y;
|
float x, y;
|
||||||
|
@ -103,6 +113,11 @@ TEST_CASE("Load Raw file in Picture", "[capiPicture]")
|
||||||
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
||||||
REQUIRE(w == Approx(200).epsilon(0.0000001));
|
REQUIRE(w == Approx(200).epsilon(0.0000001));
|
||||||
REQUIRE(h == Approx(300).epsilon(0.0000001));
|
REQUIRE(h == Approx(300).epsilon(0.0000001));
|
||||||
|
float wNew = 500.0f, hNew = 500.0f;
|
||||||
|
REQUIRE(tvg_picture_set_size(picture, wNew, hNew) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(w == Approx(wNew).epsilon(0.0000001));
|
||||||
|
REQUIRE(h == Approx(hNew).epsilon(0.0000001));
|
||||||
}
|
}
|
||||||
|
|
||||||
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
||||||
|
@ -123,8 +138,12 @@ TEST_CASE("Load Png file in Picture", "[capiPicture]")
|
||||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/test.png") == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_picture_load(picture, TEST_DIR"/test.png") == TVG_RESULT_SUCCESS);
|
||||||
|
|
||||||
//Verify Size
|
//Verify Size
|
||||||
float w, h;
|
float wNew = 500.0f, hNew = 500.0f;
|
||||||
|
float w = 0.0f, h = 0.0f;
|
||||||
|
REQUIRE(tvg_picture_set_size(picture, wNew, hNew) == TVG_RESULT_SUCCESS);
|
||||||
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
||||||
|
REQUIRE(w == Approx(wNew).epsilon(0.0000001));
|
||||||
|
REQUIRE(h == Approx(hNew).epsilon(0.0000001));
|
||||||
|
|
||||||
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue