summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martinpitt@gnome.org>2013-02-27 12:14:16 +0100
committerMartin Pitt <martinpitt@gnome.org>2013-02-27 14:49:12 +0100
commit2af5386d6cc1deba21f03c398c6368a9de6ed4ba (patch)
treeb4a3125e059de2473c7dbdeeb3589798050a350c
parentde6946c8a4ced56f7a24078b0d1aeacdb77e7f14 (diff)
downloadgobject-introspection-2af5386d6cc1deba21f03c398c6368a9de6ed4ba.tar.gz
Add test case for signal with a C array and length argument
By-product of https://bugzilla.gnome.org/show_bug.cgi?id=662241.
-rw-r--r--tests/repository/gitypelibtest.c43
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.TestObj-sig-with-array-len-prop.page44
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-sig-with-array-len-prop.page39
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-sig-with-array-len-prop.page49
-rw-r--r--tests/scanner/Regress-1.0-expected.gir18
-rw-r--r--tests/scanner/regress.c22
6 files changed, 215 insertions, 0 deletions
diff --git a/tests/repository/gitypelibtest.c b/tests/repository/gitypelibtest.c
index 54fe5234..e078699a 100644
--- a/tests/repository/gitypelibtest.c
+++ b/tests/repository/gitypelibtest.c
@@ -232,6 +232,48 @@ test_char_types (GIRepository *repo)
g_base_info_unref (prop_obj);
}
+static void
+test_signal_array_len (GIRepository *repo)
+{
+ GIObjectInfo *testobj_info;
+ GISignalInfo *sig_info;
+ GIArgInfo arg_info;
+ GITypeInfo type_info;
+ int i;
+
+ g_assert (g_irepository_require (repo, "Regress", NULL, 0, NULL));
+ testobj_info = g_irepository_find_by_name (repo, "Regress", "TestObj");
+ g_assert (testobj_info != NULL);
+
+ /* find sig-with-array-len-prop signal */
+ for (i = g_object_info_get_n_signals (testobj_info) - 1; i >= 0; --i) {
+ sig_info = g_object_info_get_signal (testobj_info, i);
+ g_assert (sig_info != NULL);
+ if (strcmp (g_base_info_get_name (sig_info), "sig-with-array-len-prop") == 0)
+ break;
+ g_base_info_unref (sig_info);
+ }
+ g_assert (i >= 0);
+
+ g_assert_cmpint (g_callable_info_get_n_args (sig_info), ==, 2);
+
+ /* verify array argument */
+ g_callable_info_load_arg (sig_info, 0, &arg_info);
+ g_assert_cmpstr (g_base_info_get_name (&arg_info), ==, "arr");
+ g_arg_info_load_type (&arg_info, &type_info);
+ g_assert_cmpint (g_type_info_get_tag (&type_info), ==, GI_TYPE_TAG_ARRAY);
+ g_assert_cmpint (g_type_info_get_array_type (&type_info), ==, GI_ARRAY_TYPE_C);
+ g_assert (!g_type_info_is_zero_terminated (&type_info));
+ g_assert_cmpint (g_type_info_get_array_length (&type_info), ==, 1);
+
+ /* verify array length argument */
+ g_callable_info_load_arg (sig_info, 1, &arg_info);
+ g_assert_cmpstr (g_base_info_get_name (&arg_info), ==, "len");
+
+ g_base_info_unref (sig_info);
+ g_base_info_unref (testobj_info);
+}
+
int
main(int argc, char **argv)
{
@@ -247,6 +289,7 @@ main(int argc, char **argv)
test_fundamental_get_ref_function_pointer (repo);
test_hash_with_cairo_typelib (repo);
test_char_types (repo);
+ test_signal_array_len (repo);
exit(0);
}
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-sig-with-array-len-prop.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-sig-with-array-len-prop.page
new file mode 100644
index 00000000..9ec983b1
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-sig-with-array-len-prop.page
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-sig-with-array-len-prop"
+ type="topic"
+ style="signal"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+
+ <link xref="Regress.TestObj" group="signal" type="guide"/>
+ <title type="link" role="topic">sig-with-array-len-prop</title>
+
+ </info>
+ <title>Regress.TestObj::sig-with-array-len-prop</title>
+
+<synopsis><code mime="text/x-csrc">
+void sig-with-array-len-prop (guint* arr,
+ gint len);
+</code></synopsis>
+
+
+ <p>This test signal similar to GSettings::change-event</p>
+
+
+
+
+<terms>
+<item>
+<title><code>arr</code></title>
+<p>numbers, or <code>NULL</code></p>
+</item>
+<item>
+<title><code>len</code></title>
+<p>length of <code>arr</code>, or 0</p>
+</item>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-sig-with-array-len-prop.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-sig-with-array-len-prop.page
new file mode 100644
index 00000000..c359b137
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-sig-with-array-len-prop.page
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-sig-with-array-len-prop"
+ type="topic"
+ style="signal"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+
+ <link xref="Regress.TestObj" group="signal" type="guide"/>
+ <title type="link" role="topic">sig-with-array-len-prop</title>
+
+ </info>
+ <title>Regress.TestObj::sig-with-array-len-prop</title>
+
+<synopsis><code mime="text/x-python">
+function callback(test_obj, arr:[Number], ):void;
+</code></synopsis>
+
+
+ <p>This test signal similar to GSettings::change-event</p>
+
+
+
+
+<terms>
+<item>
+<title><code>test_obj</code></title>
+<p>instance of <link xref="Regress.TestObj"/> that is emitting the signal</p>
+</item>
+<item>
+<title><code>arr</code></title>
+<p>numbers, or <code>null</code></p>
+</item>
+</terms>
+
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-sig-with-array-len-prop.page b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-sig-with-array-len-prop.page
new file mode 100644
index 00000000..a228de1f
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-sig-with-array-len-prop.page
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-sig-with-array-len-prop"
+ type="topic"
+ style="signal"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+
+ <link xref="Regress.TestObj" group="signal" type="guide"/>
+ <title type="link" role="topic">sig-with-array-len-prop</title>
+
+ </info>
+ <title>Regress.TestObj::sig-with-array-len-prop</title>
+
+<synopsis><code mime="text/x-python">
+def callback(test_obj, arr, len, user_param1, ...)
+</code></synopsis>
+
+
+ <p>This test signal similar to GSettings::change-event</p>
+
+
+
+
+<terms>
+<item>
+<title><code>test_obj</code></title>
+<p>instance of <link xref="Regress.TestObj"/> that is emitting the signal</p>
+</item>
+<item>
+<title><code>arr</code></title>
+<p>numbers, or <code>None</code></p>
+</item>
+<item>
+<title><code>len</code></title>
+<p>length of <code>arr</code>, or 0</p>
+</item>
+<title><code>user_param1</code></title>
+<p>first user parameter (if any) specified with the connect() method</p>
+<item>
+<title><code>...</code></title>
+<p>additional user parameters (if any)</p>
+</item>
+</terms>
+
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 35c7c694..53773cae 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -3331,6 +3331,24 @@ raise an error.</doc>
<type name="none" c:type="void"/>
</return-value>
</glib:signal>
+ <glib:signal name="sig-with-array-len-prop" when="last">
+ <doc xml:whitespace="preserve">This test signal similar to GSettings::change-event</doc>
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="arr" transfer-ownership="none" allow-none="1">
+ <doc xml:whitespace="preserve">numbers, or %NULL</doc>
+ <array length="1" zero-terminated="0" c:type="gpointer">
+ <type name="guint"/>
+ </array>
+ </parameter>
+ <parameter name="len" transfer-ownership="none">
+ <doc xml:whitespace="preserve">length of @arr, or 0</doc>
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ </parameters>
+ </glib:signal>
<glib:signal name="sig-with-array-prop" when="last">
<doc xml:whitespace="preserve">This test signal is like TelepathyGlib's
TpChannel:: group-members-changed-detailed:</doc>
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index b5fc8585..f54c2f91 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -2173,6 +2173,7 @@ regress_test_obj_default_matrix (RegressTestObj *obj, const char *somestr)
enum {
REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_PROP,
+ REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_LEN_PROP,
REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_HASH_PROP,
REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_STRV,
REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_OBJ,
@@ -2241,6 +2242,27 @@ regress_test_obj_class_init (RegressTestObjClass *klass)
G_TYPE_ARRAY);
/**
+ * RegressTestObj::sig-with-array-len-prop:
+ * @self: an object
+ * @arr: (array length=len) (element-type uint) (allow-none): numbers, or %NULL
+ * @len: length of @arr, or 0
+ *
+ * This test signal similar to GSettings::change-event
+ */
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_LEN_PROP] =
+ g_signal_new ("sig-with-array-len-prop",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_INT);
+
+ /**
* RegressTestObj::sig-with-hash-prop:
* @self: an object
* @hash: (element-type utf8 GObject.Value):