diff options
author | Benjamin Otte <otte@redhat.com> | 2010-04-26 21:28:53 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-04-26 21:42:47 +0200 |
commit | 9672aab6b7c3f1efc065a6e5eb69443a1ecaa723 (patch) | |
tree | de025e70e1cabf367863241ccd6c7fbeafd0e3c7 /test/xlib-expose-event.c | |
parent | 36e0a3d3a01f9962d97386ea2d3c60020e937a81 (diff) |
tests: Integrate xlib-expose-event test into usual tests
Previously the test was using the preamble vfunc and generating output
itself. Now it uses the draw function and ignores any but the xlib
backends.
Diffstat (limited to 'test/xlib-expose-event.c')
-rw-r--r-- | test/xlib-expose-event.c | 63 |
1 files changed, 15 insertions, 48 deletions
diff --git a/test/xlib-expose-event.c b/test/xlib-expose-event.c index fc312dadd..fb1950e26 100644 --- a/test/xlib-expose-event.c +++ b/test/xlib-expose-event.c @@ -175,36 +175,7 @@ draw (const cairo_test_context_t *ctx, } static cairo_test_status_t -compare (const cairo_test_context_t *ctx, cairo_surface_t *surface) -{ - cairo_t *cr; - cairo_surface_t *image, *reference, *diff; - cairo_status_t status; - buffer_diff_result_t result; - - diff = cairo_image_surface_create (CAIRO_FORMAT_RGB24, SIZE, SIZE); - - /* copy the pixmap to an image buffer */ - image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, SIZE, SIZE); - cr = cairo_create (image); - cairo_set_source_surface (cr, surface, 0, 0); - cairo_paint (cr); - cairo_destroy (cr); - cairo_surface_write_to_png (image, "xlib-expose-event.out.png"); - - reference = cairo_test_create_surface_from_png (ctx, "xlib-expose-event.ref.png"); - status = image_diff (ctx, reference, image, diff, &result); - - cairo_surface_destroy (reference); - cairo_surface_destroy (image); - cairo_surface_destroy (diff); - - return status == CAIRO_STATUS_SUCCESS && ! result.pixels_changed ? - CAIRO_TEST_SUCCESS : CAIRO_TEST_FAILURE; -} - -static cairo_test_status_t -preamble (cairo_test_context_t *ctx) +draw_func (cairo_t *cr, int width, int height) { Display *dpy; Drawable drawable; @@ -212,20 +183,19 @@ preamble (cairo_test_context_t *ctx) cairo_surface_t *surface; cairo_rectangle_t region[4]; int i, j; - cairo_test_status_t result = CAIRO_TEST_UNTESTED; + const cairo_test_context_t *ctx; + + ctx = cairo_test_get_context (cr); + surface = cairo_get_target (cr); - if (! cairo_test_is_target_enabled (ctx, "xlib")) - goto CLEANUP_TEST; + if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_XLIB) + return CAIRO_TEST_UNTESTED; - dpy = XOpenDisplay (NULL); - if (dpy == NULL) { - cairo_test_log (ctx, "xlib-expose-event: Cannot open display, skipping\n"); - goto CLEANUP_TEST; - } + dpy = cairo_xlib_surface_get_display (surface); if (! check_visual (dpy)) { cairo_test_log (ctx, "xlib-expose-event: default visual is not RGB24 or BGR24, skipping\n"); - goto CLEANUP_DISPLAY; + return CAIRO_TEST_UNTESTED; } screen = DefaultScreen (dpy); @@ -263,22 +233,19 @@ preamble (cairo_test_context_t *ctx) } } - result = compare (ctx, surface); - + cairo_set_source_surface (cr, surface, 0, 0); cairo_surface_destroy (surface); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_paint (cr); XFreePixmap (dpy, drawable); - CLEANUP_DISPLAY: - XCloseDisplay (dpy); - - CLEANUP_TEST: - return result; + return CAIRO_TEST_SUCCESS; } CAIRO_TEST (xlib_expose_event, "Emulate a typical expose event", "xlib", /* keywords */ NULL, /* requirements */ - 0, 0, - preamble, NULL) + SIZE, SIZE, + NULL, draw_func) |