1
0
Fork 0

clutter/tests: Remove unused color check helpers

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3595>
This commit is contained in:
Bilal Elmoussaoui 2024-02-17 14:21:33 +01:00
parent 85dbdc8fa6
commit 97635753d9
2 changed files with 5 additions and 114 deletions

View file

@ -310,9 +310,6 @@ typedef struct {
gpointer result;
guint check_actor : 1;
guint check_color : 1;
guint was_painted : 1;
} ValidateData;
@ -321,23 +318,11 @@ validate_stage (gpointer data_)
{
ValidateData *data = data_;
if (data->check_actor)
{
data->result =
clutter_stage_get_actor_at_pos (CLUTTER_STAGE (data->stage),
CLUTTER_PICK_ALL,
data->point.x,
data->point.y);
}
if (data->check_color)
{
data->result =
clutter_stage_read_pixels (CLUTTER_STAGE (data->stage),
data->point.x,
data->point.y,
1, 1);
}
data->result =
clutter_stage_get_actor_at_pos (CLUTTER_STAGE (data->stage),
CLUTTER_PICK_ALL,
data->point.x,
data->point.y);
if (!g_test_verbose ())
{
@ -395,7 +380,6 @@ clutter_test_check_actor_at_point (ClutterActor *stage,
data = g_new0 (ValidateData, 1);
data->stage = stage;
data->point = *point;
data->check_actor = TRUE;
if (g_test_verbose ())
{
@ -424,75 +408,6 @@ clutter_test_check_actor_at_point (ClutterActor *stage,
return *result == actor;
}
/**
* clutter_test_check_color_at_point:
* @stage: a #ClutterStage
* @point: coordinates to check
* @color: expected color
* @result: (out caller-allocates): color at the given coordinates
*
* Checks the color at the given coordinates on @stage, and matches
* it with the red, green, and blue channels of @color. The alpha
* component of @color and @result is ignored.
*
* Returns: %TRUE if the colors match
*/
gboolean
clutter_test_check_color_at_point (ClutterActor *stage,
const graphene_point_t *point,
const ClutterColor *color,
ClutterColor *result)
{
ValidateData *data;
gboolean retval;
guint8 *buffer;
gulong press_id = 0;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
g_return_val_if_fail (point != NULL, FALSE);
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (result != NULL, FALSE);
data = g_new0 (ValidateData, 1);
data->stage = stage;
data->point = *point;
data->check_color = TRUE;
if (g_test_verbose ())
{
g_printerr ("Press ESC to close the stage and resume the test\n");
press_id = g_signal_connect (stage, "key-press-event",
G_CALLBACK (on_key_press_event),
data);
}
clutter_actor_show (stage);
clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT,
validate_stage,
data,
NULL);
while (!data->was_painted)
g_main_context_iteration (NULL, TRUE);
g_clear_signal_handler (&press_id, stage);
buffer = data->result;
clutter_color_init (result, buffer[0], buffer[1], buffer[2], 255);
/* we only check the color channels, so we can't use clutter_color_equal() */
retval = buffer[0] == color->red &&
buffer[1] == color->green &&
buffer[2] == color->blue;
g_free (data->result);
g_free (data);
return retval;
}
static void
test_actor_paint (ClutterActor *actor,
ClutterPaintContext *paint_context)

View file

@ -25,7 +25,6 @@
#include "clutter/clutter-types.h"
#include "clutter/clutter-actor.h"
#include "clutter/clutter-color.h"
#include "clutter/clutter-event-private.h"
#include "clutter/clutter-private.h"
#include "meta/common.h"
@ -142,33 +141,10 @@ G_STMT_START { \
} \
} G_STMT_END
#define clutter_test_assert_color_at_point(stage,point,color) \
G_STMT_START { \
const graphene_point_t *__p = (point); \
const ClutterColor *__c = (color); \
ClutterActor *__stage = (stage); \
ClutterColor __res; \
if (clutter_test_check_color_at_point (__stage, __p, __c, &__res)) ; else { \
char *__str1 = clutter_color_to_string (__c); \
char *__str2 = clutter_color_to_string (&__res); \
char *__msg = g_strdup_printf ("assertion failed (color %s at %.2f,%.2f): found color %s", \
__str1, __p->x, __p->y, __str2); \
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \
g_free (__msg); \
g_free (__str1); \
g_free (__str2); \
} \
} G_STMT_END
CLUTTER_EXPORT
gboolean clutter_test_check_actor_at_point (ClutterActor *stage,
const graphene_point_t *point,
ClutterActor *actor,
ClutterActor **result);
CLUTTER_EXPORT
gboolean clutter_test_check_color_at_point (ClutterActor *stage,
const graphene_point_t *point,
const ClutterColor *color,
ClutterColor *result);
G_END_DECLS