mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-22 19:38:18 +02:00
[test/invalid-matrix] Test detection of infinities.
Feed infinities into the API and check that we correctly return INVALID_MATRIX.
This commit is contained in:
parent
012f68e043
commit
92970ec836
1 changed files with 122 additions and 1 deletions
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#if _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
|
||||
#define HAVE_INFINITY 1
|
||||
#endif
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
cairo_test_t test = {
|
||||
|
|
@ -45,7 +49,7 @@ draw (cairo_t *cr, int width, int height)
|
|||
cairo_scaled_font_t *scaled_font;
|
||||
cairo_pattern_t *pattern;
|
||||
cairo_t *cr2;
|
||||
cairo_matrix_t identity, bogus, invalid = {
|
||||
cairo_matrix_t identity, bogus, inf, invalid = {
|
||||
4.0, 4.0,
|
||||
4.0, 4.0,
|
||||
4.0, 4.0
|
||||
|
|
@ -71,6 +75,13 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
status = cairo_matrix_invert (&bogus);
|
||||
CHECK_STATUS (status, "cairo_matrix_invert(NaN)");
|
||||
|
||||
#if HAVE_INFINITY
|
||||
inf.x0 = inf.xy = inf.xx = INFINITY;
|
||||
inf.y0 = inf.yx = inf.yy = inf.xx;
|
||||
status = cairo_matrix_invert (&inf);
|
||||
CHECK_STATUS (status, "cairo_matrix_invert(infinity)");
|
||||
#endif
|
||||
|
||||
/* test cairo_matrix_invert with invalid matrix */
|
||||
status = cairo_matrix_invert (&invalid);
|
||||
CHECK_STATUS (status, "cairo_matrix_invert(invalid)");
|
||||
|
|
@ -96,6 +107,16 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
cairo_destroy (cr2);
|
||||
CHECK_STATUS (status, "cairo_transform(NaN)");
|
||||
|
||||
#if HAVE_INFINITY
|
||||
/* test cairo_transform with ∞ matrix */
|
||||
cr2 = cairo_create (target);
|
||||
cairo_transform (cr2, &inf);
|
||||
|
||||
status = cairo_status (cr2);
|
||||
cairo_destroy (cr2);
|
||||
CHECK_STATUS (status, "cairo_transform(infinity)");
|
||||
#endif
|
||||
|
||||
|
||||
/* test cairo_set_matrix with invalid matrix */
|
||||
cr2 = cairo_create (target);
|
||||
|
|
@ -113,6 +134,16 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
cairo_destroy (cr2);
|
||||
CHECK_STATUS (status, "cairo_set_matrix(NaN)");
|
||||
|
||||
#if HAVE_INFINITY
|
||||
/* test cairo_set_matrix with ∞ matrix */
|
||||
cr2 = cairo_create (target);
|
||||
cairo_set_matrix (cr2, &inf);
|
||||
|
||||
status = cairo_status (cr2);
|
||||
cairo_destroy (cr2);
|
||||
CHECK_STATUS (status, "cairo_set_matrix(infinity)");
|
||||
#endif
|
||||
|
||||
|
||||
/* test cairo_set_font_matrix with invalid matrix */
|
||||
cr2 = cairo_create (target);
|
||||
|
|
@ -136,6 +167,19 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
cairo_destroy (cr2);
|
||||
CHECK_STATUS (status, "cairo_set_font_matrix(NaN)");
|
||||
|
||||
#if HAVE_INFINITY
|
||||
/* test cairo_set_font_matrix with ∞ matrix */
|
||||
cr2 = cairo_create (target);
|
||||
cairo_set_font_matrix (cr2, &inf);
|
||||
|
||||
/* draw some text to force the font to be resolved */
|
||||
cairo_show_text (cr2, "hello");
|
||||
|
||||
status = cairo_status (cr2);
|
||||
cairo_destroy (cr2);
|
||||
CHECK_STATUS (status, "cairo_set_font_matrix(infinity)");
|
||||
#endif
|
||||
|
||||
|
||||
/* test cairo_scaled_font_create with invalid matrix */
|
||||
cr2 = cairo_create (target);
|
||||
|
|
@ -187,6 +231,33 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
cairo_font_options_destroy (font_options);
|
||||
cairo_destroy (cr2);
|
||||
|
||||
#if HAVE_INFINITY
|
||||
/* test cairo_scaled_font_create with ∞ matrix */
|
||||
cr2 = cairo_create (target);
|
||||
font_face = cairo_get_font_face (cr2);
|
||||
font_options = cairo_font_options_create ();
|
||||
cairo_get_font_options (cr, font_options);
|
||||
scaled_font = cairo_scaled_font_create (font_face,
|
||||
&inf,
|
||||
&identity,
|
||||
font_options);
|
||||
status = cairo_scaled_font_status (scaled_font);
|
||||
CHECK_STATUS (status, "cairo_scaled_font_create(infinity)");
|
||||
|
||||
cairo_scaled_font_destroy (scaled_font);
|
||||
|
||||
scaled_font = cairo_scaled_font_create (font_face,
|
||||
&identity,
|
||||
&inf,
|
||||
font_options);
|
||||
status = cairo_scaled_font_status (scaled_font);
|
||||
CHECK_STATUS (status, "cairo_scaled_font_create(infinity)");
|
||||
|
||||
cairo_scaled_font_destroy (scaled_font);
|
||||
cairo_font_options_destroy (font_options);
|
||||
cairo_destroy (cr2);
|
||||
#endif
|
||||
|
||||
|
||||
/* test cairo_pattern_set_matrix with invalid matrix */
|
||||
pattern = cairo_pattern_create_rgb (1.0, 1.0, 1.0);
|
||||
|
|
@ -202,6 +273,15 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
CHECK_STATUS (status, "cairo_pattern_set_matrix(NaN)");
|
||||
cairo_pattern_destroy (pattern);
|
||||
|
||||
#if HAVE_INFINITY
|
||||
/* test cairo_pattern_set_matrix with ∞ matrix */
|
||||
pattern = cairo_pattern_create_rgb (1.0, 1.0, 1.0);
|
||||
cairo_pattern_set_matrix (pattern, &inf);
|
||||
status = cairo_pattern_status (pattern);
|
||||
CHECK_STATUS (status, "cairo_pattern_set_matrix(infinity)");
|
||||
cairo_pattern_destroy (pattern);
|
||||
#endif
|
||||
|
||||
|
||||
/* test invalid transformations */
|
||||
cr2 = cairo_create (target);
|
||||
|
|
@ -219,6 +299,23 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
CHECK_STATUS (status, "cairo_translate(NaN, 0)");
|
||||
cairo_destroy (cr2);
|
||||
|
||||
#if HAVE_INFINITY
|
||||
cr2 = cairo_create (target);
|
||||
cairo_translate (cr2, inf.xx, inf.yy);
|
||||
CHECK_STATUS (status, "cairo_translate(∞, ∞)");
|
||||
cairo_destroy (cr2);
|
||||
|
||||
cr2 = cairo_create (target);
|
||||
cairo_translate (cr2, 0, inf.yy);
|
||||
CHECK_STATUS (status, "cairo_translate(0, ∞)");
|
||||
cairo_destroy (cr2);
|
||||
|
||||
cr2 = cairo_create (target);
|
||||
cairo_translate (cr2, inf.xx, 0);
|
||||
CHECK_STATUS (status, "cairo_translate(∞, 0)");
|
||||
cairo_destroy (cr2);
|
||||
#endif
|
||||
|
||||
|
||||
cr2 = cairo_create (target);
|
||||
cairo_scale (cr2, bogus.xx, bogus.yy);
|
||||
|
|
@ -235,6 +332,23 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
CHECK_STATUS (status, "cairo_scale(NaN, 1)");
|
||||
cairo_destroy (cr2);
|
||||
|
||||
#if HAVE_INFINITY
|
||||
cr2 = cairo_create (target);
|
||||
cairo_scale (cr2, inf.xx, inf.yy);
|
||||
CHECK_STATUS (status, "cairo_scale(∞, ∞)");
|
||||
cairo_destroy (cr2);
|
||||
|
||||
cr2 = cairo_create (target);
|
||||
cairo_scale (cr2, 1, inf.yy);
|
||||
CHECK_STATUS (status, "cairo_scale(1, ∞)");
|
||||
cairo_destroy (cr2);
|
||||
|
||||
cr2 = cairo_create (target);
|
||||
cairo_scale (cr2, inf.xx, 1);
|
||||
CHECK_STATUS (status, "cairo_scale(∞, 1)");
|
||||
cairo_destroy (cr2);
|
||||
#endif
|
||||
|
||||
cr2 = cairo_create (target);
|
||||
cairo_scale (cr2, bogus.xx, bogus.yy);
|
||||
CHECK_STATUS (status, "cairo_scale(0, 0)");
|
||||
|
|
@ -256,6 +370,13 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
|
|||
CHECK_STATUS (status, "cairo_rotate(NaN)");
|
||||
cairo_destroy (cr2);
|
||||
|
||||
#if HAVE_INFINITY
|
||||
cr2 = cairo_create (target);
|
||||
cairo_rotate (cr2, inf.xx);
|
||||
CHECK_STATUS (status, "cairo_rotate(∞)");
|
||||
cairo_destroy (cr2);
|
||||
#endif
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue