[gtk/readonly-events-1: 35/35] Update the focus test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/readonly-events-1: 35/35] Update the focus test
- Date: Tue, 18 Feb 2020 05:25:29 +0000 (UTC)
commit c2bf0b8330cb24cbdeb22c8634b731fa3cd741b5
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Feb 18 00:12:59 2020 -0500
Update the focus test
This needs an update to handle the new focus-change signal.
testsuite/gtk/focus.c | 81 ++++++++++++++++++++-------------------------------
1 file changed, 32 insertions(+), 49 deletions(-)
---
diff --git a/testsuite/gtk/focus.c b/testsuite/gtk/focus.c
index 584a2c557e..ac6d43fd7b 100644
--- a/testsuite/gtk/focus.c
+++ b/testsuite/gtk/focus.c
@@ -13,46 +13,16 @@ widget_name (GtkWidget *widget)
return G_OBJECT_TYPE_NAME (widget);
}
-static char *
-mode_to_string (GdkCrossingMode mode)
-{
- return g_enum_to_string (GDK_TYPE_CROSSING_MODE, mode);
-}
-
-static char *
-detail_to_string (GdkNotifyType detail)
-{
- return g_enum_to_string (GDK_TYPE_NOTIFY_TYPE, detail);
-}
-
-static void
-focus_in (GtkEventControllerKey *key,
- GdkCrossingMode mode,
- GdkNotifyType detail,
- GString *s)
-{
- GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (key));
-
- g_string_append_printf (s, "%s: focus-in %s %s is-focus: %d contains-focus: %d\n",
- widget_name (widget),
- mode_to_string (mode),
- detail_to_string (detail),
- gtk_event_controller_key_is_focus (key),
- gtk_event_controller_key_contains_focus (key));
-}
-
static void
-focus_out (GtkEventControllerKey *key,
- GdkCrossingMode mode,
- GdkNotifyType detail,
- GString *s)
+focus_change (GtkEventControllerKey *key,
+ GtkCrossingDirection direction,
+ GString *s)
{
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (key));
- g_string_append_printf (s, "%s: focus-out %s %s is-focus: %d contains-focus: %d\n",
+ g_string_append_printf (s, "%s: focus-change %s is-focus: %d contains-focus: %d\n",
widget_name (widget),
- mode_to_string (mode),
- detail_to_string (detail),
+ direction == GTK_CROSSING_IN ? "in" : "out",
gtk_event_controller_key_is_focus (key),
gtk_event_controller_key_contains_focus (key));
}
@@ -63,8 +33,7 @@ add_controller (GtkWidget *widget, GString *s)
GtkEventController *controller;
controller = gtk_event_controller_key_new ();
- g_signal_connect (controller, "focus-in", G_CALLBACK (focus_in), s);
- g_signal_connect (controller, "focus-out", G_CALLBACK (focus_out), s);
+ g_signal_connect (controller, "focus-change", G_CALLBACK (focus_change), s);
gtk_widget_add_controller (widget, controller);
}
@@ -138,8 +107,9 @@ test_window_focus (void)
g_print ("-> box\n%s\n", s->str);
g_assert_cmpstr (s->str, ==,
-"window: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_VIRTUAL is-focus: 0 contains-focus: 1\n"
-"box: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_ANCESTOR is-focus: 1 contains-focus: 1\n");
+"window: focus-change in is-focus: 0 contains-focus: 1\n"
+"box: focus-change in is-focus: 1 contains-focus: 1\n"
+ );
g_string_truncate (s, 0);
gtk_widget_grab_focus (entry1);
@@ -148,9 +118,13 @@ test_window_focus (void)
g_print ("box -> entry1\n%s\n", s->str);
g_assert_cmpstr (s->str, ==,
-"box: focus-out GDK_CROSSING_NORMAL GDK_NOTIFY_INFERIOR is-focus: 0 contains-focus: 1\n"
-"box1: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_VIRTUAL is-focus: 0 contains-focus: 1\n"
-"entry1: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_ANCESTOR is-focus: 1 contains-focus: 1\n");
+"box: focus-change out is-focus: 0 contains-focus: 0\n"
+"window: focus-change out is-focus: 0 contains-focus: 0\n"
+"window: focus-change in is-focus: 0 contains-focus: 1\n"
+"box: focus-change in is-focus: 0 contains-focus: 1\n"
+"box1: focus-change in is-focus: 0 contains-focus: 1\n"
+"entry1: focus-change in is-focus: 1 contains-focus: 1\n"
+ );
g_string_truncate (s, 0);
@@ -162,10 +136,15 @@ test_window_focus (void)
g_print ("entry1 -> entry2\n%s\n", s->str);
g_assert_cmpstr (s->str, ==,
-"entry1: focus-out GDK_CROSSING_NORMAL GDK_NOTIFY_NONLINEAR is-focus: 0 contains-focus: 0\n"
-"box1: focus-out GDK_CROSSING_NORMAL GDK_NOTIFY_NONLINEAR_VIRTUAL is-focus: 0 contains-focus: 0\n"
-"box2: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_NONLINEAR_VIRTUAL is-focus: 0 contains-focus: 1\n"
-"entry2: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_NONLINEAR is-focus: 1 contains-focus: 1\n");
+"entry1: focus-change out is-focus: 0 contains-focus: 0\n"
+"box1: focus-change out is-focus: 0 contains-focus: 0\n"
+"box: focus-change out is-focus: 0 contains-focus: 0\n"
+"window: focus-change out is-focus: 0 contains-focus: 0\n"
+"window: focus-change in is-focus: 0 contains-focus: 1\n"
+"box: focus-change in is-focus: 0 contains-focus: 1\n"
+"box2: focus-change in is-focus: 0 contains-focus: 1\n"
+"entry2: focus-change in is-focus: 1 contains-focus: 1\n"
+ );
g_string_truncate (s, 0);
@@ -177,9 +156,13 @@ test_window_focus (void)
g_print ("entry2 -> box\n%s", s->str);
g_assert_cmpstr (s->str, ==,
-"entry2: focus-out GDK_CROSSING_NORMAL GDK_NOTIFY_ANCESTOR is-focus: 0 contains-focus: 0\n"
-"box2: focus-out GDK_CROSSING_NORMAL GDK_NOTIFY_VIRTUAL is-focus: 0 contains-focus: 0\n"
-"box: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_INFERIOR is-focus: 1 contains-focus: 1\n");
+"entry2: focus-change out is-focus: 0 contains-focus: 0\n"
+"box2: focus-change out is-focus: 0 contains-focus: 0\n"
+"box: focus-change out is-focus: 0 contains-focus: 0\n"
+"window: focus-change out is-focus: 0 contains-focus: 0\n"
+"window: focus-change in is-focus: 0 contains-focus: 1\n"
+"box: focus-change in is-focus: 1 contains-focus: 1\n"
+ );
g_string_truncate (s, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]