mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
603f936745
framework * configure.ac: * tests/*: The tests have been reorganised into different categories: conformance, interactive and micro benchmarks. - conformance tests can be run as part of automated tests - interactive tests are basically all the existing tests - micro benchmarks focus on a single performance metric I converted the timeline tests to conformance tests and also added some tests from Neil Roberts and Ebassi. Note: currently only the conformance tests use the glib test APIs, though the micro benchmarks should too. The other change is to make the unit tests link into monolithic binaries which makes the build time for unit tests considerably faster. To deal with the extra complexity this adds to debugging individual tests I have added some sugar to the makefiles so all the tests can be run directly via a symlink and when an individual test is run this way, then a note is printed to the terminal explaining exactly how that test may be debugged using GDB. There is a convenience make rule: 'make test-report', that will run all the conformance tests and hopefully even open the results in your web browser. It skips some of the slower timeline tests, but you can run those using 'make full-report'
87 lines
2.1 KiB
C
87 lines
2.1 KiB
C
#include <gmodule.h>
|
|
#include <clutter/clutter.h>
|
|
#include <stdlib.h>
|
|
|
|
#define MAX_TEXT_LEN 10
|
|
#define MIN_FONT_SIZE 10
|
|
#define MAX_FONT_SIZE 30
|
|
|
|
static const char * const font_names[] =
|
|
{
|
|
"Sans", "Sans Italic", "Serif", "Serif Bold", "Times", "Monospace"
|
|
};
|
|
#define FONT_NAME_COUNT 6
|
|
|
|
static gboolean
|
|
on_idle (gpointer data)
|
|
{
|
|
ClutterActor *stage = CLUTTER_ACTOR (data);
|
|
int line_height = 0, xpos = 0, ypos = 0;
|
|
int stage_width = clutter_actor_get_width (stage);
|
|
int stage_height = clutter_actor_get_height (stage);
|
|
char text[MAX_TEXT_LEN + 1];
|
|
char font_name[64];
|
|
int i;
|
|
GList *children, *node;
|
|
|
|
/* Remove all of the children of the stage */
|
|
children = clutter_container_get_children (CLUTTER_CONTAINER (stage));
|
|
for (node = children; node; node = node->next)
|
|
clutter_container_remove_actor (CLUTTER_CONTAINER (stage),
|
|
CLUTTER_ACTOR (node->data));
|
|
g_list_free (children);
|
|
|
|
/* Fill the stage with new random labels */
|
|
while (ypos < stage_height)
|
|
{
|
|
int text_len = rand () % MAX_TEXT_LEN + 1;
|
|
ClutterActor *label;
|
|
|
|
for (i = 0; i < text_len; i++)
|
|
text[i] = rand () % (128 - 32) + 32;
|
|
text[text_len] = '\0';
|
|
|
|
sprintf (font_name, "%s %i",
|
|
font_names[rand () % FONT_NAME_COUNT],
|
|
rand () % (MAX_FONT_SIZE - MIN_FONT_SIZE) + MIN_FONT_SIZE);
|
|
|
|
label = clutter_label_new_with_text (font_name, text);
|
|
|
|
if (clutter_actor_get_height (label) > line_height)
|
|
line_height = clutter_actor_get_height (label);
|
|
|
|
if (xpos + clutter_actor_get_width (label) > stage_width)
|
|
{
|
|
xpos = 0;
|
|
ypos += line_height;
|
|
line_height = 0;
|
|
}
|
|
|
|
clutter_actor_set_position (label, xpos, ypos);
|
|
|
|
clutter_container_add (CLUTTER_CONTAINER (stage), label, NULL);
|
|
|
|
xpos += clutter_actor_get_width (label);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
G_MODULE_EXPORT int
|
|
test_random_text_main (int argc, char **argv)
|
|
{
|
|
ClutterActor *stage;
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
stage = clutter_stage_get_default ();
|
|
|
|
clutter_actor_show (stage);
|
|
|
|
clutter_threads_add_idle (on_idle, stage);
|
|
|
|
clutter_main ();
|
|
|
|
return 0;
|
|
}
|