summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2014-01-27 17:31:12 -0500
committerBehdad Esfahbod <behdad@behdad.org>2014-01-27 17:32:58 -0500
commit8d2e24479a1efbeeddced3574c1d9e92b8ee578d (patch)
treeba8e9140c665c2d6166dd29c60d8485a8e9c4948
parent2a7f133639bed86a29dd9693cb78c0aa42eaff30 (diff)
[tests] Add path-currentpoint
Checks whether copy_path()/append_path() preserves current-point. Currently failing.
-rw-r--r--test/Makefile.sources1
-rw-r--r--test/path-currentpoint.c89
2 files changed, 90 insertions, 0 deletions
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 534a426..916d91a 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -244,6 +244,7 @@ test_sources = \
partial-coverage.c \
pass-through.c \
path-append.c \
+ path-currentpoint.c \
path-stroke-twice.c \
path-precision.c \
pattern-get-type.c \
diff --git a/test/path-currentpoint.c b/test/path-currentpoint.c
new file mode 100644
index 0000000..ccd44b1
--- /dev/null
+++ b/test/path-currentpoint.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2014 Google, Inc.
+ *
+ * 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.
+ */
+
+#include "cairo-test.h"
+
+#include <assert.h>
+
+static void
+assert_point (cairo_t *cr, double expected_x, double expected_y) {
+ double x, y;
+ assert (cairo_has_current_point (cr));
+ cairo_get_current_point (cr, &x, &y);
+ assert (x == expected_x);
+ assert (y == expected_y);
+}
+
+static void
+assert_point_maintained (cairo_t *cr, double expected_x, double expected_y) {
+ cairo_path_t *path;
+
+ assert_point (cr, expected_x, expected_y);
+
+ path = cairo_copy_path (cr);
+
+ cairo_new_path (cr);
+ cairo_rectangle (cr, 5, 5, 10, 20);
+ cairo_stroke (cr);
+
+ cairo_new_path (cr);
+ cairo_append_path (cr, path);
+ cairo_path_destroy (path);
+
+ assert_point (cr, expected_x, expected_y);
+}
+
+static cairo_test_status_t
+preamble (cairo_test_context_t *ctx)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 20, 20);
+ cr = cairo_create (surface);
+
+ cairo_new_path (cr);
+ cairo_move_to (cr, 1., 2.);
+ assert_point_maintained (cr, 1., 2.);
+
+ cairo_line_to (cr, 4., 5.);
+ cairo_move_to (cr, 2., 1.);
+ assert_point_maintained (cr, 2., 1.);
+
+ cairo_move_to (cr, 5, 5);
+ cairo_arc (cr, 5, 5, 10, 0, M_PI / 3);
+ cairo_close_path (cr);
+ assert_point_maintained (cr, 5, 5);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (path_currentpoint,
+ "Test save/restore path maintains current point",
+ "api", /* keywords */
+ NULL, /* requirements */
+ 0, 0,
+ preamble, NULL)