[gtk/wip/matthiasc/shortcut-4: 57/85] Add tests for shortcut actions
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/shortcut-4: 57/85] Add tests for shortcut actions
- Date: Thu, 26 Mar 2020 03:20:40 +0000 (UTC)
commit cb821d5df350ffa73507883cc483239e73cde99b
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Mar 19 23:58:59 2020 -0400
Add tests for shortcut actions
testsuite/gtk/shortcuts.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
---
diff --git a/testsuite/gtk/shortcuts.c b/testsuite/gtk/shortcuts.c
index 846e4cd0e4..757b2803e4 100644
--- a/testsuite/gtk/shortcuts.c
+++ b/testsuite/gtk/shortcuts.c
@@ -245,6 +245,71 @@ test_trigger_trigger (void)
gtk_shortcut_trigger_unref (trigger4);
}
+static int callback_count;
+
+static gboolean
+callback (GtkWidget *widget,
+ GVariant *args,
+ gpointer user_data)
+{
+ callback_count++;
+ return TRUE;
+}
+
+static void
+test_action_basic (void)
+{
+ GtkShortcutAction *action;
+
+ action = gtk_nothing_action_new ();
+ g_assert_cmpint (gtk_shortcut_action_get_action_type (action), ==, GTK_SHORTCUT_ACTION_NOTHING);
+ gtk_shortcut_action_unref (action);
+
+ action = gtk_callback_action_new (callback, NULL, NULL);
+ g_assert_cmpint (gtk_shortcut_action_get_action_type (action), ==, GTK_SHORTCUT_ACTION_CALLBACK);
+ gtk_shortcut_action_unref (action);
+
+ action = gtk_mnemonic_action_new ();
+ g_assert_cmpint (gtk_shortcut_action_get_action_type (action), ==, GTK_SHORTCUT_ACTION_MNEMONIC);
+ gtk_shortcut_action_unref (action);
+
+ action = gtk_activate_action_new ();
+ g_assert_cmpint (gtk_shortcut_action_get_action_type (action), ==, GTK_SHORTCUT_ACTION_ACTIVATE);
+ gtk_shortcut_action_unref (action);
+
+ action = gtk_signal_action_new ("activate");
+ g_assert_cmpint (gtk_shortcut_action_get_action_type (action), ==, GTK_SHORTCUT_ACTION_SIGNAL);
+ g_assert_cmpstr (gtk_signal_action_get_signal_name (action), ==, "activate");
+ gtk_shortcut_action_unref (action);
+
+ action = gtk_action_action_new ("text.undo");
+ g_assert_cmpint (gtk_shortcut_action_get_action_type (action), ==, GTK_SHORTCUT_ACTION_ACTION);
+ g_assert_cmpstr (gtk_action_action_get_name (action), ==, "text.undo");
+ gtk_shortcut_action_unref (action);
+}
+
+static void
+test_action_activate (void)
+{
+ GtkShortcutAction *action;
+ GtkWidget *widget;
+
+ widget = gtk_label_new ("");
+ g_object_ref_sink (widget);
+
+ action = gtk_nothing_action_new ();
+ g_assert_cmpint (gtk_shortcut_action_activate (action, 0, widget, NULL), ==, FALSE);
+ gtk_shortcut_action_unref (action);
+
+ callback_count = 0;
+ action = gtk_callback_action_new (callback, NULL, NULL);
+ g_assert_cmpint (gtk_shortcut_action_activate (action, 0, widget , NULL), ==, TRUE);
+ g_assert_cmpint (callback_count, ==, 1);
+ gtk_shortcut_action_unref (action);
+
+ g_object_unref (widget);
+}
+
int
main (int argc, char *argv[])
{
@@ -254,6 +319,8 @@ main (int argc, char *argv[])
g_test_add_func ("/shortcuts/trigger/equal", test_trigger_equal);
g_test_add_func ("/shortcuts/trigger/parse", test_trigger_parse);
g_test_add_func ("/shortcuts/trigger/trigger", test_trigger_trigger);
+ g_test_add_func ("/shortcuts/action/basic", test_action_basic);
+ g_test_add_func ("/shortcuts/action/activate", test_action_activate);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]