[gtk] Add a test for action introspection
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Add a test for action introspection
- Date: Sat, 22 Jun 2019 23:32:41 +0000 (UTC)
commit 135580108a78512d7a998d5340bb4b21a7fa6bec
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 22 23:11:49 2019 +0000
Add a test for action introspection
This checks that gtk_widget_query_action works.
testsuite/gtk/action.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
---
diff --git a/testsuite/gtk/action.c b/testsuite/gtk/action.c
index 81be2464b8..6c3b457534 100644
--- a/testsuite/gtk/action.c
+++ b/testsuite/gtk/action.c
@@ -246,6 +246,54 @@ test_overlap (void)
g_object_unref (box_actions);
}
+/* Test that gtk_widget_class_query_action
+ * yields the expected results
+ */
+static void
+test_introspection (void)
+{
+ GtkWidgetClass *class = g_type_class_ref (GTK_TYPE_TEXT);
+ guint i;
+ GType owner;
+ const char *name;
+ const GVariantType *params;
+ const char *property;
+ struct {
+ GType owner;
+ const char *name;
+ const char *params;
+ const char *property;
+ } expected[] = {
+ { GTK_TYPE_TEXT, "clipboard.cut", NULL, NULL },
+ { GTK_TYPE_TEXT, "clipboard.copy", NULL, NULL },
+ { GTK_TYPE_TEXT, "clipboard.paste", NULL, NULL },
+ { GTK_TYPE_TEXT, "selection.delete", NULL, NULL },
+ { GTK_TYPE_TEXT, "selection.select-all", NULL, NULL },
+ { GTK_TYPE_TEXT, "misc.insert-emoji", NULL, NULL },
+ { GTK_TYPE_TEXT, "misc.toggle-visibility", NULL, "visibility" },
+ };
+
+ i = 0;
+ while (gtk_widget_class_query_action (class,
+ i,
+ &owner,
+ &name,
+ ¶ms,
+ &property))
+ {
+ g_assert (expected[i].owner == owner);
+ g_assert (strcmp (expected[i].name, name) == 0);
+ g_assert ((expected[i].params == NULL && params == NULL) ||
+ strcmp (expected[i].params, g_variant_type_peek_string (params)) == 0);
+ g_assert ((expected[i].property == NULL && property == NULL) ||
+ strcmp (expected[i].property, property) == 0);
+ i++;
+ }
+ g_assert (i == G_N_ELEMENTS (expected));
+
+ g_type_class_unref (class);
+}
+
int
main (int argc,
char *argv[])
@@ -255,6 +303,7 @@ main (int argc,
g_test_add_func ("/action/inheritance", test_action);
g_test_add_func ("/action/text", test_text);
g_test_add_func ("/action/overlap", test_overlap);
+ g_test_add_func ("/action/introspection", test_introspection);
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]