[cairo-commit] test/Makefile.am test/Makefile.sources test/ps-eps.c test/ps-eps.ref.eps

Adrian Johnson ajohnson at kemper.freedesktop.org
Thu Sep 24 07:02:10 PDT 2009


 test/Makefile.am      |    2 +
 test/Makefile.sources |    1 
 test/ps-eps.c         |   85 ++++++++++++++++++++++++++++++++++++++++++++++++++
 test/ps-eps.ref.eps   |   84 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 172 insertions(+)

New commits:
commit 120247ac55d92d9c9b24fad45c765d16e692f355
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Thu Sep 24 23:02:38 2009 +0930

    Add EPS test
    
    This test demonstrates a regression in the EPS output since 1.8.8.
    The ps-eps.ref.eps was created with 1.8.8.

diff --git a/test/Makefile.am b/test/Makefile.am
index b8174f6..2890917 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1123,6 +1123,7 @@ font-options			\
 multi-page			\
 pdf-features			\
 png				\
+ps-eps                          \
 ps-features			\
 svg-clip			\
 svg-surface			\
@@ -1284,6 +1285,7 @@ CLEANFILES +=					\
 	ps-surface-source.out.ps		\
 	pdf-features.pdf			\
 	pdf-mime-data.out*			\
+	ps-eps.eps				\
 	ps-features.ps				\
 	svg-clip.svg				\
 	svg-surface.svg				\
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 4f3ecea..769fb0f 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -253,6 +253,7 @@ pdf_surface_test_sources = \
 	pdf-surface-source.c
 
 ps_surface_test_sources = \
+	ps-eps.c \
 	ps-features.c \
 	ps-surface-source.c
 
diff --git a/test/ps-eps.c b/test/ps-eps.c
new file mode 100644
index 0000000..726cb46
--- /dev/null
+++ b/test/ps-eps.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ * Copyright © 2009 Adrian Johnson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ * Author: Adrian Johnson <ajohnson at redneon.com>
+ */
+
+#include <stdio.h>
+#include <math.h>
+#include <cairo.h>
+#include <cairo-ps.h>
+
+#include "cairo-test.h"
+
+/* Test EPS output.
+ */
+
+static cairo_test_status_t
+preamble (cairo_test_context_t *ctx)
+{
+    cairo_surface_t *surface;
+    cairo_t *cr;
+    cairo_status_t status;
+    const char *filename;
+
+    if (! (cairo_test_is_target_enabled (ctx, "ps2") ||
+	   cairo_test_is_target_enabled (ctx, "ps3")))
+    {
+	return CAIRO_TEST_UNTESTED;
+    }
+
+    filename = "ps-eps.out.eps";
+
+    surface = cairo_ps_surface_create (filename, 595, 842);
+    cairo_ps_surface_set_eps (surface, TRUE);
+    cr = cairo_create (surface);
+
+    cairo_new_sub_path (cr);
+    cairo_arc (cr, 100, 100, 25, 0, 2*M_PI);
+    cairo_set_line_width (cr, 10);
+    cairo_stroke (cr);
+
+    cairo_show_page (cr);
+
+    status = cairo_status (cr);
+
+    cairo_destroy (cr);
+    cairo_surface_destroy (surface);
+
+    if (status) {
+	cairo_test_log (ctx, "Failed to create ps surface for file %s: %s\n",
+			filename, cairo_status_to_string (status));
+	return CAIRO_TEST_FAILURE;
+    }
+
+    printf ("ps-eps: Please check that %s looks/prints the same as ps-eps.ref.eps.\n", filename);
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (ps_eps,
+	    "Check EPS output from PS surface",
+	    "ps, api", /* keywords */
+	    NULL, /* requirements */
+	    0, 0,
+	    preamble, NULL)
diff --git a/test/ps-eps.ref.eps b/test/ps-eps.ref.eps
new file mode 100644
index 0000000..e4fc1be
--- /dev/null
+++ b/test/ps-eps.ref.eps
@@ -0,0 +1,84 @@
+%!PS-Adobe-3.0 EPSF-3.0
+%%Creator: cairo 1.8.8 (http://cairographics.org)
+%%CreationDate: Thu Sep 24 23:15:35 2009
+%%Pages: 1
+%%BoundingBox: 70 712 130 772
+%%DocumentData: Clean7Bit
+%%LanguageLevel: 2
+%%EndComments
+%%BeginProlog
+/cairo_eps_state save def
+/dict_count countdictstack def
+/op_count count 1 sub def
+userdict begin
+/q { gsave } bind def
+/Q { grestore } bind def
+/cm { 6 array astore concat } bind def
+/w { setlinewidth } bind def
+/J { setlinecap } bind def
+/j { setlinejoin } bind def
+/M { setmiterlimit } bind def
+/d { setdash } bind def
+/m { moveto } bind def
+/l { lineto } bind def
+/c { curveto } bind def
+/h { closepath } bind def
+/re { exch dup neg 3 1 roll 5 3 roll moveto 0 rlineto
+      0 exch rlineto 0 rlineto closepath } bind def
+/S { stroke } bind def
+/f { fill } bind def
+/f* { eofill } bind def
+/B { fill stroke } bind def
+/B* { eofill stroke } bind def
+/n { newpath } bind def
+/W { clip } bind def
+/W* { eoclip } bind def
+/BT { } bind def
+/ET { } bind def
+/pdfmark where { pop globaldict /?pdfmark /exec load put }
+    { globaldict begin /?pdfmark /pop load def /pdfmark
+    /cleartomark load def end } ifelse
+/BDC { mark 3 1 roll /BDC pdfmark } bind def
+/EMC { mark /EMC pdfmark } bind def
+/cairo_store_point { /cairo_point_y exch def /cairo_point_x exch def } def
+/Tj { show currentpoint cairo_store_point } bind def
+/TJ {
+  {
+    dup
+    type /stringtype eq
+    { show } { -0.001 mul 0 cairo_font_matrix dtransform rmoveto } ifelse
+  } forall
+  currentpoint cairo_store_point
+} bind def
+/cairo_selectfont { cairo_font_matrix aload pop pop pop 0 0 6 array astore
+    cairo_font exch selectfont cairo_point_x cairo_point_y moveto } bind def
+/Tf { pop /cairo_font exch def /cairo_font_matrix where
+      { pop cairo_selectfont } if } bind def
+/Td { matrix translate cairo_font_matrix matrix concatmatrix dup
+      /cairo_font_matrix exch def dup 4 get exch 5 get cairo_store_point
+      /cairo_font where { pop cairo_selectfont } if } bind def
+/Tm { 2 copy 8 2 roll 6 array astore /cairo_font_matrix exch def
+      cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind def
+/g { setgray } bind def
+/rg { setrgbcolor } bind def
+/d1 { setcachedevice } bind def
+%%EndProlog
+%%Page: 1 1
+%%BeginPageSetup
+%%PageBoundingBox: 70 712 130 772
+%%EndPageSetup
+q
+0 g
+10 w
+0 J
+0 j
+[] 0.0 d
+10 M 125 742 m 125 728.191 113.809 717 100 717 c 86.191 717 75 728.191 75 
+742 c 75 755.809 86.191 767 100 767 c 113.809 767 125 755.809 125 742 c S
+Q
+showpage
+%%Trailer
+count op_count sub {pop} repeat
+countdictstack dict_count sub {end} repeat
+cairo_eps_state restore
+%%EOF


More information about the cairo-commit mailing list