mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 07:56:14 -05:00
tests/clutter: Don't have tests take arguments
It just complicates things; we can't run them right now, so just get rid of the runtime variability; just change the macros if you want to tweak the test, would you be able to get it running. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
This commit is contained in:
parent
af501ac472
commit
475296ee9a
@ -26,21 +26,9 @@ typedef struct SuperOH
|
||||
ClutterTimeline *timeline;
|
||||
} SuperOH;
|
||||
|
||||
static gint n_hands = NHANDS;
|
||||
|
||||
int
|
||||
test_actors_main (int argc, char *argv[]);
|
||||
|
||||
static GOptionEntry super_oh_entries[] = {
|
||||
{
|
||||
"num-hands", 'n',
|
||||
0,
|
||||
G_OPTION_ARG_INT, &n_hands,
|
||||
"Number of hands", "HANDS"
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
on_group_destroy (ClutterActor *actor,
|
||||
SuperOH *oh)
|
||||
@ -54,7 +42,7 @@ on_hand_destroy (ClutterActor *actor,
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
for (i = 0; i < NHANDS; i++)
|
||||
{
|
||||
if (oh->hand[i] == actor)
|
||||
oh->hand[i] = NULL;
|
||||
@ -102,7 +90,7 @@ input_cb (ClutterActor *stage,
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
for (i = 0; i < NHANDS; i++)
|
||||
{
|
||||
if (oh->hand[i] != NULL)
|
||||
clutter_actor_show (oh->hand[i]);
|
||||
@ -129,7 +117,7 @@ frame_cb (ClutterTimeline *timeline,
|
||||
if (oh->group != NULL)
|
||||
clutter_actor_set_rotation_angle (oh->group, CLUTTER_Z_AXIS, rotation);
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
for (i = 0; i < NHANDS; i++)
|
||||
{
|
||||
/* Rotate each hand around there centers - to get this we need
|
||||
* to take into account any scaling.
|
||||
@ -161,10 +149,7 @@ test_actors_main (int argc, char *argv[])
|
||||
|
||||
error = NULL;
|
||||
|
||||
clutter_test_init_with_args (&argc, &argv,
|
||||
NULL,
|
||||
super_oh_entries,
|
||||
NULL);
|
||||
clutter_test_init (&argc, &argv);
|
||||
|
||||
oh = g_new (SuperOH, 1);
|
||||
|
||||
@ -199,14 +184,13 @@ test_actors_main (int argc, char *argv[])
|
||||
clutter_actor_add_constraint (oh->group, clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_BOTH, 0.5));
|
||||
clutter_actor_add_constraint (oh->group, clutter_bind_constraint_new (oh->stage, CLUTTER_BIND_SIZE, 0.0f));
|
||||
|
||||
oh->hand = g_new (ClutterActor*, n_hands);
|
||||
oh->hand = g_new (ClutterActor *, NHANDS);
|
||||
|
||||
oh->stage_width = clutter_actor_get_width (oh->stage);
|
||||
oh->stage_height = clutter_actor_get_height (oh->stage);
|
||||
oh->radius = (oh->stage_width + oh->stage_height)
|
||||
/ n_hands;
|
||||
oh->radius = (oh->stage_width + oh->stage_height) / NHANDS;
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
for (i = 0; i < NHANDS; i++)
|
||||
{
|
||||
gint x, y, w, h;
|
||||
|
||||
@ -231,12 +215,12 @@ test_actors_main (int argc, char *argv[])
|
||||
|
||||
x = oh->stage_width / 2
|
||||
+ oh->radius
|
||||
* cos (i * G_PI / (n_hands / 2))
|
||||
* cos (i * G_PI / (NHANDS / 2))
|
||||
- w / 2;
|
||||
|
||||
y = oh->stage_height / 2
|
||||
+ oh->radius
|
||||
* sin (i * G_PI / (n_hands / 2))
|
||||
* sin (i * G_PI / (NHANDS / 2))
|
||||
- h / 2;
|
||||
|
||||
clutter_actor_set_position (oh->hand[i], x, y);
|
||||
|
@ -49,8 +49,7 @@ static const struct {
|
||||
static const gint n_easing_modes = G_N_ELEMENTS (easing_modes);
|
||||
static gint current_mode = 0;
|
||||
|
||||
static gint duration = 1;
|
||||
static gboolean recenter = FALSE;
|
||||
#define DURATION 1
|
||||
|
||||
static ClutterActor *main_stage = NULL;
|
||||
static ClutterActor *easing_mode_label = NULL;
|
||||
@ -115,7 +114,7 @@ on_button_press (ClutterActor *actor,
|
||||
cur_mode = easing_modes[current_mode].mode;
|
||||
|
||||
clutter_actor_save_easing_state (rectangle);
|
||||
clutter_actor_set_easing_duration (rectangle, duration * 1000);
|
||||
clutter_actor_set_easing_duration (rectangle, DURATION * 1000);
|
||||
clutter_actor_set_easing_mode (rectangle, cur_mode);
|
||||
clutter_actor_set_position (rectangle, event->x, event->y);
|
||||
|
||||
@ -199,25 +198,6 @@ make_bouncer (gfloat width,
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GOptionEntry test_easing_entries[] = {
|
||||
{
|
||||
"re-center", 'r',
|
||||
0,
|
||||
G_OPTION_ARG_NONE, &recenter,
|
||||
"Re-center the actor when the animation ends",
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"duration", 'd',
|
||||
0,
|
||||
G_OPTION_ARG_INT, &duration,
|
||||
"Duration of the animation",
|
||||
"SECONDS"
|
||||
},
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
G_MODULE_EXPORT int
|
||||
test_easing_main (int argc, char *argv[])
|
||||
{
|
||||
@ -225,10 +205,7 @@ test_easing_main (int argc, char *argv[])
|
||||
gchar *text;
|
||||
gfloat stage_width, stage_height;
|
||||
|
||||
clutter_test_init_with_args (&argc, &argv,
|
||||
NULL,
|
||||
test_easing_entries,
|
||||
NULL);
|
||||
clutter_test_init (&argc, &argv);
|
||||
|
||||
stage = clutter_test_get_stage ();
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "Easing Modes");
|
||||
|
@ -11,18 +11,6 @@
|
||||
#define STAGE_WIDTH 800
|
||||
#define STAGE_HEIGHT 600
|
||||
|
||||
gboolean run_all = FALSE;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{
|
||||
"run-all", 'a',
|
||||
0,
|
||||
G_OPTION_ARG_NONE, &run_all,
|
||||
"Run all tests", ""
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
typedef struct _TestState
|
||||
{
|
||||
ClutterActor *stage;
|
||||
@ -136,10 +124,7 @@ main (int argc, char *argv[])
|
||||
g_setenv ("CLUTTER_VBLANK", "none", FALSE);
|
||||
g_setenv ("CLUTTER_SHOW_FPS", "1", FALSE);
|
||||
|
||||
clutter_test_init_with_args (&argc, &argv,
|
||||
NULL,
|
||||
entries,
|
||||
NULL);
|
||||
clutter_test_init (&argc, &argv);
|
||||
|
||||
state.current_test = 0;
|
||||
|
||||
|
@ -8,25 +8,6 @@
|
||||
#define N_ACTORS 100
|
||||
#define N_EVENTS 5
|
||||
|
||||
static gint n_actors = N_ACTORS;
|
||||
static gint n_events = N_EVENTS;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{
|
||||
"num-actors", 'a',
|
||||
0,
|
||||
G_OPTION_ARG_INT, &n_actors,
|
||||
"Number of actors", "ACTORS"
|
||||
},
|
||||
{
|
||||
"num-events", 'e',
|
||||
0,
|
||||
G_OPTION_ARG_INT, &n_events,
|
||||
"Number of events", "EVENTS"
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static gboolean
|
||||
motion_event_cb (ClutterActor *actor, ClutterEvent *event, gpointer user_data)
|
||||
{
|
||||
@ -39,9 +20,9 @@ do_events (ClutterActor *stage)
|
||||
glong i;
|
||||
static gdouble angle = 0;
|
||||
|
||||
for (i = 0; i < n_events; i++)
|
||||
for (i = 0; i < N_EVENTS; i++)
|
||||
{
|
||||
angle += (2.0 * G_PI) / (gdouble)n_actors;
|
||||
angle += (2.0 * G_PI) / (double) N_ACTORS;
|
||||
while (angle > G_PI * 2.0)
|
||||
angle -= G_PI * 2.0;
|
||||
|
||||
@ -83,10 +64,7 @@ main (int argc, char **argv)
|
||||
g_setenv ("CLUTTER_DEFAULT_FPS", "1000", FALSE);
|
||||
g_setenv ("CLUTTER_SHOW_FPS", "1", FALSE);
|
||||
|
||||
clutter_test_init_with_args (&argc, &argv,
|
||||
NULL,
|
||||
entries,
|
||||
NULL);
|
||||
clutter_test_init (&argc, &argv);
|
||||
|
||||
stage = clutter_test_get_stage ();
|
||||
clutter_actor_set_size (stage, 512, 512);
|
||||
@ -95,21 +73,21 @@ main (int argc, char **argv)
|
||||
|
||||
printf ("Picking performance test with "
|
||||
"%d actors and %d events per frame\n",
|
||||
n_actors,
|
||||
n_events);
|
||||
N_ACTORS,
|
||||
N_EVENTS);
|
||||
|
||||
for (i = n_actors - 1; i >= 0; i--)
|
||||
for (i = N_ACTORS - 1; i >= 0; i--)
|
||||
{
|
||||
angle = ((2.0 * G_PI) / (gdouble) n_actors) * i;
|
||||
angle = ((2.0 * G_PI) / (double) N_ACTORS) * i;
|
||||
|
||||
color.red = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, i))) /
|
||||
(gdouble)(n_actors/4.0) - 1.0)) * 255.0;
|
||||
color.green = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0,
|
||||
fmod (i + (n_actors/3.0)*2, n_actors)))) /
|
||||
(gdouble)(n_actors/4) - 1.0)) * 255.0;
|
||||
color.blue = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0,
|
||||
fmod ((i + (n_actors/3.0)), n_actors)))) /
|
||||
(gdouble)(n_actors/4.0) - 1.0)) * 255.0;
|
||||
color.red = (1.0 - ABS ((MAX (0, MIN (N_ACTORS / 2.0 + 0, i))) /
|
||||
(double) (N_ACTORS / 4.0) - 1.0)) * 255.0;
|
||||
color.green = (1.0 - ABS ((MAX (0, MIN (N_ACTORS / 2.0 + 0,
|
||||
fmod (i + (N_ACTORS / 3.0) * 2, N_ACTORS)))) /
|
||||
(double) (N_ACTORS / 4) - 1.0)) * 255.0;
|
||||
color.blue = (1.0 - ABS ((MAX (0, MIN (N_ACTORS / 2.0 + 0,
|
||||
fmod ((i + (N_ACTORS / 3.0)), N_ACTORS)))) /
|
||||
(double) (N_ACTORS / 4.0) - 1.0)) * 255.0;
|
||||
|
||||
rect = clutter_actor_new ();
|
||||
clutter_actor_set_background_color (rect, &color);
|
||||
|
@ -10,22 +10,6 @@
|
||||
static gint n_actors = N_ACTORS;
|
||||
static gint n_events = N_EVENTS;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{
|
||||
"num-actors", 'a',
|
||||
0,
|
||||
G_OPTION_ARG_INT, &n_actors,
|
||||
"Number of actors", "ACTORS"
|
||||
},
|
||||
{
|
||||
"num-events", 'e',
|
||||
0,
|
||||
G_OPTION_ARG_INT, &n_events,
|
||||
"Number of events", "EVENTS"
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static gboolean
|
||||
motion_event_cb (ClutterActor *actor, ClutterEvent *event, gpointer user_data)
|
||||
{
|
||||
@ -72,10 +56,7 @@ main (int argc, char **argv)
|
||||
|
||||
clutter_perf_fps_init ();
|
||||
|
||||
clutter_test_init_with_args (&argc, &argv,
|
||||
NULL,
|
||||
entries,
|
||||
NULL);
|
||||
clutter_test_init (&argc, &argv);
|
||||
|
||||
stage = clutter_test_get_stage ();
|
||||
clutter_actor_set_size (stage, 512, 512);
|
||||
|
Loading…
Reference in New Issue
Block a user