mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
tests: remove capi tests
@Issue: https://github.com/thorvg/thorvg/issues/2978
This commit is contained in:
parent
d069156994
commit
b5d81be339
16 changed files with 0 additions and 2340 deletions
|
@ -1,154 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
|
||||
TEST_CASE("Animation Basic", "[capiAnimation]")
|
||||
{
|
||||
Tvg_Animation* animation = tvg_animation_new();
|
||||
REQUIRE(animation);
|
||||
|
||||
Tvg_Paint* picture = tvg_animation_get_picture(animation);
|
||||
REQUIRE(picture);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(picture, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_PICTURE);
|
||||
|
||||
//Negative cases
|
||||
REQUIRE(tvg_animation_set_frame(animation, 0) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
auto frame = 0.0f;
|
||||
REQUIRE(tvg_animation_set_frame(animation, frame) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
REQUIRE(tvg_animation_get_frame(animation, nullptr) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_animation_get_frame(animation, &frame) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(frame == 0.0f);
|
||||
|
||||
REQUIRE(tvg_animation_get_total_frame(animation, nullptr) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_animation_get_total_frame(animation, &frame) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(frame == 0.0f);
|
||||
|
||||
REQUIRE(tvg_animation_get_duration(animation, nullptr) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
float duration = 0.0f;
|
||||
REQUIRE(tvg_animation_get_duration(animation, &duration) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(duration == 0.0f);
|
||||
|
||||
REQUIRE(tvg_animation_del(nullptr) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_animation_del(animation) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#ifdef THORVG_LOTTIE_LOADER_SUPPORT
|
||||
|
||||
TEST_CASE("Animation Lottie", "[capiAnimation]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Animation* animation = tvg_animation_new();
|
||||
REQUIRE(animation);
|
||||
|
||||
Tvg_Paint* picture = tvg_animation_get_picture(animation);
|
||||
REQUIRE(picture);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(picture, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_PICTURE);
|
||||
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/invalid.json") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/test.json") == TVG_RESULT_SUCCESS);
|
||||
|
||||
float frame;
|
||||
REQUIRE(tvg_animation_get_total_frame(animation, &frame) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(frame == Approx(120).margin(0.001f));
|
||||
|
||||
REQUIRE(tvg_animation_set_frame(animation, frame - 1) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_animation_get_frame(animation, &frame) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(frame == Approx(119).margin(0.001f));
|
||||
|
||||
float duration;
|
||||
REQUIRE(tvg_animation_get_duration(animation, &duration) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(duration == Approx(4.004).margin(0.001f)); //120/29.97
|
||||
|
||||
REQUIRE(tvg_animation_del(animation) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Animation Segment", "[capiAnimation]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Animation* animation = tvg_animation_new();
|
||||
REQUIRE(animation);
|
||||
|
||||
Tvg_Paint* picture = tvg_animation_get_picture(animation);
|
||||
REQUIRE(picture);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(picture, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_PICTURE);
|
||||
|
||||
float begin, end;
|
||||
|
||||
//Segment by range before loaded
|
||||
REQUIRE(tvg_animation_set_segment(animation, 0, 0.5) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
//Get current segment before loaded
|
||||
REQUIRE(tvg_animation_get_segment(animation, &begin, &end) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
//Animation load
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/lottiemarker.json") == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Get current segment before segment
|
||||
REQUIRE(tvg_animation_get_segment(animation, &begin, &end) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(begin == 0.0f);
|
||||
REQUIRE(end == 1.0f);
|
||||
|
||||
//Get only segment begin
|
||||
REQUIRE(tvg_animation_get_segment(animation, &begin, nullptr) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(begin == 0.0f);
|
||||
|
||||
//Get only segment end
|
||||
REQUIRE(tvg_animation_get_segment(animation, nullptr, &end) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(end == 1.0f);
|
||||
|
||||
//Segment by range
|
||||
REQUIRE(tvg_animation_set_segment(animation, 0.25, 0.5) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Get current segment before segment
|
||||
REQUIRE(tvg_animation_get_segment(animation, &begin, &end) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(begin == 0.25);
|
||||
REQUIRE(end == 0.5);
|
||||
|
||||
//Segment by invalid range
|
||||
REQUIRE(tvg_animation_set_segment(animation, -0.5, 1.5) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_animation_del(animation) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
|
||||
TEST_CASE("Set/Get fill color", "[capiShapeFill]")
|
||||
{
|
||||
Tvg_Paint *paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_shape_set_fill_color(paint, 120, 154, 180, 100) == TVG_RESULT_SUCCESS);
|
||||
|
||||
uint8_t r = 0, g = 0, b = 0, a = 0;
|
||||
REQUIRE(tvg_shape_get_fill_color(paint, &r, &g, &b, &a) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(r == 120);
|
||||
REQUIRE(g == 154);
|
||||
REQUIRE(b == 180);
|
||||
REQUIRE(a == 100);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set/Get fill color on invalid shape", "[capiShapeFill]")
|
||||
{
|
||||
REQUIRE(tvg_shape_set_fill_color(NULL, 120, 154, 180, 100) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
uint8_t r, g, b, a;
|
||||
REQUIRE(tvg_shape_get_fill_color(NULL, &r, &g, &b, &a) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
TEST_CASE("Set/Get shape fill rule", "[capiShapeFill]")
|
||||
{
|
||||
Tvg_Paint *paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_shape_set_fill_rule(paint, TVG_FILL_RULE_EVEN_ODD) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Fill_Rule rule = TVG_FILL_RULE_WINDING;
|
||||
REQUIRE(tvg_shape_get_fill_rule(paint, &rule) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(rule == TVG_FILL_RULE_EVEN_ODD);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set/Get shape fill rule on invalid object", "[capiShapeFill]")
|
||||
{
|
||||
REQUIRE(tvg_shape_set_fill_rule(NULL, TVG_FILL_RULE_EVEN_ODD) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
Tvg_Fill_Rule rule;
|
||||
REQUIRE(tvg_shape_get_fill_rule(NULL, &rule) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
#include <cstring>
|
||||
|
||||
TEST_CASE("Basic capi initialization", "[capiInitializer]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Version", "[tvgInitializer]")
|
||||
{
|
||||
REQUIRE(tvg_engine_version(NULL, NULL, NULL, NULL) == TVG_RESULT_SUCCESS);
|
||||
uint32_t major, minor, micro;
|
||||
const char* curVersion;
|
||||
tvg_engine_version(&major, &minor, µ, &curVersion);
|
||||
REQUIRE(strcmp(curVersion, THORVG_VERSION_STRING) == 0);
|
||||
char curVersion2[10];
|
||||
snprintf(curVersion2, sizeof(curVersion2), "%d.%d.%d", major, minor, micro);
|
||||
REQUIRE(strcmp(curVersion2, THORVG_VERSION_STRING) == 0);
|
||||
}
|
|
@ -1,286 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
TEST_CASE("Linear Gradient Basic Create", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_gradient_get_type(gradient, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_LINEAR_GRAD);
|
||||
REQUIRE(type != TVG_TYPE_RADIAL_GRAD);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Linear Gradient start and end position", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
|
||||
REQUIRE(gradient);
|
||||
REQUIRE(tvg_linear_gradient_set(gradient, 10.0, 20.0, 50.0, 40.0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
float x1, y1, x2, y2;
|
||||
REQUIRE(tvg_linear_gradient_get(gradient, &x1, &y1, &x2, &y2) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(x1 == 10.0);
|
||||
REQUIRE(y1 == 20.0);
|
||||
REQUIRE(x2 == 50.0);
|
||||
REQUIRE(y2 == 40.0);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Linear Gradient in shape", "[capiLinearGradient]")
|
||||
{
|
||||
REQUIRE(tvg_shape_set_gradient(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
REQUIRE(tvg_shape_set_gradient(NULL, gradient) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
REQUIRE(tvg_shape_set_gradient(shape, gradient) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Gradient *gradient_ret = NULL;
|
||||
REQUIRE(tvg_shape_get_gradient(shape, &gradient_ret) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(gradient_ret);
|
||||
|
||||
REQUIRE(tvg_shape_set_gradient(shape, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Linear Gradient color stops", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Color_Stop color_stops[2] =
|
||||
{
|
||||
{0.0, 0, 0, 0, 255},
|
||||
{1.0, 0, 255, 0, 255},
|
||||
};
|
||||
|
||||
const Tvg_Color_Stop *color_stops_ret;
|
||||
uint32_t color_stops_count_ret;
|
||||
|
||||
REQUIRE(tvg_gradient_set_color_stops(gradient, color_stops, 2) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(color_stops_count_ret == 2);
|
||||
REQUIRE(color_stops_ret[0].a == 255);
|
||||
REQUIRE(color_stops_ret[1].g == 255);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Linear Gradient duplicate", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Color_Stop color_stops[3] =
|
||||
{
|
||||
{0.0f, 255, 0, 0, 155},
|
||||
{0.8f, 0, 255, 0, 155},
|
||||
{1.0f, 128, 0, 128, 155},
|
||||
};
|
||||
REQUIRE(tvg_gradient_set_color_stops(gradient, color_stops, 3) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_linear_gradient_set(gradient, 11.1f, 22.2f, 33.3f, 44.4f) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Gradient *gradient_dup = tvg_gradient_duplicate(gradient);
|
||||
REQUIRE(gradient_dup);
|
||||
|
||||
const Tvg_Color_Stop *color_stops_dup = NULL;
|
||||
uint32_t color_stops_count_dup = 0;
|
||||
REQUIRE(tvg_gradient_get_color_stops(gradient_dup, &color_stops_dup, &color_stops_count_dup) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(color_stops_count_dup == 3);
|
||||
REQUIRE(color_stops_dup);
|
||||
REQUIRE(color_stops_dup[1].offset == Approx(0.8f).margin(0.000001));
|
||||
REQUIRE(color_stops_dup[2].a == 155);
|
||||
REQUIRE(color_stops_dup[2].r == 128);
|
||||
|
||||
float x1, y1, x2, y2;
|
||||
REQUIRE(tvg_linear_gradient_get(gradient_dup, &x1, &y1, &x2, &y2) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(x1 == Approx(11.1f).margin(0.000001));
|
||||
REQUIRE(y1 == Approx(22.2f).margin(0.000001));
|
||||
REQUIRE(x2 == Approx(33.3f).margin(0.000001));
|
||||
REQUIRE(y2 == Approx(44.4f).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_del(gradient_dup) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Linear Gradient type", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Gradient* grad = tvg_linear_gradient_new();
|
||||
REQUIRE(grad);
|
||||
|
||||
Tvg_Gradient* grad_copy = tvg_gradient_duplicate(grad);
|
||||
REQUIRE(grad_copy);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
Tvg_Type type2 = TVG_TYPE_UNDEF;
|
||||
|
||||
REQUIRE(tvg_gradient_get_type(nullptr, &type) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_get_type(grad, nullptr) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_get_type(grad, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_get_type(grad_copy, &type2) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type2 == type);
|
||||
|
||||
REQUIRE(tvg_gradient_del(grad_copy) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_del(grad) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Linear Gradient clear data", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Color_Stop color_stops[2] =
|
||||
{
|
||||
{0.0, 0, 0, 0, 255},
|
||||
{1.0, 0, 255, 0, 255},
|
||||
};
|
||||
|
||||
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_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(color_stops_ret);
|
||||
REQUIRE(color_stops_count_ret == 2);
|
||||
|
||||
REQUIRE(tvg_gradient_set_color_stops(gradient, NULL, 0) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(color_stops_ret == nullptr);
|
||||
REQUIRE(color_stops_count_ret == 0);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Linear Gradient spread", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Stroke_Fill spread;
|
||||
REQUIRE(tvg_gradient_set_spread(gradient, TVG_STROKE_FILL_PAD) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_get_spread(gradient, &spread) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(spread == TVG_STROKE_FILL_PAD);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_del(NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
TEST_CASE("Linear Gradient transformation", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Matrix matrix_get;
|
||||
|
||||
REQUIRE(tvg_gradient_get_transform(NULL, &matrix_get) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_get_transform(gradient, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_get_transform(gradient, &matrix_get) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(matrix_get.e11 == Approx(1.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e12 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e13 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e21 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e22 == Approx(1.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e23 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e31 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e32 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e33 == Approx(1.0f).margin(0.000001));
|
||||
|
||||
Tvg_Matrix matrix_set = {1.1f, -2.2f, 3.3f, -4.4f, 5.5f, -6.6f, 7.7f, -8.8f, 9.9f};
|
||||
REQUIRE(tvg_gradient_set_transform(NULL, &matrix_set) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_set_transform(gradient, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_set_transform(gradient, &matrix_set) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_gradient_get_transform(gradient, &matrix_get) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(matrix_get.e11 == Approx(matrix_set.e11).margin(0.000001));
|
||||
REQUIRE(matrix_get.e12 == Approx(matrix_set.e12).margin(0.000001));
|
||||
REQUIRE(matrix_get.e13 == Approx(matrix_set.e13).margin(0.000001));
|
||||
REQUIRE(matrix_get.e21 == Approx(matrix_set.e21).margin(0.000001));
|
||||
REQUIRE(matrix_get.e22 == Approx(matrix_set.e22).margin(0.000001));
|
||||
REQUIRE(matrix_get.e23 == Approx(matrix_set.e23).margin(0.000001));
|
||||
REQUIRE(matrix_get.e31 == Approx(matrix_set.e31).margin(0.000001));
|
||||
REQUIRE(matrix_get.e32 == Approx(matrix_set.e32).margin(0.000001));
|
||||
REQUIRE(matrix_get.e33 == Approx(matrix_set.e33).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Stroke Linear Gradient", "[capiLinearGradient]")
|
||||
{
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_linear_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Color_Stop color_stops[2] =
|
||||
{
|
||||
{0.0, 0, 0, 0, 255},
|
||||
{1.0, 0, 255, 0, 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_gradient(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_set_stroke_gradient(NULL, gradient) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_set_stroke_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);
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
#ifdef THORVG_LOTTIE_LOADER_SUPPORT
|
||||
|
||||
TEST_CASE("Lottie Slot", "[capiLottie]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Animation* animation = tvg_lottie_animation_new();
|
||||
REQUIRE(animation);
|
||||
|
||||
Tvg_Paint* picture = tvg_animation_get_picture(animation);
|
||||
REQUIRE(picture);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(picture, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_PICTURE);
|
||||
|
||||
const char* slotJson = R"({"gradient_fill":{"p":{"p":2,"k":{"a":0,"k":[0,0.1,0.1,0.2,1,1,0.1,0.2,0.1,1]}}}})";
|
||||
|
||||
//Slot override before loaded
|
||||
REQUIRE(tvg_lottie_animation_override(animation, slotJson) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
//Animation load
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/lottieslot.json") == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Slot revert before overriding
|
||||
REQUIRE(tvg_lottie_animation_override(animation, nullptr) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Slot override
|
||||
REQUIRE(tvg_lottie_animation_override(animation, slotJson) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Slot revert
|
||||
REQUIRE(tvg_lottie_animation_override(animation, nullptr) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Slot override after reverting
|
||||
REQUIRE(tvg_lottie_animation_override(animation, slotJson) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Slot override with invalid JSON
|
||||
REQUIRE(tvg_lottie_animation_override(animation, "") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_animation_del(animation) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Lottie Slot 2", "[capiLottie]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Animation* animation = tvg_lottie_animation_new();
|
||||
REQUIRE(animation);
|
||||
|
||||
Tvg_Paint* picture = tvg_animation_get_picture(animation);
|
||||
REQUIRE(picture);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(picture, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_PICTURE);
|
||||
|
||||
const char* slotJson = R"({"lottie-icon-outline":{"p":{"a":0,"k":[1,1,0]}},"lottie-icon-solid":{"p":{"a":0,"k":[0,0,1]}}})";
|
||||
|
||||
//Animation load
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/lottieslotkeyframe.json") == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Slot override
|
||||
REQUIRE(tvg_lottie_animation_override(animation, slotJson) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Slot revert
|
||||
REQUIRE(tvg_lottie_animation_override(animation, nullptr) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Slot override after reverting
|
||||
REQUIRE(tvg_lottie_animation_override(animation, slotJson) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_animation_del(animation) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Lottie Marker", "[capiLottie]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Animation* animation = tvg_lottie_animation_new();
|
||||
REQUIRE(animation);
|
||||
|
||||
Tvg_Paint* picture = tvg_animation_get_picture(animation);
|
||||
REQUIRE(picture);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(picture, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_PICTURE);
|
||||
|
||||
//Set marker before loaded
|
||||
REQUIRE(tvg_lottie_animation_set_marker(animation, "sectionC") == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
//Animation load
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/lottiemarker.json") == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Set marker
|
||||
REQUIRE(tvg_lottie_animation_set_marker(animation, "sectionA") == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Set marker by invalid name
|
||||
REQUIRE(tvg_lottie_animation_set_marker(animation, "") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
//Get marker count
|
||||
uint32_t cnt = 0;
|
||||
REQUIRE(tvg_lottie_animation_get_markers_cnt(animation, &cnt) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(cnt == 3);
|
||||
|
||||
//Get marker name by index
|
||||
const char* name = nullptr;
|
||||
REQUIRE(tvg_lottie_animation_get_marker(animation, 1, &name) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(!strcmp(name, "sectionB"));
|
||||
|
||||
//Get marker name by invalid index
|
||||
REQUIRE(tvg_lottie_animation_get_marker(animation, -1, &name) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_animation_del(animation) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,5 +0,0 @@
|
|||
// The only purpose of this file is to DEFINE the catch config so it can include main()
|
||||
|
||||
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
|
||||
|
||||
#include "../catch.hpp"
|
|
@ -1,387 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
|
||||
TEST_CASE("Paint Transform", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Matrix matrix_set = {1, 0, 0, 0, 1, 0, 0, 0, 1}, matrix_get;
|
||||
|
||||
REQUIRE(tvg_paint_set_transform(paint, &matrix_set) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_transform(paint, &matrix_get) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(matrix_get.e11 == Approx(matrix_set.e11).margin(0.000001));
|
||||
REQUIRE(matrix_get.e12 == Approx(matrix_set.e12).margin(0.000001));
|
||||
REQUIRE(matrix_get.e13 == Approx(matrix_set.e13).margin(0.000001));
|
||||
REQUIRE(matrix_get.e21 == Approx(matrix_set.e21).margin(0.000001));
|
||||
REQUIRE(matrix_get.e22 == Approx(matrix_set.e22).margin(0.000001));
|
||||
REQUIRE(matrix_get.e23 == Approx(matrix_set.e23).margin(0.000001));
|
||||
REQUIRE(matrix_get.e31 == Approx(matrix_set.e31).margin(0.000001));
|
||||
REQUIRE(matrix_get.e32 == Approx(matrix_set.e32).margin(0.000001));
|
||||
REQUIRE(matrix_get.e33 == Approx(matrix_set.e33).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Translate", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Matrix matrix;
|
||||
|
||||
REQUIRE(tvg_paint_translate(paint, 20, 30) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_transform(paint, &matrix) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(matrix.e11 == Approx(1).margin(0.000001));
|
||||
REQUIRE(matrix.e12 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e13 == Approx(20).margin(0.000001));
|
||||
REQUIRE(matrix.e21 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e22 == Approx(1).margin(0.000001));
|
||||
REQUIRE(matrix.e23 == Approx(30).margin(0.000001));
|
||||
REQUIRE(matrix.e31 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e32 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e33 == Approx(1).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Scale", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Matrix matrix;
|
||||
|
||||
REQUIRE(tvg_paint_scale(paint, 2.5f) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_transform(paint, &matrix) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(matrix.e11 == Approx(2.5).margin(0.000001));
|
||||
REQUIRE(matrix.e12 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e13 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e21 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e22 == Approx(2.5).margin(0.000001));
|
||||
REQUIRE(matrix.e23 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e31 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e32 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e33 == Approx(1).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Rotate", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Matrix matrix;
|
||||
|
||||
REQUIRE(tvg_paint_rotate(paint, 180.0f) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_transform(paint, &matrix) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(matrix.e11 == Approx(-1).margin(0.000001));
|
||||
REQUIRE(matrix.e12 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e13 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e21 == Approx(-0).margin(0.000001));
|
||||
REQUIRE(matrix.e22 == Approx(-1).margin(0.000001));
|
||||
REQUIRE(matrix.e23 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e31 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e32 == Approx(0).margin(0.000001));
|
||||
REQUIRE(matrix.e33 == Approx(1).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Opacity", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
uint8_t opacity;
|
||||
|
||||
REQUIRE(tvg_paint_set_opacity(paint, 0) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_opacity(paint, &opacity) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(0 == opacity);
|
||||
|
||||
REQUIRE(tvg_paint_set_opacity(paint, 128) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_opacity(paint, &opacity) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(128 == opacity);
|
||||
|
||||
REQUIRE(tvg_paint_set_opacity(paint, 255) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_opacity(paint, &opacity) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(255 == opacity);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Bounds", "[capiPaint]")
|
||||
{
|
||||
tvg_engine_init(TVG_ENGINE_SW, 0);
|
||||
Tvg_Canvas* canvas = tvg_swcanvas_create();
|
||||
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_canvas_push(canvas, paint) == TVG_RESULT_SUCCESS);
|
||||
|
||||
float x, y, w, h;
|
||||
|
||||
REQUIRE(tvg_canvas_update_paint(canvas, paint) == 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, true) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(x == 0);
|
||||
REQUIRE(y == 10);
|
||||
REQUIRE(w == 20);
|
||||
REQUIRE(h == 100);
|
||||
|
||||
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_line_to(paint, 20, 110) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h, false) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(x == 0);
|
||||
REQUIRE(y == 10);
|
||||
REQUIRE(w == 20);
|
||||
REQUIRE(h == 100);
|
||||
|
||||
REQUIRE(tvg_canvas_update_paint(canvas, paint) == TVG_RESULT_SUCCESS);
|
||||
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));
|
||||
|
||||
tvg_canvas_destroy(canvas);
|
||||
tvg_engine_term(TVG_ENGINE_SW);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Duplication", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_paint_set_opacity(paint, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_translate(paint, 200, 100) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_scale(paint, 2.2f) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_rotate(paint, 90.0f) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Paint* paint_copy = tvg_paint_duplicate(paint);
|
||||
REQUIRE(paint_copy);
|
||||
|
||||
uint8_t opacity;
|
||||
REQUIRE(tvg_paint_get_opacity(paint_copy, &opacity) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(0 == opacity);
|
||||
|
||||
Tvg_Matrix matrix;
|
||||
REQUIRE(tvg_paint_get_transform(paint, &matrix) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(matrix.e11 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix.e12 == Approx(-2.2f).margin(0.000001));
|
||||
REQUIRE(matrix.e13 == Approx(200.0f).margin(0.000001));
|
||||
REQUIRE(matrix.e21 == Approx(2.2f).margin(0.000001));
|
||||
REQUIRE(matrix.e22 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix.e23 == Approx(100.0f).margin(0.000001));
|
||||
REQUIRE(matrix.e31 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix.e32 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix.e33 == Approx(1.0f).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_del(paint_copy) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Identifier", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Paint* paint_copy = tvg_paint_duplicate(paint);
|
||||
REQUIRE(paint_copy);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
Tvg_Type type2 = TVG_TYPE_UNDEF;
|
||||
|
||||
REQUIRE(tvg_paint_get_type(nullptr, &type) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_type(paint, nullptr) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_type(paint, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_get_type(paint_copy, &type2) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type2 == type);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint_copy) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Clipping", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_paint_set_clip(paint, NULL) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Paint* target = tvg_shape_new();
|
||||
REQUIRE(target);
|
||||
REQUIRE(tvg_paint_set_clip(paint, target) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_set_clip(paint, NULL) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint AlphaMask Composite Method", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Paint* target = tvg_shape_new();
|
||||
REQUIRE(target);
|
||||
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, NULL, TVG_MASK_METHOD_NONE) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, target, TVG_MASK_METHOD_NONE) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, NULL, TVG_MASK_METHOD_ALPHA) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
Tvg_Paint* target2 = tvg_shape_new();
|
||||
REQUIRE(target2);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, target2, TVG_MASK_METHOD_ALPHA) == TVG_RESULT_SUCCESS);
|
||||
|
||||
const Tvg_Paint* target3 = nullptr;
|
||||
Tvg_Mask_Method method = TVG_MASK_METHOD_NONE;
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, NULL, &method) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, &target3, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, &target3, &method) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(method == TVG_MASK_METHOD_ALPHA);
|
||||
REQUIRE(target2 == target3);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint InvAlphaMask Composite Method", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Paint* target = tvg_shape_new();
|
||||
REQUIRE(target);
|
||||
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, NULL, TVG_MASK_METHOD_NONE) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, target, TVG_MASK_METHOD_NONE) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, NULL, TVG_MASK_METHOD_INVERSE_ALPHA) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
Tvg_Paint* target2 = tvg_shape_new();
|
||||
REQUIRE(target2);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, target2, TVG_MASK_METHOD_INVERSE_ALPHA) == TVG_RESULT_SUCCESS);
|
||||
|
||||
const Tvg_Paint* target3 = nullptr;
|
||||
Tvg_Mask_Method method = TVG_MASK_METHOD_NONE;
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, NULL, &method) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, &target3, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, &target3, &method) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(method == TVG_MASK_METHOD_INVERSE_ALPHA);
|
||||
REQUIRE(target2 == target3);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint LumaMask Composite Method", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Paint* target = tvg_shape_new();
|
||||
REQUIRE(target);
|
||||
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, NULL, TVG_MASK_METHOD_NONE) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, target, TVG_MASK_METHOD_NONE) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, NULL, TVG_MASK_METHOD_LUMA) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, NULL, TVG_MASK_METHOD_INVERSE_LUMA) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
Tvg_Paint* target2 = tvg_shape_new();
|
||||
REQUIRE(target2);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, target2, TVG_MASK_METHOD_LUMA) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Paint* target3 = tvg_shape_new();
|
||||
REQUIRE(target3);
|
||||
REQUIRE(tvg_paint_set_mask_method(paint, target3, TVG_MASK_METHOD_INVERSE_LUMA) == TVG_RESULT_SUCCESS);
|
||||
|
||||
const Tvg_Paint* target4 = nullptr;
|
||||
Tvg_Mask_Method method = TVG_MASK_METHOD_NONE;
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, NULL, &method) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, &target4, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_mask_method(paint, &target4, &method) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(method == TVG_MASK_METHOD_INVERSE_LUMA);
|
||||
REQUIRE(target3 == target4);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Reference Counter", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(tvg_paint_get_ref(paint) == 0);
|
||||
REQUIRE(tvg_paint_unref(paint, false) == 0);
|
||||
REQUIRE(tvg_paint_ref(paint) == 1);
|
||||
REQUIRE(tvg_paint_ref(paint) == 2);
|
||||
REQUIRE(tvg_paint_ref(paint) == 3);
|
||||
REQUIRE(tvg_paint_unref(paint, true) == 2);
|
||||
REQUIRE(tvg_paint_unref(paint, true) == 1);
|
||||
REQUIRE(tvg_paint_unref(paint, true) == 0);
|
||||
|
||||
tvg_engine_init(TVG_ENGINE_SW, 0);
|
||||
|
||||
Tvg_Canvas* canvas = tvg_swcanvas_create();
|
||||
|
||||
paint = tvg_shape_new();
|
||||
REQUIRE(tvg_paint_ref(paint) == 1);
|
||||
tvg_canvas_push(canvas, paint);
|
||||
REQUIRE(tvg_paint_get_ref(paint) == 2);
|
||||
tvg_canvas_clear(canvas, true, false);
|
||||
REQUIRE(tvg_paint_get_ref(paint) == 1);
|
||||
REQUIRE(tvg_paint_unref(paint, true) == 0);
|
||||
|
||||
paint = tvg_shape_new();
|
||||
REQUIRE(tvg_paint_ref(paint) == 1);
|
||||
Tvg_Paint* scene = tvg_scene_new();
|
||||
tvg_scene_push(scene, paint);
|
||||
tvg_canvas_push(canvas, scene);
|
||||
tvg_canvas_clear(canvas, true, false);
|
||||
REQUIRE(tvg_paint_get_ref(paint) == 1);
|
||||
REQUIRE(tvg_paint_unref(paint, true) == 0);
|
||||
|
||||
paint = tvg_shape_new();
|
||||
REQUIRE(tvg_paint_ref(paint) == 1);
|
||||
scene = tvg_scene_new();
|
||||
tvg_scene_push(scene, paint);
|
||||
tvg_scene_clear(scene, true);
|
||||
tvg_canvas_push(canvas, scene);
|
||||
tvg_canvas_clear(canvas, true, false);
|
||||
REQUIRE(tvg_paint_unref(paint, true) == 0);
|
||||
|
||||
tvg_canvas_destroy(canvas);
|
||||
|
||||
tvg_engine_term(TVG_ENGINE_SW);
|
||||
}
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
|
||||
TEST_CASE("Load Raw file in Picture", "[capiPicture]")
|
||||
{
|
||||
Tvg_Paint* picture = tvg_picture_new();
|
||||
REQUIRE(picture);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(picture, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_PICTURE);
|
||||
REQUIRE(type != TVG_TYPE_SHAPE);
|
||||
REQUIRE(type != TVG_TYPE_SCENE);
|
||||
|
||||
//Load Raw Data
|
||||
FILE* fp = fopen(TEST_DIR"/rawimage_200x300.raw", "r");
|
||||
if (!fp) return;
|
||||
|
||||
uint32_t* data = (uint32_t*)malloc(sizeof(uint32_t) * (200*300));
|
||||
|
||||
if (data && fread(data, sizeof(uint32_t), 200*300, fp) > 0) {
|
||||
//Negative
|
||||
REQUIRE(tvg_picture_load_raw(picture, nullptr, 100, 100, TVG_COLORSPACE_ARGB8888, true) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_picture_load_raw(nullptr, data, 200, 300, TVG_COLORSPACE_ARGB8888, true) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_picture_load_raw(picture, data, 0, 0, TVG_COLORSPACE_ARGB8888, true) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
//Positive
|
||||
REQUIRE(tvg_picture_load_raw(picture, data, 200, 300, TVG_COLORSPACE_ARGB8888, true) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_picture_load_raw(picture, data, 200, 300, TVG_COLORSPACE_ARGB8888, false) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Verify Size
|
||||
float w, h;
|
||||
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(w == Approx(200).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);
|
||||
|
||||
fclose(fp);
|
||||
free(data);
|
||||
}
|
||||
|
||||
#ifdef THORVG_SVG_LOADER_SUPPORT
|
||||
|
||||
TEST_CASE("Load Svg file in Picture", "[capiPicture]")
|
||||
{
|
||||
Tvg_Paint* picture = tvg_picture_new();
|
||||
REQUIRE(picture);
|
||||
|
||||
//Negative
|
||||
REQUIRE(tvg_picture_load(nullptr, TEST_DIR"/logo.svg") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
//Invalid file
|
||||
REQUIRE(tvg_picture_load(picture, "invalid.svg") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
//Load Svg file
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/logo.svg") == TVG_RESULT_SUCCESS);
|
||||
|
||||
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(w == Approx(wNew).epsilon(0.0000001));
|
||||
REQUIRE(h == Approx(hNew).epsilon(0.0000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Load Svg Data in Picture", "[capiPicture]")
|
||||
{
|
||||
static const char* svg = "<svg height=\"1000\" viewBox=\"0 0 600 600\" width=\"1000\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M.10681413.09784845 1000.0527.01592069V1000.0851L.06005738 999.9983Z\" fill=\"#ffffff\" stroke-width=\"3.910218\"/><g fill=\"#252f35\"><g stroke-width=\"3.864492\"><path d=\"M256.61221 100.51736H752.8963V386.99554H256.61221Z\"/><path d=\"M201.875 100.51736H238.366478V386.99554H201.875Z\"/><path d=\"M771.14203 100.51736H807.633508V386.99554H771.14203Z\"/></g><path d=\"M420.82388 380H588.68467V422.805317H420.82388Z\" stroke-width=\"3.227\"/><path d=\"m420.82403 440.7101v63.94623l167.86079 25.5782V440.7101Z\"/><path d=\"M420.82403 523.07258V673.47362L588.68482 612.59701V548.13942Z\"/></g><g fill=\"#222f35\"><path d=\"M420.82403 691.37851 588.68482 630.5019 589 834H421Z\"/><path d=\"m420.82403 852.52249h167.86079v28.64782H420.82403v-28.64782 0 0\"/><path d=\"m439.06977 879.17031c0 0-14.90282 8.49429-18.24574 15.8161-4.3792 9.59153 0 31.63185 0 31.63185h167.86079c0 0 4.3792-22.04032 0-31.63185-3.34292-7.32181-18.24574-15.8161-18.24574-15.8161z\"/></g><g fill=\"#ffffff\"><path d=\"m280 140h15v55l8 10 8-10v-55h15v60l-23 25-23-25z\"/><path d=\"m335 140v80h45v-50h-25v10h10v30h-15v-57h18v-13z\"/></g></svg>";
|
||||
|
||||
Tvg_Paint* picture = tvg_picture_new();
|
||||
REQUIRE(picture);
|
||||
|
||||
//Negative
|
||||
REQUIRE(tvg_picture_load_data(nullptr, svg, strlen(svg), nullptr, nullptr, true) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_picture_load_data(picture, nullptr, strlen(svg), nullptr, nullptr, true) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_picture_load_data(picture, svg, 0, nullptr, nullptr, true) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
//Positive
|
||||
REQUIRE(tvg_picture_load_data(picture, svg, strlen(svg), "svg", nullptr, false) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Verify Size
|
||||
float w, h;
|
||||
REQUIRE(tvg_picture_get_size(picture, &w, &h) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(w == 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));
|
||||
|
||||
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef THORVG_PNG_LOADER_SUPPORT
|
||||
|
||||
TEST_CASE("Load Png file in Picture", "[capiPicture]")
|
||||
{
|
||||
Tvg_Paint* picture = tvg_picture_new();
|
||||
REQUIRE(picture);
|
||||
|
||||
//Invalid file
|
||||
REQUIRE(tvg_picture_load(picture, "invalid.png") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
//Load Png file
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/test.png") == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Verify Size
|
||||
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(w == Approx(wNew).epsilon(0.0000001));
|
||||
REQUIRE(h == Approx(hNew).epsilon(0.0000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef THORVG_JPG_LOADER_SUPPORT
|
||||
|
||||
TEST_CASE("Load Jpg file in Picture", "[capiPicture]")
|
||||
{
|
||||
Tvg_Paint* picture = tvg_picture_new();
|
||||
REQUIRE(picture);
|
||||
|
||||
//Invalid file
|
||||
REQUIRE(tvg_picture_load(picture, "invalid.jpg") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
//Load Png file
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/test.jpg") == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Verify Size
|
||||
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(w == Approx(wNew).epsilon(0.0000001));
|
||||
REQUIRE(h == Approx(hNew).epsilon(0.0000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef THORVG_WEBP_LOADER_SUPPORT
|
||||
|
||||
TEST_CASE("Load Webp file in Picture", "[capiPicture]")
|
||||
{
|
||||
Tvg_Paint* picture = tvg_picture_new();
|
||||
REQUIRE(picture);
|
||||
|
||||
//Invalid file
|
||||
REQUIRE(tvg_picture_load(picture, "invalid.webp") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
//Load Png file
|
||||
REQUIRE(tvg_picture_load(picture, TEST_DIR"/test.webp") == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Verify Size
|
||||
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(w == Approx(wNew).epsilon(0.0000001));
|
||||
REQUIRE(h == Approx(hNew).epsilon(0.0000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(picture) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,234 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
TEST_CASE("Basic Create", "[capiRadialGradient]")
|
||||
{
|
||||
Tvg_Gradient *gradient = tvg_radial_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_gradient_get_type(gradient, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_RADIAL_GRAD);
|
||||
REQUIRE(type != TVG_TYPE_LINEAR_GRAD);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set gradient center point and radius", "[capiRadialGradient]")
|
||||
{
|
||||
Tvg_Gradient *gradient = tvg_radial_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
REQUIRE(tvg_radial_gradient_set(gradient, 10.0, 15.0, 30.0, 11.0, 16.0, 1.0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
float cx, cy, r, fx, fy, fr;
|
||||
REQUIRE(tvg_radial_gradient_get(gradient, &cx, &cy, &r, &fx, &fy, &fr) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(cx == Approx(10.0).margin(0.000001));
|
||||
REQUIRE(cy == Approx(15.0).margin(0.000001));
|
||||
REQUIRE(r == Approx(30.0).margin(0.000001));
|
||||
REQUIRE(fx == Approx(11.0).margin(0.000001));
|
||||
REQUIRE(fy == Approx(16.0).margin(0.000001));
|
||||
REQUIRE(fr == Approx(1.0).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set gradient in shape", "[capiRadialGradient]")
|
||||
{
|
||||
REQUIRE(tvg_shape_set_gradient(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_radial_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
REQUIRE(tvg_shape_set_gradient(NULL, gradient) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_set_gradient(shape, gradient) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Gradient *gradient_ret = NULL;
|
||||
REQUIRE(tvg_shape_get_gradient(shape, &gradient_ret) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(gradient_ret);
|
||||
|
||||
REQUIRE(tvg_shape_set_gradient(shape, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set/Get color stops", "[capiRadialGradient]")
|
||||
{
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_radial_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Color_Stop color_stops[2] = {
|
||||
{0.0, 0, 0, 0, 255},
|
||||
{1.0, 0, 255, 0, 255},
|
||||
};
|
||||
|
||||
const Tvg_Color_Stop *color_stops_ret;
|
||||
uint32_t color_stops_count_ret;
|
||||
|
||||
REQUIRE(tvg_gradient_set_color_stops(gradient, color_stops, 2) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(color_stops_count_ret == 2);
|
||||
|
||||
REQUIRE(color_stops_ret[0].a == 255);
|
||||
REQUIRE(color_stops_ret[1].g == 255);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Clear gradient data", "[capiRadialGradient]")
|
||||
{
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_radial_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Color_Stop color_stops[2] = {
|
||||
{0.0, 0, 0, 0, 255},
|
||||
{1.0, 0, 255, 0, 255},
|
||||
};
|
||||
|
||||
const Tvg_Color_Stop *color_stops_ret;
|
||||
uint32_t color_stops_count_ret;
|
||||
|
||||
REQUIRE(tvg_gradient_set_color_stops(gradient, color_stops, 2) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(color_stops_ret);
|
||||
REQUIRE(color_stops_count_ret == 2);
|
||||
|
||||
REQUIRE(tvg_gradient_set_color_stops(gradient, NULL, 0) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_get_color_stops(gradient, &color_stops_ret, &color_stops_count_ret) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(color_stops_ret == nullptr);
|
||||
REQUIRE(color_stops_count_ret == 0);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set/Get gradient spread", "[capiRadialGradient]")
|
||||
{
|
||||
Tvg_Gradient *gradient = tvg_radial_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
REQUIRE(tvg_gradient_set_spread(gradient, TVG_STROKE_FILL_PAD) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Stroke_Fill spread;
|
||||
REQUIRE(tvg_gradient_get_spread(gradient, &spread) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(spread == TVG_STROKE_FILL_PAD);
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_gradient_del(NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
TEST_CASE("Radial Gradient transformation", "[capiRadialGradient]")
|
||||
{
|
||||
Tvg_Gradient *gradient = tvg_radial_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
Tvg_Matrix matrix_get;
|
||||
|
||||
REQUIRE(tvg_gradient_get_transform(NULL, &matrix_get) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_get_transform(gradient, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_get_transform(gradient, &matrix_get) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(matrix_get.e11 == Approx(1.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e12 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e13 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e21 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e22 == Approx(1.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e23 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e31 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e32 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(matrix_get.e33 == Approx(1.0f).margin(0.000001));
|
||||
|
||||
Tvg_Matrix matrix_set = {1.1f, -2.2f, 3.3f, -4.4f, 5.5f, -6.6f, 7.7f, -8.8f, 9.9f};
|
||||
REQUIRE(tvg_gradient_set_transform(NULL, &matrix_set) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_set_transform(gradient, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_gradient_set_transform(gradient, &matrix_set) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_gradient_get_transform(gradient, &matrix_get) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(matrix_get.e11 == Approx(matrix_set.e11).margin(0.000001));
|
||||
REQUIRE(matrix_get.e12 == Approx(matrix_set.e12).margin(0.000001));
|
||||
REQUIRE(matrix_get.e13 == Approx(matrix_set.e13).margin(0.000001));
|
||||
REQUIRE(matrix_get.e21 == Approx(matrix_set.e21).margin(0.000001));
|
||||
REQUIRE(matrix_get.e22 == Approx(matrix_set.e22).margin(0.000001));
|
||||
REQUIRE(matrix_get.e23 == Approx(matrix_set.e23).margin(0.000001));
|
||||
REQUIRE(matrix_get.e31 == Approx(matrix_set.e31).margin(0.000001));
|
||||
REQUIRE(matrix_get.e32 == Approx(matrix_set.e32).margin(0.000001));
|
||||
REQUIRE(matrix_get.e33 == Approx(matrix_set.e33).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_gradient_del(gradient) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Stroke Radial Gradient", "[capiRadialGradient]")
|
||||
{
|
||||
Tvg_Paint *shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
Tvg_Gradient *gradient = tvg_radial_gradient_new();
|
||||
REQUIRE(gradient);
|
||||
|
||||
REQUIRE(tvg_radial_gradient_set(gradient, 10.0, 15.0, 30.0, 11.0, 16.0, 0.0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Color_Stop color_stops[2] = {
|
||||
{0.0, 0, 0, 0, 255},
|
||||
{1.0, 0, 255, 0, 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_gradient(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_set_stroke_gradient(NULL, gradient) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_set_stroke_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);
|
||||
|
||||
float cx, cy, r, fx, fy, fr;
|
||||
REQUIRE(tvg_radial_gradient_get(gradient_ret, &cx, &cy, &r, &fx, &fy, &fr) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(cx == Approx(10.0).margin(0.000001));
|
||||
REQUIRE(cy == Approx(15.0).margin(0.000001));
|
||||
REQUIRE(r == Approx(30.0).margin(0.000001));
|
||||
REQUIRE(fx == Approx(11.0).margin(0.000001));
|
||||
REQUIRE(fy == Approx(16.0).margin(0.000001));
|
||||
REQUIRE(fr == Approx(0.0).margin(0.000001));
|
||||
|
||||
REQUIRE(tvg_paint_del(shape) == TVG_RESULT_SUCCESS);
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
|
||||
TEST_CASE("Create and delete a Saver", "[capiSaver]")
|
||||
{
|
||||
Tvg_Saver* saver = tvg_saver_new();
|
||||
REQUIRE(saver);
|
||||
|
||||
REQUIRE(tvg_saver_del(nullptr) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_saver_del(saver) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#if defined(THORVG_GIF_SAVER_SUPPORT) && defined(THORVG_LOTTIE_LOADER_SUPPORT)
|
||||
|
||||
TEST_CASE("Save a lottie into gif", "[capiSavers]")
|
||||
{
|
||||
//TODO: GIF Save Test
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
TEST_CASE("Create a Scene", "[capiScene]")
|
||||
{
|
||||
Tvg_Paint* scene = tvg_scene_new();
|
||||
REQUIRE(scene);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(scene, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_SCENE);
|
||||
REQUIRE(type != TVG_TYPE_PICTURE);
|
||||
REQUIRE(type != TVG_TYPE_SHAPE);
|
||||
|
||||
REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paints Into a Scene", "[capiScene]")
|
||||
{
|
||||
Tvg_Paint* scene = tvg_scene_new();
|
||||
REQUIRE(scene);
|
||||
|
||||
//Pushing Paints
|
||||
REQUIRE(tvg_scene_push(scene, tvg_shape_new()) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_scene_push(scene, tvg_picture_new()) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_scene_push(scene, tvg_scene_new()) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Pushing Null Pointer
|
||||
REQUIRE(tvg_scene_push(scene, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_scene_push(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Clear the Scene", "[capiScene]")
|
||||
{
|
||||
Tvg_Paint* scene = tvg_scene_new();
|
||||
REQUIRE(scene);
|
||||
|
||||
REQUIRE(tvg_scene_push(scene, tvg_shape_new()) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_scene_clear(scene, true) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Invalid scene
|
||||
REQUIRE(tvg_scene_clear(NULL, false) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Scene reusing paints", "[capiScene]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Canvas* canvas = tvg_swcanvas_create();
|
||||
REQUIRE(canvas);
|
||||
|
||||
uint32_t* buffer = (uint32_t*) malloc(sizeof(uint32_t) * 200 * 200);
|
||||
REQUIRE(buffer);
|
||||
|
||||
REQUIRE(tvg_swcanvas_set_target(canvas, buffer, 200, 200, 200, TVG_COLORSPACE_ARGB8888) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Paint* scene = tvg_scene_new();
|
||||
REQUIRE(scene);
|
||||
|
||||
Tvg_Paint* shape = tvg_shape_new();
|
||||
REQUIRE(shape);
|
||||
|
||||
REQUIRE(tvg_scene_push(scene, shape) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_canvas_push(canvas, scene) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_canvas_update(canvas) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//No deallocate shape.
|
||||
REQUIRE(tvg_scene_clear(scene, false) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Reuse shape.
|
||||
REQUIRE(tvg_scene_push(scene, shape) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_destroy(canvas) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
|
||||
free(buffer);
|
||||
}
|
|
@ -1,308 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
TEST_CASE("Multiple shapes", "[capiShapes]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(paint, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_SHAPE);
|
||||
REQUIRE(type != TVG_TYPE_SCENE);
|
||||
REQUIRE(type != TVG_TYPE_PICTURE);
|
||||
|
||||
REQUIRE(tvg_shape_append_rect(paint, 0, 0, 100, 100, 0, 0) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_append_rect(paint, 0, 0, 100, 100, 50, 50) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_append_rect(paint, 0, 0, 100, 100, 100, 100) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_append_circle(paint, 100, 100, 50, 50) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_append_circle(paint, 100, 100, 0, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Invalid paint
|
||||
REQUIRE(tvg_shape_append_rect(NULL, 0, 0, 0, 0, 0, 0) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_append_circle(NULL, 0, 0, 0, 0) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Shape reset", "[capiShapes]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_shape_reset(NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_reset(paint) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Shape path", "[capiShapePath]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Path_Command* cmds_get;
|
||||
Tvg_Point* pts_get;
|
||||
uint32_t cnt;
|
||||
uint32_t i;
|
||||
|
||||
Tvg_Path_Command cmds[11];
|
||||
cmds[0] = TVG_PATH_COMMAND_MOVE_TO;
|
||||
cmds[1] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[2] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[3] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[4] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[5] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[6] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[7] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[8] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[9] = TVG_PATH_COMMAND_LINE_TO;
|
||||
cmds[10] = TVG_PATH_COMMAND_CLOSE;
|
||||
|
||||
Tvg_Point pts[10];
|
||||
pts[0] = {199, 34}; //MoveTo
|
||||
pts[1] = {253, 143}; //LineTo
|
||||
pts[2] = {374, 160}; //LineTo
|
||||
pts[3] = {287, 244}; //LineTo
|
||||
pts[4] = {307, 365}; //LineTo
|
||||
pts[5] = {199, 309}; //LineTo
|
||||
pts[6] = {97, 365}; //LineTo
|
||||
pts[7] = {112, 245}; //LineTo
|
||||
pts[8] = {26, 161}; //LineTo
|
||||
pts[9] = {146, 143}; //LineTo
|
||||
|
||||
REQUIRE(tvg_shape_append_path(paint, cmds, 11, pts, 10) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_shape_get_path_commands(paint, (const Tvg_Path_Command**) &cmds_get, &cnt) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(cnt == 11);
|
||||
for (i = 0; i < cnt; i++) {
|
||||
REQUIRE(cmds_get[i] == cmds[i]);
|
||||
}
|
||||
|
||||
REQUIRE(tvg_shape_get_path_coords(paint, (const Tvg_Point**) &pts_get, &cnt) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(cnt == 10);
|
||||
for (i = 0; i < cnt; i++) {
|
||||
REQUIRE(pts_get[i].x == pts[i].x);
|
||||
REQUIRE(pts_get[i].y == pts[i].y);
|
||||
}
|
||||
|
||||
//Invalid paint
|
||||
REQUIRE(tvg_shape_append_path(NULL, NULL, 0, NULL, 0) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_get_path_coords(NULL, NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_shape_reset(paint) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_shape_move_to(paint, 0, 10) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_line_to(paint, 100, 110) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_line_to(paint, 100, 10) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_close(paint) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_shape_move_to(paint, 100, 0) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_cubic_to(paint, 150, 0, 200, 50, 200, 100) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_close(paint) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//Invalid paint
|
||||
REQUIRE(tvg_shape_move_to(NULL, 0, 0) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_line_to(NULL, 0, 0) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_cubic_to(NULL, 0, 0, 0, 0, 0, 0) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_close(NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Stroke width", "[capiStrokeWidth]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
float stroke;
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_width(paint, 0.0f) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_width(paint, &stroke) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(stroke == 0.0f);
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_width(paint, 5.0f) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_width(paint, &stroke) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(stroke == 5.0f);
|
||||
|
||||
//Invalid paint or width pointer
|
||||
REQUIRE(tvg_shape_set_stroke_width(NULL, 0) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_get_stroke_width(NULL, &stroke) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_get_stroke_width(paint, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Stroke color", "[capiStrokeColor]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
uint8_t r, g, b, a;
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_color(paint, 100, 200, 50, 1) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_color(paint, &r, &g, &b, &a) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(r == 100);
|
||||
REQUIRE(g == 200);
|
||||
REQUIRE(b == 50);
|
||||
REQUIRE(a == 1);
|
||||
|
||||
//Invalid paint or no color pointers
|
||||
REQUIRE(tvg_shape_set_stroke_color(NULL, 0, 0, 0, 0) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_get_stroke_color(NULL, &r, &g, &b, &a) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_get_stroke_color(paint, &r, &g, &b, NULL) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_color(paint, NULL, NULL, NULL, &a) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Stroke dash", "[capiStrokeDash]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
float dash[2] = {20, 10};
|
||||
float* dash_get;
|
||||
uint32_t cnt;
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_dash(paint, dash, 2, 0.0f) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_dash(paint, (const float**) &dash_get, &cnt, nullptr) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(cnt == 2);
|
||||
for (uint32_t i = 0; i < cnt; i++) {
|
||||
REQUIRE(dash_get[i] == dash[i]);
|
||||
}
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Stroke cap", "[capiStrokeCap]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Stroke_Cap cap;
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_cap(paint, TVG_STROKE_CAP_ROUND) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_cap(paint, &cap) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(cap == TVG_STROKE_CAP_ROUND);
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_cap(paint, TVG_STROKE_CAP_BUTT) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_cap(paint, &cap) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(cap == TVG_STROKE_CAP_BUTT);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Stroke join", "[capiStrokeJoin]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Stroke_Join join;
|
||||
float ml = -1.0f;
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_join(paint, TVG_STROKE_JOIN_BEVEL) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_join(paint, &join) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(join == TVG_STROKE_JOIN_BEVEL);
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_join(paint, TVG_STROKE_JOIN_MITER) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_join(paint, &join) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(join == TVG_STROKE_JOIN_MITER);
|
||||
|
||||
|
||||
REQUIRE(tvg_shape_get_stroke_miterlimit(paint, &ml) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(ml == 4.0f);
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_miterlimit(paint, 1000.0f) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_stroke_miterlimit(paint, &ml) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(ml == 1000.0f);
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_miterlimit(paint, -0.001f) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
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);
|
||||
|
||||
REQUIRE(tvg_shape_set_stroke_trim(NULL, 0.33f, 0.66f, false) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_set_stroke_trim(paint, 0.33f, 0.66f, false) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Fill color", "[capiFillColor]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
uint8_t r, g, b, a;
|
||||
|
||||
REQUIRE(tvg_shape_set_fill_color(paint, 129, 190, 57, 20) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_fill_color(paint, &r, &g, &b, &a) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(r == 129);
|
||||
REQUIRE(g == 190);
|
||||
REQUIRE(b == 57);
|
||||
REQUIRE(a == 20);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Fill rule", "[capiFillRule]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
Tvg_Fill_Rule rule, rule_get;
|
||||
|
||||
rule = TVG_FILL_RULE_EVEN_ODD;
|
||||
REQUIRE(tvg_shape_set_fill_rule(paint, rule) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_fill_rule(paint, &rule_get) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(rule == rule_get);
|
||||
|
||||
rule = TVG_FILL_RULE_WINDING;
|
||||
REQUIRE(tvg_shape_set_fill_rule(paint, rule) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_get_fill_rule(paint, &rule_get) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(rule == rule_get);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint order", "[capiPaintOrder]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_shape_set_paint_order(nullptr, true) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_shape_set_paint_order(paint, true) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_set_paint_order(paint, false) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 - 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
#ifdef THORVG_SW_RASTER_SUPPORT
|
||||
|
||||
TEST_CASE("Canvas missing initialization", "[capiSwCanvas]")
|
||||
{
|
||||
Tvg_Canvas* canvas = tvg_swcanvas_create();
|
||||
REQUIRE(!canvas);
|
||||
}
|
||||
|
||||
TEST_CASE("Basic canvas", "[capiSwCanvas]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Canvas* canvas = tvg_swcanvas_create();
|
||||
REQUIRE(canvas);
|
||||
|
||||
Tvg_Canvas* canvas2 = tvg_swcanvas_create();
|
||||
REQUIRE(canvas2);
|
||||
|
||||
REQUIRE(tvg_canvas_destroy(canvas) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_canvas_destroy(canvas2) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Canvas initialization", "[capiSwCanvas]")
|
||||
{
|
||||
uint32_t* buffer = (uint32_t*) malloc(sizeof(uint32_t) * 200 * 200);
|
||||
REQUIRE(buffer);
|
||||
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Canvas* canvas = tvg_swcanvas_create();
|
||||
REQUIRE(canvas);
|
||||
|
||||
REQUIRE(tvg_swcanvas_set_target(canvas, buffer, 200, 200, 200, TVG_COLORSPACE_ARGB8888) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_swcanvas_set_mempool(canvas, TVG_MEMPOOL_POLICY_DEFAULT) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_destroy(canvas) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
TEST_CASE("Canvas draw", "[capiSwCanvas]")
|
||||
{
|
||||
uint32_t* buffer = (uint32_t*) malloc(sizeof(uint32_t) * 200 * 200);
|
||||
REQUIRE(buffer);
|
||||
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Canvas* canvas = tvg_swcanvas_create();
|
||||
REQUIRE(canvas);
|
||||
|
||||
REQUIRE(tvg_canvas_draw(canvas) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
REQUIRE(tvg_canvas_sync(canvas) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
REQUIRE(tvg_swcanvas_set_target(canvas, buffer, 200, 200, 200, TVG_COLORSPACE_ARGB8888) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_draw(canvas) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
REQUIRE(tvg_canvas_sync(canvas) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_canvas_push(canvas, paint) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_draw(canvas) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_canvas_sync(canvas) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_canvas_clear(canvas, true, true) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Paint* paint2 = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_shape_append_rect(paint2, 0, 0, 100, 100, 0, 0) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_shape_set_fill_color(paint2, 255, 255, 255, 255) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_push(canvas, paint2) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_draw(canvas) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_canvas_sync(canvas) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_destroy(canvas) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
TEST_CASE("Canvas update, clear and reuse", "[capiSwCanvas]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Canvas* canvas = tvg_swcanvas_create();
|
||||
REQUIRE(canvas);
|
||||
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
||||
REQUIRE(tvg_canvas_push(canvas, paint) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_update_paint(canvas, paint) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//negative
|
||||
REQUIRE(tvg_canvas_clear(canvas, false, true) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
//make it sure sync before changing the target
|
||||
REQUIRE(tvg_canvas_sync(canvas) == TVG_RESULT_SUCCESS);
|
||||
|
||||
uint32_t buffer[25];
|
||||
REQUIRE(tvg_swcanvas_set_target(canvas, buffer, 5, 5, 5, TVG_COLORSPACE_ARGB8888) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_canvas_clear(canvas, false, true) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_canvas_destroy(canvas) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024 the ThorVG project. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_capi.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "../catch.hpp"
|
||||
|
||||
#ifdef THORVG_TTF_LOADER_SUPPORT
|
||||
|
||||
TEST_CASE("Create text", "[capiText]")
|
||||
{
|
||||
Tvg_Paint* text = tvg_text_new();
|
||||
REQUIRE(text);
|
||||
|
||||
Tvg_Type type = TVG_TYPE_UNDEF;
|
||||
REQUIRE(tvg_paint_get_type(text, &type) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(type == TVG_TYPE_TEXT);
|
||||
|
||||
REQUIRE(tvg_paint_del(text) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Load/unload TTF file", "[capiText]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_font_load(TEST_DIR"/invalid.ttf") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_font_load("") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_font_load(TEST_DIR"/Arial.ttf") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_font_unload(TEST_DIR"/Arial.ttf") == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_font_unload(TEST_DIR"/invalid.ttf") == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
REQUIRE(tvg_font_unload("") == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Load/unload TTF file from a memory", "[capiText]")
|
||||
{
|
||||
REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
FILE *file = fopen(TEST_DIR"/Arial.ttf", "rb");
|
||||
REQUIRE(file);
|
||||
fseek(file, 0, SEEK_END);
|
||||
long data_size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
char* data = (char*)malloc(data_size);
|
||||
REQUIRE(data);
|
||||
REQUIRE(fread(data, 1, data_size, file) > 0);
|
||||
|
||||
static const char* svg = "<svg height=\"1000\" viewBox=\"0 0 600 600\" ></svg>";
|
||||
|
||||
//load
|
||||
REQUIRE(tvg_font_load_data("Err", data, 0, "ttf", false) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_font_load_data(NULL, data, data_size, "ttf", false) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_font_load_data("Svg", svg, strlen(svg), "svg", false) == TVG_RESULT_NOT_SUPPORTED);
|
||||
REQUIRE(tvg_font_load_data("Arial1", data, data_size, "err", false) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_font_load_data("Arial2", data, data_size, "ttf", true) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_font_load_data("Arial3", data, data_size, NULL, false) == TVG_RESULT_SUCCESS);
|
||||
|
||||
//unload
|
||||
REQUIRE(tvg_font_load_data("Err", NULL, data_size, "ttf", false) == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
REQUIRE(tvg_font_load_data(NULL, NULL, data_size, "ttf", false) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_font_load_data("Arial1", NULL, 0, "ttf", false) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_font_load_data("Arial2", NULL, 0, NULL, false) == TVG_RESULT_SUCCESS);
|
||||
|
||||
free(data);
|
||||
fclose(file);
|
||||
|
||||
REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set font", "[capiText]")
|
||||
{
|
||||
Tvg_Paint* text = tvg_text_new();
|
||||
REQUIRE(text);
|
||||
|
||||
REQUIRE(tvg_font_load(TEST_DIR"/Arial.ttf") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_text_set_font(NULL, "Arial", 10.0f, "") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_text_set_font(text, "Unknown", 10.0f, "") == TVG_RESULT_INSUFFICIENT_CONDITION);
|
||||
REQUIRE(tvg_text_set_font(text, "Arial", 10.0f, "") == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_text_set_font(text, "Arial", 22.0f, "italic") == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_text_set_font(text, "Arial", 10.0f, "unknown") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(text) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set text", "[capiText]")
|
||||
{
|
||||
Tvg_Paint* text = tvg_text_new();
|
||||
REQUIRE(text);
|
||||
|
||||
REQUIRE(tvg_font_load(TEST_DIR"/Arial.ttf") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_text_set_text(NULL, "some random text") == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_text_set_text(text, "") == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_text_set_text(text, NULL) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_text_set_text(text, "THORVG Text") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(text) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set solid text fill", "[capiText]")
|
||||
{
|
||||
Tvg_Paint* text = tvg_text_new();
|
||||
REQUIRE(text);
|
||||
|
||||
REQUIRE(tvg_font_load(TEST_DIR"/Arial.ttf") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_text_set_fill_color(text, 10, 20, 30) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_text_set_font(text, "Arial", 10.0f, "") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_text_set_fill_color(NULL, 10, 20, 30) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_text_set_fill_color(text, 10, 20, 30) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(text) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Set gradient text fill", "[capiText]")
|
||||
{
|
||||
Tvg_Paint* text = tvg_text_new();
|
||||
REQUIRE(text);
|
||||
|
||||
Tvg_Gradient *gradientRad = tvg_radial_gradient_new();
|
||||
REQUIRE(gradientRad);
|
||||
REQUIRE(tvg_radial_gradient_set(gradientRad, 10.0, 15.0, 30.0, 10.0, 15.0, 0.0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Gradient *gradientLin = tvg_linear_gradient_new();
|
||||
REQUIRE(gradientLin);
|
||||
REQUIRE(tvg_linear_gradient_set(gradientLin, 10.0, 20.0, 50.0, 40.0) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_font_load(TEST_DIR"/Arial.ttf") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_text_set_gradient(text, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
|
||||
REQUIRE(tvg_text_set_font(text, "Arial", 10.0f, "") == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_text_set_gradient(text, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_text_set_gradient(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_text_set_gradient(text, gradientLin) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_text_set_gradient(text, gradientRad) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(text) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,24 +0,0 @@
|
|||
test_file = [
|
||||
'capiAnimation.cpp',
|
||||
'capiInitializer.cpp',
|
||||
'capiFill.cpp',
|
||||
'capiLinearGradient.cpp',
|
||||
'capiLottie.cpp',
|
||||
'capiMain.cpp',
|
||||
'capiPaint.cpp',
|
||||
'capiPicture.cpp',
|
||||
'capiRadialGradient.cpp',
|
||||
'capiSavers.cpp',
|
||||
'capiScene.cpp',
|
||||
'capiShape.cpp',
|
||||
'capiSwCanvas.cpp',
|
||||
'capiText.cpp'
|
||||
]
|
||||
|
||||
tests = executable('capiUnitTests',
|
||||
test_file,
|
||||
include_directories : headers,
|
||||
link_with : thorvg_lib,
|
||||
cpp_args : compiler_flags)
|
||||
|
||||
test('Capi Unit Tests', tests)
|
|
@ -34,7 +34,3 @@ tests = executable('tvgUnitTests',
|
|||
dependencies : test_dep)
|
||||
|
||||
test('Unit Tests', tests, args : ['--success'])
|
||||
|
||||
if get_option('bindings').contains('capi')
|
||||
subdir('capi')
|
||||
endif
|
||||
|
|
Loading…
Add table
Reference in a new issue