summaryrefslogtreecommitdiff
path: root/test/mime-data.c
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2013-09-15 21:27:50 +0930
committerAdrian Johnson <ajohnson@redneon.com>2013-09-15 21:27:50 +0930
commit412a4c34d9207c339fd16a99756ea96082dc993f (patch)
tree92cc102bb824f793f174275542888979b76ffac8 /test/mime-data.c
parent5c0caa6f82374ec38a33d5f25a725f60bc121887 (diff)
downloadcairo-412a4c34d9207c339fd16a99756ea96082dc993f.tar.gz
test: update mime-data to test jbig2 mime types
Diffstat (limited to 'test/mime-data.c')
-rw-r--r--test/mime-data.c97
1 files changed, 96 insertions, 1 deletions
diff --git a/test/mime-data.c b/test/mime-data.c
index b1074cdeb..c744f5c9b 100644
--- a/test/mime-data.c
+++ b/test/mime-data.c
@@ -116,6 +116,97 @@ paint_file (cairo_t *cr,
}
static cairo_test_status_t
+paint_jbig2_file (cairo_t *cr, int x, int y)
+{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
+ cairo_surface_t *image;
+ unsigned char *mime_data;
+ unsigned int mime_length;
+ cairo_status_t status;
+ const char jbig2_image1_filename[] = "image1.jb2";
+ const char jbig2_image2_filename[] = "image2.jb2";
+ const char jbig2_global_filename[] = "global.jb2";
+
+ /* Deliberately use a non-matching MIME images, so that we can identify
+ * when the MIME representation is used in preference to the plain image
+ * surface.
+ */
+
+ /* Image 1 */
+
+ status = read_file (ctx, jbig2_image1_filename, &mime_data, &mime_length);
+ if (status)
+ return cairo_test_status_from_status (ctx, status);
+
+ image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 200, 50);
+
+ status = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID,
+ (unsigned char *)"global", 6, NULL, NULL);
+ if (status) {
+ cairo_surface_destroy (image);
+ return cairo_test_status_from_status (ctx, status);
+ }
+
+ status = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JBIG2,
+ mime_data, mime_length,
+ free, mime_data);
+ if (status) {
+ cairo_surface_destroy (image);
+ free (mime_data);
+ return cairo_test_status_from_status (ctx, status);
+ }
+
+ cairo_set_source_surface (cr, image, x, y);
+ cairo_surface_destroy (image);
+
+ cairo_paint (cr);
+
+ /* Image 2 */
+
+ status = read_file (ctx, jbig2_image2_filename, &mime_data, &mime_length);
+ if (status)
+ return cairo_test_status_from_status (ctx, status);
+
+ image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 200, 50);
+
+ status = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID,
+ (unsigned char *)"global", 6, NULL, NULL);
+ if (status) {
+ cairo_surface_destroy (image);
+ return cairo_test_status_from_status (ctx, status);
+ }
+
+ status = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JBIG2,
+ mime_data, mime_length,
+ free, mime_data);
+ if (status) {
+ cairo_surface_destroy (image);
+ free (mime_data);
+ return cairo_test_status_from_status (ctx, status);
+ }
+
+ /* Set the global data */
+ status = read_file (ctx, jbig2_global_filename, &mime_data, &mime_length);
+ if (status)
+ return cairo_test_status_from_status (ctx, status);
+
+ status = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_JBIG2_GLOBAL,
+ mime_data, mime_length,
+ free, mime_data);
+ if (status) {
+ cairo_surface_destroy (image);
+ free (mime_data);
+ return cairo_test_status_from_status (ctx, status);
+ }
+
+ cairo_set_source_surface (cr, image, x, y + 50);
+ cairo_surface_destroy (image);
+
+ cairo_paint (cr);
+ return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
const char jpg_filename[] = "jpeg.jpg";
@@ -135,6 +226,10 @@ draw (cairo_t *cr, int width, int height)
if (status)
return status;
+ status = paint_jbig2_file (cr, 0, 150);
+ if (status)
+ return status;
+
return CAIRO_TEST_SUCCESS;
}
@@ -142,5 +237,5 @@ CAIRO_TEST (mime_data,
"Check that the mime-data embedding works",
"jpeg, api", /* keywords */
NULL, /* requirements */
- 200, 150,
+ 200, 250,
NULL, draw)