2011-05-05 22:34:38 +00:00
|
|
|
#ifndef _TEST_UTILS_H_
|
|
|
|
#define _TEST_UTILS_H_
|
|
|
|
|
2012-03-06 18:21:28 +00:00
|
|
|
/* We don't really care about functions that are defined without a
|
|
|
|
header for the unit tests so we can just disable it here */
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma GCC diagnostic ignored "-Wmissing-declarations"
|
|
|
|
#endif
|
|
|
|
|
2012-03-06 23:41:49 +00:00
|
|
|
typedef enum _TestFlags
|
2011-05-05 22:34:38 +00:00
|
|
|
{
|
2012-03-06 23:36:45 +00:00
|
|
|
TEST_KNOWN_FAILURE = 1<<0,
|
|
|
|
TEST_REQUIREMENT_GL = 1<<1,
|
|
|
|
TEST_REQUIREMENT_NPOT = 1<<2,
|
|
|
|
TEST_REQUIREMENT_TEXTURE_3D = 1<<3,
|
|
|
|
TEST_REQUIREMENT_POINT_SPRITE = 1<<4
|
2012-03-06 23:41:49 +00:00
|
|
|
} TestFlags;
|
2012-02-23 12:30:51 +00:00
|
|
|
|
2012-03-16 19:54:13 +00:00
|
|
|
extern CoglContext *ctx;
|
|
|
|
extern CoglFramebuffer *fb;
|
2011-05-05 22:34:38 +00:00
|
|
|
|
|
|
|
void
|
2012-03-16 19:54:13 +00:00
|
|
|
test_utils_init (TestFlags flags);
|
2011-05-05 22:34:38 +00:00
|
|
|
|
|
|
|
void
|
2012-03-16 19:54:13 +00:00
|
|
|
test_utils_fini (void);
|
2011-05-05 22:34:38 +00:00
|
|
|
|
2011-10-26 13:15:14 +00:00
|
|
|
/*
|
|
|
|
* test_utils_check_pixel:
|
2012-03-16 19:54:13 +00:00
|
|
|
* @framebuffer: The #CoglFramebuffer to read from
|
2011-10-26 13:15:14 +00:00
|
|
|
* @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
|
|
|
|
*
|
2012-03-16 19:54:13 +00:00
|
|
|
* This performs reads a pixel on the given cogl @framebuffer and
|
2011-10-26 13:15:14 +00:00
|
|
|
* 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
|
2012-03-16 19:54:13 +00:00
|
|
|
test_utils_check_pixel (CoglFramebuffer *framebuffer,
|
|
|
|
int x, int y, guint32 expected_pixel);
|
2011-10-26 13:15:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* test_utils_check_pixel:
|
2012-03-16 19:54:13 +00:00
|
|
|
* @framebuffer: The #CoglFramebuffer to read from
|
2011-10-26 13:15:14 +00:00
|
|
|
* @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
|
|
|
|
*
|
2012-03-16 19:54:13 +00:00
|
|
|
* This performs reads a pixel on the given cogl @framebuffer and
|
2011-10-26 13:15:14 +00:00
|
|
|
* 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
|
2012-03-16 19:54:13 +00:00
|
|
|
test_utils_check_pixel_rgb (CoglFramebuffer *framebuffer,
|
|
|
|
int x, int y, int r, int g, int b);
|
2011-10-26 13:15:14 +00:00
|
|
|
|
2011-10-31 14:55:20 +00:00
|
|
|
/*
|
|
|
|
* test_utils_check_region:
|
2012-03-16 19:54:13 +00:00
|
|
|
* @framebuffer: The #CoglFramebuffer to read from
|
2011-10-31 14:55:20 +00:00
|
|
|
* @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
|
|
|
|
*
|
2012-03-16 19:54:13 +00:00
|
|
|
* Performs a read pixel on the specified region of the given cogl
|
|
|
|
* @framebuffer and asserts that it matches the given color. The alpha
|
2011-10-31 14:55:20 +00:00
|
|
|
* 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
|
2012-03-16 19:54:13 +00:00
|
|
|
test_utils_check_region (CoglFramebuffer *framebuffer,
|
|
|
|
int x, int y,
|
2011-10-31 14:55:20 +00:00
|
|
|
int width, int height,
|
|
|
|
guint32 expected_rgba);
|
|
|
|
|
2012-01-28 13:40:22 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
2012-02-10 16:57:24 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
2012-02-23 12:30:51 +00:00
|
|
|
/* cogl_test_verbose:
|
|
|
|
*
|
|
|
|
* Queries if the user asked for verbose output or not.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
cogl_test_verbose (void);
|
|
|
|
|
2011-05-05 22:34:38 +00:00
|
|
|
#endif /* _TEST_UTILS_H_ */
|