From cd9e1be6ae40720ba54aff496d4a3ff928e57741 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sat, 28 Jan 2012 13:40:22 +0000 Subject: [PATCH] test-utils: Expose the compare_pixel function The compare pixel function was a static function used internally by the test_utils_check_* functions. It takes a pointer to a pixel in a buffer read back from Cogl and compares it with an expected value. This function could also be useful in tests wanting to check the data returned from a call to cogl_texture_get_data so we should share it with the rest of the tests. https://bugzilla.gnome.org/show_bug.cgi?id=668913 Reviewed-by: Robert Bragg --- tests/conform/test-utils.c | 8 ++++---- tests/conform/test-utils.h | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c index 9d4d7e9e9..a5ba89159 100644 --- a/tests/conform/test-utils.c +++ b/tests/conform/test-utils.c @@ -85,8 +85,8 @@ compare_component (int a, int b) return ABS (a - b) <= 1; } -static void -compare_pixel (const guint8 *screen_pixel, guint32 expected_pixel) +void +test_utils_compare_pixel (const guint8 *screen_pixel, guint32 expected_pixel) { /* Compare each component with a small fuzz factor */ if (!compare_component (screen_pixel[0], expected_pixel >> 24) || @@ -115,7 +115,7 @@ test_utils_check_pixel (int x, int y, guint32 expected_pixel) COGL_PIXEL_FORMAT_RGBA_8888_PRE, pixel); - compare_pixel (pixel, expected_pixel); + test_utils_compare_pixel (pixel, expected_pixel); } void @@ -144,7 +144,7 @@ test_utils_check_region (int x, int y, for (y = 0; y < height; y++) for (x = 0; x < width; x++) { - compare_pixel (p, expected_rgba); + test_utils_compare_pixel (p, expected_rgba); p += 4; } diff --git a/tests/conform/test-utils.h b/tests/conform/test-utils.h index a82766c1f..c53037464 100644 --- a/tests/conform/test-utils.h +++ b/tests/conform/test-utils.h @@ -88,4 +88,17 @@ 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); + #endif /* _TEST_UTILS_H_ */