Commit 6fdf882e authored by Kristian Rietveld's avatar Kristian Rietveld

Add unit test for part 1 of bug 659022

This tests a case where gtk_tree_model_filter_row_changed() is run
for a node with visible_siter != NULL, however its parent has
visible_iter == NULL. For this case, no valid paths can be generated
as the node cannot be accessed (because the parent is invisible).
parent e1f79e82
......@@ -6602,6 +6602,65 @@ specific_bug_658696 (void)
g_object_unref (filter);
}
static gboolean
specific_bug_659022_visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
GtkTreeIter tmp;
if (!gtk_tree_model_iter_parent (model, &tmp, iter))
{
if (gtk_tree_model_iter_n_children (model, iter) >= 2)
return TRUE;
else
return FALSE;
}
return TRUE;
}
static void
specific_bug_659022_row_changed_emission (void)
{
GtkTreeModel *filter;
GtkTreeModel *model;
GtkTreeModelRefCount *ref_model;
GtkTreeIter parent, child, child2;
GtkTreePath *path;
GtkWidget *tree_view;
model = gtk_tree_model_ref_count_new ();
ref_model = GTK_TREE_MODEL_REF_COUNT (model);
filter = gtk_tree_model_filter_new (model, NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
specific_bug_659022_visible_func,
NULL, NULL);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (filter));
gtk_tree_store_insert (GTK_TREE_STORE (model), &parent, NULL, 0);
gtk_tree_store_insert (GTK_TREE_STORE (model), &child, &parent, 0);
gtk_tree_store_insert (GTK_TREE_STORE (model), &child2, &parent, 0);
gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter));
gtk_tree_store_remove (GTK_TREE_STORE (model), &child2);
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter));
path = gtk_tree_model_get_path (model, &child);
gtk_tree_model_row_changed (model, path, &child);
gtk_tree_path_free (path);
gtk_widget_destroy (tree_view);
g_object_unref (filter);
g_object_unref (model);
}
/* main */
void
......@@ -6955,4 +7014,6 @@ register_filter_model_tests (void)
specific_bug_657353);
g_test_add_func ("/TreeModelFilter/specific/bug-658696",
specific_bug_658696);
g_test_add_func ("/TreeModelFilter/specific/bug-659022/row-changed-emission",
specific_bug_659022_row_changed_emission);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment