[cairo-commit] cairo/test create-from-png.c,1.7,1.8

Carl Worth commit at pdx.freedesktop.org
Thu Jul 28 10:41:11 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv5350/test

Modified Files:
	create-from-png.c 
Log Message:

        * src/cairo-png.c: (read_png),
        (cairo_image_surface_create_from_png): Fix so that one of three
        different error status values will be returned:

                CAIRO_STATUS_NO_MEMORY
                CAIRO_STATUS_FILE_NOT_FOUND
                CAIRO_STATUS_READ_ERROR

        * src/cairo.h:
        * src/cairo.c: (cairo_status_to_string): Add new
        CAIRO_STATUS_FILE_NOT_FOUND.

        * src/cairoint.h:
        * src/cairo-surface.c: Add new _cairo_surface_nil_read_error and
        _cairo_surface_nil_file_not_found.

        * test/create-from-png.c: (draw): Test the new FILE_NOT_FOUND
        error.


Index: create-from-png.c
===================================================================
RCS file: /cvs/cairo/cairo/test/create-from-png.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- create-from-png.c	27 Jul 2005 16:23:29 -0000	1.7
+++ create-from-png.c	28 Jul 2005 17:41:09 -0000	1.8
@@ -43,13 +43,22 @@
     char *filename;
     cairo_surface_t *surface;
 
+    surface = cairo_image_surface_create_from_png ("___THIS_FILE_DOES_NOT_EXIST___");
+    if (cairo_surface_status (surface) != CAIRO_STATUS_FILE_NOT_FOUND) {
+	cairo_test_log ("Error: expected \"file not found\", but got: %s\n",
+			cairo_status_to_string (cairo_surface_status (surface)));
+	return CAIRO_TEST_FAILURE;
+    }
+
     xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
 	       "create-from-png-ref.png");
 
     surface = cairo_image_surface_create_from_png (filename);
 
-    if (surface == NULL) {
-	cairo_test_log ("Error: failed to open file %s\n", filename);
+    if (cairo_surface_status (surface)) {
+	cairo_test_log ("Error reading PNG image %s: %s\n",
+			filename,
+			cairo_status_to_string (cairo_surface_status (surface)));
 	free (filename);
 	return CAIRO_TEST_FAILURE;
     }




More information about the cairo-commit mailing list