mutter/tests/conform/test-utils.h
Robert Bragg bbcbece6c9 tests: Improve thoroughness and reporting of make test
This patch reworks our conformance testing framework because it seems
that glib's gtesting framework isn't really well suited to our use case.
For example we weren't able to test windows builds given the way we
were using it and also for each test we'd like to repeat the test
with several different environments so we can test important driver and
feature combinations.

This patch instead switches away to a simplified but custom approach for
running our unit tests. We hope that having a more bespoke setup will
enable us to easily extend it to focus on the details important to us.

Notable changes with this new approach are:

We can now run 'make test' for our mingw windows builds.

We've got rid of all the test-*report* make rules and we're just left
with 'make test'

'make test' now runs each test several times with different driver and
feature combinations checking the result for each run. 'make test' will
then output a concise table of all of the results.

The combinations tested are:
- OpenGL Fixed Function
- OpenGL ARBfp
- OpenGL GLSL
- OpenGL No NPOT texture support
- OpenGLES 2.0
- OpenGLES 2.0 No NPOT texture support

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-24 14:42:31 +00:00

117 lines
3.6 KiB
C

#ifndef _TEST_UTILS_H_
#define _TEST_UTILS_H_
typedef enum _TestRequirement
{
TEST_REQUIREMENT_GL = 1<<0,
TEST_REQUIREMENT_NPOT = 1<<2,
TEST_REQUIREMENT_TEXTURE_3D = 1<<3
} TestRequirement;
/* For compatability since we used to use the glib gtester
* infrastructure and all our unit tests have an entry
* point with a first argument of this type... */
typedef struct _TestUtilsGTestFixture TestUtilsGTestFixture;
/* Stuff you put in here is setup once in main() and gets passed around to
* all test functions and fixture setup/teardown functions in the data
* argument */
typedef struct _TestUtilsSharedState
{
int *argc_addr;
char ***argv_addr;
CoglContext *ctx;
CoglFramebuffer *fb;
} TestUtilsSharedState;
void
test_utils_init (TestUtilsSharedState *state,
TestRequirement requirements);
void
test_utils_fini (TestUtilsSharedState *state);
/*
* test_utils_check_pixel:
* @x: x co-ordinate of the pixel to test
* @y: y co-ordinate of the pixel to test
* @pixel: An integer of the form 0xRRGGBBAA representing the expected
* pixel value
*
* This performs reads a pixel on the current cogl framebuffer and
* asserts that it matches the given color. The alpha channel of the
* color is ignored. The pixels are converted to a string and compared
* with g_assert_cmpstr so that if the comparison fails then the
* assert will display a meaningful message
*/
void
test_utils_check_pixel (int x, int y, guint32 expected_pixel);
/*
* test_utils_check_pixel:
* @x: x co-ordinate of the pixel to test
* @y: y co-ordinate of the pixel to test
* @pixel: An integer of the form 0xrrggbb representing the expected pixel value
*
* This performs reads a pixel on the current cogl framebuffer and
* asserts that it matches the given color. The alpha channel of the
* color is ignored. The pixels are converted to a string and compared
* with g_assert_cmpstr so that if the comparison fails then the
* assert will display a meaningful message
*/
void
test_utils_check_pixel_rgb (int x, int y, int r, int g, int b);
/*
* test_utils_check_region:
* @x: x co-ordinate of the region to test
* @y: y co-ordinate of the region to test
* @width: width of the region to test
* @height: height of the region to test
* @pixel: An integer of the form 0xrrggbb representing the expected region color
*
* Performs a read pixel on the specified region of the current cogl
* framebuffer and asserts that it matches the given color. The alpha
* channel of the color is ignored. The pixels are converted to a
* string and compared with g_assert_cmpstr so that if the comparison
* fails then the assert will display a meaningful message
*/
void
test_utils_check_region (int x, int y,
int width, int height,
guint32 expected_rgba);
/*
* test_utils_compare_pixel:
* @screen_pixel: A pixel stored in memory
* @expected_pixel: The expected RGBA value
*
* Compares a pixel from a buffer to an expected value. The pixels are
* converted to a string and compared with g_assert_cmpstr so that if
* the comparison fails then the assert will display a meaningful
* message.
*/
void
test_utils_compare_pixel (const guint8 *screen_pixel, guint32 expected_pixel);
/*
* test_utils_create_color_texture:
* @context: A #CoglContext
* @color: A color to put in the texture
*
* Creates a 1x1-pixel RGBA texture filled with the given color.
*/
CoglTexture *
test_utils_create_color_texture (CoglContext *context,
guint32 color);
/* cogl_test_verbose:
*
* Queries if the user asked for verbose output or not.
*/
gboolean
cogl_test_verbose (void);
#endif /* _TEST_UTILS_H_ */