[Cogl] [PATCH] Convert the test-atlas-migration test to a standalone Cogl test
Neil Roberts
neil at linux.intel.com
Wed May 16 04:58:38 PDT 2012
This updates test-atlas-migration from being a Clutter-based test to a
Cogl-based test.
---
tests/conform/Makefile.am | 2 +-
tests/conform/test-atlas-migration.c | 41 ++++++++++++++++++++++-----------
tests/conform/test-conform-main.c | 2 +-
3 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
index 81931fd..e57e6e9 100644
--- a/tests/conform/Makefile.am
+++ b/tests/conform/Makefile.am
@@ -22,13 +22,13 @@ unported_test_sources = \
test-texture-mipmaps.c \
test-texture-pixmap-x11.c \
test-texture-rectangle.c \
- test-atlas-migration.c \
test-vertex-buffer-contiguous.c \
test-vertex-buffer-interleved.c \
test-vertex-buffer-mutability.c \
$(NULL)
test_sources = \
+ test-atlas-migration.c \
test-bitmask.c \
test-blend-strings.c \
test-depth-test.c \
diff --git a/tests/conform/test-atlas-migration.c b/tests/conform/test-atlas-migration.c
index 56be060..55660a8 100644
--- a/tests/conform/test-atlas-migration.c
+++ b/tests/conform/test-atlas-migration.c
@@ -1,6 +1,6 @@
-#include <clutter/clutter.h>
+#include <cogl/cogl.h>
-#include "test-conform-common.h"
+#include "test-utils.h"
#define N_TEXTURES 128
@@ -10,16 +10,21 @@
#define COLOR_FOR_SIZE(size) \
(colors + (size) % 3)
-static const ClutterColor colors[] =
+typedef struct
+{
+ uint8_t red, green, blue, alpha;
+} TestColor;
+
+static const TestColor colors[] =
{ { 0xff, 0x00, 0x00, 0xff },
{ 0x00, 0xff, 0x00, 0xff },
{ 0x00, 0x00, 0xff, 0xff } };
-static CoglHandle
+static CoglTexture *
create_texture (int size)
{
- CoglHandle texture;
- const ClutterColor *color;
+ CoglTexture *texture;
+ const TestColor *color;
uint8_t *data, *p;
int x, y;
@@ -65,11 +70,11 @@ create_texture (int size)
}
static void
-verify_texture (CoglHandle texture, int size)
+verify_texture (CoglTexture *texture, int size)
{
uint8_t *data, *p;
int x, y;
- const ClutterColor *color;
+ const TestColor *color;
color = COLOR_FOR_SIZE (size);
@@ -86,9 +91,18 @@ verify_texture (CoglHandle texture, int size)
for (x = 0; x < size; x++)
{
- g_assert_cmpint (p[0], ==, color->red * opacity / 255);
- g_assert_cmpint (p[1], ==, color->green * opacity / 255);
- g_assert_cmpint (p[2], ==, color->blue * opacity / 255);
+ TestColor real_color =
+ {
+ color->red * opacity / 255,
+ color->green * opacity / 255,
+ color->blue * opacity / 255
+ };
+
+ test_utils_compare_pixel (p,
+ (real_color.red << 24) |
+ (real_color.green << 16) |
+ (real_color.blue << 8) |
+ opacity);
g_assert_cmpint (p[3], ==, opacity);
p += 4;
@@ -99,10 +113,9 @@ verify_texture (CoglHandle texture, int size)
}
void
-test_atlas_migration (TestUtilsGTestFixture *fixture,
- void *data)
+test_atlas_migration (void)
{
- CoglHandle textures[N_TEXTURES];
+ CoglTexture *textures[N_TEXTURES];
int i, tex_num;
/* Create and destroy all of the textures a few times to increase
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 4b9f009..5b38aa1 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -72,7 +72,7 @@ main (int argc, char **argv)
ADD_TEST (test_wrap_modes, 0);
UNPORTED_TEST (test_texture_pixmap_x11);
UNPORTED_TEST (test_texture_get_set_data);
- UNPORTED_TEST (test_atlas_migration);
+ ADD_TEST (test_atlas_migration, 0);
ADD_TEST (test_read_texture_formats, 0);
ADD_TEST (test_write_texture_formats, 0);
--
1.7.3.16.g9464b
More information about the Cogl
mailing list