[vala/0.54] tests: Extend "access virtual signal of interface" test to increase coverage



commit ae64b23813cb768b9465d0e6e45736682986271e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Oct 18 12:23:21 2021 +0200

    tests: Extend "access virtual signal of interface" test to increase coverage

 tests/objects/bug642809.c-expected | 105 +++++++++++++++++++++++++++++++++++++
 tests/objects/bug642809.vala       |   6 +++
 2 files changed, 111 insertions(+)
---
diff --git a/tests/objects/bug642809.c-expected b/tests/objects/bug642809.c-expected
index a63c8ea22..1ca3ce361 100644
--- a/tests/objects/bug642809.c-expected
+++ b/tests/objects/bug642809.c-expected
@@ -41,6 +41,22 @@ enum  {
        BAR_NUM_PROPERTIES
 };
 static GParamSpec* bar_properties[BAR_NUM_PROPERTIES];
+
+#define TYPE_MANAM (manam_get_type ())
+#define MANAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MANAM, Manam))
+#define MANAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MANAM, ManamClass))
+#define IS_MANAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MANAM))
+#define IS_MANAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MANAM))
+#define MANAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MANAM, ManamClass))
+
+typedef struct _Manam Manam;
+typedef struct _ManamClass ManamClass;
+typedef struct _ManamPrivate ManamPrivate;
+enum  {
+       MANAM_0_PROPERTY,
+       MANAM_NUM_PROPERTIES
+};
+static GParamSpec* manam_properties[MANAM_NUM_PROPERTIES];
 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
 struct _FooIface {
@@ -57,8 +73,19 @@ struct _BarClass {
        GObjectClass parent_class;
 };
 
+struct _Manam {
+       GObject parent_instance;
+       ManamPrivate * priv;
+};
+
+struct _ManamClass {
+       GObjectClass parent_class;
+};
+
 static gpointer bar_parent_class = NULL;
 static FooIface * bar_foo_parent_iface = NULL;
+static gpointer manam_parent_class = NULL;
+static FooIface * manam_foo_parent_iface = NULL;
 
 VALA_EXTERN GType foo_get_type (void) G_GNUC_CONST ;
 static void foo_real_virtual_signal (Foo* self);
@@ -68,6 +95,13 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (Bar, g_object_unref)
 VALA_EXTERN Bar* bar_new (void);
 VALA_EXTERN Bar* bar_construct (GType object_type);
 static GType bar_get_type_once (void);
+VALA_EXTERN GType manam_get_type (void) G_GNUC_CONST ;
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (Manam, g_object_unref)
+static void manam_real_virtual_signal (Foo* base);
+VALA_EXTERN Manam* manam_new (void);
+VALA_EXTERN Manam* manam_construct (GType object_type);
+VALA_EXTERN void foo_virtual_signal (Foo* self);
+static GType manam_get_type_once (void);
 static void _vala_main (void);
 
 static void
@@ -162,14 +196,85 @@ bar_get_type (void)
        return bar_type_id__volatile;
 }
 
+static void
+manam_real_virtual_signal (Foo* base)
+{
+       Manam * self;
+       self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_MANAM, Manam);
+}
+
+Manam*
+manam_construct (GType object_type)
+{
+       Manam * self = NULL;
+       self = (Manam*) g_object_new (object_type, NULL);
+       return self;
+}
+
+Manam*
+manam_new (void)
+{
+       return manam_construct (TYPE_MANAM);
+}
+
+static void
+manam_class_init (ManamClass * klass,
+                  gpointer klass_data)
+{
+       manam_parent_class = g_type_class_peek_parent (klass);
+}
+
+static void
+manam_foo_interface_init (FooIface * iface,
+                          gpointer iface_data)
+{
+       manam_foo_parent_iface = g_type_interface_peek_parent (iface);
+       iface->virtual_signal = (void (*) (Foo*)) manam_real_virtual_signal;
+}
+
+static void
+manam_instance_init (Manam * self,
+                     gpointer klass)
+{
+}
+
+static GType
+manam_get_type_once (void)
+{
+       static const GTypeInfo g_define_type_info = { sizeof (ManamClass), (GBaseInitFunc) NULL, 
(GBaseFinalizeFunc) NULL, (GClassInitFunc) manam_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Manam), 
0, (GInstanceInitFunc) manam_instance_init, NULL };
+       static const GInterfaceInfo foo_info = { (GInterfaceInitFunc) manam_foo_interface_init, 
(GInterfaceFinalizeFunc) NULL, NULL};
+       GType manam_type_id;
+       manam_type_id = g_type_register_static (G_TYPE_OBJECT, "Manam", &g_define_type_info, 0);
+       g_type_add_interface_static (manam_type_id, TYPE_FOO, &foo_info);
+       return manam_type_id;
+}
+
+GType
+manam_get_type (void)
+{
+       static volatile gsize manam_type_id__volatile = 0;
+       if (g_once_init_enter (&manam_type_id__volatile)) {
+               GType manam_type_id;
+               manam_type_id = manam_get_type_once ();
+               g_once_init_leave (&manam_type_id__volatile, manam_type_id);
+       }
+       return manam_type_id__volatile;
+}
+
 static void
 _vala_main (void)
 {
        Bar* bar = NULL;
        Bar* _tmp0_;
+       Manam* manam = NULL;
+       Manam* _tmp1_;
        _tmp0_ = bar_new ();
        bar = _tmp0_;
        g_signal_emit (G_TYPE_CHECK_INSTANCE_CAST (bar, TYPE_FOO, Foo), 
foo_signals[FOO_VIRTUAL_SIGNAL_SIGNAL], 0);
+       _tmp1_ = manam_new ();
+       manam = _tmp1_;
+       g_signal_emit (G_TYPE_CHECK_INSTANCE_CAST (manam, TYPE_FOO, Foo), 
foo_signals[FOO_VIRTUAL_SIGNAL_SIGNAL], 0);
+       _g_object_unref0 (manam);
        _g_object_unref0 (bar);
 }
 
diff --git a/tests/objects/bug642809.vala b/tests/objects/bug642809.vala
index 91ba53e48..ca248875f 100644
--- a/tests/objects/bug642809.vala
+++ b/tests/objects/bug642809.vala
@@ -5,7 +5,13 @@ interface Foo : Object {
 class Bar : Object, Foo {
 }
 
+class Manam : Object, Foo {
+       public override void virtual_signal () { }
+}
+
 void main () {
        var bar = new Bar ();
        bar.virtual_signal ();
+       var manam = new Manam ();
+       manam.virtual_signal ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]