b5a7657076
This makes a start on porting the Cogl conformance tests that currently still live in the Clutter repository to be standalone Cogl tests that no longer require a ClutterStage. The main thing is that this commit brings in is the basic testing infrastructure we need, so now we can port more and more tests incrementally. Since the test suite wants a way to synchronize X requests/replies and we can't simply call XSynchronize in the test-utils code before we know if we are really running on X this adds a check for an environment variable named "COGL_X11_SYNC" in cogl-xlib-renderer.c and if it's set it forces XSynchronize (dpy, TRUE) to be called. By default the conformance tests are run off screen. This makes the tests run much faster and they also don't interfere with other work you may want to do by constantly stealing focus. CoglOnscreen framebuffers obviously don't get tested this way so it's important that the tests also get run on screen every once in a while, especially if changes are being made to CoglFramebuffer related code. On screen testing can be enabled by setting COGL_TEST_ONSCREEN=1 in your environment.
87 lines
2.0 KiB
C
87 lines
2.0 KiB
C
|
|
#include <clutter/clutter.h>
|
|
#include <cogl/cogl.h>
|
|
#include <string.h>
|
|
|
|
#include "test-conform-common.h"
|
|
|
|
CoglUserDataKey private_key0;
|
|
CoglUserDataKey private_key1;
|
|
CoglUserDataKey private_key2;
|
|
|
|
static int user_data0;
|
|
static int user_data1;
|
|
static int user_data2;
|
|
|
|
static int destroy0_count = 0;
|
|
static int destroy1_count = 0;
|
|
static int destroy2_count = 0;
|
|
|
|
static void
|
|
destroy0_cb (void *user_data)
|
|
{
|
|
g_assert (user_data == &user_data0);
|
|
destroy0_count++;
|
|
}
|
|
|
|
static void
|
|
destroy1_cb (void *user_data)
|
|
{
|
|
g_assert (user_data == &user_data1);
|
|
destroy1_count++;
|
|
}
|
|
|
|
static void
|
|
destroy2_cb (void *user_data)
|
|
{
|
|
g_assert (user_data == &user_data2);
|
|
destroy2_count++;
|
|
}
|
|
|
|
void
|
|
test_cogl_object (TestUtilsGTestFixture *fixture,
|
|
void *data)
|
|
{
|
|
CoglPath *path;
|
|
|
|
/* Assuming that COGL_OBJECT_N_PRE_ALLOCATED_USER_DATA_ENTRIES == 2
|
|
* test associating 2 pointers to private data with an object */
|
|
cogl_path_new ();
|
|
path = cogl_get_path ();
|
|
|
|
cogl_object_set_user_data (COGL_OBJECT (path),
|
|
&private_key0,
|
|
&user_data0,
|
|
destroy0_cb);
|
|
|
|
cogl_object_set_user_data (COGL_OBJECT (path),
|
|
&private_key1,
|
|
&user_data1,
|
|
destroy1_cb);
|
|
|
|
cogl_object_set_user_data (COGL_OBJECT (path),
|
|
&private_key2,
|
|
&user_data2,
|
|
destroy2_cb);
|
|
|
|
cogl_object_set_user_data (COGL_OBJECT (path),
|
|
&private_key1,
|
|
NULL,
|
|
destroy1_cb);
|
|
|
|
cogl_object_set_user_data (COGL_OBJECT (path),
|
|
&private_key1,
|
|
&user_data1,
|
|
destroy1_cb);
|
|
|
|
cogl_object_unref (path);
|
|
|
|
g_assert_cmpint (destroy0_count, ==, 1);
|
|
g_assert_cmpint (destroy1_count, ==, 2);
|
|
g_assert_cmpint (destroy2_count, ==, 1);
|
|
|
|
if (g_test_verbose ())
|
|
g_print ("OK\n");
|
|
}
|
|
|