summaryrefslogtreecommitdiff
path: root/testsuite/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2023-04-09 04:42:12 +0200
committerBenjamin Otte <otte@redhat.com>2023-05-09 17:00:39 +0200
commit6df8eafc3a21104f17d5a0ab63e918e3b8d7c6db (patch)
treeb4872e8be9ddbb7debee356043db26985b403cf0 /testsuite/gtk
parent8e69c5c89c7601e7851bf1ae5d6e4a5d45f9a7dc (diff)
downloadgtk+-6df8eafc3a21104f17d5a0ab63e918e3b8d7c6db.tar.gz
testsuite: Add verbose output to listitemmanager test
Diffstat (limited to 'testsuite/gtk')
-rw-r--r--testsuite/gtk/listitemmanager.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/testsuite/gtk/listitemmanager.c b/testsuite/gtk/listitemmanager.c
index 38dcf8238a..7c07000bee 100644
--- a/testsuite/gtk/listitemmanager.c
+++ b/testsuite/gtk/listitemmanager.c
@@ -255,6 +255,9 @@ test_create_with_items (void)
source = create_source_model (1, 50);
selection = gtk_no_selection_new (G_LIST_MODEL (source));
gtk_list_item_manager_set_model (items, GTK_SELECTION_MODEL (selection));
+ check_list_item_manager (items, NULL, 0);
+ gtk_list_item_manager_set_model (items, GTK_SELECTION_MODEL (selection));
+ check_list_item_manager (items, NULL, 0);
g_object_unref (selection);
gtk_window_destroy (GTK_WINDOW (widget));
@@ -265,6 +268,24 @@ test_create_with_items (void)
#define N_RUNS 500
static void
+print_changes_cb (GListModel *model,
+ guint position,
+ guint removed,
+ guint added,
+ gpointer unused)
+{
+ if (!g_test_verbose ())
+ return;
+
+ if (removed == 0)
+ g_test_message ("%u/%u: adding %u items", position, g_list_model_get_n_items (model), added);
+ else if (added == 0)
+ g_test_message ("%u/%u: removing %u items", position, g_list_model_get_n_items (model), removed);
+ else
+ g_test_message ("%u/%u: removing %u and adding %u items", position, g_list_model_get_n_items (model), removed, added);
+}
+
+static void
test_exhaustive (void)
{
GtkListItemTracker *trackers[N_TRACKERS];
@@ -287,6 +308,7 @@ test_exhaustive (void)
store = g_list_store_new (G_TYPE_OBJECT);
flatten = gtk_flatten_list_model_new (G_LIST_MODEL (store));
selection = gtk_no_selection_new (G_LIST_MODEL (flatten));
+ g_signal_connect (selection, "items-changed", G_CALLBACK (print_changes_cb), NULL);
gtk_list_item_manager_set_model (items, GTK_SELECTION_MODEL (selection));
for (i = 0; i < N_RUNS; i++)
@@ -297,6 +319,8 @@ test_exhaustive (void)
switch (g_test_rand_int_range (0, 5))
{
case 0:
+ if (g_test_verbose ())
+ g_test_message ("GC and checking");
check_list_item_manager (items, trackers, N_TRACKERS);
break;
@@ -320,11 +344,16 @@ test_exhaustive (void)
n_items = g_list_model_get_n_items (G_LIST_MODEL (selection));
if (n_items > 0)
{
+ guint tracker_id = g_test_rand_int_range (0, N_TRACKERS);
+ guint pos = g_test_rand_int_range (0, n_items);
+ guint n_before = g_test_rand_int_range (0, N_WIDGETS_PER_TRACKER / 2);
+ guint n_after = g_test_rand_int_range (0, N_WIDGETS_PER_TRACKER / 2);
+ if (g_test_verbose ())
+ g_test_message ("setting tracker %u to %u -%u + %u", tracker_id, pos, n_before, n_after);
gtk_list_item_tracker_set_position (items,
- trackers [g_test_rand_int_range (0, N_TRACKERS)],
- g_test_rand_int_range (0, n_items),
- g_test_rand_int_range (0, N_WIDGETS_PER_TRACKER / 2),
- g_test_rand_int_range (0, N_WIDGETS_PER_TRACKER / 2));
+ trackers [tracker_id],
+ pos,
+ n_before, n_after);
}
break;