mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-26 02:48:54 +02:00
gdbus-codegen: test --interface-info-{header,body}
This test is rudimentary but better than nothing.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "gdbus-tests.h"
|
||||
|
||||
#include "gdbus-test-codegen-generated.h"
|
||||
#include "gdbus-test-codegen-generated-interface-info.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
@@ -2463,6 +2464,110 @@ test_deprecations (void)
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
assert_arg_infos_equal (GDBusArgInfo **a,
|
||||
GDBusArgInfo **b)
|
||||
{
|
||||
if (a == NULL)
|
||||
{
|
||||
g_assert_null (b);
|
||||
return;
|
||||
}
|
||||
|
||||
g_assert_nonnull (b);
|
||||
|
||||
for (; *a != NULL && *b != NULL; a++, b++)
|
||||
{
|
||||
g_assert_cmpstr ((*a)->name, ==, (*b)->name);
|
||||
g_assert_cmpstr ((*a)->signature, ==, (*b)->signature);
|
||||
}
|
||||
|
||||
g_assert_null (*a);
|
||||
g_assert_null (*b);
|
||||
}
|
||||
|
||||
static void
|
||||
assert_annotations_equal (GDBusAnnotationInfo **a,
|
||||
GDBusAnnotationInfo **b)
|
||||
{
|
||||
guint a_len = count_annotations (a);
|
||||
guint b_len = count_annotations (b);
|
||||
|
||||
g_assert_cmpuint (a_len, ==, b_len);
|
||||
|
||||
if (a == NULL || b == NULL)
|
||||
return;
|
||||
|
||||
for (; *a != NULL && *b != NULL; a++, b++)
|
||||
{
|
||||
g_assert_cmpstr ((*a)->key, ==, (*b)->key);
|
||||
g_assert_cmpstr ((*a)->value, ==, (*b)->value);
|
||||
assert_annotations_equal ((*a)->annotations, (*b)->annotations);
|
||||
}
|
||||
|
||||
g_assert_null (*a);
|
||||
g_assert_null (*b);
|
||||
}
|
||||
|
||||
/* Test that the GDBusInterfaceInfo structure generated by gdbus-codegen
|
||||
* --interface-info-body matches that generated by the other mode.
|
||||
*/
|
||||
static void
|
||||
test_standalone_interface_info (void)
|
||||
{
|
||||
GDBusInterfaceSkeleton *skel = G_DBUS_INTERFACE_SKELETON (foo_igen_bar_skeleton_new ());
|
||||
GDBusInterfaceInfo *skel_info = g_dbus_interface_skeleton_get_info (skel);
|
||||
const GDBusInterfaceInfo *slim_info = &org_project_bar_interface;
|
||||
gsize i;
|
||||
|
||||
g_assert_cmpstr (skel_info->name, ==, slim_info->name);
|
||||
|
||||
for (i = 0; skel_info->methods[i] != NULL; i++)
|
||||
{
|
||||
GDBusMethodInfo *skel_method = skel_info->methods[i];
|
||||
GDBusMethodInfo *slim_method = slim_info->methods[i];
|
||||
|
||||
g_assert_nonnull (slim_method);
|
||||
g_assert_cmpstr (skel_method->name, ==, slim_method->name);
|
||||
assert_arg_infos_equal (skel_method->in_args, slim_method->in_args);
|
||||
assert_arg_infos_equal (skel_method->out_args, slim_method->out_args);
|
||||
assert_annotations_equal (skel_method->annotations, slim_method->annotations);
|
||||
}
|
||||
g_assert_null (slim_info->methods[i]);
|
||||
|
||||
for (i = 0; skel_info->signals[i] != NULL; i++)
|
||||
{
|
||||
GDBusSignalInfo *skel_signal = skel_info->signals[i];
|
||||
GDBusSignalInfo *slim_signal = slim_info->signals[i];
|
||||
|
||||
g_assert_nonnull (slim_signal);
|
||||
g_assert_cmpstr (skel_signal->name, ==, slim_signal->name);
|
||||
assert_arg_infos_equal (skel_signal->args, slim_signal->args);
|
||||
assert_annotations_equal (skel_signal->annotations, slim_signal->annotations);
|
||||
}
|
||||
g_assert_null (slim_info->signals[i]);
|
||||
|
||||
for (i = 0; skel_info->properties[i] != NULL; i++)
|
||||
{
|
||||
GDBusPropertyInfo *skel_prop = skel_info->properties[i];
|
||||
GDBusPropertyInfo *slim_prop = slim_info->properties[i];
|
||||
|
||||
g_assert_nonnull (slim_prop);
|
||||
|
||||
g_assert_cmpstr (skel_prop->name, ==, slim_prop->name);
|
||||
g_assert_cmpstr (skel_prop->signature, ==, slim_prop->signature);
|
||||
g_assert_cmpuint (skel_prop->flags, ==, slim_prop->flags);
|
||||
assert_annotations_equal (skel_prop->annotations, slim_prop->annotations);
|
||||
}
|
||||
g_assert_null (slim_info->properties[i]);
|
||||
|
||||
assert_annotations_equal (skel_info->annotations, slim_info->annotations);
|
||||
|
||||
g_clear_object (&skel);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
@@ -2475,6 +2580,7 @@ main (int argc,
|
||||
g_test_add_func ("/gdbus/codegen/property-naming", test_property_naming);
|
||||
g_test_add_func ("/gdbus/codegen/autocleanups", test_autocleanups);
|
||||
g_test_add_func ("/gdbus/codegen/deprecations", test_deprecations);
|
||||
g_test_add_func ("/gdbus/codegen/standalone-interface-info", test_standalone_interface_info);
|
||||
|
||||
return session_bus_run ();
|
||||
}
|
||||
|
Reference in New Issue
Block a user