mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-23 17:38:54 +02:00
tests: Verify GParamSpecPool creation
Ensure that the fix in commit af024b6d7e7d3fbef23c1f7d1f7704fc90ac4fb1 works, by replicating what gobject-introspection does: - initialise the default GTypeInterface from a GType without also initialising GObjectClass - install a property for the interface - find the GParamSpec using g_object_interface_find_property()
This commit is contained in:
@@ -83,6 +83,7 @@ gobject_tests = {
|
|||||||
'binding' : {},
|
'binding' : {},
|
||||||
'bindinggroup' : {},
|
'bindinggroup' : {},
|
||||||
'properties' : {},
|
'properties' : {},
|
||||||
|
'properties-introspection' : {},
|
||||||
'reference' : {},
|
'reference' : {},
|
||||||
'flags' : {},
|
'flags' : {},
|
||||||
'value' : {},
|
'value' : {},
|
||||||
|
60
gobject/tests/properties-introspection.c
Normal file
60
gobject/tests/properties-introspection.c
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/* properties-introspection.c: Test the properties introspection API
|
||||||
|
*
|
||||||
|
* SPDX-FileCopyrightText: 2023 Emmanuele Bassi
|
||||||
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This test is isolated so we can control the initialization of
|
||||||
|
* GObjectClass, and the global GParamSpecPool
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_DECLARE_INTERFACE (MyTestable, my_testable, MY, TESTABLE, GObject)
|
||||||
|
|
||||||
|
struct _MyTestableInterface
|
||||||
|
{
|
||||||
|
GTypeInterface g_iface;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_INTERFACE (MyTestable, my_testable, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
static void
|
||||||
|
my_testable_default_init (MyTestableInterface *iface)
|
||||||
|
{
|
||||||
|
g_object_interface_install_property (iface,
|
||||||
|
g_param_spec_int ("check", NULL, NULL, -1, 10, 0, G_PARAM_READWRITE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
properties_introspection (void)
|
||||||
|
{
|
||||||
|
g_test_summary ("Verify that introspecting properties on an interface initializes the GParamSpecPool.");
|
||||||
|
|
||||||
|
if (g_test_subprocess ())
|
||||||
|
{
|
||||||
|
gpointer klass = g_type_default_interface_ref (my_testable_get_type ());
|
||||||
|
g_assert_nonnull (klass);
|
||||||
|
|
||||||
|
GParamSpec *pspec = g_object_interface_find_property (klass, "check");
|
||||||
|
g_assert_nonnull (pspec);
|
||||||
|
|
||||||
|
g_type_default_interface_unref (klass);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_test_trap_subprocess (NULL, 0, G_TEST_SUBPROCESS_DEFAULT);
|
||||||
|
g_test_trap_assert_passed ();
|
||||||
|
g_test_trap_assert_stderr ("");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
|
g_test_add_func ("/properties/introspection", properties_introspection);
|
||||||
|
|
||||||
|
return g_test_run ();
|
||||||
|
}
|
Reference in New Issue
Block a user