test capi: update tvg_paint_get_bounds() utc.

The api has been changed by 060564cc93
update it according its change.
This commit is contained in:
Hermet Park 2021-10-01 19:31:04 +09:00 committed by Hermet Park
parent ca9a9c3a42
commit 9737dd4a89
2 changed files with 15 additions and 5 deletions

View file

@ -807,21 +807,21 @@ TVG_EXPORT Tvg_Paint* tvg_paint_duplicate(Tvg_Paint* paint);
/*! /*!
* \brief Gets the bounding box of the Tvg_Paint object before any transformation. (BETA_API) * \brief Gets the axis-aligned bounding box of the Tvg_Paint object. (BETA_API)
* *
* \param[in] paint The Tvg_Paint object of which to get the bounds. * \param[in] paint The Tvg_Paint object of which to get the bounds.
* \param[out] x The x coordinate of the upper left corner of the object. * \param[out] x The x coordinate of the upper left corner of the object.
* \param[out] y The y coordinate of the upper left corner of the object. * \param[out] y The y coordinate of the upper left corner of the object.
* \param[out] w The width of the object. * \param[out] w The width of the object.
* \param[out] h The height of the object. * \param[out] h The height of the object.
* \param[in] transformed if @c true, apply the transformation of the paint. * \param[in] transformed If @c true, the transformation of the paint is taken into account, otherwise it isn't.
* *
* \return Tvg_Result enumeration. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer.
* \retval TVG_RESULT_INSUFFICIENT_CONDITION Other errors. * \retval TVG_RESULT_INSUFFICIENT_CONDITION Other errors.
* *
* \note Transformation of an object changes the returned values. * \note The bounding box doesn't indicate the actual drawing region. It's the smallest rectangle that encloses the object.
*/ */
TVG_EXPORT Tvg_Result tvg_paint_get_bounds(const Tvg_Paint* paint, float* x, float* y, float* w, float* h, bool transformed); TVG_EXPORT Tvg_Result tvg_paint_get_bounds(const Tvg_Paint* paint, float* x, float* y, float* w, float* h, bool transformed);

View file

@ -142,7 +142,7 @@ TEST_CASE("Paint Bounds", "[capiPaint]")
float x, y, w, h; float x, y, w, h;
REQUIRE(tvg_shape_append_rect(paint, 0, 10, 20, 100, 0, 0) == TVG_RESULT_SUCCESS); REQUIRE(tvg_shape_append_rect(paint, 0, 10, 20, 100, 0, 0) == TVG_RESULT_SUCCESS);
REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h) == TVG_RESULT_SUCCESS); REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h, true) == TVG_RESULT_SUCCESS);
REQUIRE(x == 0); REQUIRE(x == 0);
REQUIRE(y == 10); REQUIRE(y == 10);
@ -151,15 +151,25 @@ TEST_CASE("Paint Bounds", "[capiPaint]")
REQUIRE(tvg_shape_reset(paint) == TVG_RESULT_SUCCESS); REQUIRE(tvg_shape_reset(paint) == TVG_RESULT_SUCCESS);
REQUIRE(tvg_paint_translate(paint, 100, 100) == TVG_RESULT_SUCCESS);
REQUIRE(tvg_paint_scale(paint, 2) == TVG_RESULT_SUCCESS);
REQUIRE(tvg_shape_move_to(paint, 0, 10) == TVG_RESULT_SUCCESS); REQUIRE(tvg_shape_move_to(paint, 0, 10) == TVG_RESULT_SUCCESS);
REQUIRE(tvg_shape_line_to(paint, 20, 110) == TVG_RESULT_SUCCESS); REQUIRE(tvg_shape_line_to(paint, 20, 110) == TVG_RESULT_SUCCESS);
REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h) == TVG_RESULT_SUCCESS); REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h, false) == TVG_RESULT_SUCCESS);
REQUIRE(x == 0); REQUIRE(x == 0);
REQUIRE(y == 10); REQUIRE(y == 10);
REQUIRE(w == 20); REQUIRE(w == 20);
REQUIRE(h == 100); REQUIRE(h == 100);
REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h, true) == TVG_RESULT_SUCCESS);
REQUIRE(x == Approx(100.0f).margin(0.000001));
REQUIRE(y == Approx(120.0f).margin(0.000001));
REQUIRE(w == Approx(40.0f).margin(0.000001));
REQUIRE(h == Approx(200.0f).margin(0.000001));
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS); REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
} }