[test/surface-source] Skip tests if we cannot create the source surface.

Check that the test environment supports the desired source and avoid
triggering asserts in the test routines.
This commit is contained in:
Chris Wilson 2008-04-07 10:42:57 +01:00
parent 056d3c853e
commit d0672e85ef
2 changed files with 18 additions and 5 deletions

View file

@ -28,8 +28,6 @@
#include <cairo-xlib.h>
#include <cairo-xlib-xrender.h>
#include <assert.h>
#define NAME "glitz"
#include "surface-source.c"
@ -174,18 +172,25 @@ static cairo_surface_t *
create_source_surface (int size)
{
struct closure *closure;
glitz_surface_t * glitz_surface;
glitz_surface_t *glitz_surface;
cairo_surface_t *surface;
closure = xcalloc (1, sizeof (struct closure));
closure->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
assert (closure->dpy);
if (closure->dpy == NULL) {
free (closure);
return NULL;
}
glitz_surface = _glitz_glx_create_surface (GLITZ_STANDARD_ARGB32,
size, size,
closure);
assert (glitz_surface != NULL);
if (glitz_surface == NULL) {
XCloseDisplay (closure->dpy);
free (closure);
return NULL;
}
surface = cairo_glitz_surface_create (glitz_surface);

View file

@ -89,5 +89,13 @@ draw (cairo_t *cr, int width, int height)
int
main (void)
{
cairo_surface_t *surface;
surface = create_source_surface (SIZE);
if (surface == NULL) /* can't create the source so skip the test */
return CAIRO_TEST_SUCCESS;
cairo_surface_destroy (surface);
return cairo_test (&test);
}