diff options
author | Benjamin Otte <otte@redhat.com> | 2011-12-10 04:52:48 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2011-12-10 08:00:26 +0100 |
commit | 4d3986e709f46cf829e91f1382185a69f6e185c4 (patch) | |
tree | 90367128613e4a08786e46656362081433725dc4 | |
parent | 6e099a11aeb6284d83cf85324a979e4e64569b82 (diff) | |
download | gtk+-4d3986e709f46cf829e91f1382185a69f6e185c4.tar.gz |
tests: Dump the operation that is performed to stderr
-rw-r--r-- | tests/testtreechanging.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/testtreechanging.c b/tests/testtreechanging.c index 825caeb22a..943b641d8d 100644 --- a/tests/testtreechanging.c +++ b/tests/testtreechanging.c @@ -57,6 +57,33 @@ get_rows (GtkTreeView *treeview) return GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (treeview), "rows")); } +static void +log_operation_for_path (GtkTreePath *path, + const char *operation_name) +{ + char *path_string; + + path_string = gtk_tree_path_to_string (path); + + g_printerr ("%10s %s\n", operation_name, path_string); + + g_free (path_string); +} + +static void +log_operation (GtkTreeModel *model, + GtkTreeIter *iter, + const char *operation_name) +{ + GtkTreePath *path; + + path = gtk_tree_model_get_path (model, iter); + + log_operation_for_path (path, operation_name); + + gtk_tree_path_free (path); +} + /* moves iter to the next iter in the model in the display order * inside a treeview. Returns FALSE if no more rows exist. */ @@ -106,6 +133,7 @@ delete (GtkTreeView *treeview) } n_rows -= count_children (model, &iter) + 1; + log_operation (model, &iter, "remove"); gtk_tree_store_remove (GTK_TREE_STORE (model), &iter); set_rows (treeview, n_rows); } @@ -115,6 +143,7 @@ add_one (GtkTreeModel *model, GtkTreeIter *iter) { guint n = gtk_tree_model_iter_n_children (model, iter); + GtkTreeIter new_iter; static guint counter = 0; if (n > 0 && g_random_boolean ()) @@ -126,11 +155,12 @@ add_one (GtkTreeModel *model, } gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), - NULL, + &new_iter, iter, g_random_int_range (-1, n), 0, ++counter, -1); + log_operation (model, &new_iter, "add"); } static void @@ -175,6 +205,7 @@ expand (GtkTreeView *treeview) path = gtk_tree_model_get_path (model, &iter); if (!gtk_tree_view_row_expanded (treeview, path)) { + log_operation (model, &iter, "expand"); gtk_tree_view_expand_row (treeview, path, FALSE); gtk_tree_path_free (path); return; @@ -212,6 +243,7 @@ collapse (GtkTreeView *treeview) if (last) { + log_operation_for_path (last, "collapse"); gtk_tree_view_collapse_row (treeview, last); gtk_tree_path_free (last); } |