api-special-cases: Also test contexts

This adds code to the api-special-cases test which also tests the behavior of
cairo when the cairo context or the surface that is target is in an error state
or finished. These new tests call into all public entry points defined in
cairo.h which receive a cairo_t * as their first argument.

Currently this causes a new crash in the testsuite:

  cairo-surface.c:394:
  _cairo_surface_begin_modification: Assertion `!  surface->finished' failed.

Reported-by: christophe.troestler@umons.ac.be
References: https://bugs.freedesktop.org/show_bug.cgi?id=68014
Signed-off-by: Uli Schlachter <psychon@znc.in>
surface: Error out on finished surfaces

Finished surfaces and surfaces with an error status must not be usable anymore,
so refuse to work on them.

This improves the result for api-special-cases.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68014

Signed-off-by: Uli Schlachter <psychon@znc.in>
push_group: Refuse working with unusable surface

Make cairo_push_group() fail when the context's target surface is finished.

This fixes the api-special-cases for the xcb backend:

   Detected error during xcb run: error=9, seqno=0x13c, major=53, minor=0

The problem was that the Pixmap for the cairo surface was already freed and
cairo still tried to use it again as the drawable in a CreatePixmap request.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
surface_get_extents: Reject finished or error surface

This fixes a crash in the api-special-cases with xlib-xcb when calling
cairo_clip_extents() on a context that refers to a finished surface.

The crash was a simple NULL pointer dereference, because the underlying xcb
surface that was used in xlib-xcb was gone and set to NULL already.

Signed-off-by: Uli Schlachter <psychon@znc.in>