From 669b5badf4b069ae41d3c493a9504e848a400675 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Thu, 30 May 2024 21:14:13 +0200 Subject: [PATCH] test: add strokeTrim tests --- test/capi/capiShape.cpp | 19 +++++++++++++++++++ test/testShape.cpp | 11 +++++++++++ 2 files changed, 30 insertions(+) diff --git a/test/capi/capiShape.cpp b/test/capi/capiShape.cpp index f845ac25..66ca9504 100644 --- a/test/capi/capiShape.cpp +++ b/test/capi/capiShape.cpp @@ -246,7 +246,26 @@ TEST_CASE("Stroke join", "[capiStrokeJoin]") REQUIRE(tvg_shape_get_stroke_miterlimit(paint, &ml) == TVG_RESULT_SUCCESS); REQUIRE(ml == 1000.0f); + REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS); +} +TEST_CASE("Stroke trim", "[capiStrokeTrim]") +{ + Tvg_Paint* paint = tvg_shape_new(); + REQUIRE(paint); + + float begin, end; + bool simultaneous; + + REQUIRE(tvg_shape_get_stroke_trim(NULL, &begin, &end, &simultaneous) == TVG_RESULT_INVALID_ARGUMENT); + REQUIRE(tvg_shape_get_stroke_trim(paint, &begin, &end, &simultaneous) == TVG_RESULT_SUCCESS); + + REQUIRE(tvg_shape_set_stroke_trim(NULL, 0.33, 0.66, false) == TVG_RESULT_INVALID_ARGUMENT); + REQUIRE(tvg_shape_set_stroke_trim(paint, 0.33, 0.66, false) == TVG_RESULT_SUCCESS); + REQUIRE(tvg_shape_get_stroke_trim(paint, &begin, &end, &simultaneous) == TVG_RESULT_SUCCESS); + REQUIRE(begin == Approx(0.33).margin(0.000001)); + REQUIRE(end == Approx(0.66).margin(0.000001)); + REQUIRE(simultaneous == false); REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS); } diff --git a/test/testShape.cpp b/test/testShape.cpp index 2914757f..8f2ca7e5 100644 --- a/test/testShape.cpp +++ b/test/testShape.cpp @@ -203,6 +203,17 @@ TEST_CASE("Stroking", "[tvgShape]") REQUIRE(shape->strokeMiterlimit() == 1000.0f); REQUIRE(shape->strokeMiterlimit(-0.001f) == Result::NonSupport); + //Stroke Trim + float begin, end; + REQUIRE(shape->strokeTrim(&begin, &end) == true); + REQUIRE(begin == Approx(0.0).margin(0.000001)); + REQUIRE(end == Approx(1.0).margin(0.000001)); + + REQUIRE(shape->strokeTrim(0.3, 0.88, false) == Result::Success); + REQUIRE(shape->strokeTrim(&begin, &end) == false); + REQUIRE(begin == Approx(0.3).margin(0.000001)); + REQUIRE(end == Approx(0.88).margin(0.000001)); + //Stroke Order After Stroke Setting REQUIRE(shape->order(true) == Result::Success); REQUIRE(shape->order(false) == Result::Success);