[gtk+] tests: Add select/unselect calls
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] tests: Add select/unselect calls
- Date: Sat, 10 Dec 2011 07:01:41 +0000 (UTC)
commit ef4c4b7836e90f36c6d7fcef8e5e67b6dfab1d66
Author: Benjamin Otte <otte redhat com>
Date: Sat Dec 10 06:24:40 2011 +0100
tests: Add select/unselect calls
tests/testtreechanging.c | 51 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 46 insertions(+), 5 deletions(-)
---
diff --git a/tests/testtreechanging.c b/tests/testtreechanging.c
index bd688ff..f8b90ff 100644
--- a/tests/testtreechanging.c
+++ b/tests/testtreechanging.c
@@ -110,28 +110,43 @@ tree_model_iter_step (GtkTreeModel *model,
return FALSE;
}
+/* NB: may include invisible iters (because they are collapsed) */
static void
-delete (GtkTreeView *treeview)
+tree_view_random_iter (GtkTreeView *treeview,
+ GtkTreeIter *iter)
{
guint n_rows = get_rows (treeview);
guint i = g_random_int_range (0, n_rows);
GtkTreeModel *model;
- GtkTreeIter iter;
model = gtk_tree_view_get_model (treeview);
- if (!gtk_tree_model_get_iter_first (model, &iter))
+ if (!gtk_tree_model_get_iter_first (model, iter))
return;
while (i-- > 0)
{
- if (!tree_model_iter_step (model, &iter))
+ if (!tree_model_iter_step (model, iter))
{
g_assert_not_reached ();
return;
}
}
+ return;
+}
+
+static void
+delete (GtkTreeView *treeview)
+{
+ guint n_rows = get_rows (treeview);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_tree_view_get_model (treeview);
+
+ tree_view_random_iter (treeview, &iter);
+
n_rows -= count_children (model, &iter) + 1;
log_operation (model, &iter, "remove");
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
@@ -249,6 +264,30 @@ collapse (GtkTreeView *treeview)
}
}
+static void
+select_ (GtkTreeView *treeview)
+{
+ GtkTreeIter iter;
+
+ tree_view_random_iter (treeview, &iter);
+
+ log_operation (gtk_tree_view_get_model (treeview), &iter, "select");
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection (treeview),
+ &iter);
+}
+
+static void
+unselect (GtkTreeView *treeview)
+{
+ GtkTreeIter iter;
+
+ tree_view_random_iter (treeview, &iter);
+
+ log_operation (gtk_tree_view_get_model (treeview), &iter, "unselect");
+ gtk_tree_selection_unselect_iter (gtk_tree_view_get_selection (treeview),
+ &iter);
+}
+
/* sanity checks */
static void
@@ -322,7 +361,9 @@ dance (gpointer treeview)
add_or_delete,
add_or_delete,
expand,
- collapse
+ collapse,
+ select_,
+ unselect
};
guint i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]