summaryrefslogtreecommitdiff
path: root/tests/gir
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2021-03-05 19:32:38 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2021-03-05 19:32:38 +0100
commit328faa8e402b8f4b6abbc7099929c3e1442336b2 (patch)
tree82413c1522d2e85bcba9a84f286090037bcd4d0f /tests/gir
parent8723f32a94b99cf3a87b12b576b857ea2716bf12 (diff)
downloadvala-328faa8e402b8f4b6abbc7099929c3e1442336b2.tar.gz
tests: Add more "gir" tests to increase coverage
Diffstat (limited to 'tests/gir')
-rw-r--r--tests/gir/async-creation-method.test70
-rw-r--r--tests/gir/signal-virtual.test49
2 files changed, 119 insertions, 0 deletions
diff --git a/tests/gir/async-creation-method.test b/tests/gir/async-creation-method.test
new file mode 100644
index 000000000..fccafb0b8
--- /dev/null
+++ b/tests/gir/async-creation-method.test
@@ -0,0 +1,70 @@
+GIR
+
+Input:
+
+<class name="Foo"
+ c:symbol-prefix="foo"
+ c:type="TestFoo"
+ parent="GObject.Object"
+ glib:type-name="TestFoo"
+ glib:get-type="test_foo_get_type"
+ glib:type-struct="FooClass">
+ <constructor name="new_finish"
+ c:identifier="test_foo_new_finish"
+ throws="1">
+ <return-value transfer-ownership="full">
+ <type name="Foo" c:type="TestFoo*"/>
+ </return-value>
+ <parameters>
+ <parameter name="async_result" transfer-ownership="none">
+ <type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
+ </parameter>
+ </parameters>
+ </constructor>
+ <function name="new_async"
+ c:identifier="test_foo_new_async">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="cancellable"
+ transfer-ownership="none"
+ nullable="1"
+ allow-none="1">
+ <type name="Gio.Cancellable" c:type="GCancellable*"/>
+ </parameter>
+ <parameter name="callback"
+ transfer-ownership="none"
+ nullable="1"
+ allow-none="1"
+ scope="async"
+ closure="2">
+ <type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback"/>
+ </parameter>
+ <parameter name="user_data"
+ transfer-ownership="none"
+ nullable="1"
+ allow-none="1">
+ <type name="gpointer" c:type="gpointer"/>
+ </parameter>
+ </parameters>
+ </function>
+ <field name="parent_instance">
+ <type name="GObject.Object" c:type="GObject"/>
+ </field>
+</class>
+<record name="FooClass"
+ c:type="TestFooClass"
+ glib:is-gtype-struct-for="Foo">
+ <field name="parent_class">
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
+ </field>
+</record>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public class Foo : GLib.Object {
+ [CCode (cname = "test_foo_new_async", has_construct_function = false)]
+ public async Foo (GLib.Cancellable? cancellable) throws GLib.Error;
+}
diff --git a/tests/gir/signal-virtual.test b/tests/gir/signal-virtual.test
new file mode 100644
index 000000000..b0073eddd
--- /dev/null
+++ b/tests/gir/signal-virtual.test
@@ -0,0 +1,49 @@
+GIR
+
+Input:
+
+<class name="Foo" c:type="TestFoo" glib:type-name="TestFoo" glib:get-type="test_foo_get_type" glib:type-struct="FooClass" parent="GObject.Object">
+ <virtual-method name="signal_virtual">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="self" transfer-ownership="none">
+ <type name="Foo" c:type="TestFoo*"/>
+ </instance-parameter>
+ </parameters>
+ </virtual-method>
+ <constructor name="new" c:identifier="test_foo_new">
+ <return-value transfer-ownership="full">
+ <type name="Test.Foo" c:type="TestFoo*"/>
+ </return-value>
+ </constructor>
+ <glib:signal name="signal-virtual">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ </glib:signal>
+</class>
+<record name="FooClass" c:type="TestFooClass" glib:is-gtype-struct-for="Foo">
+ <field name="signal_virtual">
+ <callback name="signal_virtual" c:type="signal_virtual">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="Test.Foo" c:type="TestFoo*"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
+</record>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public class Foo : GLib.Object {
+ [CCode (has_construct_function = false)]
+ public Foo ();
+ public virtual signal void signal_virtual ();
+}