tests/wayland: Make test driver properties table multi typed
Store values as GVariant's. This will allow to add other types property types than strings. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
This commit is contained in:
parent
29850b7345
commit
a0877dc071
@ -329,7 +329,23 @@ bind_test_driver (struct wl_client *client,
|
||||
|
||||
g_hash_table_iter_init (&iter, test_driver->properties);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
test_driver_send_property (resource, key, value);
|
||||
{
|
||||
GVariant *variant = value;
|
||||
|
||||
if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
|
||||
{
|
||||
test_driver_send_property (resource,
|
||||
key,
|
||||
g_variant_get_string (variant, NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_autofree char *variant_string = NULL;
|
||||
|
||||
variant_string = g_variant_print (variant, TRUE);
|
||||
g_warning ("Unhandled test driver variant '%s'", variant_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -375,7 +391,8 @@ static void
|
||||
meta_wayland_test_driver_init (MetaWaylandTestDriver *test_driver)
|
||||
{
|
||||
test_driver->properties = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_free);
|
||||
g_free,
|
||||
(GDestroyNotify) g_variant_unref);
|
||||
}
|
||||
|
||||
MetaWaylandTestDriver *
|
||||
@ -416,7 +433,7 @@ meta_wayland_test_driver_set_property (MetaWaylandTestDriver *test_driver,
|
||||
{
|
||||
g_hash_table_replace (test_driver->properties,
|
||||
g_strdup (name),
|
||||
g_strdup (value));
|
||||
g_variant_new_string (value));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -198,7 +198,7 @@ create_gbm_device (WaylandDisplay *display)
|
||||
const char *gpu_path;
|
||||
int fd;
|
||||
|
||||
gpu_path = lookup_property_value (display, "gpu-path");
|
||||
gpu_path = lookup_property_string (display, "gpu-path");
|
||||
if (!gpu_path)
|
||||
return NULL;
|
||||
|
||||
@ -244,7 +244,7 @@ test_driver_handle_property (void *user_data,
|
||||
|
||||
g_hash_table_replace (display->properties,
|
||||
g_strdup (name),
|
||||
g_strdup (value));
|
||||
g_variant_new_string (value));
|
||||
}
|
||||
|
||||
static const struct test_driver_listener test_driver_listener = {
|
||||
@ -411,7 +411,8 @@ wayland_display_new_full (WaylandDisplayCapabilities capabilities,
|
||||
|
||||
display->capabilities = capabilities;
|
||||
display->properties = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_free);
|
||||
g_free,
|
||||
(GDestroyNotify) g_variant_unref);
|
||||
display->formats = g_hash_table_new_full (NULL, NULL, NULL, g_free);
|
||||
|
||||
display->display = wayland_display;
|
||||
@ -689,10 +690,19 @@ wayland_surface_set_opaque (WaylandSurface *surface)
|
||||
}
|
||||
|
||||
const char *
|
||||
lookup_property_value (WaylandDisplay *display,
|
||||
const char *name)
|
||||
lookup_property_string (WaylandDisplay *display,
|
||||
const char *name)
|
||||
{
|
||||
return g_hash_table_lookup (display->properties, name);
|
||||
GVariant *variant;
|
||||
const char *value;
|
||||
|
||||
variant = g_hash_table_lookup (display->properties, name);
|
||||
if (!variant)
|
||||
return NULL;
|
||||
|
||||
g_variant_get (variant, "&s", &value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -124,8 +124,8 @@ void draw_surface (WaylandDisplay *display,
|
||||
int height,
|
||||
uint32_t color);
|
||||
|
||||
const char * lookup_property_value (WaylandDisplay *display,
|
||||
const char *name);
|
||||
const char * lookup_property_string (WaylandDisplay *display,
|
||||
const char *name);
|
||||
|
||||
void wait_for_effects_completed (WaylandDisplay *display,
|
||||
struct wl_surface *surface);
|
||||
|
Loading…
x
Reference in New Issue
Block a user