1 /* Extensive GtkTreeModelFilter tests.
2 * Copyright (C) 2009,2011 Kristian Rietveld <kris@gtk.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 * - Proper coverage checking to see if the unit tests cover
26 * - Verify if the ref counting is done properly for both the
27 * normal ref_count and the zero_ref_count. One way to test
28 * this area is by collapsing/expanding branches on the view
29 * that is connected to the filter model.
30 * - Check if the iterator stamp is incremented at the correct times.
38 #define LEVEL_LENGTH 5
41 create_tree_store_set_values (GtkTreeStore *store,
48 path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter);
49 path_string = gtk_tree_path_to_string (path);
51 gtk_tree_store_set (store, iter,
56 gtk_tree_path_free (path);
61 create_tree_store_recurse (int depth,
68 for (i = 0; i < LEVEL_LENGTH; i++)
72 gtk_tree_store_insert (store, &iter, parent, i);
73 create_tree_store_set_values (store, &iter, visible);
76 create_tree_store_recurse (depth - 1, store, &iter, visible);
81 create_tree_store (int depth,
86 store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
88 create_tree_store_recurse (depth, store, NULL, visible);
102 ROW_HAS_CHILD_TOGGLED,
109 signal_name_to_string (SignalName signal)
114 return "row-inserted";
117 return "row-deleted";
120 return "row-changed";
122 case ROW_HAS_CHILD_TOGGLED:
123 return "row-has-child-toggled";
126 return "rows-reordered";
145 signal_new (SignalName signal, GtkTreePath *path)
149 s = g_new0 (Signal, 1);
151 s->path = gtk_tree_path_copy (path);
157 signal_free (Signal *s)
160 gtk_tree_path_free (s->path);
169 GtkTreeModel *client;
170 gulong signal_ids[LAST_SIGNAL];
176 signal_monitor_generic_handler (SignalMonitor *m,
183 if (g_queue_is_empty (m->queue))
187 path_str = gtk_tree_path_to_string (path);
188 g_error ("Signal queue empty, got signal %s path %s\n",
189 signal_name_to_string (signal), path_str);
192 g_assert_not_reached ();
195 if (m->client != model)
197 g_error ("Model mismatch; expected %p, got %p\n",
199 g_assert_not_reached ();
202 s = g_queue_peek_tail (m->queue);
205 /* For debugging: output signals that are coming in. Leaks memory. */
206 g_print ("signal=%s path=%s\n", signal_name_to_string (signal),
207 gtk_tree_path_to_string (path));
210 if (s->signal != signal
211 || gtk_tree_path_compare (s->path, path) != 0)
213 gchar *path_str, *s_path_str;
215 s_path_str = gtk_tree_path_to_string (s->path);
216 path_str = gtk_tree_path_to_string (path);
218 g_error ("Signals don't match; expected signal %s path %s, got signal %s path %s\n",
219 signal_name_to_string (s->signal), s_path_str,
220 signal_name_to_string (signal), path_str);
225 g_assert_not_reached ();
228 s = g_queue_pop_tail (m->queue);
234 signal_monitor_row_inserted (GtkTreeModel *model,
239 signal_monitor_generic_handler (data, ROW_INSERTED,
244 signal_monitor_row_deleted (GtkTreeModel *model,
248 signal_monitor_generic_handler (data, ROW_DELETED,
253 signal_monitor_row_changed (GtkTreeModel *model,
258 signal_monitor_generic_handler (data, ROW_CHANGED,
263 signal_monitor_row_has_child_toggled (GtkTreeModel *model,
268 signal_monitor_generic_handler (data, ROW_HAS_CHILD_TOGGLED,
273 signal_monitor_rows_reordered (GtkTreeModel *model,
279 signal_monitor_generic_handler (data, ROWS_REORDERED,
283 static SignalMonitor *
284 signal_monitor_new (GtkTreeModel *client)
288 m = g_new0 (SignalMonitor, 1);
289 m->client = g_object_ref (client);
290 m->queue = g_queue_new ();
292 m->signal_ids[ROW_INSERTED] = g_signal_connect (client,
294 G_CALLBACK (signal_monitor_row_inserted),
296 m->signal_ids[ROW_DELETED] = g_signal_connect (client,
298 G_CALLBACK (signal_monitor_row_deleted),
300 m->signal_ids[ROW_CHANGED] = g_signal_connect (client,
302 G_CALLBACK (signal_monitor_row_changed),
304 m->signal_ids[ROW_HAS_CHILD_TOGGLED] = g_signal_connect (client,
305 "row-has-child-toggled",
306 G_CALLBACK (signal_monitor_row_has_child_toggled),
308 m->signal_ids[ROWS_REORDERED] = g_signal_connect (client,
310 G_CALLBACK (signal_monitor_rows_reordered),
317 signal_monitor_free (SignalMonitor *m)
321 for (i = 0; i < LAST_SIGNAL; i++)
322 g_signal_handler_disconnect (m->client, m->signal_ids[i]);
324 g_object_unref (m->client);
327 g_queue_free (m->queue);
333 signal_monitor_assert_is_empty (SignalMonitor *m)
335 g_assert (g_queue_is_empty (m->queue));
339 signal_monitor_append_signal_path (SignalMonitor *m,
345 s = signal_new (signal, path);
346 g_queue_push_head (m->queue, s);
350 signal_monitor_append_signal (SignalMonitor *m,
352 const gchar *path_string)
357 path = gtk_tree_path_new_from_string (path_string);
359 s = signal_new (signal, path);
360 g_queue_push_head (m->queue, s);
362 gtk_tree_path_free (path);
371 GtkWidget *tree_view;
374 GtkTreeModelFilter *filter;
376 SignalMonitor *monitor;
378 guint block_signals : 1;
383 filter_test_store_signal (FilterTest *fixture)
385 if (fixture->block_signals)
386 g_signal_stop_emission_by_name (fixture->store, "row-changed");
391 filter_test_setup_generic (FilterTest *fixture,
392 gconstpointer test_data,
397 const GtkTreePath *vroot = test_data;
398 GtkTreeModel *filter;
400 fixture->store = create_tree_store (depth, !empty);
402 g_signal_connect_swapped (fixture->store, "row-changed",
403 G_CALLBACK (filter_test_store_signal), fixture);
405 /* Please forgive me for casting const away. */
406 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (fixture->store),
407 (GtkTreePath *)vroot);
408 fixture->filter = GTK_TREE_MODEL_FILTER (filter);
411 gtk_tree_model_filter_set_visible_column (fixture->filter, 1);
413 /* We need a tree view that's listening to get ref counting from that
416 fixture->tree_view = gtk_tree_view_new_with_model (filter);
418 fixture->monitor = signal_monitor_new (filter);
422 filter_test_setup_expand_root (FilterTest *fixture)
427 path = gtk_tree_path_new_from_indices (0, -1);
429 for (i = 0; i < LEVEL_LENGTH; i++)
431 gtk_tree_view_expand_row (GTK_TREE_VIEW (fixture->tree_view),
433 gtk_tree_path_next (path);
435 gtk_tree_path_free (path);
439 filter_test_setup (FilterTest *fixture,
440 gconstpointer test_data)
442 filter_test_setup_generic (fixture, test_data, 3, FALSE, FALSE);
446 filter_test_setup_empty (FilterTest *fixture,
447 gconstpointer test_data)
449 filter_test_setup_generic (fixture, test_data, 3, TRUE, FALSE);
453 filter_test_setup_unfiltered (FilterTest *fixture,
454 gconstpointer test_data)
456 filter_test_setup_generic (fixture, test_data, 3, FALSE, TRUE);
460 filter_test_setup_unfiltered_root_expanded (FilterTest *fixture,
461 gconstpointer test_data)
463 filter_test_setup_unfiltered (fixture, test_data);
464 filter_test_setup_expand_root (fixture);
468 filter_test_setup_empty_unfiltered (FilterTest *fixture,
469 gconstpointer test_data)
471 filter_test_setup_generic (fixture, test_data, 3, TRUE, TRUE);
475 filter_test_setup_empty_unfiltered_root_expanded (FilterTest *fixture,
476 gconstpointer test_data)
478 filter_test_setup_empty_unfiltered (fixture, test_data);
479 filter_test_setup_expand_root (fixture);
483 strip_virtual_root (GtkTreePath *path,
484 GtkTreePath *root_path)
486 GtkTreePath *real_path;
491 int depth = gtk_tree_path_get_depth (path);
492 int root_depth = gtk_tree_path_get_depth (root_path);
494 real_path = gtk_tree_path_new ();
496 for (j = 0; j < depth - root_depth; j++)
497 gtk_tree_path_append_index (real_path,
498 gtk_tree_path_get_indices (path)[root_depth + j]);
501 real_path = gtk_tree_path_copy (path);
507 count_visible (FilterTest *fixture,
508 GtkTreePath *store_path)
514 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
517 for (i = 0; i < LEVEL_LENGTH; i++)
521 gtk_tree_model_get (GTK_TREE_MODEL (fixture->store), &iter,
533 filter_test_append_refilter_signals_recurse (FilterTest *fixture,
534 GtkTreePath *store_path,
535 GtkTreePath *filter_path,
537 GtkTreePath *root_path)
540 int rows_deleted = 0;
543 gtk_tree_path_down (store_path);
544 gtk_tree_path_down (filter_path);
546 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
549 for (i = 0; i < LEVEL_LENGTH; i++)
552 GtkTreePath *real_path;
554 gtk_tree_model_get (GTK_TREE_MODEL (fixture->store), &iter,
559 (!gtk_tree_path_is_descendant (store_path, root_path)
560 || !gtk_tree_path_compare (store_path, root_path)))
562 if (!gtk_tree_path_compare (store_path, root_path))
565 && gtk_tree_model_iter_has_child (GTK_TREE_MODEL (fixture->store),
568 GtkTreePath *store_copy;
569 GtkTreePath *filter_copy;
571 store_copy = gtk_tree_path_copy (store_path);
572 filter_copy = gtk_tree_path_copy (filter_path);
573 filter_test_append_refilter_signals_recurse (fixture,
578 gtk_tree_path_free (store_copy);
579 gtk_tree_path_free (filter_copy);
583 gtk_tree_path_next (store_path);
584 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
587 gtk_tree_path_next (filter_path);
592 real_path = strip_virtual_root (filter_path, root_path);
596 /* This row will be inserted */
597 signal_monitor_append_signal_path (fixture->monitor, ROW_CHANGED,
600 if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (fixture->store),
603 signal_monitor_append_signal_path (fixture->monitor,
604 ROW_HAS_CHILD_TOGGLED,
609 GtkTreePath *store_copy;
610 GtkTreePath *filter_copy;
612 store_copy = gtk_tree_path_copy (store_path);
613 filter_copy = gtk_tree_path_copy (filter_path);
614 filter_test_append_refilter_signals_recurse (fixture,
619 gtk_tree_path_free (store_copy);
620 gtk_tree_path_free (filter_copy);
624 GtkTreePath *tmp_path;
626 /* If all child rows are invisible, then the last row to
627 * become invisible will emit row-has-child-toggled on the
631 tmp_path = gtk_tree_path_copy (store_path);
632 gtk_tree_path_append_index (tmp_path, 0);
634 if (count_visible (fixture, tmp_path) == 0)
635 signal_monitor_append_signal_path (fixture->monitor,
636 ROW_HAS_CHILD_TOGGLED,
639 gtk_tree_path_free (tmp_path);
643 gtk_tree_path_next (filter_path);
647 /* This row will be deleted */
649 signal_monitor_append_signal_path (fixture->monitor, ROW_DELETED,
653 gtk_tree_path_free (real_path);
655 gtk_tree_path_next (store_path);
656 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
659 if (rows_deleted == LEVEL_LENGTH
660 && gtk_tree_path_get_depth (filter_path) > 1)
662 GtkTreePath *real_path;
664 gtk_tree_path_up (store_path);
665 gtk_tree_path_up (filter_path);
667 /* A row-has-child-toggled will be emitted on the parent */
670 && gtk_tree_path_is_descendant (store_path, root_path)
671 && gtk_tree_path_compare (store_path, root_path)))
673 real_path = strip_virtual_root (filter_path, root_path);
674 signal_monitor_append_signal_path (fixture->monitor,
675 ROW_HAS_CHILD_TOGGLED,
678 gtk_tree_path_free (real_path);
684 filter_test_append_refilter_signals (FilterTest *fixture,
687 /* A special function that walks the tree store like the
688 * model validation functions below.
691 GtkTreePath *filter_path;
693 path = gtk_tree_path_new ();
694 filter_path = gtk_tree_path_new ();
695 filter_test_append_refilter_signals_recurse (fixture,
700 gtk_tree_path_free (path);
701 gtk_tree_path_free (filter_path);
705 filter_test_append_refilter_signals_with_vroot (FilterTest *fixture,
707 GtkTreePath *root_path)
709 /* A special function that walks the tree store like the
710 * model validation functions below.
713 GtkTreePath *filter_path;
715 path = gtk_tree_path_new ();
716 filter_path = gtk_tree_path_new ();
717 filter_test_append_refilter_signals_recurse (fixture,
722 gtk_tree_path_free (path);
723 gtk_tree_path_free (filter_path);
727 filter_test_enable_filter (FilterTest *fixture)
729 gtk_tree_model_filter_set_visible_column (fixture->filter, 1);
730 gtk_tree_model_filter_refilter (fixture->filter);
734 filter_test_block_signals (FilterTest *fixture)
736 fixture->block_signals = TRUE;
740 filter_test_unblock_signals (FilterTest *fixture)
742 fixture->block_signals = FALSE;
746 filter_test_teardown (FilterTest *fixture,
747 gconstpointer test_data)
749 signal_monitor_free (fixture->monitor);
751 gtk_widget_destroy (fixture->tree_view);
753 g_object_unref (fixture->filter);
754 g_object_unref (fixture->store);
758 * Model structure validation
762 check_filter_model_recurse (FilterTest *fixture,
763 GtkTreePath *store_parent_path,
764 GtkTreePath *filter_parent_path)
767 GtkTreeIter store_iter;
768 GtkTreeIter filter_iter;
769 gboolean store_has_next, filter_has_next;
771 gtk_tree_path_down (store_parent_path);
772 gtk_tree_path_down (filter_parent_path);
774 store_has_next = gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
775 &store_iter, store_parent_path);
776 filter_has_next = gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->filter),
777 &filter_iter, filter_parent_path);
779 for (i = 0; i < LEVEL_LENGTH; i++)
783 g_return_if_fail (store_has_next == TRUE);
785 gtk_tree_model_get (GTK_TREE_MODEL (fixture->store),
793 gchar *filter_str, *store_str;
795 g_return_if_fail (filter_has_next == TRUE);
798 tmp = gtk_tree_model_get_path (GTK_TREE_MODEL (fixture->filter),
800 g_return_if_fail (gtk_tree_path_compare (tmp, filter_parent_path) == 0);
802 /* Verify model content */
803 gtk_tree_model_get (GTK_TREE_MODEL (fixture->store),
807 gtk_tree_model_get (GTK_TREE_MODEL (fixture->filter),
812 g_return_if_fail (g_strcmp0 (store_str, filter_str) == 0);
817 if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (fixture->filter),
820 g_return_if_fail (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (fixture->store), &store_iter));
822 check_filter_model_recurse (fixture,
823 gtk_tree_path_copy (store_parent_path),
827 /* Only when we do not recurse we need to free tmp */
828 gtk_tree_path_free (tmp);
830 gtk_tree_path_next (filter_parent_path);
831 filter_has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->filter), &filter_iter);
834 gtk_tree_path_next (store_parent_path);
835 store_has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &store_iter);
838 /* Both models should have no more content! */
839 g_return_if_fail (store_has_next == FALSE);
840 g_return_if_fail (filter_has_next == FALSE);
842 gtk_tree_path_free (store_parent_path);
843 gtk_tree_path_free (filter_parent_path);
847 check_filter_model (FilterTest *fixture)
851 if (fixture->monitor)
852 signal_monitor_assert_is_empty (fixture->monitor);
854 path = gtk_tree_path_new ();
856 check_filter_model_recurse (fixture, path, gtk_tree_path_copy (path));
860 check_filter_model_with_root (FilterTest *fixture,
863 if (fixture->monitor)
864 signal_monitor_assert_is_empty (fixture->monitor);
866 check_filter_model_recurse (fixture,
867 gtk_tree_path_copy (path),
868 gtk_tree_path_new ());
874 check_level_length (GtkTreeModelFilter *filter,
876 const int expected_length)
882 model_length = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (filter), NULL);
883 g_assert_cmpint (model_length, ==, expected_length);
888 gboolean retrieved_iter = FALSE;
891 retrieved_iter = gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (filter),
893 g_return_if_fail (retrieved_iter);
894 model_length = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (filter), &iter);
895 g_assert_cmpint (model_length, ==, expected_length);
900 set_path_visibility (FilterTest *fixture,
904 GtkTreeIter store_iter;
906 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store),
908 gtk_tree_store_set (fixture->store, &store_iter,
915 insert_path_with_visibility (FilterTest *fixture,
916 const gchar *path_string,
921 GtkTreeIter parent, iter;
923 path = gtk_tree_path_new_from_string (path_string);
924 position = gtk_tree_path_get_indices (path)[gtk_tree_path_get_depth (path)];
925 gtk_tree_path_up (path);
927 if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &parent, path))
929 gtk_tree_store_insert (fixture->store, &iter, &parent, position);
930 create_tree_store_set_values (fixture->store, &iter, visible);
932 gtk_tree_path_free (path);
941 verify_test_suite (FilterTest *fixture,
942 gconstpointer user_data)
944 check_filter_model (fixture);
948 verify_test_suite_vroot (FilterTest *fixture,
949 gconstpointer user_data)
951 check_filter_model_with_root (fixture, (GtkTreePath *)user_data);
956 filled_hide_root_level (FilterTest *fixture,
957 gconstpointer user_data)
959 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "2");
960 set_path_visibility (fixture, "2", FALSE);
961 check_filter_model (fixture);
962 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
964 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
965 set_path_visibility (fixture, "0", FALSE);
966 check_filter_model (fixture);
967 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
969 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "2");
970 set_path_visibility (fixture, "4", FALSE);
971 check_filter_model (fixture);
972 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 3);
976 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
977 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
979 set_path_visibility (fixture, "1", FALSE);
980 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 4);
982 set_path_visibility (fixture, "3", FALSE);
983 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 5);
985 check_filter_model (fixture);
988 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
989 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
990 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "1");
991 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
993 set_path_visibility (fixture, "1", TRUE);
994 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 4);
996 set_path_visibility (fixture, "3", TRUE);
997 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 3);
999 check_filter_model (fixture);
1003 filled_hide_child_levels (FilterTest *fixture,
1004 gconstpointer user_data)
1006 set_path_visibility (fixture, "0:2", FALSE);
1007 check_filter_model (fixture);
1008 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1009 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 1);
1011 set_path_visibility (fixture, "0:4", FALSE);
1012 check_filter_model (fixture);
1013 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1014 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1016 set_path_visibility (fixture, "0:4:3", FALSE);
1017 check_filter_model (fixture);
1018 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1019 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1021 set_path_visibility (fixture, "0:4:0", FALSE);
1022 set_path_visibility (fixture, "0:4:1", FALSE);
1023 set_path_visibility (fixture, "0:4:2", FALSE);
1024 set_path_visibility (fixture, "0:4:4", FALSE);
1025 check_filter_model (fixture);
1026 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1027 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1029 /* Since "0:2" is hidden, "0:4" must be "0:3" in the filter model */
1030 set_path_visibility (fixture, "0:4", TRUE);
1031 check_filter_model (fixture);
1032 check_level_length (fixture->filter, "0:3", 0);
1034 set_path_visibility (fixture, "0:2", TRUE);
1035 check_filter_model (fixture);
1036 check_level_length (fixture->filter, "0:2", LEVEL_LENGTH);
1037 check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
1038 check_level_length (fixture->filter, "0:4", 0);
1040 /* Once 0:4:0 got inserted, 0:4 became a parent. Because 0:4 is
1041 * not visible, not signals are emitted.
1043 set_path_visibility (fixture, "0:4:2", TRUE);
1044 set_path_visibility (fixture, "0:4:4", TRUE);
1045 signal_monitor_assert_is_empty (fixture->monitor);
1046 check_level_length (fixture->filter, "0:4", 2);
1050 filled_hide_child_levels_root_expanded (FilterTest *fixture,
1051 gconstpointer user_data)
1055 path = gtk_tree_path_new_from_indices (0, -1);
1056 gtk_tree_view_expand_row (GTK_TREE_VIEW (fixture->tree_view), path, FALSE);
1057 gtk_tree_path_free (path);
1059 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0:2");
1060 set_path_visibility (fixture, "0:2", FALSE);
1061 check_filter_model (fixture);
1062 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1063 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 1);
1065 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0:3");
1066 set_path_visibility (fixture, "0:4", FALSE);
1067 check_filter_model (fixture);
1068 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1069 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1071 set_path_visibility (fixture, "0:4:3", FALSE);
1072 check_filter_model (fixture);
1073 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1074 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1076 set_path_visibility (fixture, "0:4:0", FALSE);
1077 set_path_visibility (fixture, "0:4:1", FALSE);
1078 set_path_visibility (fixture, "0:4:2", FALSE);
1079 set_path_visibility (fixture, "0:4:4", FALSE);
1080 check_filter_model (fixture);
1081 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1082 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1084 /* Since "0:2" is hidden, "0:4" must be "0:3" in the filter model */
1085 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:3");
1086 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:3");
1087 set_path_visibility (fixture, "0:4", TRUE);
1088 check_filter_model (fixture);
1089 check_level_length (fixture->filter, "0:3", 0);
1091 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:2");
1092 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:2");
1093 set_path_visibility (fixture, "0:2", TRUE);
1094 check_filter_model (fixture);
1095 check_level_length (fixture->filter, "0:2", LEVEL_LENGTH);
1096 check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
1097 check_level_length (fixture->filter, "0:4", 0);
1099 /* has-child-toggled for 0:4 is required. */
1100 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
1101 set_path_visibility (fixture, "0:4:2", TRUE);
1102 set_path_visibility (fixture, "0:4:4", TRUE);
1103 signal_monitor_assert_is_empty (fixture->monitor);
1104 check_level_length (fixture->filter, "0:4", 2);
1109 filled_vroot_hide_root_level (FilterTest *fixture,
1110 gconstpointer user_data)
1112 GtkTreePath *path = (GtkTreePath *)user_data;
1114 /* These changes do not affect the filter's root level */
1115 set_path_visibility (fixture, "0", FALSE);
1116 check_filter_model_with_root (fixture, path);
1117 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1118 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1120 set_path_visibility (fixture, "4", FALSE);
1121 check_filter_model_with_root (fixture, path);
1122 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1123 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1125 /* Even though we set the virtual root parent node to FALSE,
1126 * the virtual root contents remain.
1128 set_path_visibility (fixture, "2", FALSE);
1129 check_filter_model_with_root (fixture, path);
1130 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1131 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1134 set_path_visibility (fixture, "1", FALSE);
1135 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1136 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1138 set_path_visibility (fixture, "3", FALSE);
1139 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1140 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1142 check_filter_model_with_root (fixture, path);
1145 set_path_visibility (fixture, "2", TRUE);
1146 check_filter_model_with_root (fixture, path);
1147 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1148 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1150 set_path_visibility (fixture, "1", TRUE);
1151 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1152 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1154 set_path_visibility (fixture, "3", TRUE);
1155 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1156 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1158 check_filter_model_with_root (fixture, path);
1160 /* Now test changes in the virtual root level */
1161 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "2");
1162 set_path_visibility (fixture, "2:2", FALSE);
1163 check_filter_model_with_root (fixture, path);
1164 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1166 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "3");
1167 set_path_visibility (fixture, "2:4", FALSE);
1168 check_filter_model_with_root (fixture, path);
1169 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
1171 set_path_visibility (fixture, "1:4", FALSE);
1172 check_filter_model_with_root (fixture, path);
1173 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
1175 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "3");
1176 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "3");
1177 set_path_visibility (fixture, "2:4", TRUE);
1178 check_filter_model_with_root (fixture, path);
1179 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1181 set_path_visibility (fixture, "2", FALSE);
1182 check_filter_model_with_root (fixture, path);
1183 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1185 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1186 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1187 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1188 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1189 set_path_visibility (fixture, "2:0", FALSE);
1190 set_path_visibility (fixture, "2:1", FALSE);
1191 set_path_visibility (fixture, "2:2", FALSE);
1192 set_path_visibility (fixture, "2:3", FALSE);
1193 set_path_visibility (fixture, "2:4", FALSE);
1194 check_filter_model_with_root (fixture, path);
1195 check_level_length (fixture->filter, NULL, 0);
1197 set_path_visibility (fixture, "2", TRUE);
1198 check_filter_model_with_root (fixture, path);
1199 check_level_length (fixture->filter, NULL, 0);
1201 set_path_visibility (fixture, "1:4", FALSE);
1202 check_filter_model_with_root (fixture, path);
1203 check_level_length (fixture->filter, NULL, 0);
1205 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1206 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1207 set_path_visibility (fixture, "2:4", TRUE);
1208 check_filter_model_with_root (fixture, path);
1209 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 4);
1211 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1212 set_path_visibility (fixture, "2:4", FALSE);
1213 check_filter_model_with_root (fixture, path);
1214 check_level_length (fixture->filter, NULL, 0);
1216 set_path_visibility (fixture, "2", FALSE);
1217 check_filter_model_with_root (fixture, path);
1218 check_level_length (fixture->filter, NULL, 0);
1220 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1221 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1222 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "1");
1223 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
1224 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "2");
1225 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1226 set_path_visibility (fixture, "2:0", TRUE);
1227 set_path_visibility (fixture, "2:1", TRUE);
1228 set_path_visibility (fixture, "2:2", TRUE);
1229 check_filter_model_with_root (fixture, path);
1230 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
1232 set_path_visibility (fixture, "2", TRUE);
1233 check_filter_model_with_root (fixture, path);
1234 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
1238 filled_vroot_hide_child_levels (FilterTest *fixture,
1239 gconstpointer user_data)
1241 GtkTreePath *path = (GtkTreePath *)user_data;
1243 set_path_visibility (fixture, "2:0:2", FALSE);
1244 check_filter_model_with_root (fixture, path);
1245 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1246 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 1);
1248 set_path_visibility (fixture, "2:0:4", FALSE);
1249 check_filter_model_with_root (fixture, path);
1250 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1251 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1253 set_path_visibility (fixture, "2:0:4:3", FALSE);
1254 check_filter_model_with_root (fixture, path);
1255 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1256 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1258 set_path_visibility (fixture, "2:0:4:0", FALSE);
1259 set_path_visibility (fixture, "2:0:4:1", FALSE);
1260 set_path_visibility (fixture, "2:0:4:2", FALSE);
1261 set_path_visibility (fixture, "2:0:4:4", FALSE);
1262 check_filter_model_with_root (fixture, path);
1263 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1264 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1266 /* Since "0:2" is hidden, "0:4" must be "0:3" in the filter model */
1267 set_path_visibility (fixture, "2:0:4", TRUE);
1268 check_filter_model_with_root (fixture, path);
1269 check_level_length (fixture->filter, "0:3", 0);
1271 set_path_visibility (fixture, "2:0:2", TRUE);
1272 check_filter_model_with_root (fixture, path);
1273 check_level_length (fixture->filter, "0:2", LEVEL_LENGTH);
1274 check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
1275 check_level_length (fixture->filter, "0:4", 0);
1277 /* Once 0:4:0 got inserted, 0:4 became a parent */
1278 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
1279 set_path_visibility (fixture, "2:0:4:2", TRUE);
1280 set_path_visibility (fixture, "2:0:4:4", TRUE);
1281 check_level_length (fixture->filter, "0:4", 2);
1285 filled_vroot_hide_child_levels_root_expanded (FilterTest *fixture,
1286 gconstpointer user_data)
1288 GtkTreePath *path = (GtkTreePath *)user_data;
1289 GtkTreePath *tmp_path;
1291 tmp_path = gtk_tree_path_new_from_indices (0, -1);
1292 gtk_tree_view_expand_row (GTK_TREE_VIEW (fixture->tree_view), tmp_path, FALSE);
1293 gtk_tree_path_free (tmp_path);
1295 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0:2");
1296 set_path_visibility (fixture, "2:0:2", FALSE);
1297 check_filter_model_with_root (fixture, path);
1298 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1299 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 1);
1301 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0:3");
1302 set_path_visibility (fixture, "2:0:4", FALSE);
1303 check_filter_model_with_root (fixture, path);
1304 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1305 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1307 set_path_visibility (fixture, "2:0:4:3", FALSE);
1308 check_filter_model_with_root (fixture, path);
1309 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1310 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1312 set_path_visibility (fixture, "2:0:4:0", FALSE);
1313 set_path_visibility (fixture, "2:0:4:1", FALSE);
1314 set_path_visibility (fixture, "2:0:4:2", FALSE);
1315 set_path_visibility (fixture, "2:0:4:4", FALSE);
1316 check_filter_model_with_root (fixture, path);
1317 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1318 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1320 /* Since "0:2" is hidden, "0:4" must be "0:3" in the filter model */
1321 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:3");
1322 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:3");
1323 set_path_visibility (fixture, "2:0:4", TRUE);
1324 check_filter_model_with_root (fixture, path);
1325 check_level_length (fixture->filter, "0:3", 0);
1327 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:2");
1328 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:2");
1329 set_path_visibility (fixture, "2:0:2", TRUE);
1330 check_filter_model_with_root (fixture, path);
1331 check_level_length (fixture->filter, "0:2", LEVEL_LENGTH);
1332 check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
1333 check_level_length (fixture->filter, "0:4", 0);
1335 /* Once 0:4:0 got inserted, 0:4 became a parent */
1336 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
1337 set_path_visibility (fixture, "2:0:4:2", TRUE);
1338 set_path_visibility (fixture, "2:0:4:4", TRUE);
1339 check_level_length (fixture->filter, "0:4", 2);
1343 empty_show_nodes (FilterTest *fixture,
1344 gconstpointer user_data)
1346 check_filter_model (fixture);
1347 check_level_length (fixture->filter, NULL, 0);
1349 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1350 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1351 set_path_visibility (fixture, "3", TRUE);
1352 check_filter_model (fixture);
1353 check_level_length (fixture->filter, NULL, 1);
1354 check_level_length (fixture->filter, "0", 0);
1356 set_path_visibility (fixture, "3:2:2", TRUE);
1357 check_filter_model (fixture);
1358 check_level_length (fixture->filter, NULL, 1);
1359 check_level_length (fixture->filter, "0", 0);
1361 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1362 set_path_visibility (fixture, "3:2", TRUE);
1363 check_filter_model (fixture);
1364 check_level_length (fixture->filter, NULL, 1);
1365 check_level_length (fixture->filter, "0", 1);
1366 check_level_length (fixture->filter, "0:0", 1);
1367 check_level_length (fixture->filter, "0:0:0", 0);
1369 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1370 set_path_visibility (fixture, "3", FALSE);
1371 check_filter_model (fixture);
1372 check_level_length (fixture->filter, NULL, 0);
1374 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1375 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1376 set_path_visibility (fixture, "3:2:1", TRUE);
1377 set_path_visibility (fixture, "3", TRUE);
1378 check_filter_model (fixture);
1379 check_level_length (fixture->filter, NULL, 1);
1380 check_level_length (fixture->filter, "0", 1);
1381 check_level_length (fixture->filter, "0:0", 2);
1382 check_level_length (fixture->filter, "0:0:0", 0);
1386 empty_show_multiple_nodes (FilterTest *fixture,
1387 gconstpointer user_data)
1390 GtkTreePath *changed_path;
1392 check_filter_model (fixture);
1393 check_level_length (fixture->filter, NULL, 0);
1395 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1396 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1397 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "1");
1398 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
1400 /* We simulate a change in visible func condition with this. The
1401 * visibility state of multiple nodes changes at once, we emit row-changed
1402 * for these nodes (and others) after that.
1404 filter_test_block_signals (fixture);
1405 set_path_visibility (fixture, "3", TRUE);
1406 set_path_visibility (fixture, "4", TRUE);
1407 filter_test_unblock_signals (fixture);
1409 changed_path = gtk_tree_path_new ();
1410 gtk_tree_path_append_index (changed_path, 2);
1411 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
1412 &iter, changed_path);
1413 /* Invisible node - so no signals expected */
1414 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1415 changed_path, &iter);
1417 gtk_tree_path_next (changed_path);
1418 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1419 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1420 changed_path, &iter);
1422 gtk_tree_path_next (changed_path);
1423 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1424 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1425 changed_path, &iter);
1427 gtk_tree_path_free (changed_path);
1429 check_filter_model (fixture);
1430 check_level_length (fixture->filter, NULL, 2);
1431 check_level_length (fixture->filter, "0", 0);
1433 set_path_visibility (fixture, "3:2:2", TRUE);
1434 check_filter_model (fixture);
1435 check_level_length (fixture->filter, NULL, 2);
1436 check_level_length (fixture->filter, "0", 0);
1438 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1439 set_path_visibility (fixture, "3:2", TRUE);
1440 check_filter_model (fixture);
1441 check_level_length (fixture->filter, NULL, 2);
1442 check_level_length (fixture->filter, "0", 1);
1443 check_level_length (fixture->filter, "0:0", 1);
1444 check_level_length (fixture->filter, "0:0:0", 0);
1446 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1447 set_path_visibility (fixture, "3", FALSE);
1448 check_filter_model (fixture);
1449 check_level_length (fixture->filter, NULL, 1);
1451 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1452 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1453 set_path_visibility (fixture, "3:2:1", TRUE);
1454 set_path_visibility (fixture, "3", TRUE);
1455 check_filter_model (fixture);
1456 check_level_length (fixture->filter, NULL, 2);
1457 check_level_length (fixture->filter, "0", 1);
1458 check_level_length (fixture->filter, "0:0", 2);
1459 check_level_length (fixture->filter, "0:0:0", 0);
1463 empty_vroot_show_nodes (FilterTest *fixture,
1464 gconstpointer user_data)
1466 GtkTreePath *path = (GtkTreePath *)user_data;
1468 check_filter_model_with_root (fixture, path);
1469 check_level_length (fixture->filter, NULL, 0);
1471 set_path_visibility (fixture, "2", TRUE);
1472 check_filter_model_with_root (fixture, path);
1473 check_level_length (fixture->filter, NULL, 0);
1475 set_path_visibility (fixture, "2:2:2", TRUE);
1476 check_filter_model_with_root (fixture, path);
1477 check_level_length (fixture->filter, NULL, 0);
1479 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1480 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1481 set_path_visibility (fixture, "2:2", TRUE);
1482 check_filter_model_with_root (fixture, path);
1483 check_level_length (fixture->filter, NULL, 1);
1484 check_level_length (fixture->filter, "0", 1);
1485 check_level_length (fixture->filter, "0:0", 0);
1487 set_path_visibility (fixture, "3", TRUE);
1488 check_filter_model_with_root (fixture, path);
1489 check_level_length (fixture->filter, NULL, 1);
1491 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1492 set_path_visibility (fixture, "2:2", FALSE);
1493 check_filter_model_with_root (fixture, path);
1494 check_level_length (fixture->filter, NULL, 0);
1496 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1497 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1498 set_path_visibility (fixture, "2:2:1", TRUE);
1499 set_path_visibility (fixture, "2:2", TRUE);
1500 check_filter_model_with_root (fixture, path);
1501 check_level_length (fixture->filter, NULL, 1);
1502 check_level_length (fixture->filter, "0", 2);
1503 check_level_length (fixture->filter, "0:1", 0);
1507 empty_vroot_show_multiple_nodes (FilterTest *fixture,
1508 gconstpointer user_data)
1511 GtkTreePath *changed_path;
1512 GtkTreePath *path = (GtkTreePath *)user_data;
1514 check_filter_model_with_root (fixture, path);
1515 check_level_length (fixture->filter, NULL, 0);
1517 /* We simulate a change in visible func condition with this. The
1518 * visibility state of multiple nodes changes at once, we emit row-changed
1519 * for these nodes (and others) after that.
1521 filter_test_block_signals (fixture);
1522 set_path_visibility (fixture, "2", TRUE);
1523 set_path_visibility (fixture, "3", TRUE);
1524 filter_test_unblock_signals (fixture);
1526 changed_path = gtk_tree_path_new ();
1527 gtk_tree_path_append_index (changed_path, 1);
1528 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
1529 &iter, changed_path);
1530 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1531 changed_path, &iter);
1533 gtk_tree_path_next (changed_path);
1534 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1535 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1536 changed_path, &iter);
1538 gtk_tree_path_next (changed_path);
1539 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1540 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1541 changed_path, &iter);
1543 gtk_tree_path_next (changed_path);
1544 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1545 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1546 changed_path, &iter);
1548 gtk_tree_path_free (changed_path);
1550 check_filter_model_with_root (fixture, path);
1551 check_level_length (fixture->filter, NULL, 0);
1553 set_path_visibility (fixture, "2:2:2", TRUE);
1554 check_filter_model_with_root (fixture, path);
1555 check_level_length (fixture->filter, NULL, 0);
1557 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1558 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1559 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "1");
1560 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
1562 /* Again, we simulate a call to refilter */
1563 filter_test_block_signals (fixture);
1564 set_path_visibility (fixture, "2:2", TRUE);
1565 set_path_visibility (fixture, "2:3", TRUE);
1566 filter_test_unblock_signals (fixture);
1568 changed_path = gtk_tree_path_new ();
1569 gtk_tree_path_append_index (changed_path, 2);
1570 gtk_tree_path_append_index (changed_path, 1);
1571 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
1572 &iter, changed_path);
1573 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1574 changed_path, &iter);
1576 gtk_tree_path_next (changed_path);
1577 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1578 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1579 changed_path, &iter);
1581 gtk_tree_path_next (changed_path);
1582 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1583 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1584 changed_path, &iter);
1586 gtk_tree_path_next (changed_path);
1587 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1588 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1589 changed_path, &iter);
1591 gtk_tree_path_free (changed_path);
1593 check_filter_model_with_root (fixture, path);
1594 check_level_length (fixture->filter, NULL, 2);
1595 check_level_length (fixture->filter, "0", 1);
1596 check_level_length (fixture->filter, "0:0", 0);
1598 set_path_visibility (fixture, "3", TRUE);
1599 check_filter_model_with_root (fixture, path);
1600 check_level_length (fixture->filter, NULL, 2);
1602 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1603 set_path_visibility (fixture, "2:2", FALSE);
1604 check_filter_model_with_root (fixture, path);
1605 check_level_length (fixture->filter, NULL, 1);
1607 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1608 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1609 set_path_visibility (fixture, "2:2:1", TRUE);
1610 set_path_visibility (fixture, "2:2", TRUE);
1611 check_filter_model_with_root (fixture, path);
1612 check_level_length (fixture->filter, NULL, 2);
1613 check_level_length (fixture->filter, "0", 2);
1614 check_level_length (fixture->filter, "0:1", 0);
1619 unfiltered_hide_single (FilterTest *fixture,
1620 gconstpointer user_data)
1623 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
1624 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1625 set_path_visibility (fixture, "2", FALSE);
1627 signal_monitor_assert_is_empty (fixture->monitor);
1628 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1630 /* The view only shows the root level, so we only expect signals
1631 * for the root level.
1633 filter_test_append_refilter_signals (fixture, 1);
1634 filter_test_enable_filter (fixture);
1636 check_filter_model (fixture);
1637 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1641 unfiltered_hide_single_root_expanded (FilterTest *fixture,
1642 gconstpointer user_data)
1645 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
1646 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1647 set_path_visibility (fixture, "2", FALSE);
1649 signal_monitor_assert_is_empty (fixture->monitor);
1650 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1652 filter_test_append_refilter_signals (fixture, 2);
1653 filter_test_enable_filter (fixture);
1655 check_filter_model (fixture);
1656 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1660 unfiltered_hide_single_child (FilterTest *fixture,
1661 gconstpointer user_data)
1664 /* This row is not shown, so its signal is not propagated */
1665 set_path_visibility (fixture, "2:2", FALSE);
1667 signal_monitor_assert_is_empty (fixture->monitor);
1668 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1669 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1671 /* The view only shows the root level, so we only expect signals
1672 * for the root level.
1674 filter_test_append_refilter_signals (fixture, 0);
1675 filter_test_enable_filter (fixture);
1677 check_filter_model (fixture);
1678 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1679 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1683 unfiltered_hide_single_child_root_expanded (FilterTest *fixture,
1684 gconstpointer user_data)
1687 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1688 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1689 set_path_visibility (fixture, "2:2", FALSE);
1691 signal_monitor_assert_is_empty (fixture->monitor);
1692 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1693 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1695 filter_test_append_refilter_signals (fixture, 2);
1696 filter_test_enable_filter (fixture);
1698 check_filter_model (fixture);
1699 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1700 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1704 unfiltered_hide_single_multi_level (FilterTest *fixture,
1705 gconstpointer user_data)
1708 /* This row is not shown, so its signal is not propagated */
1709 set_path_visibility (fixture, "2:2:2", FALSE);
1711 /* This row is not shown, so its signal is not propagated */
1712 set_path_visibility (fixture, "2:2", FALSE);
1714 signal_monitor_assert_is_empty (fixture->monitor);
1715 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1716 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1717 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
1719 /* The view only shows the root level, so we only expect signals
1720 * for the root level.
1722 filter_test_append_refilter_signals (fixture, 1);
1723 filter_test_enable_filter (fixture);
1725 check_filter_model (fixture);
1726 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1727 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1729 set_path_visibility (fixture, "2:2", TRUE);
1731 check_filter_model (fixture);
1732 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1733 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1734 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH - 1);
1738 unfiltered_hide_single_multi_level_root_expanded (FilterTest *fixture,
1739 gconstpointer user_data)
1742 /* This row is not shown, so its signal is not propagated */
1743 set_path_visibility (fixture, "2:2:2", FALSE);
1745 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1746 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1747 set_path_visibility (fixture, "2:2", FALSE);
1749 signal_monitor_assert_is_empty (fixture->monitor);
1750 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1751 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1752 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
1754 filter_test_append_refilter_signals (fixture, 2);
1755 filter_test_enable_filter (fixture);
1757 check_filter_model (fixture);
1758 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1759 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1761 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "2:2");
1762 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1763 set_path_visibility (fixture, "2:2", TRUE);
1765 check_filter_model (fixture);
1766 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1767 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1768 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH - 1);
1774 unfiltered_vroot_hide_single (FilterTest *fixture,
1775 gconstpointer user_data)
1778 GtkTreePath *path = (GtkTreePath *)user_data;
1780 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
1781 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1782 set_path_visibility (fixture, "2:2", FALSE);
1784 signal_monitor_assert_is_empty (fixture->monitor);
1785 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1787 /* The view only shows the root level, so we only expect signals
1788 * for the root level. (Though for the depth argument, we have to
1789 * take the virtual root into account).
1791 filter_test_append_refilter_signals_with_vroot (fixture, 2, path);
1792 filter_test_enable_filter (fixture);
1794 check_filter_model_with_root (fixture, path);
1795 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1799 unfiltered_vroot_hide_single_child (FilterTest *fixture,
1800 gconstpointer user_data)
1803 GtkTreePath *path = (GtkTreePath *)user_data;
1805 /* Not visible, so no signal will be received. */
1806 set_path_visibility (fixture, "2:2:2", FALSE);
1808 signal_monitor_assert_is_empty (fixture->monitor);
1809 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1810 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1812 /* The view only shows the root level, so we only expect signals
1813 * for the root level. (Though for the depth argument, we have to
1814 * take the virtual root into account).
1816 filter_test_append_refilter_signals_with_vroot (fixture, 2, path);
1817 filter_test_enable_filter (fixture);
1819 check_filter_model_with_root (fixture, path);
1820 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1821 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1825 unfiltered_vroot_hide_single_child_root_expanded (FilterTest *fixture,
1826 gconstpointer user_data)
1829 GtkTreePath *path = (GtkTreePath *)user_data;
1831 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1832 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1833 set_path_visibility (fixture, "2:2:2", FALSE);
1835 signal_monitor_assert_is_empty (fixture->monitor);
1836 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1837 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1839 filter_test_append_refilter_signals_with_vroot (fixture, 3, path);
1840 filter_test_enable_filter (fixture);
1842 check_filter_model_with_root (fixture, path);
1843 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1844 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1848 unfiltered_vroot_hide_single_multi_level (FilterTest *fixture,
1849 gconstpointer user_data)
1852 GtkTreePath *path = (GtkTreePath *)user_data;
1854 /* This row is not shown, so its signal is not propagated */
1855 set_path_visibility (fixture, "2:2:2:2", FALSE);
1857 /* Not shown, so no signal */
1858 set_path_visibility (fixture, "2:2:2", FALSE);
1860 signal_monitor_assert_is_empty (fixture->monitor);
1861 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1862 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1863 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
1865 /* We only expect signals for the root level. The depth is 2
1866 * because we have to take the virtual root into account.
1868 filter_test_append_refilter_signals_with_vroot (fixture, 2, path);
1869 filter_test_enable_filter (fixture);
1871 check_filter_model_with_root (fixture, path);
1872 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1873 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1875 /* Not shown, so no signal */
1876 set_path_visibility (fixture, "2:2:2", TRUE);
1878 check_filter_model_with_root (fixture, path);
1879 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1880 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1881 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH - 1);
1885 unfiltered_vroot_hide_single_multi_level_root_expanded (FilterTest *fixture,
1886 gconstpointer user_data)
1889 GtkTreePath *path = (GtkTreePath *)user_data;
1891 /* This row is not shown, so its signal is not propagated */
1892 set_path_visibility (fixture, "2:2:2:2", FALSE);
1894 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1895 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1896 set_path_visibility (fixture, "2:2:2", FALSE);
1898 signal_monitor_assert_is_empty (fixture->monitor);
1899 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1900 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1901 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
1903 filter_test_append_refilter_signals_with_vroot (fixture, 3, path);
1904 filter_test_enable_filter (fixture);
1906 check_filter_model_with_root (fixture, path);
1907 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1908 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1910 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "2:2");
1911 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1912 set_path_visibility (fixture, "2:2:2", TRUE);
1914 check_filter_model_with_root (fixture, path);
1915 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1916 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1917 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH - 1);
1921 unfiltered_show_single (FilterTest *fixture,
1922 gconstpointer user_data)
1925 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
1926 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1927 set_path_visibility (fixture, "2", TRUE);
1929 signal_monitor_assert_is_empty (fixture->monitor);
1930 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1932 /* We only expect signals for the root level */
1933 filter_test_append_refilter_signals (fixture, 1);
1934 filter_test_enable_filter (fixture);
1936 check_filter_model (fixture);
1937 check_level_length (fixture->filter, NULL, 1);
1941 unfiltered_show_single_child (FilterTest *fixture,
1942 gconstpointer user_data)
1945 set_path_visibility (fixture, "2:2", TRUE);
1947 signal_monitor_assert_is_empty (fixture->monitor);
1948 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1949 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1951 /* We only expect signals for the root level */
1952 filter_test_append_refilter_signals (fixture, 1);
1953 filter_test_enable_filter (fixture);
1955 check_filter_model (fixture);
1956 check_level_length (fixture->filter, NULL, 0);
1958 /* From here we are filtered, "2" in the real model is "0" in the filter
1961 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1962 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1963 set_path_visibility (fixture, "2", TRUE);
1964 signal_monitor_assert_is_empty (fixture->monitor);
1965 check_level_length (fixture->filter, NULL, 1);
1966 check_level_length (fixture->filter, "0", 1);
1970 unfiltered_show_single_child_root_expanded (FilterTest *fixture,
1971 gconstpointer user_data)
1974 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1975 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1976 set_path_visibility (fixture, "2:2", TRUE);
1978 signal_monitor_assert_is_empty (fixture->monitor);
1979 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1980 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1982 filter_test_append_refilter_signals (fixture, 2);
1983 filter_test_enable_filter (fixture);
1985 check_filter_model (fixture);
1986 check_level_length (fixture->filter, NULL, 0);
1988 /* From here we are filtered, "2" in the real model is "0" in the filter
1991 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1992 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1993 set_path_visibility (fixture, "2", TRUE);
1994 signal_monitor_assert_is_empty (fixture->monitor);
1995 check_level_length (fixture->filter, NULL, 1);
1996 check_level_length (fixture->filter, "0", 1);
2000 unfiltered_show_single_multi_level (FilterTest *fixture,
2001 gconstpointer user_data)
2004 /* The view is not showing these rows (collapsed state), so it is not
2005 * referenced. The signal should not go through.
2007 set_path_visibility (fixture, "2:2:2", TRUE);
2008 set_path_visibility (fixture, "2:2", TRUE);
2010 signal_monitor_assert_is_empty (fixture->monitor);
2011 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
2012 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
2013 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
2015 /* We only expect signals for the first level */
2016 filter_test_append_refilter_signals (fixture, 1);
2017 filter_test_enable_filter (fixture);
2019 check_filter_model (fixture);
2020 check_level_length (fixture->filter, NULL, 0);
2022 /* From here we are filtered, "2" in the real model is "0" in the filter
2025 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
2026 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
2027 set_path_visibility (fixture, "2", TRUE);
2028 check_filter_model (fixture);
2029 check_level_length (fixture->filter, NULL, 1);
2030 check_level_length (fixture->filter, "0", 1);
2031 check_level_length (fixture->filter, "0:0", 1);
2035 unfiltered_show_single_multi_level_root_expanded (FilterTest *fixture,
2036 gconstpointer user_data)
2039 /* The view is not showing this row (collapsed state), so it is not
2040 * referenced. The signal should not go through.
2042 set_path_visibility (fixture, "2:2:2", TRUE);
2044 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
2045 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
2046 set_path_visibility (fixture, "2:2", TRUE);
2048 signal_monitor_assert_is_empty (fixture->monitor);
2049 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
2050 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
2051 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
2053 filter_test_append_refilter_signals (fixture, 2);
2054 filter_test_enable_filter (fixture);
2056 check_filter_model (fixture);
2057 check_level_length (fixture->filter, NULL, 0);
2059 /* From here we are filtered, "2" in the real model is "0" in the filter
2062 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
2063 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
2064 set_path_visibility (fixture, "2", TRUE);
2065 check_filter_model (fixture);
2066 check_level_length (fixture->filter, NULL, 1);
2067 check_level_length (fixture->filter, "0", 1);
2068 check_level_length (fixture->filter, "0:0", 1);
2072 unfiltered_vroot_show_single (FilterTest *fixture,
2073 gconstpointer user_data)
2076 GtkTreePath *path = (GtkTreePath *)user_data;
2078 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
2079 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
2080 set_path_visibility (fixture, "2:2", TRUE);
2082 signal_monitor_assert_is_empty (fixture->monitor);
2083 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
2085 /* The view only shows the root level, so the filter model only has
2086 * the first two levels cached.
2088 filter_test_append_refilter_signals_with_vroot (fixture, 2, path);
2089 filter_test_enable_filter (fixture);
2091 check_filter_model_with_root (fixture, path);
2092 check_level_length (fixture->filter, NULL, 1);
2096 unfiltered_vroot_show_single_child (FilterTest *fixture,
2097 gconstpointer user_data)
2100 GtkTreePath *path = (GtkTreePath *)user_data;
2102 set_path_visibility (fixture, "2:2:2", TRUE);
2104 signal_monitor_assert_is_empty (fixture->monitor);
2105 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
2106 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
2108 /* The view only shows the root level, so the filter model only has
2109 * the first two levels cached.
2111 filter_test_append_refilter_signals_with_vroot (fixture, 2, path);
2112 filter_test_enable_filter (fixture);
2114 check_filter_model_with_root (fixture, path);
2115 check_level_length (fixture->filter, NULL, 0);
2117 /* From here we are filtered, "2" in the real model is "0" in the filter
2120 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
2121 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
2122 set_path_visibility (fixture, "2:2", TRUE);
2123 signal_monitor_assert_is_empty (fixture->monitor);
2124 check_level_length (fixture->filter, NULL, 1);
2125 check_level_length (fixture->filter, "0", 1);
2129 unfiltered_vroot_show_single_child_root_expanded (FilterTest *fixture,
2130 gconstpointer user_data)
2133 GtkTreePath *path = (GtkTreePath *)user_data;
2135 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
2136 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
2137 set_path_visibility (fixture, "2:2:2", TRUE);
2139 signal_monitor_assert_is_empty (fixture->monitor);
2140 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
2141 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
2143 filter_test_append_refilter_signals_with_vroot (fixture, 3, path);
2144 filter_test_enable_filter (fixture);
2146 check_filter_model_with_root (fixture, path);
2147 check_level_length (fixture->filter, NULL, 0);
2149 /* From here we are filtered, "2" in the real model is "0" in the filter
2152 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
2153 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
2154 set_path_visibility (fixture, "2:2", TRUE);
2155 signal_monitor_assert_is_empty (fixture->monitor);
2156 check_level_length (fixture->filter, NULL, 1);
2157 check_level_length (fixture->filter, "0", 1);
2162 unfiltered_vroot_show_single_multi_level (FilterTest *fixture,
2163 gconstpointer user_data)
2166 GtkTreePath *path = (GtkTreePath *)user_data;
2168 /* The view is not showing this row (collapsed state), so it is not
2169 * referenced. The signal should not go through.
2171 set_path_visibility (fixture, "2:2:2:2", TRUE);
2173 set_path_visibility (fixture, "2:2:2", TRUE);
2175 signal_monitor_assert_is_empty (fixture->monitor);
2176 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
2177 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
2178 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
2180 /* We only expect signals for the root level */
2181 filter_test_append_refilter_signals_with_vroot (fixture, 2, path);
2182 filter_test_enable_filter (fixture);
2184 check_filter_model_with_root (fixture, path);
2185 check_level_length (fixture->filter, NULL, 0);
2187 /* From here we are filtered, "2" in the real model is "0" in the filter
2190 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
2191 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
2192 set_path_visibility (fixture, "2:2", TRUE);
2193 check_filter_model_with_root (fixture, path);
2194 check_level_length (fixture->filter, NULL, 1);
2195 check_level_length (fixture->filter, "0", 1);
2196 check_level_length (fixture->filter, "0:0", 1);
2200 unfiltered_vroot_show_single_multi_level_root_expanded (FilterTest *fixture,
2201 gconstpointer user_data)
2204 GtkTreePath *path = (GtkTreePath *)user_data;
2206 /* The view is not showing this row (collapsed state), so it is not
2207 * referenced. The signal should not go through.
2209 set_path_visibility (fixture, "2:2:2:2", TRUE);
2211 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
2212 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
2213 set_path_visibility (fixture, "2:2:2", TRUE);
2215 signal_monitor_assert_is_empty (fixture->monitor);
2216 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
2217 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
2218 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
2220 filter_test_append_refilter_signals_with_vroot (fixture, 3, path);
2221 filter_test_enable_filter (fixture);
2223 check_filter_model_with_root (fixture, path);
2224 check_level_length (fixture->filter, NULL, 0);
2226 /* From here we are filtered, "2" in the real model is "0" in the filter
2229 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
2230 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
2231 set_path_visibility (fixture, "2:2", TRUE);
2232 check_filter_model_with_root (fixture, path);
2233 check_level_length (fixture->filter, NULL, 1);
2234 check_level_length (fixture->filter, "0", 1);
2235 check_level_length (fixture->filter, "0:0", 1);
2240 insert_before (void)
2242 GtkTreeStore *store;
2243 GtkTreeModel *filter;
2244 GtkWidget *tree_view;
2245 SignalMonitor *monitor;
2247 GtkTreeIter last_iter;
2250 /* This tests two aspects of the row-inserted handling:
2251 * 1) If the newly inserted node was already handled by building
2252 * the root level, don't handle it a second time.
2253 * 2) Offsets of existing nodes must be updated when a new
2257 store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
2258 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
2259 gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (filter),
2262 tree_view = gtk_tree_view_new_with_model (filter);
2263 monitor = signal_monitor_new (filter);
2265 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 0);
2268 path = gtk_tree_path_new_from_indices (0, -1);
2269 signal_monitor_append_signal_path (monitor, ROW_INSERTED, path);
2270 gtk_tree_path_free (path);
2272 gtk_tree_store_insert_with_values (store, &iter, NULL, 0,
2273 0, "Foo", 1, TRUE, -1);
2275 signal_monitor_assert_is_empty (monitor);
2276 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 1);
2279 path = gtk_tree_path_new_from_indices (1, -1);
2280 signal_monitor_append_signal_path (monitor, ROW_INSERTED, path);
2281 gtk_tree_path_free (path);
2283 gtk_tree_store_insert_with_values (store, &iter, NULL, 1,
2284 0, "Foo", 1, TRUE, -1);
2287 signal_monitor_assert_is_empty (monitor);
2288 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 2);
2290 /* Insert on 1 again -- invisible */
2291 gtk_tree_store_insert_with_values (store, &iter, NULL, 1,
2292 0, "Foo", 1, FALSE, -1);
2294 signal_monitor_assert_is_empty (monitor);
2295 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 2);
2297 /* Insert on 1 again -- visible */
2298 path = gtk_tree_path_new_from_indices (1, -1);
2299 signal_monitor_append_signal_path (monitor, ROW_INSERTED, path);
2300 gtk_tree_path_free (path);
2302 gtk_tree_store_insert_with_values (store, &iter, NULL, 1,
2303 0, "Foo", 1, TRUE, -1);
2305 signal_monitor_assert_is_empty (monitor);
2306 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 3);
2308 /* Modify the iter that should be at the last position and check the
2311 path = gtk_tree_path_new_from_indices (2, -1);
2312 signal_monitor_append_signal_path (monitor, ROW_CHANGED, path);
2313 gtk_tree_path_free (path);
2315 gtk_tree_store_set (store, &last_iter, 0, "Foo changed", -1);
2317 signal_monitor_assert_is_empty (monitor);
2318 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 3);
2324 GtkTreeStore *store;
2325 GtkTreeModel *filter;
2326 GtkWidget *tree_view;
2327 SignalMonitor *monitor;
2328 GtkTreeIter parent, iter;
2331 store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
2333 gtk_tree_store_insert_with_values (store, &parent, NULL, 0,
2334 0, "Parent", 1, TRUE, -1);
2337 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
2338 gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (filter),
2341 tree_view = gtk_tree_view_new_with_model (filter);
2342 monitor = signal_monitor_new (filter);
2344 /* Insert child -- invisible */
2345 path = gtk_tree_path_new_from_indices (0, -1);
2346 signal_monitor_append_signal_path (monitor, ROW_HAS_CHILD_TOGGLED, path);
2347 /* The signal is received twice, once a pass through from GtkTreeStore
2348 * and one generated by GtkTreeModelFilter. Not accurate, but cannot
2351 signal_monitor_append_signal_path (monitor, ROW_HAS_CHILD_TOGGLED, path);
2352 gtk_tree_path_free (path);
2354 gtk_tree_store_insert_with_values (store, &iter, &parent, 1,
2355 0, "Child", 1, FALSE, -1);
2357 signal_monitor_assert_is_empty (monitor);
2358 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 1);
2361 path = gtk_tree_path_new_from_indices (0, 0, -1);
2362 signal_monitor_append_signal_path (monitor, ROW_INSERTED, path);
2363 gtk_tree_path_up (path); /* 0 */
2364 signal_monitor_append_signal_path (monitor, ROW_HAS_CHILD_TOGGLED, path);
2365 gtk_tree_path_free (path);
2367 gtk_tree_store_insert_with_values (store, &iter, &parent, 0,
2368 0, "Child", 1, TRUE, -1);
2370 signal_monitor_assert_is_empty (monitor);
2371 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 1);
2373 /* Insert child -- invisible */
2374 gtk_tree_store_insert_with_values (store, &iter, &parent, 1,
2375 0, "Child", 1, FALSE, -1);
2377 signal_monitor_assert_is_empty (monitor);
2378 check_level_length (GTK_TREE_MODEL_FILTER (filter), NULL, 1);
2386 GtkTreeIter iter, iter1, iter2, iter3;
2388 GtkTreeModel *filter;
2389 GtkWidget *view G_GNUC_UNUSED;
2391 list = gtk_list_store_new (1, G_TYPE_INT);
2392 gtk_list_store_insert_with_values (list, &iter1, 0, 0, 1, -1);
2393 gtk_list_store_insert_with_values (list, &iter, 1, 0, 2, -1);
2394 gtk_list_store_insert_with_values (list, &iter, 2, 0, 3, -1);
2395 gtk_list_store_insert_with_values (list, &iter, 3, 0, 4, -1);
2396 gtk_list_store_insert_with_values (list, &iter, 4, 0, 5, -1);
2397 gtk_list_store_insert_with_values (list, &iter, 5, 0, 6, -1);
2398 gtk_list_store_insert_with_values (list, &iter2, 6, 0, 7, -1);
2399 gtk_list_store_insert_with_values (list, &iter3, 7, 0, 8, -1);
2401 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (list), NULL);
2402 view = gtk_tree_view_new_with_model (filter);
2404 gtk_list_store_remove (list, &iter1);
2405 gtk_list_store_remove (list, &iter3);
2406 gtk_list_store_remove (list, &iter2);
2408 gtk_widget_destroy (view);
2409 g_object_unref (filter);
2410 g_object_unref (list);
2414 remove_node_vroot (void)
2416 GtkTreeIter parent, root;
2417 GtkTreeIter iter, iter1, iter2, iter3;
2419 GtkTreeModel *filter;
2421 GtkWidget *view G_GNUC_UNUSED;
2423 tree = gtk_tree_store_new (1, G_TYPE_INT);
2424 gtk_tree_store_insert_with_values (tree, &parent, NULL, 0, 0, 0, -1);
2425 gtk_tree_store_insert_with_values (tree, &root, &parent, 0, 0, 0, -1);
2427 gtk_tree_store_insert_with_values (tree, &iter1, &root, 0, 0, 1, -1);
2428 gtk_tree_store_insert_with_values (tree, &iter, &root, 1, 0, 2, -1);
2429 gtk_tree_store_insert_with_values (tree, &iter, &root, 2, 0, 3, -1);
2430 gtk_tree_store_insert_with_values (tree, &iter, &root, 3, 0, 4, -1);
2431 gtk_tree_store_insert_with_values (tree, &iter, &root, 4, 0, 5, -1);
2432 gtk_tree_store_insert_with_values (tree, &iter, &root, 5, 0, 6, -1);
2433 gtk_tree_store_insert_with_values (tree, &iter2, &root, 6, 0, 7, -1);
2434 gtk_tree_store_insert_with_values (tree, &iter3, &root, 7, 0, 8, -1);
2436 path = gtk_tree_path_new_from_indices (0, 0, -1);
2437 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (tree), path);
2438 gtk_tree_path_free (path);
2440 view = gtk_tree_view_new_with_model (filter);
2442 gtk_tree_store_remove (tree, &iter1);
2443 gtk_tree_store_remove (tree, &iter3);
2444 gtk_tree_store_remove (tree, &iter2);
2446 gtk_widget_destroy (view);
2447 g_object_unref (filter);
2448 g_object_unref (tree);
2452 remove_vroot_ancestor (void)
2454 GtkTreeIter parent, root;
2455 GtkTreeIter iter, iter1, iter2, iter3;
2457 GtkTreeModel *filter;
2459 GtkWidget *view G_GNUC_UNUSED;
2461 tree = gtk_tree_store_new (1, G_TYPE_INT);
2462 gtk_tree_store_insert_with_values (tree, &parent, NULL, 0, 0, 0, -1);
2463 gtk_tree_store_insert_with_values (tree, &root, &parent, 0, 0, 0, -1);
2465 gtk_tree_store_insert_with_values (tree, &iter1, &root, 0, 0, 1, -1);
2466 gtk_tree_store_insert_with_values (tree, &iter, &root, 1, 0, 2, -1);
2467 gtk_tree_store_insert_with_values (tree, &iter, &root, 2, 0, 3, -1);
2468 gtk_tree_store_insert_with_values (tree, &iter, &root, 3, 0, 4, -1);
2469 gtk_tree_store_insert_with_values (tree, &iter, &root, 4, 0, 5, -1);
2470 gtk_tree_store_insert_with_values (tree, &iter, &root, 5, 0, 6, -1);
2471 gtk_tree_store_insert_with_values (tree, &iter2, &root, 6, 0, 7, -1);
2472 gtk_tree_store_insert_with_values (tree, &iter3, &root, 7, 0, 8, -1);
2474 path = gtk_tree_path_new_from_indices (0, 0, -1);
2475 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (tree), path);
2476 gtk_tree_path_free (path);
2478 view = gtk_tree_view_new_with_model (filter);
2480 gtk_tree_store_remove (tree, &parent);
2482 gtk_widget_destroy (view);
2483 g_object_unref (filter);
2484 g_object_unref (tree);
2489 specific_path_dependent_filter_func (GtkTreeModel *model,
2495 path = gtk_tree_model_get_path (model, iter);
2496 if (gtk_tree_path_get_indices (path)[0] < 4)
2503 specific_path_dependent_filter (void)
2509 GtkTreeModel *filter;
2511 list = gtk_list_store_new (1, G_TYPE_INT);
2512 gtk_list_store_insert_with_values (list, &iter, 0, 0, 1, -1);
2513 gtk_list_store_insert_with_values (list, &iter, 1, 0, 2, -1);
2514 gtk_list_store_insert_with_values (list, &iter, 2, 0, 3, -1);
2515 gtk_list_store_insert_with_values (list, &iter, 3, 0, 4, -1);
2516 gtk_list_store_insert_with_values (list, &iter, 4, 0, 5, -1);
2517 gtk_list_store_insert_with_values (list, &iter, 5, 0, 6, -1);
2518 gtk_list_store_insert_with_values (list, &iter, 6, 0, 7, -1);
2519 gtk_list_store_insert_with_values (list, &iter, 7, 0, 8, -1);
2521 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (list));
2522 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (sort), NULL);
2523 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
2524 specific_path_dependent_filter_func,
2527 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort), 0,
2528 GTK_SORT_DESCENDING);
2530 for (i = 0; i < 4; i++)
2532 if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (list), &iter,
2534 gtk_list_store_remove (list, &iter);
2536 if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (list), &iter,
2538 gtk_list_store_remove (list, &iter);
2541 g_object_unref (filter);
2542 g_object_unref (sort);
2543 g_object_unref (list);
2548 specific_append_after_collapse_visible_func (GtkTreeModel *model,
2553 gboolean hide_negative_numbers;
2555 gtk_tree_model_get (model, iter, 1, &number, -1);
2556 hide_negative_numbers = GPOINTER_TO_INT (g_object_get_data (data, "private-hide-negative-numbers"));
2558 return (number >= 0 || !hide_negative_numbers);
2562 specific_append_after_collapse (void)
2564 /* This test is based on one of the test cases I found in my
2565 * old test cases directory. I unfortunately do not have a record
2566 * from who this test case originated. -Kris.
2570 * - Show tree, expand, collapse.
2575 GtkTreeIter child_iter;
2576 GtkTreeIter child_iter2;
2577 GtkTreePath *append_path;
2578 GtkTreeStore *store;
2579 GtkTreeModel *filter;
2583 GtkWidget *tree_view;
2585 store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_INT);
2587 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
2588 g_object_set_data (G_OBJECT (filter), "private-hide-negative-numbers",
2589 GINT_TO_POINTER (FALSE));
2590 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
2591 specific_append_after_collapse_visible_func,
2594 sort = gtk_tree_model_sort_new_with_model (filter);
2596 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2597 tree_view = gtk_tree_view_new_with_model (sort);
2598 gtk_container_add (GTK_CONTAINER (window), tree_view);
2599 gtk_widget_realize (tree_view);
2601 while (gtk_events_pending ())
2602 gtk_main_iteration ();
2604 gtk_tree_store_prepend (store, &iter, NULL);
2605 gtk_tree_store_set (store, &iter,
2606 0, "hallo", 1, 1, -1);
2608 gtk_tree_store_append (store, &child_iter, &iter);
2609 gtk_tree_store_set (store, &child_iter,
2610 0, "toemaar", 1, 1, -1);
2612 gtk_tree_store_append (store, &child_iter2, &child_iter);
2613 gtk_tree_store_set (store, &child_iter2,
2614 0, "very deep", 1, 1, -1);
2616 append_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &child_iter2);
2618 gtk_tree_store_append (store, &child_iter, &iter);
2619 gtk_tree_store_set (store, &child_iter,
2620 0, "sja", 1, 1, -1);
2622 gtk_tree_store_append (store, &child_iter, &iter);
2623 gtk_tree_store_set (store, &child_iter,
2624 0, "some word", 1, -1, -1);
2626 /* Expand and collapse the tree */
2627 gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
2628 while (gtk_events_pending ())
2629 gtk_main_iteration ();
2631 gtk_tree_view_collapse_all (GTK_TREE_VIEW (tree_view));
2632 while (gtk_events_pending ())
2633 gtk_main_iteration ();
2635 /* Add another it */
2636 g_object_set_data (G_OBJECT (filter), "private-hide-negative-numbers",
2637 GINT_TO_POINTER (TRUE));
2639 if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, append_path))
2641 gtk_tree_store_append (store, &child_iter, &iter);
2642 gtk_tree_store_set (store, &child_iter,
2643 0, "new new new !!", 1, 1, -1);
2645 gtk_tree_path_free (append_path);
2648 gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
2649 while (gtk_events_pending ())
2650 gtk_main_iteration ();
2655 specific_sort_filter_remove_node_compare_func (GtkTreeModel *model,
2664 specific_sort_filter_remove_node_visible_func (GtkTreeModel *model,
2670 /* Do reference the model */
2671 gtk_tree_model_get (model, iter, 0, &item, -1);
2678 specific_sort_filter_remove_node (void)
2680 /* This test is based on one of the test cases I found in my
2681 * old test cases directory. I unfortunately do not have a record
2682 * from who this test case originated. -Kris.
2685 * - Create tree store, sort, filter models. The sort model has
2686 * a default sort func that is enabled, filter model a visible func
2687 * that defaults to returning FALSE.
2688 * - Remove a node from the tree store.
2692 GtkTreeStore *store;
2693 GtkTreeModel *filter;
2697 GtkWidget *tree_view;
2699 store = gtk_tree_store_new (1, G_TYPE_STRING);
2700 gtk_tree_store_append (store, &iter, NULL);
2701 gtk_tree_store_set (store, &iter, 0, "Hello1", -1);
2703 gtk_tree_store_append (store, &iter, NULL);
2704 gtk_tree_store_set (store, &iter, 0, "Hello2", -1);
2706 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
2707 gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (sort),
2708 specific_sort_filter_remove_node_compare_func, NULL, NULL);
2710 filter = gtk_tree_model_filter_new (sort, NULL);
2711 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
2712 specific_sort_filter_remove_node_visible_func,
2716 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2717 tree_view = gtk_tree_view_new_with_model (filter);
2718 gtk_container_add (GTK_CONTAINER (window), tree_view);
2719 gtk_widget_realize (tree_view);
2721 while (gtk_events_pending ())
2722 gtk_main_iteration ();
2725 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
2726 gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
2727 gtk_tree_store_remove (store, &iter);
2729 while (gtk_events_pending ())
2730 gtk_main_iteration ();
2735 specific_sort_filter_remove_root (void)
2737 /* This test is based on one of the test cases I found in my
2738 * old test cases directory. I unfortunately do not have a record
2739 * from who this test case originated. -Kris.
2742 GtkTreeModel *model, *sort, *filter;
2743 GtkTreeIter root, mid, leaf;
2746 model = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_INT));
2747 gtk_tree_store_append (GTK_TREE_STORE (model), &root, NULL);
2748 gtk_tree_store_append (GTK_TREE_STORE (model), &mid, &root);
2749 gtk_tree_store_append (GTK_TREE_STORE (model), &leaf, &mid);
2751 path = gtk_tree_model_get_path (model, &mid);
2753 sort = gtk_tree_model_sort_new_with_model (model);
2754 filter = gtk_tree_model_filter_new (sort, path);
2756 gtk_tree_path_free (path);
2758 gtk_tree_store_remove (GTK_TREE_STORE (model), &root);
2760 g_object_unref (filter);
2761 g_object_unref (sort);
2762 g_object_unref (model);
2767 specific_root_mixed_visibility (void)
2770 GtkTreeModel *filter;
2771 /* A bit nasty, apologies */
2774 fixture.store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
2776 for (i = 0; i < LEVEL_LENGTH; i++)
2780 gtk_tree_store_insert (fixture.store, &iter, NULL, i);
2782 create_tree_store_set_values (fixture.store, &iter, TRUE);
2784 create_tree_store_set_values (fixture.store, &iter, FALSE);
2787 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (fixture.store), NULL);
2788 fixture.filter = GTK_TREE_MODEL_FILTER (filter);
2789 fixture.monitor = NULL;
2791 gtk_tree_model_filter_set_visible_column (fixture.filter, 1);
2793 /* In order to trigger the potential bug, we should not access
2794 * the filter model here (so don't call the check functions).
2797 /* Change visibility of an odd row to TRUE */
2798 set_path_visibility (&fixture, "3", TRUE);
2799 check_filter_model (&fixture);
2800 check_level_length (fixture.filter, NULL, 4);
2806 specific_has_child_filter_filter_func (GtkTreeModel *model,
2810 return gtk_tree_model_iter_has_child (model, iter);
2814 specific_has_child_filter (void)
2816 GtkTreeModel *filter;
2817 GtkTreeIter iter, root;
2818 FilterTest fixture; /* This is not how it should be done */
2819 GtkWidget *tree_view;
2821 fixture.store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
2822 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (fixture.store), NULL);
2823 fixture.filter = GTK_TREE_MODEL_FILTER (filter);
2824 fixture.monitor = signal_monitor_new (filter);
2826 tree_view = gtk_tree_view_new_with_model (filter);
2828 /* We will filter on parent state using a filter function. We will
2829 * manually keep the boolean column in sync, so that we can use
2830 * check_filter_model() to check the consistency of the model.
2832 /* FIXME: We need a check_filter_model() that is not tied to LEVEL_LENGTH
2833 * to be able to check the structure here. We keep the calls to
2834 * check_filter_model() commented out until then.
2836 gtk_tree_model_filter_set_visible_func (fixture.filter,
2837 specific_has_child_filter_filter_func,
2840 /* The first node will be initially invisible: no signals */
2841 gtk_tree_store_append (fixture.store, &root, NULL);
2842 create_tree_store_set_values (fixture.store, &root, FALSE);
2844 /* check_filter_model (&fixture); */
2845 check_level_length (fixture.filter, NULL, 0);
2846 signal_monitor_assert_is_empty (fixture.monitor);
2848 /* Insert a child node. This will cause the parent to become visible
2849 * since there is a child now.
2851 signal_monitor_append_signal (fixture.monitor, ROW_INSERTED, "0");
2852 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "0");
2853 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "0");
2855 gtk_tree_store_append (fixture.store, &iter, &root);
2856 create_tree_store_set_values (fixture.store, &iter, TRUE);
2858 /* Parent must now be visible. Do the level length check first,
2859 * to avoid modifying the child model triggering a row-changed to
2862 check_level_length (fixture.filter, NULL, 1);
2863 check_level_length (fixture.filter, "0", 0);
2864 signal_monitor_assert_is_empty (fixture.monitor);
2866 /* This should propagate row-changed */
2867 signal_monitor_append_signal (fixture.monitor, ROW_CHANGED, "0");
2868 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "0");
2870 set_path_visibility (&fixture, "0", TRUE);
2871 /* check_filter_model (&fixture); */
2872 signal_monitor_assert_is_empty (fixture.monitor);
2874 /* New root node, no child, so no signal */
2875 gtk_tree_store_append (fixture.store, &root, NULL);
2876 check_level_length (fixture.filter, NULL, 1);
2877 signal_monitor_assert_is_empty (fixture.monitor);
2879 /* When the child comes in, this node will become visible */
2880 signal_monitor_append_signal (fixture.monitor, ROW_INSERTED, "1");
2881 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "1");
2882 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "1");
2883 signal_monitor_append_signal (fixture.monitor, ROW_CHANGED, "1");
2884 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "1");
2886 gtk_tree_store_append (fixture.store, &iter, &root);
2887 check_level_length (fixture.filter, NULL, 2);
2888 check_level_length (fixture.filter, "1", 0);
2890 create_tree_store_set_values (fixture.store, &root, TRUE);
2891 create_tree_store_set_values (fixture.store, &iter, TRUE);
2893 /* check_filter_model (&fixture); */
2894 signal_monitor_assert_is_empty (fixture.monitor);
2896 /* Add another child for 1 */
2897 gtk_tree_store_append (fixture.store, &iter, &root);
2898 create_tree_store_set_values (fixture.store, &iter, TRUE);
2899 check_level_length (fixture.filter, NULL, 2);
2900 check_level_length (fixture.filter, "0", 0);
2901 check_level_length (fixture.filter, "1", 0);
2902 signal_monitor_assert_is_empty (fixture.monitor);
2904 /* Now remove one of the remaining child rows */
2905 signal_monitor_append_signal (fixture.monitor, ROW_DELETED, "0");
2907 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture.store),
2909 gtk_tree_store_remove (fixture.store, &iter);
2911 check_level_length (fixture.filter, NULL, 1);
2912 check_level_length (fixture.filter, "0", 0);
2914 set_path_visibility (&fixture, "0", FALSE);
2915 /* check_filter_model (&fixture); */
2916 signal_monitor_assert_is_empty (fixture.monitor);
2921 specific_root_has_child_filter_filter_func (GtkTreeModel *model,
2928 path = gtk_tree_model_get_path (model, iter);
2929 depth = gtk_tree_path_get_depth (path);
2930 gtk_tree_path_free (path);
2935 return gtk_tree_model_iter_has_child (model, iter);
2939 specific_root_has_child_filter (void)
2941 GtkTreeModel *filter;
2942 GtkTreeIter iter, root;
2943 FilterTest fixture; /* This is not how it should be done ... */
2944 GtkWidget *tree_view;
2946 /* This is a variation on the above test case, specific has-child-filter,
2947 * herein the has-child check for visibility only applies to root level
2948 * nodes. In this test, children are always visible because we
2949 * only filter based on the "has child" criterion.
2952 fixture.store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
2953 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (fixture.store), NULL);
2954 fixture.filter = GTK_TREE_MODEL_FILTER (filter);
2955 fixture.monitor = signal_monitor_new (filter);
2957 tree_view = gtk_tree_view_new_with_model (filter);
2959 /* We will filter on parent state using a filter function. We will
2960 * manually keep the boolean column in sync, so that we can use
2961 * check_filter_model() to check the consistency of the model.
2963 /* FIXME: We need a check_filter_model() that is not tied to LEVEL_LENGTH
2964 * to be able to check the structure here. We keep the calls to
2965 * check_filter_model() commented out until then.
2967 gtk_tree_model_filter_set_visible_func (fixture.filter,
2968 specific_root_has_child_filter_filter_func,
2971 /* Add a first node, this will be invisible initially, so no signal
2972 * should be emitted.
2974 gtk_tree_store_append (fixture.store, &root, NULL);
2975 create_tree_store_set_values (fixture.store, &root, FALSE);
2977 signal_monitor_assert_is_empty (fixture.monitor);
2978 /* check_filter_model (&fixture); */
2979 check_level_length (fixture.filter, NULL, 0);
2981 /* Add a child node. This will cause the parent to become visible,
2982 * so we expect row-inserted signals for both.
2984 signal_monitor_append_signal (fixture.monitor, ROW_INSERTED, "0");
2985 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "0");
2986 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "0");
2988 gtk_tree_store_append (fixture.store, &iter, &root);
2989 signal_monitor_assert_is_empty (fixture.monitor);
2991 check_level_length (fixture.filter, NULL, 1);
2992 check_level_length (fixture.filter, "0", 1);
2994 /* Modify the content of iter, yields row-changed signals */
2995 signal_monitor_append_signal (fixture.monitor, ROW_CHANGED, "0:0");
2997 create_tree_store_set_values (fixture.store, &iter, TRUE);
2998 signal_monitor_assert_is_empty (fixture.monitor);
3000 /* Parent must now be visible. Do the level length check first,
3001 * to avoid modifying the child model triggering a row-changed to
3004 check_level_length (fixture.filter, NULL, 1);
3005 check_level_length (fixture.filter, "0", 1);
3008 signal_monitor_append_signal (fixture.monitor, ROW_CHANGED, "0");
3009 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "0");
3011 set_path_visibility (&fixture, "0", TRUE);
3012 /* check_filter_model (&fixture); */
3014 signal_monitor_assert_is_empty (fixture.monitor);
3016 /* Insert another node in the root level. Initially invisible, so
3017 * not expecting any signal.
3019 gtk_tree_store_append (fixture.store, &root, NULL);
3020 check_level_length (fixture.filter, NULL, 1);
3022 signal_monitor_assert_is_empty (fixture.monitor);
3024 /* Adding a child node which also makes parent at path 1 visible. */
3025 signal_monitor_append_signal (fixture.monitor, ROW_INSERTED, "1");
3026 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "1");
3027 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "1");
3029 gtk_tree_store_append (fixture.store, &iter, &root);
3030 check_level_length (fixture.filter, NULL, 2);
3031 check_level_length (fixture.filter, "1", 1);
3033 signal_monitor_assert_is_empty (fixture.monitor);
3035 /* Check if row-changed is propagated */
3036 signal_monitor_append_signal (fixture.monitor, ROW_CHANGED, "1");
3037 /* is row-has-child-toggled really necessary? */
3038 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "1");
3039 signal_monitor_append_signal (fixture.monitor, ROW_CHANGED, "1:0");
3041 create_tree_store_set_values (fixture.store, &root, TRUE);
3042 create_tree_store_set_values (fixture.store, &iter, TRUE);
3043 /* check_filter_model (&fixture); */
3044 signal_monitor_assert_is_empty (fixture.monitor);
3046 /* Insert another child under node 1 */
3047 signal_monitor_append_signal (fixture.monitor, ROW_INSERTED, "1:1");
3048 signal_monitor_append_signal (fixture.monitor, ROW_CHANGED, "1:1");
3050 gtk_tree_store_append (fixture.store, &iter, &root);
3051 create_tree_store_set_values (fixture.store, &iter, TRUE);
3052 check_level_length (fixture.filter, NULL, 2);
3053 check_level_length (fixture.filter, "0", 1);
3054 check_level_length (fixture.filter, "1", 2);
3055 signal_monitor_assert_is_empty (fixture.monitor);
3057 /* Set a child node to invisible. This should not yield any
3058 * change, because filtering is only done on whether the root
3059 * node has a child, which it still has.
3061 signal_monitor_append_signal (fixture.monitor, ROW_CHANGED, "0:0");
3063 set_path_visibility (&fixture, "0:0", FALSE);
3064 signal_monitor_assert_is_empty (fixture.monitor);
3066 /* Now remove one of the remaining child rows */
3067 signal_monitor_append_signal (fixture.monitor, ROW_DELETED, "0:0");
3068 signal_monitor_append_signal (fixture.monitor, ROW_HAS_CHILD_TOGGLED, "0");
3069 signal_monitor_append_signal (fixture.monitor, ROW_DELETED, "0");
3071 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture.store),
3073 gtk_tree_store_remove (fixture.store, &iter);
3075 check_level_length (fixture.filter, NULL, 1);
3076 check_level_length (fixture.filter, "0", 2);
3077 signal_monitor_assert_is_empty (fixture.monitor);
3079 /* Set visibility of 0 to FALSE, no-op for filter model since
3080 * the child 0:0 is already gone
3082 set_path_visibility (&fixture, "0", FALSE);
3083 /* check_filter_model (&fixture); */
3084 signal_monitor_assert_is_empty (fixture.monitor);
3089 specific_filter_add_child (void)
3091 /* This test is based on one of the test cases I found in my
3092 * old test cases directory. I unfortunately do not have a record
3093 * from who this test case originated. -Kris.
3097 GtkTreeIter iter_first;
3099 GtkTreeStore *store;
3100 GtkTreeModel *filter G_GNUC_UNUSED;
3102 store = gtk_tree_store_new (1, G_TYPE_STRING);
3104 gtk_tree_store_append (store, &iter_first, NULL);
3105 gtk_tree_store_set (store, &iter_first, 0, "Hello", -1);
3107 gtk_tree_store_append (store, &iter, NULL);
3108 gtk_tree_store_set (store, &iter, 0, "Hello", -1);
3110 gtk_tree_store_append (store, &iter, NULL);
3111 gtk_tree_store_set (store, &iter, 0, "Hello", -1);
3113 gtk_tree_store_append (store, &iter, NULL);
3114 gtk_tree_store_set (store, &iter, 0, "Hello", -1);
3116 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
3118 gtk_tree_store_set (store, &iter, 0, "Hello", -1);
3119 gtk_tree_store_append (store, &child, &iter_first);
3120 gtk_tree_store_set (store, &child, 0, "Hello", -1);
3124 specific_list_store_clear (void)
3128 GtkTreeModel *filter;
3129 GtkWidget *view G_GNUC_UNUSED;
3131 list = gtk_list_store_new (1, G_TYPE_INT);
3132 gtk_list_store_insert_with_values (list, &iter, 0, 0, 1, -1);
3133 gtk_list_store_insert_with_values (list, &iter, 1, 0, 2, -1);
3134 gtk_list_store_insert_with_values (list, &iter, 2, 0, 3, -1);
3135 gtk_list_store_insert_with_values (list, &iter, 3, 0, 4, -1);
3136 gtk_list_store_insert_with_values (list, &iter, 4, 0, 5, -1);
3137 gtk_list_store_insert_with_values (list, &iter, 5, 0, 6, -1);
3138 gtk_list_store_insert_with_values (list, &iter, 6, 0, 7, -1);
3139 gtk_list_store_insert_with_values (list, &iter, 7, 0, 8, -1);
3141 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (list), NULL);
3142 view = gtk_tree_view_new_with_model (filter);
3144 gtk_list_store_clear (list);
3148 specific_sort_ref_leaf_and_remove_ancestor (void)
3150 GtkTreeIter iter, child, child2, child3;
3154 GtkTreeRowReference *rowref;
3155 GtkWidget *view G_GNUC_UNUSED;
3157 tree = gtk_tree_store_new (1, G_TYPE_INT);
3158 gtk_tree_store_insert_with_values (tree, &iter, NULL, 0, 0, 1, -1);
3159 gtk_tree_store_insert_with_values (tree, &iter, NULL, 1, 0, 2, -1);
3160 gtk_tree_store_insert_with_values (tree, &iter, NULL, 2, 0, 3, -1);
3161 gtk_tree_store_insert_with_values (tree, &iter, NULL, 3, 0, 4, -1);
3163 gtk_tree_store_insert_with_values (tree, &child, &iter, 0, 0, 50, -1);
3164 gtk_tree_store_insert_with_values (tree, &child2, &child, 0, 0, 6, -1);
3165 gtk_tree_store_insert_with_values (tree, &child3, &child2, 0, 0, 7, -1);
3167 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (tree));
3168 view = gtk_tree_view_new_with_model (sort);
3169 gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
3171 path = gtk_tree_path_new_from_indices (3, 0, 0, 0, -1);
3172 rowref = gtk_tree_row_reference_new (sort, path);
3173 gtk_tree_path_free (path);
3175 path = gtk_tree_path_new_from_indices (3, 0, 0, 0, -1);
3176 rowref = gtk_tree_row_reference_new (sort, path);
3177 gtk_tree_path_free (path);
3179 path = gtk_tree_path_new_from_indices (3, 0, -1);
3180 rowref = gtk_tree_row_reference_new (sort, path);
3181 gtk_tree_path_free (path);
3183 path = gtk_tree_path_new_from_indices (3, -1);
3184 rowref = gtk_tree_row_reference_new (sort, path);
3185 gtk_tree_path_free (path);
3187 /* Deleting a parent */
3188 path = gtk_tree_path_new_from_indices (3, 0, -1);
3189 gtk_tree_model_get_iter (GTK_TREE_MODEL (tree), &iter, path);
3190 gtk_tree_store_remove (tree, &iter);
3191 gtk_tree_path_free (path);
3193 gtk_tree_row_reference_free (rowref);
3197 specific_ref_leaf_and_remove_ancestor (void)
3199 GtkTreeIter iter, child, child2, child3;
3201 GtkTreeModel *filter;
3203 GtkTreeRowReference *rowref;
3204 GtkWidget *view G_GNUC_UNUSED;
3206 tree = gtk_tree_store_new (1, G_TYPE_INT);
3207 gtk_tree_store_insert_with_values (tree, &iter, NULL, 0, 0, 1, -1);
3208 gtk_tree_store_insert_with_values (tree, &iter, NULL, 1, 0, 2, -1);
3209 gtk_tree_store_insert_with_values (tree, &iter, NULL, 2, 0, 3, -1);
3210 gtk_tree_store_insert_with_values (tree, &iter, NULL, 3, 0, 4, -1);
3212 gtk_tree_store_insert_with_values (tree, &child, &iter, 0, 0, 50, -1);
3213 gtk_tree_store_insert_with_values (tree, &child2, &child, 0, 0, 6, -1);
3214 gtk_tree_store_insert_with_values (tree, &child3, &child2, 0, 0, 7, -1);
3216 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (tree), NULL);
3217 view = gtk_tree_view_new_with_model (filter);
3218 gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
3220 path = gtk_tree_path_new_from_indices (3, 0, 0, 0, -1);
3221 rowref = gtk_tree_row_reference_new (filter, path);
3222 gtk_tree_path_free (path);
3224 path = gtk_tree_path_new_from_indices (3, 0, 0, 0, -1);
3225 rowref = gtk_tree_row_reference_new (filter, path);
3226 gtk_tree_path_free (path);
3228 path = gtk_tree_path_new_from_indices (3, 0, -1);
3229 rowref = gtk_tree_row_reference_new (filter, path);
3230 gtk_tree_path_free (path);
3232 path = gtk_tree_path_new_from_indices (3, -1);
3233 rowref = gtk_tree_row_reference_new (filter, path);
3234 gtk_tree_path_free (path);
3236 /* Deleting a parent */
3237 path = gtk_tree_path_new_from_indices (3, 0, -1);
3238 gtk_tree_model_get_iter (GTK_TREE_MODEL (tree), &iter, path);
3239 gtk_tree_store_remove (tree, &iter);
3240 gtk_tree_path_free (path);
3242 gtk_tree_row_reference_free (rowref);
3246 specific_virtual_ref_leaf_and_remove_ancestor (void)
3248 GtkTreeIter iter, child, child2, child3;
3250 GtkTreeModel *filter;
3252 GtkTreeRowReference *rowref;
3253 GtkWidget *view G_GNUC_UNUSED;
3255 tree = gtk_tree_store_new (1, G_TYPE_INT);
3256 gtk_tree_store_insert_with_values (tree, &iter, NULL, 0, 0, 1, -1);
3257 gtk_tree_store_insert_with_values (tree, &iter, NULL, 1, 0, 2, -1);
3258 gtk_tree_store_insert_with_values (tree, &iter, NULL, 2, 0, 3, -1);
3259 gtk_tree_store_insert_with_values (tree, &iter, NULL, 3, 0, 4, -1);
3261 gtk_tree_store_insert_with_values (tree, &child, &iter, 0, 0, 50, -1);
3262 gtk_tree_store_insert_with_values (tree, &child2, &child, 0, 0, 6, -1);
3263 gtk_tree_store_insert_with_values (tree, &child3, &child2, 0, 0, 7, -1);
3265 /* Set a virtual root of 3:0 */
3266 path = gtk_tree_path_new_from_indices (3, 0, -1);
3267 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (tree), path);
3268 gtk_tree_path_free (path);
3270 view = gtk_tree_view_new_with_model (filter);
3271 gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
3273 path = gtk_tree_path_new_from_indices (0, 0, -1);
3274 rowref = gtk_tree_row_reference_new (filter, path);
3275 gtk_tree_path_free (path);
3277 path = gtk_tree_path_new_from_indices (0, 0, -1);
3278 rowref = gtk_tree_row_reference_new (filter, path);
3279 gtk_tree_path_free (path);
3281 path = gtk_tree_path_new_from_indices (0, -1);
3282 rowref = gtk_tree_row_reference_new (filter, path);
3283 gtk_tree_path_free (path);
3285 /* Deleting the virtual root */
3286 path = gtk_tree_path_new_from_indices (3, 0, -1);
3287 gtk_tree_model_get_iter (GTK_TREE_MODEL (tree), &iter, path);
3288 gtk_tree_store_remove (tree, &iter);
3289 gtk_tree_path_free (path);
3291 gtk_tree_row_reference_free (rowref);
3296 specific_bug_301558_sort_func (GtkTreeModel *model,
3303 gtk_tree_model_get (model, a, 0, &i, -1);
3304 gtk_tree_model_get (model, b, 0, &j, -1);
3310 specific_bug_301558 (void)
3312 /* Test case for GNOME Bugzilla bug 301558 provided by
3316 GtkTreeModel *filter;
3318 GtkTreeIter root, iter, iter2;
3319 GtkWidget *view G_GNUC_UNUSED;
3323 g_test_bug ("301558");
3325 tree = gtk_tree_store_new (2, G_TYPE_INT, G_TYPE_BOOLEAN);
3326 gtk_tree_store_append (tree, &iter, NULL);
3327 gtk_tree_store_set (tree, &iter, 0, 123, 1, TRUE, -1);
3328 gtk_tree_store_append (tree, &iter2, &iter);
3329 gtk_tree_store_set (tree, &iter2, 0, 73, 1, TRUE, -1);
3331 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (tree));
3332 gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (sort),
3333 specific_bug_301558_sort_func,
3336 filter = gtk_tree_model_filter_new (sort, NULL);
3337 gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (filter), 1);
3339 view = gtk_tree_view_new_with_model (filter);
3341 while (gtk_events_pending ())
3342 gtk_main_iteration ();
3346 for (i = 0; i < 10; i++)
3348 if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tree), &root))
3349 g_assert_not_reached ();
3353 gtk_tree_store_append (tree, &iter, &root);
3354 gtk_tree_store_set (tree, &iter, 0, 456, 1, TRUE, -1);
3359 n = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (tree), &root);
3360 gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (tree), &iter,
3362 gtk_tree_store_remove (tree, &iter);
3371 specific_bug_311955_filter_func (GtkTreeModel *model,
3377 gtk_tree_model_get (model, iter, 0, &value, -1);
3379 return (value != 0);
3383 specific_bug_311955 (void)
3385 /* This is a test case for GNOME Bugzilla bug 311955. It was written
3388 GtkTreeIter iter, child, root;
3389 GtkTreeStore *store;
3391 GtkTreeModel *filter;
3393 GtkWidget *window G_GNUC_UNUSED;
3394 GtkWidget *tree_view;
3398 g_test_bug ("311955");
3400 store = gtk_tree_store_new (1, G_TYPE_INT);
3402 gtk_tree_store_append (store, &root, NULL);
3403 gtk_tree_store_set (store, &root, 0, 33, -1);
3405 gtk_tree_store_append (store, &iter, &root);
3406 gtk_tree_store_set (store, &iter, 0, 50, -1);
3408 gtk_tree_store_append (store, &iter, NULL);
3409 gtk_tree_store_set (store, &iter, 0, 22, -1);
3411 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
3412 filter = gtk_tree_model_filter_new (sort, NULL);
3414 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
3415 specific_bug_311955_filter_func,
3418 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3419 tree_view = gtk_tree_view_new_with_model (filter);
3420 g_object_unref (store);
3422 gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
3424 while (gtk_events_pending ())
3425 gtk_main_iteration ();
3428 for (i = 0; i < 4; i++)
3430 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &root);
3432 gtk_tree_store_append (store, &iter, &root);
3435 gtk_tree_store_set (store, &iter, 0, i, -1);
3439 gtk_tree_store_append (store, &child, &iter);
3440 gtk_tree_store_set (store, &child, 0, 10, -1);
3444 while (gtk_events_pending ())
3445 gtk_main_iteration ();
3447 /* Remove bottommost child from the tree. */
3448 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &root);
3449 n = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), &root);
3451 if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter, &root, n - 2))
3453 if (gtk_tree_model_iter_children (GTK_TREE_MODEL (store), &child, &iter))
3454 gtk_tree_store_remove (store, &child);
3457 g_assert_not_reached ();
3461 specific_bug_346800 (void)
3463 /* This is a test case for GNOME Bugzilla bug 346800. It was written
3464 * by Jonathan Matthew.
3467 GtkTreeIter node_iters[50];
3468 GtkTreeIter child_iters[50];
3469 GtkTreeModel *model;
3470 GtkTreeModelFilter *filter;
3471 GtkTreeStore *store;
3475 columns = g_new (GType, 2);
3476 columns[0] = G_TYPE_STRING;
3477 columns[1] = G_TYPE_BOOLEAN;
3478 store = gtk_tree_store_newv (2, columns);
3479 model = GTK_TREE_MODEL (store);
3481 g_test_bug ("346800");
3483 filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (model, NULL));
3484 gtk_tree_model_filter_set_visible_column (filter, 1);
3486 for (i=0; i<items; i++)
3488 /* allocate random amounts of junk, otherwise the filter model's arrays can expand without moving */
3491 gtk_tree_store_append (store, &node_iters[i], NULL);
3492 gtk_tree_store_set (store, &node_iters[i],
3494 1, ((i%6) == 0) ? FALSE : TRUE,
3498 gtk_tree_store_append (store, &child_iters[i], &node_iters[i]);
3499 gtk_tree_store_set (store, &child_iters[i],
3500 0, "something else",
3503 gtk_tree_model_filter_refilter (filter);
3507 gtk_tree_store_set (GTK_TREE_STORE (model), &child_iters[i-1], 1,
3508 (i & 1) ? TRUE : FALSE, -1);
3509 gtk_tree_model_filter_refilter (filter);
3511 gtk_tree_store_set (GTK_TREE_STORE (model), &child_iters[i-2], 1,
3512 (i & 1) ? FALSE: TRUE, -1);
3513 gtk_tree_model_filter_refilter (filter);
3519 specific_bug_464173_visible_func (GtkTreeModel *model,
3523 gboolean *visible = (gboolean *)data;
3529 specific_bug_464173 (void)
3531 /* Test case for GNOME Bugzilla bug 464173, test case written
3532 * by Andreas Koehler.
3534 GtkTreeStore *model;
3535 GtkTreeModelFilter *f_model;
3536 GtkTreeIter iter1, iter2;
3537 GtkWidget *view G_GNUC_UNUSED;
3538 gboolean visible = TRUE;
3540 g_test_bug ("464173");
3542 model = gtk_tree_store_new (1, G_TYPE_STRING);
3543 gtk_tree_store_append (model, &iter1, NULL);
3544 gtk_tree_store_set (model, &iter1, 0, "Foo", -1);
3545 gtk_tree_store_append (model, &iter2, &iter1);
3546 gtk_tree_store_set (model, &iter2, 0, "Bar", -1);
3548 f_model = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (GTK_TREE_MODEL(model), NULL));
3549 gtk_tree_model_filter_set_visible_func (f_model,
3550 specific_bug_464173_visible_func,
3553 view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (f_model));
3556 gtk_tree_model_filter_refilter (f_model);
3561 specific_bug_540201_filter_func (GtkTreeModel *model,
3565 gboolean has_children;
3567 has_children = gtk_tree_model_iter_has_child (model, iter);
3569 return has_children;
3573 specific_bug_540201 (void)
3575 /* Test case for GNOME Bugzilla bug 540201, steps provided by
3578 GtkTreeIter iter, root;
3579 GtkTreeStore *store;
3580 GtkTreeModel *filter;
3582 GtkWidget *tree_view G_GNUC_UNUSED;
3584 g_test_bug ("540201");
3586 store = gtk_tree_store_new (1, G_TYPE_INT);
3588 gtk_tree_store_append (store, &root, NULL);
3589 gtk_tree_store_set (store, &root, 0, 33, -1);
3591 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
3592 tree_view = gtk_tree_view_new_with_model (filter);
3594 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
3595 specific_bug_540201_filter_func,
3598 gtk_tree_store_append (store, &iter, &root);
3599 gtk_tree_store_set (store, &iter, 0, 50, -1);
3601 gtk_tree_store_append (store, &iter, &root);
3602 gtk_tree_store_set (store, &iter, 0, 22, -1);
3605 gtk_tree_store_append (store, &root, NULL);
3606 gtk_tree_store_set (store, &root, 0, 33, -1);
3608 gtk_tree_store_append (store, &iter, &root);
3609 gtk_tree_store_set (store, &iter, 0, 22, -1);
3614 specific_bug_549287_visible_func (GtkTreeModel *model,
3618 gboolean result = FALSE;
3620 result = gtk_tree_model_iter_has_child (model, iter);
3626 specific_bug_549287 (void)
3628 /* Test case for GNOME Bugzilla bug 529287, provided by Julient Puydt */
3631 GtkTreeStore *store;
3632 GtkTreeModel *filtered;
3633 GtkWidget *view G_GNUC_UNUSED;
3635 GtkTreeIter *swap, *parent, *child;
3637 g_test_bug ("529287");
3639 store = gtk_tree_store_new (1, G_TYPE_STRING);
3640 filtered = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
3641 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filtered),
3642 specific_bug_549287_visible_func,
3645 view = gtk_tree_view_new_with_model (filtered);
3647 for (i = 0; i < 4; i++)
3649 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
3651 parent = gtk_tree_iter_copy (&iter);
3652 child = gtk_tree_iter_copy (&iter);
3654 while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store),
3663 gtk_tree_store_append (store, child, parent);
3664 gtk_tree_store_set (store, child,
3668 gtk_tree_iter_free (parent);
3669 gtk_tree_iter_free (child);
3673 gtk_tree_store_append (store, &iter, NULL);
3674 gtk_tree_store_set (store, &iter,
3679 /* since we inserted something, we changed the visibility conditions: */
3680 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filtered));
3685 specific_bug_621076_visible_func (GtkTreeModel *model,
3689 gboolean visible = FALSE;
3692 gtk_tree_model_get (model, iter, 0, &str, -1);
3693 if (str != NULL && g_str_has_prefix (str, "visible"))
3699 GtkTreeIter child_iter;
3702 /* Recursively check if we have a visible child */
3703 for (valid = gtk_tree_model_iter_children (model, &child_iter, iter);
3704 valid; valid = gtk_tree_model_iter_next (model, &child_iter))
3706 if (specific_bug_621076_visible_func (model, &child_iter, data))
3721 specific_bug_621076 (void)
3723 /* Test case for GNOME Bugzilla bug 621076, provided by Xavier Claessens */
3725 /* This test case differs from has-child-filter and root-has-child-filter
3726 * in that the visible function both filters on content and model
3727 * structure. Also, it is recursive.
3730 GtkTreeStore *store;
3731 GtkTreeModel *filter;
3733 GtkTreeIter group_iter;
3734 GtkTreeIter item_iter;
3735 SignalMonitor *monitor;
3737 g_test_bug ("621076");
3739 store = gtk_tree_store_new (1, G_TYPE_STRING);
3740 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
3741 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
3742 specific_bug_621076_visible_func,
3745 view = gtk_tree_view_new_with_model (filter);
3746 g_object_ref_sink (view);
3748 monitor = signal_monitor_new (filter);
3750 signal_monitor_append_signal (monitor, ROW_INSERTED, "0");
3751 gtk_tree_store_insert_with_values (store, &item_iter, NULL, -1,
3752 0, "visible-group-0",
3754 signal_monitor_assert_is_empty (monitor);
3756 /* visible-group-0 is not expanded, so ROW_INSERTED should not be emitted
3757 * for its children. However, ROW_HAS_CHILD_TOGGLED should be emitted on
3758 * visible-group-0 to tell the view that row can be expanded. */
3759 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "0");
3760 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "0");
3761 group_iter = item_iter;
3762 gtk_tree_store_insert_with_values (store, &item_iter, &group_iter, -1,
3765 signal_monitor_assert_is_empty (monitor);
3767 signal_monitor_append_signal (monitor, ROW_INSERTED, "1");
3768 gtk_tree_store_insert_with_values (store, &item_iter, NULL, -1,
3769 0, "visible-group-1",
3771 signal_monitor_assert_is_empty (monitor);
3773 /* We are adding an hidden item inside visible-group-1, so
3774 * ROW_HAS_CHILD_TOGGLED should not be emitted. It is emitted though,
3775 * because the signal originating at TreeStore will be propagated,
3776 * as well a generated signal because the state of the parent *could*
3777 * change by a change in the model.
3779 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "1");
3780 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "1");
3781 group_iter = item_iter;
3782 gtk_tree_store_insert_with_values (store, &item_iter, &group_iter, -1,
3785 signal_monitor_assert_is_empty (monitor);
3787 /* This group is invisible and its parent too. Nothing should be emitted */
3788 group_iter = item_iter;
3789 gtk_tree_store_insert_with_values (store, &item_iter, &group_iter, -1,
3792 signal_monitor_assert_is_empty (monitor);
3794 /* Adding a visible item in this group hierarchy will make all nodes
3795 * in this path visible. The first level should simply tell the view
3796 * that it now has a child, and the view will load the tree if needed
3797 * (depends on the expanded state).
3799 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "1");
3800 group_iter = item_iter;
3801 gtk_tree_store_insert_with_values (store, &item_iter, &group_iter, -1,
3802 0, "visible-1:0:0:0",
3804 signal_monitor_assert_is_empty (monitor);
3806 check_level_length (GTK_TREE_MODEL_FILTER (filter), "1", 1);
3808 gtk_tree_store_insert_with_values (store, &item_iter, NULL, -1,
3811 signal_monitor_assert_is_empty (monitor);
3813 /* Parent is invisible, and adding this invisible item won't change that,
3814 * so no signal should be emitted. */
3815 group_iter = item_iter;
3816 gtk_tree_store_insert_with_values (store, NULL, &group_iter, -1,
3819 signal_monitor_assert_is_empty (monitor);
3821 /* This makes group-2 visible, so it gets inserted and tells it has
3824 signal_monitor_append_signal (monitor, ROW_INSERTED, "2");
3825 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "2");
3826 gtk_tree_store_insert_with_values (store, NULL, &group_iter, -1,
3829 signal_monitor_assert_is_empty (monitor);
3831 /* group-2 is already visible, so this time it is a normal insertion */
3832 signal_monitor_append_signal (monitor, ROW_INSERTED, "2:1");
3833 gtk_tree_store_insert_with_values (store, NULL, &group_iter, -1,
3836 signal_monitor_assert_is_empty (monitor);
3839 gtk_tree_store_insert_with_values (store, &item_iter, NULL, -1,
3842 signal_monitor_assert_is_empty (monitor);
3844 /* Parent is invisible, and adding this invisible item won't change that,
3845 * so no signal should be emitted. */
3846 group_iter = item_iter;
3847 gtk_tree_store_insert_with_values (store, NULL, &group_iter, -1,
3850 signal_monitor_assert_is_empty (monitor);
3852 gtk_tree_store_insert_with_values (store, &item_iter, &group_iter, -1,
3855 signal_monitor_assert_is_empty (monitor);
3857 /* This will make group 3 visible. */
3858 signal_monitor_append_signal (monitor, ROW_INSERTED, "3");
3859 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "3");
3860 signal_monitor_append_signal (monitor, ROW_INSERTED, "3:0");
3861 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "3");
3862 gtk_tree_store_set (store, &item_iter, 0, "visible-3:1", -1);
3863 signal_monitor_assert_is_empty (monitor);
3865 /* Make sure all groups are expanded, so the filter has the tree cached */
3866 gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
3867 while (gtk_events_pending ())
3868 gtk_main_iteration ();
3870 /* Should only yield a row-changed */
3871 signal_monitor_append_signal (monitor, ROW_CHANGED, "3:0");
3872 gtk_tree_store_set (store, &item_iter, 0, "visible-3:1", -1);
3873 signal_monitor_assert_is_empty (monitor);
3875 /* Now remove/hide some items. If a group loses its last item, the group
3876 * should be deleted instead of the item.
3879 signal_monitor_append_signal (monitor, ROW_DELETED, "2:1");
3880 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &item_iter, "2:2");
3881 gtk_tree_store_remove (store, &item_iter);
3882 signal_monitor_assert_is_empty (monitor);
3884 signal_monitor_append_signal (monitor, ROW_DELETED, "2:0");
3885 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "2");
3886 signal_monitor_append_signal (monitor, ROW_DELETED, "2");
3887 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &item_iter, "2:1");
3888 gtk_tree_store_set (store, &item_iter, 0, "invisible-2:1", -1);
3889 signal_monitor_assert_is_empty (monitor);
3891 signal_monitor_append_signal (monitor, ROW_DELETED, "1:0:0:0");
3892 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "1:0:0");
3893 signal_monitor_append_signal (monitor, ROW_DELETED, "1:0");
3894 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "1");
3895 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &item_iter, "1:0:0:0");
3896 gtk_tree_store_remove (store, &item_iter);
3897 signal_monitor_assert_is_empty (monitor);
3899 /* Hide a group using row-changed instead of row-deleted */
3900 /* Caution: group 2 is gone, so offsets of the signals have moved. */
3901 signal_monitor_append_signal (monitor, ROW_DELETED, "2:0");
3902 signal_monitor_append_signal (monitor, ROW_HAS_CHILD_TOGGLED, "2");
3903 signal_monitor_append_signal (monitor, ROW_DELETED, "2");
3904 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &item_iter,
3906 gtk_tree_store_set (store, &item_iter, 0, "invisible-3:1", -1);
3907 signal_monitor_assert_is_empty (monitor);
3912 GtkTreeViewColumn *col;
3914 gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
3916 col = gtk_tree_view_column_new_with_attributes ("foo",
3917 gtk_cell_renderer_text_new (),
3919 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
3921 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3922 g_signal_connect (window, "delete-event",
3923 G_CALLBACK (gtk_widget_destroy), NULL);
3924 g_signal_connect (window, "destroy",
3925 G_CALLBACK (gtk_main_quit), NULL);
3927 gtk_container_add (GTK_CONTAINER (window), view);
3929 gtk_widget_show (view);
3930 gtk_widget_show (window);
3937 signal_monitor_free (monitor);
3938 g_object_unref (view);
3939 g_object_unref (store);
3940 g_object_unref (filter);
3946 register_filter_model_tests (void)
3948 g_test_add ("/TreeModelFilter/self/verify-test-suite",
3952 filter_test_teardown);
3954 g_test_add ("/TreeModelFilter/self/verify-test-suite/vroot/depth-1",
3955 FilterTest, gtk_tree_path_new_from_indices (2, -1),
3957 verify_test_suite_vroot,
3958 filter_test_teardown);
3959 g_test_add ("/TreeModelFilter/self/verify-test-suite/vroot/depth-2",
3960 FilterTest, gtk_tree_path_new_from_indices (2, 3, -1),
3962 verify_test_suite_vroot,
3963 filter_test_teardown);
3966 g_test_add ("/TreeModelFilter/filled/hide-root-level",
3969 filled_hide_root_level,
3970 filter_test_teardown);
3971 g_test_add ("/TreeModelFilter/filled/hide-child-levels",
3974 filled_hide_child_levels,
3975 filter_test_teardown);
3976 g_test_add ("/TreeModelFilter/filled/hide-child-levels/root-expanded",
3979 filled_hide_child_levels_root_expanded,
3980 filter_test_teardown);
3982 g_test_add ("/TreeModelFilter/filled/hide-root-level/vroot",
3983 FilterTest, gtk_tree_path_new_from_indices (2, -1),
3985 filled_vroot_hide_root_level,
3986 filter_test_teardown);
3987 g_test_add ("/TreeModelFilter/filled/hide-child-levels/vroot",
3988 FilterTest, gtk_tree_path_new_from_indices (2, -1),
3990 filled_vroot_hide_child_levels,
3991 filter_test_teardown);
3992 g_test_add ("/TreeModelFilter/filled/hide-child-levels/vroot-root-expanded",
3993 FilterTest, gtk_tree_path_new_from_indices (2, -1),
3995 filled_vroot_hide_child_levels_root_expanded,
3996 filter_test_teardown);
3999 g_test_add ("/TreeModelFilter/empty/show-nodes",
4001 filter_test_setup_empty,
4003 filter_test_teardown);
4004 g_test_add ("/TreeModelFilter/empty/show-multiple-nodes",
4006 filter_test_setup_empty,
4007 empty_show_multiple_nodes,
4008 filter_test_teardown);
4010 g_test_add ("/TreeModelFilter/empty/show-nodes/vroot",
4011 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4012 filter_test_setup_empty,
4013 empty_vroot_show_nodes,
4014 filter_test_teardown);
4015 g_test_add ("/TreeModelFilter/empty/show-multiple-nodes/vroot",
4016 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4017 filter_test_setup_empty,
4018 empty_vroot_show_multiple_nodes,
4019 filter_test_teardown);
4022 g_test_add ("/TreeModelFilter/unfiltered/hide-single",
4024 filter_test_setup_unfiltered,
4025 unfiltered_hide_single,
4026 filter_test_teardown);
4027 g_test_add ("/TreeModelFilter/unfiltered/hide-single/root-expanded",
4029 filter_test_setup_unfiltered_root_expanded,
4030 unfiltered_hide_single_root_expanded,
4031 filter_test_teardown);
4032 g_test_add ("/TreeModelFilter/unfiltered/hide-single-child",
4034 filter_test_setup_unfiltered,
4035 unfiltered_hide_single_child,
4036 filter_test_teardown);
4037 g_test_add ("/TreeModelFilter/unfiltered/hide-single-child/root-expanded",
4039 filter_test_setup_unfiltered_root_expanded,
4040 unfiltered_hide_single_child_root_expanded,
4041 filter_test_teardown);
4042 g_test_add ("/TreeModelFilter/unfiltered/hide-single-multi-level",
4044 filter_test_setup_unfiltered,
4045 unfiltered_hide_single_multi_level,
4046 filter_test_teardown);
4047 g_test_add ("/TreeModelFilter/unfiltered/hide-single-multi-level/root-expanded",
4049 filter_test_setup_unfiltered_root_expanded,
4050 unfiltered_hide_single_multi_level_root_expanded,
4051 filter_test_teardown);
4053 g_test_add ("/TreeModelFilter/unfiltered/hide-single/vroot",
4054 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4055 filter_test_setup_unfiltered,
4056 unfiltered_vroot_hide_single,
4057 filter_test_teardown);
4058 g_test_add ("/TreeModelFilter/unfiltered/hide-single-child/vroot",
4059 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4060 filter_test_setup_unfiltered,
4061 unfiltered_vroot_hide_single_child,
4062 filter_test_teardown);
4063 g_test_add ("/TreeModelFilter/unfiltered/hide-single-child/vroot/root-expanded",
4064 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4065 filter_test_setup_unfiltered_root_expanded,
4066 unfiltered_vroot_hide_single_child_root_expanded,
4067 filter_test_teardown);
4068 g_test_add ("/TreeModelFilter/unfiltered/hide-single-multi-level/vroot",
4069 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4070 filter_test_setup_unfiltered,
4071 unfiltered_vroot_hide_single_multi_level,
4072 filter_test_teardown);
4073 g_test_add ("/TreeModelFilter/unfiltered/hide-single-multi-level/vroot/root-expanded",
4074 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4075 filter_test_setup_unfiltered_root_expanded,
4076 unfiltered_vroot_hide_single_multi_level_root_expanded,
4077 filter_test_teardown);
4081 g_test_add ("/TreeModelFilter/unfiltered/show-single",
4083 filter_test_setup_empty_unfiltered,
4084 unfiltered_show_single,
4085 filter_test_teardown);
4086 g_test_add ("/TreeModelFilter/unfiltered/show-single-child",
4088 filter_test_setup_empty_unfiltered,
4089 unfiltered_show_single_child,
4090 filter_test_teardown);
4091 g_test_add ("/TreeModelFilter/unfiltered/show-single-child/root-expanded",
4093 filter_test_setup_empty_unfiltered_root_expanded,
4094 unfiltered_show_single_child_root_expanded,
4095 filter_test_teardown);
4096 g_test_add ("/TreeModelFilter/unfiltered/show-single-multi-level",
4098 filter_test_setup_empty_unfiltered,
4099 unfiltered_show_single_multi_level,
4100 filter_test_teardown);
4101 g_test_add ("/TreeModelFilter/unfiltered/show-single-multi-level/root-expanded",
4103 filter_test_setup_empty_unfiltered_root_expanded,
4104 unfiltered_show_single_multi_level_root_expanded,
4105 filter_test_teardown);
4107 g_test_add ("/TreeModelFilter/unfiltered/show-single/vroot",
4108 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4109 filter_test_setup_empty_unfiltered,
4110 unfiltered_vroot_show_single,
4111 filter_test_teardown);
4112 g_test_add ("/TreeModelFilter/unfiltered/show-single-child/vroot",
4113 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4114 filter_test_setup_empty_unfiltered,
4115 unfiltered_vroot_show_single_child,
4116 filter_test_teardown);
4117 g_test_add ("/TreeModelFilter/unfiltered/show-single-child/vroot/root-expanded",
4118 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4119 filter_test_setup_empty_unfiltered_root_expanded,
4120 unfiltered_vroot_show_single_child_root_expanded,
4121 filter_test_teardown);
4122 g_test_add ("/TreeModelFilter/unfiltered/show-single-multi-level/vroot",
4123 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4124 filter_test_setup_empty_unfiltered,
4125 unfiltered_vroot_show_single_multi_level,
4126 filter_test_teardown);
4127 g_test_add ("/TreeModelFilter/unfiltered/show-single-multi-level/vroot/root-expanded",
4128 FilterTest, gtk_tree_path_new_from_indices (2, -1),
4129 filter_test_setup_empty_unfiltered_root_expanded,
4130 unfiltered_vroot_show_single_multi_level_root_expanded,
4131 filter_test_teardown);
4133 /* Inserts in child models after creation of filter model */
4134 g_test_add_func ("/TreeModelFilter/insert/before",
4136 g_test_add_func ("/TreeModelFilter/insert/child",
4139 /* Removals from child model after creating of filter model */
4140 g_test_add_func ("/TreeModelFilter/remove/node",
4142 g_test_add_func ("/TreeModelFilter/remove/node-vroot",
4144 g_test_add_func ("/TreeModelFilter/remove/vroot-ancestor",
4145 remove_vroot_ancestor);
4148 g_test_add_func ("/TreeModelFilter/specific/path-dependent-filter",
4149 specific_path_dependent_filter);
4150 g_test_add_func ("/TreeModelFilter/specific/append-after-collapse",
4151 specific_append_after_collapse);
4152 g_test_add_func ("/TreeModelFilter/specific/sort-filter-remove-node",
4153 specific_sort_filter_remove_node);
4154 g_test_add_func ("/TreeModelFilter/specific/sort-filter-remove-root",
4155 specific_sort_filter_remove_root);
4156 g_test_add_func ("/TreeModelFilter/specific/root-mixed-visibility",
4157 specific_root_mixed_visibility);
4158 g_test_add_func ("/TreeModelFilter/specific/has-child-filter",
4159 specific_has_child_filter);
4160 g_test_add_func ("/TreeModelFilter/specific/root-has-child-filter",
4161 specific_root_has_child_filter);
4162 g_test_add_func ("/TreeModelFilter/specific/filter-add-child",
4163 specific_filter_add_child);
4164 g_test_add_func ("/TreeModelFilter/specific/list-store-clear",
4165 specific_list_store_clear);
4166 g_test_add_func ("/TreeModelFilter/specific/sort-ref-leaf-and-remove-ancestor",
4167 specific_sort_ref_leaf_and_remove_ancestor);
4168 g_test_add_func ("/TreeModelFilter/specific/ref-leaf-and-remove-ancestor",
4169 specific_ref_leaf_and_remove_ancestor);
4170 g_test_add_func ("/TreeModelFilter/specific/virtual-ref-leaf-and-remove-ancestor",
4171 specific_virtual_ref_leaf_and_remove_ancestor);
4173 g_test_add_func ("/TreeModelFilter/specific/bug-301558",
4174 specific_bug_301558);
4175 g_test_add_func ("/TreeModelFilter/specific/bug-311955",
4176 specific_bug_311955);
4177 g_test_add_func ("/TreeModelFilter/specific/bug-346800",
4178 specific_bug_346800);
4179 g_test_add_func ("/TreeModelFilter/specific/bug-464173",
4180 specific_bug_464173);
4181 g_test_add_func ("/TreeModelFilter/specific/bug-540201",
4182 specific_bug_540201);
4183 g_test_add_func ("/TreeModelFilter/specific/bug-549287",
4184 specific_bug_549287);
4185 g_test_add_func ("/TreeModelFilter/specific/bug-621076",
4186 specific_bug_621076);