[gtk/kill-containers: 23/43] testsuite: Redo listbox sort test



commit 0712a77e8b43328142e44d3716c2a94f42e51558
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 8 22:39:51 2020 -0400

    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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]