From c55aa7e590c37b1e239dd793e2fc3027962ebe1c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 8 May 2020 22:39:51 -0400 Subject: [PATCH] testsuite: Redo listbox sort test This test was relying on gtk_container_forall returning the visual (ie sorted) order of children, while iterating with the widget dom api gives the insertion order. Instead of using gtk_container_forall, use gtk_list_box_row_get_index to reconstruct the visual order. --- testsuite/gtk/listbox.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/testsuite/gtk/listbox.c b/testsuite/gtk/listbox.c index c36c855faa..0c646bd5d3 100644 --- a/testsuite/gtk/listbox.c +++ b/testsuite/gtk/listbox.c @@ -24,18 +24,22 @@ static void check_sorted (GtkListBox *list) { GtkWidget *row, *label; - gint n1, n2; + int res[100]; + int index, value; + int i; - n2 = n1 = 0; for (row = gtk_widget_get_first_child (GTK_WIDGET (list)); row != NULL; row = gtk_widget_get_next_sibling (row)) { - n1 = n2; + index = gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (row)); label = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row)); - n2 = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), "data")); - g_assert_cmpint (n1, <=, n2); + value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), "data")); + res[index] = value; } + + for (i = 1; i < 100; i++) + g_assert (res[i - 1] <= res[i]); } static void