[gtk/wip/matthiasc/focus2: 82/91] focus test: check the new properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/focus2: 82/91] focus test: check the new properties
- Date: Fri, 8 Mar 2019 22:24:35 +0000 (UTC)
commit 8e6985bdc0610e055db2cb9017f4741951a6e76d
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Mar 8 09:56:17 2019 -0500
focus test: check the new properties
Test that is-focus and contains-focus have the
expected values, as focus moves around.
testsuite/gtk/focus.c | 58 ++++++++++++++++++++++++++++++++-------------------
1 file changed, 36 insertions(+), 22 deletions(-)
---
diff --git a/testsuite/gtk/focus.c b/testsuite/gtk/focus.c
index a6ffeccbad..d89004df02 100644
--- a/testsuite/gtk/focus.c
+++ b/testsuite/gtk/focus.c
@@ -25,17 +25,35 @@ detail_to_string (GdkNotifyType detail)
return g_enum_to_string (GDK_TYPE_NOTIFY_TYPE, detail);
}
+static void
+add_event (GtkEventController *controller,
+ gboolean in,
+ GdkCrossingMode mode,
+ GdkNotifyType detail,
+ GString *s)
+{
+ gboolean is_focus;
+ gboolean contains_focus;
+ GtkWidget *widget = gtk_event_controller_get_widget (controller);
+ g_object_get (controller,
+ "is-focus", &is_focus,
+ "contains-focus", &contains_focus,
+ NULL);
+ g_string_append_printf (s, "%s: %s %s %s is-focus: %d contains-focus: %d\n",
+ widget_name (widget),
+ in ? "focus-in" : "focus-out",
+ mode_to_string (mode),
+ detail_to_string (detail),
+ is_focus, contains_focus);
+}
+
static void
focus_in (GtkEventController *controller,
GdkCrossingMode mode,
GdkNotifyType detail,
GString *s)
{
- GtkWidget *widget = gtk_event_controller_get_widget (controller);
- g_string_append_printf (s, "%s: focus-in %s %s\n",
- widget_name (widget),
- mode_to_string (mode),
- detail_to_string (detail));
+ add_event (controller, TRUE, mode, detail, s);
}
static void
@@ -44,11 +62,7 @@ focus_out (GtkEventController *controller,
GdkNotifyType detail,
GString *s)
{
- GtkWidget *widget = gtk_event_controller_get_widget (controller);
- g_string_append_printf (s, "%s: focus-out %s %s\n",
- widget_name (widget),
- mode_to_string (mode),
- detail_to_string (detail));
+ add_event (controller, FALSE, mode, detail, s);
}
static void
@@ -132,8 +146,8 @@ 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\n"
-"box: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_ANCESTOR\n");
+"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: 0\n");
g_string_truncate (s, 0);
gtk_widget_grab_focus (entry1);
@@ -142,9 +156,9 @@ 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\n"
-"box1: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_VIRTUAL\n"
-"entry1: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_ANCESTOR\n");
+"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: 0\n");
g_string_truncate (s, 0);
@@ -156,10 +170,10 @@ 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\n"
-"box1: focus-out GDK_CROSSING_NORMAL GDK_NOTIFY_NONLINEAR_VIRTUAL\n"
-"box2: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_NONLINEAR_VIRTUAL\n"
-"entry2: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_NONLINEAR\n");
+"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: 0\n");
g_string_truncate (s, 0);
@@ -171,9 +185,9 @@ 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\n"
-"box2: focus-out GDK_CROSSING_NORMAL GDK_NOTIFY_VIRTUAL\n"
-"box: focus-in GDK_CROSSING_NORMAL GDK_NOTIFY_INFERIOR\n");
+"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: 0\n");
g_string_truncate (s, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]