tests/color-management: Move some utility functions higher up

That means they'll be re-usable without having to declare them on top.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
This commit is contained in:
Jonas Ådahl 2022-09-03 15:48:11 +02:00 committed by Marge Bot
parent 255cd9a9ff
commit b29604c3f8

View File

@ -148,6 +148,63 @@ get_colord_mock_proxy (void)
return proxy; return proxy;
} }
static void
wait_for_profile_assigned (MetaColorDevice *color_device,
const char *profile_id)
{
while (TRUE)
{
MetaColorProfile *color_profile;
color_profile = meta_color_device_get_assigned_profile (color_device);
if (color_profile &&
g_strcmp0 (meta_color_profile_get_id (color_profile),
profile_id) == 0)
break;
g_main_context_iteration (NULL, TRUE);
}
}
static void
on_device_updated (MetaColorDevice *color_device,
gboolean *run)
{
*run = FALSE;
}
static void
wait_for_device_updated (MetaColorDevice *color_device)
{
gulong handler_id;
gboolean run = TRUE;
handler_id = g_signal_connect (color_device, "updated",
G_CALLBACK (on_device_updated),
&run);
while (run)
g_main_context_iteration (NULL, TRUE);
g_signal_handler_disconnect (color_device, handler_id);
}
static void
assert_gamma_array (uint16_t *expected,
uint16_t *values,
size_t size)
{
size_t i;
for (i = 0; i < size; i++)
{
if (expected[i] != values[i])
{
g_error ("Expected %hu at but got %hu at index %zu",
expected[i], values[i], i);
}
}
}
static void static void
set_colord_device_profiles (const char *cd_device_id, set_colord_device_profiles (const char *cd_device_id,
const char **cd_profile_ids, const char **cd_profile_ids,
@ -682,63 +739,6 @@ meta_test_color_management_profile_efivar (void)
unlink (efivar_path); unlink (efivar_path);
} }
static void
wait_for_profile_assigned (MetaColorDevice *color_device,
const char *profile_id)
{
while (TRUE)
{
MetaColorProfile *color_profile;
color_profile = meta_color_device_get_assigned_profile (color_device);
if (color_profile &&
g_strcmp0 (meta_color_profile_get_id (color_profile),
profile_id) == 0)
break;
g_main_context_iteration (NULL, TRUE);
}
}
static void
on_device_updated (MetaColorDevice *color_device,
gboolean *run)
{
*run = FALSE;
}
static void
wait_for_device_updated (MetaColorDevice *color_device)
{
gulong handler_id;
gboolean run = TRUE;
handler_id = g_signal_connect (color_device, "updated",
G_CALLBACK (on_device_updated),
&run);
while (run)
g_main_context_iteration (NULL, TRUE);
g_signal_handler_disconnect (color_device, handler_id);
}
static void
assert_gamma_array (uint16_t *expected,
uint16_t *values,
size_t size)
{
size_t i;
for (i = 0; i < size; i++)
{
if (expected[i] != values[i])
{
g_error ("Expected %hu at but got %hu at index %zu",
expected[i], values[i], i);
}
}
}
static void static void
meta_test_color_management_night_light_calibrated (void) meta_test_color_management_night_light_calibrated (void)
{ {