summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-04-16 12:09:54 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-04-16 12:31:17 -0400
commit5095e87bb7cf0736e9afcc63665bdec7c51d00b6 (patch)
tree21e92d305f0490de40dd3d8c1e05e632dda7062a /testsuite
parent54b99d281b5aaeb40b230d18ee281b57e30d48fb (diff)
downloadgtk+-5095e87bb7cf0736e9afcc63665bdec7c51d00b6.tar.gz
testsuite: Add some checks for focus states
This is some opportunistic checking in a test that is really about focus chains, but better than nothing.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gtk/test-focus-chain.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/gtk/test-focus-chain.c b/testsuite/gtk/test-focus-chain.c
index 53fab0d5a3..5419dbc2ae 100644
--- a/testsuite/gtk/test-focus-chain.c
+++ b/testsuite/gtk/test-focus-chain.c
@@ -86,6 +86,34 @@ done:
return diff;
}
+static void
+check_focus_states (GtkWidget *focus_widget)
+{
+ GtkStateFlags state;
+ GtkWidget *parent;
+
+ if (focus_widget == NULL)
+ return;
+
+ /* Check that we set :focus and :focus-within on the focus_widget,
+ * and :focus-within on its ancestors
+ */
+
+ state = gtk_widget_get_state_flags (focus_widget);
+ g_assert_true ((state & (GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_FOCUS_WITHIN)) ==
+ (GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_FOCUS_WITHIN));
+
+ parent = gtk_widget_get_parent (focus_widget);
+ while (parent)
+ {
+ state = gtk_widget_get_state_flags (parent);
+ g_assert_true ((state & GTK_STATE_FLAG_FOCUS_WITHIN) == GTK_STATE_FLAG_FOCUS_WITHIN);
+ g_assert_true ((state & GTK_STATE_FLAG_FOCUSED) == 0);
+
+ parent = gtk_widget_get_parent (parent);
+ }
+}
+
static char *
generate_focus_chain (GtkWidget *window,
GtkDirectionType dir)
@@ -109,6 +137,8 @@ generate_focus_chain (GtkWidget *window,
focus = gtk_window_get_focus (GTK_WINDOW (window));
+ check_focus_states (focus);
+
if (focus)
{
/* ui files can't put a name on the embedded text,