diff options
author | Havoc Pennington <hp@redhat.com> | 2001-01-10 23:44:22 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-01-10 23:44:22 +0000 |
commit | 740ee8ef9467725b5cac7c145c4d1c5d065e8f74 (patch) | |
tree | 41d2b89f5e052b309db8950b4f5a45018bb87190 /tests/testtreeview.c | |
parent | 85267e9224f8ffec7aeafb8ccbed583d60e7bf4c (diff) | |
download | gtk+-740ee8ef9467725b5cac7c145c4d1c5d065e8f74.tar.gz |
handle case where sibling == iter (gtk_tree_store_insert_after): handle
2001-01-10 Havoc Pennington <hp@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_insert_before): handle case
where sibling == iter
(gtk_tree_store_insert_after): handle sibling == iter
(gtk_tree_store_prepend): remove stamp checks
(gtk_tree_store_insert_before): ditto
(gtk_tree_store_append): ditto
(gtk_tree_store_get_path): ditto
(gtk_tree_store_get_value): ditto
(gtk_tree_store_iter_has_child): ditto
(gtk_tree_store_iter_n_children): ditto
(gtk_tree_store_iter_nth_child): ditto
(gtk_tree_store_insert_after): ditto
(gtk_tree_store_is_ancestor): ditto
(gtk_tree_store_iter_depth): ditto
(gtk_tree_store_insert_before): assert that sibling's parent is
the same as the passed-in parent
(gtk_tree_store_insert_after): assert that sibling's parent is
the same as the passed-in parent
* gtk/gtktreemodel.c (gtk_tree_model_get_first): new convenience
function to get the first iterator in a model
* gtk/gtktreestore.c (gtk_tree_store_get_root_iter): remove,
conventionally the "root" in this sense is just NULL afaict.
* gtk/gtkliststore.c (gtk_list_store_insert_before): handle case
where sibling == iter
(gtk_list_store_insert_after): handle case where sibling == iter
* tests/testtreeview.c (run_automated_tests): fairly lame basic
automated tests for ListStore, TreeStore
* gtk/gtkliststore.c (gtk_list_store_remove): update tail pointer
(gtk_list_store_insert): update tail pointer, and fix it to work
(gtk_list_store_insert_before): update tail pointer, and fix it to work
(gtk_list_store_append): use tail to be faster
(gtk_list_store_prepend): fix it, update tail pointer
(gtk_list_store_insert_after): fix it, update tail pointer
* gtk/gtkliststore.h (struct _GtkListStore): add tail pointer for
the list
Diffstat (limited to 'tests/testtreeview.c')
-rw-r--r-- | tests/testtreeview.c | 178 |
1 files changed, 176 insertions, 2 deletions
diff --git a/tests/testtreeview.c b/tests/testtreeview.c index 3ddaf6e897..dae6baab84 100644 --- a/tests/testtreeview.c +++ b/tests/testtreeview.c @@ -1372,10 +1372,184 @@ create_prop_editor (GObject *object) */ static void +treestore_torture_recurse (GtkTreeStore *store, + GtkTreeIter *root, + gint depth) +{ + GtkTreeModel *model; + gint i; + GtkTreeIter iter; + + model = GTK_TREE_MODEL (store); + + if (depth > 2) + return; + + ++depth; + + gtk_tree_store_append (store, &iter, root); + + gtk_tree_model_iter_children (model, &iter, root); + + i = 0; + while (i < 100) + { + gtk_tree_store_append (store, &iter, root); + ++i; + } + + while (gtk_tree_model_iter_children (model, &iter, root)) + gtk_tree_store_remove (store, &iter); + + gtk_tree_store_append (store, &iter, root); + + /* inserts before last node in tree */ + i = 0; + while (i < 100) + { + gtk_tree_store_insert_before (store, &iter, root, &iter); + ++i; + } + + /* inserts after the node before the last node */ + i = 0; + while (i < 100) + { + gtk_tree_store_insert_after (store, &iter, root, &iter); + ++i; + } + + /* inserts after the last node */ + gtk_tree_store_append (store, &iter, root); + + i = 0; + while (i < 100) + { + gtk_tree_store_insert_after (store, &iter, root, &iter); + ++i; + } + + /* remove everything again */ + while (gtk_tree_model_iter_children (model, &iter, root)) + gtk_tree_store_remove (store, &iter); + + + /* Prepends */ + gtk_tree_store_prepend (store, &iter, root); + + i = 0; + while (i < 100) + { + gtk_tree_store_prepend (store, &iter, root); + ++i; + } + + /* remove everything again */ + while (gtk_tree_model_iter_children (model, &iter, root)) + gtk_tree_store_remove (store, &iter); + + gtk_tree_store_append (store, &iter, root); + gtk_tree_store_append (store, &iter, root); + gtk_tree_store_append (store, &iter, root); + gtk_tree_store_append (store, &iter, root); + + while (gtk_tree_model_iter_children (model, &iter, root)) + { + treestore_torture_recurse (store, &iter, depth); + gtk_tree_store_remove (store, &iter); + } +} + +static void run_automated_tests (void) { + g_print ("Running automated tests...\n"); + /* FIXME TreePath basic verification */ - /* FIXME consistency checks on the models */ - + /* FIXME generic consistency checks on the models */ + + { + /* Make sure list store mutations don't crash anything */ + GtkListStore *store; + GtkTreeModel *model; + gint i; + GtkTreeIter iter; + + store = gtk_list_store_new_with_types (1, G_TYPE_INT); + + model = GTK_TREE_MODEL (store); + + i = 0; + while (i < 100) + { + gtk_list_store_append (store, &iter); + ++i; + } + + while (gtk_tree_model_get_first (model, &iter)) + gtk_list_store_remove (store, &iter); + + gtk_list_store_append (store, &iter); + + /* inserts before last node in list */ + i = 0; + while (i < 100) + { + gtk_list_store_insert_before (store, &iter, &iter); + ++i; + } + + /* inserts after the node before the last node */ + i = 0; + while (i < 100) + { + gtk_list_store_insert_after (store, &iter, &iter); + ++i; + } + + /* inserts after the last node */ + gtk_list_store_append (store, &iter); + + i = 0; + while (i < 100) + { + gtk_list_store_insert_after (store, &iter, &iter); + ++i; + } + + /* remove everything again */ + while (gtk_tree_model_get_first (model, &iter)) + gtk_list_store_remove (store, &iter); + + + /* Prepends */ + gtk_list_store_prepend (store, &iter); + + i = 0; + while (i < 100) + { + gtk_list_store_prepend (store, &iter); + ++i; + } + + /* remove everything again */ + while (gtk_tree_model_get_first (model, &iter)) + gtk_list_store_remove (store, &iter); + + g_object_unref (G_OBJECT (store)); + } + + { + /* Make sure tree store mutations don't crash anything */ + GtkTreeStore *store; + + store = gtk_tree_store_new_with_types (1, G_TYPE_INT); + + treestore_torture_recurse (store, NULL, 0); + + g_object_unref (G_OBJECT (store)); + } + + g_print ("Passed.\n"); } |