#include "cairo-test.h"
#include <stddef.h>
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
const cairo_test_context_t *ctx = cairo_test_get_context (cr);
cairo_surface_t *surface;
cairo_pattern_t *pattern;
cairo_t *cr2;
cr2 = cairo_create (cairo_get_target (cr));
surface = cairo_image_surface_create_from_png ("___THIS_FILE_DOES_NOT_EXIST___");
pattern = cairo_pattern_create_for_surface (surface);
cairo_set_source (cr2, pattern);
cairo_paint (cr2);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (surface);
if (cairo_status (cr2) != CAIRO_STATUS_FILE_NOT_FOUND) {
cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n",
cairo_status_to_string (cairo_status (cr2)),
cairo_status_to_string (CAIRO_STATUS_FILE_NOT_FOUND));
cairo_destroy (cr2);
return CAIRO_TEST_FAILURE;
}
cairo_destroy (cr2);
cr2 = cairo_create (cairo_get_target (cr));
pattern = cairo_pattern_create_for_surface (NULL);
cairo_set_source (cr2, pattern);
cairo_paint (cr2);
cairo_pattern_destroy (pattern);
if (cairo_status (cr2) != CAIRO_STATUS_NULL_POINTER) {
cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n",
cairo_status_to_string (cairo_status (cr2)),
cairo_status_to_string (CAIRO_STATUS_NULL_POINTER));
cairo_destroy (cr2);
return CAIRO_TEST_FAILURE;
}
cairo_destroy (cr2);
cairo_surface_finish (NULL);
surface = cairo_image_surface_create_from_png ("___THIS_FILE_DOES_NOT_EXIST___");
cairo_surface_finish (surface);
cairo_surface_destroy (surface);
cr2 = cairo_create (cairo_get_target (cr));
cairo_restore (cr2);
if (cairo_status (cr2) != CAIRO_STATUS_INVALID_RESTORE) {
cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n",
cairo_status_to_string (cairo_status (cr2)),
cairo_status_to_string (CAIRO_STATUS_INVALID_RESTORE));
cairo_destroy (cr2);
return CAIRO_TEST_FAILURE;
}
cairo_get_fill_rule (cr2);
cairo_destroy (cr2);
cr2 = cairo_create (NULL);
if (cairo_status (cr2) != CAIRO_STATUS_NULL_POINTER) {
cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n",
cairo_status_to_string (cairo_status (cr2)),
cairo_status_to_string (CAIRO_STATUS_NULL_POINTER));
cairo_destroy (cr2);
return CAIRO_TEST_FAILURE;
}
if (cairo_get_target (cr2) == NULL) {
cairo_test_log (ctx, "Error: cairo_get_target() returned NULL\n");
cairo_destroy (cr2);
return CAIRO_TEST_FAILURE;
}
cairo_push_group (cr2);
cairo_stroke (cr2);
pattern = cairo_pop_group (cr2);
cairo_pattern_destroy (pattern);
cairo_destroy (cr2);
return CAIRO_TEST_SUCCESS;
}
CAIRO_TEST (nil_surface,
"Test that nil surfaces do not make cairo crash.",
"api",
NULL,
1, 1,
NULL, draw)