summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2011-08-18 15:10:47 +0200
committerUli Schlachter <psychon@znc.in>2011-08-18 16:34:44 +0200
commitaeba5acbad463db3a9eeb44e26a15979d1831472 (patch)
treec2696c40b85f374e510b9b7c7cef1e2d4cbbe841 /test
parent8951c51d9e63dc175bc1eff6592833de627bce74 (diff)
test: Add a test that maps a huge surface
This test currently fails in the xcb backend if xcb-shm is enabled. Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.refs1
-rw-r--r--test/Makefile.sources1
-rw-r--r--test/xcb-huge-image-shm.c67
-rw-r--r--test/xcb-huge-image-shm.ref.pngbin0 -> 97 bytes
4 files changed, 69 insertions, 0 deletions
diff --git a/test/Makefile.refs b/test/Makefile.refs
index 2d291f08..500fd827 100644
--- a/test/Makefile.refs
+++ b/test/Makefile.refs
@@ -1402,6 +1402,7 @@ REFERENCE_IMAGES = \
world-map-stroke.ref.png \
world-map.image16.ref.png \
world-map.ref.png \
+ xcb-huge-image-shm.ref.png \
xcb-snapshot-assert.ref.png \
xcb-stress-cache.ref.png \
xcb-surface-source.argb32.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index a39a201e..70011934 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -320,6 +320,7 @@ test_sources = \
user-font-rescale.c \
world-map.c \
white-in-noop.c \
+ xcb-huge-image-shm.c \
xcb-stress-cache.c \
xcb-snapshot-assert.c \
xcomposite-projection.c \
diff --git a/test/xcb-huge-image-shm.c b/test/xcb-huge-image-shm.c
new file mode 100644
index 00000000..269d7f0d
--- /dev/null
+++ b/test/xcb-huge-image-shm.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2011 Uli Schlachter
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Uli Schlachter <psychon@znc.in>
+ */
+
+#include "cairo-test.h"
+
+#define WIDTH 3000
+#define HEIGHT 3000
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_surface_t *surface;
+ cairo_surface_t *image;
+ cairo_t *cr2;
+
+ /* We use a similar surface to have way smaller ref images */
+ surface = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ WIDTH, HEIGHT);
+
+ /* First we have to defeat xcb's deferred clear */
+ cr2 = cairo_create (surface);
+ cairo_test_paint_checkered (cr2);
+ cairo_destroy (cr2);
+
+ /* Now we try to map this to an image. This will try to use shared memory
+ * but fail the allocation, because of the huge surface. */
+ image = cairo_surface_map_to_image (surface, NULL);
+ cairo_surface_unmap_image (surface, image);
+
+ /* Finally we make sure that errors aren't lost. */
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_paint (cr);
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (xcb_huge_image_shm,
+ "Force a failed shm allocation when receiving an image",
+ "xcb", /* keywords */
+ NULL, /* requirements */
+ 2, 2,
+ NULL, draw)
diff --git a/test/xcb-huge-image-shm.ref.png b/test/xcb-huge-image-shm.ref.png
new file mode 100644
index 00000000..a0b24c8a
--- /dev/null
+++ b/test/xcb-huge-image-shm.ref.png
Binary files differ