1 /* Extensive GtkTreeModelFilter tests.
2 * Copyright (C) 2009 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 guint signal_ids[LAST_SIGNAL];
176 signal_monitor_generic_handler (SignalMonitor *m,
183 if (g_queue_is_empty (m->queue))
185 g_error ("Signal queue empty\n");
186 g_assert_not_reached ();
189 if (m->client != model)
191 g_error ("Model mismatch; expected %p, got %p\n",
193 g_assert_not_reached ();
196 s = g_queue_peek_tail (m->queue);
199 /* For debugging: output signals that are coming in. Leaks memory. */
200 g_print ("signal=%d path=%s\n", signal, gtk_tree_path_to_string (path));
203 if (s->signal != signal
204 || gtk_tree_path_compare (s->path, path) != 0)
206 gchar *path_str, *s_path_str;
208 s_path_str = gtk_tree_path_to_string (s->path);
209 path_str = gtk_tree_path_to_string (path);
211 g_error ("Signals don't match; expected signal %s path %s, got signal %s path %s\n",
212 signal_name_to_string (s->signal), s_path_str,
213 signal_name_to_string (signal), path_str);
218 g_assert_not_reached ();
221 s = g_queue_pop_tail (m->queue);
227 signal_monitor_row_inserted (GtkTreeModel *model,
232 signal_monitor_generic_handler (data, ROW_INSERTED,
237 signal_monitor_row_deleted (GtkTreeModel *model,
241 signal_monitor_generic_handler (data, ROW_DELETED,
246 signal_monitor_row_changed (GtkTreeModel *model,
251 signal_monitor_generic_handler (data, ROW_CHANGED,
256 signal_monitor_row_has_child_toggled (GtkTreeModel *model,
261 signal_monitor_generic_handler (data, ROW_HAS_CHILD_TOGGLED,
266 signal_monitor_rows_reordered (GtkTreeModel *model,
272 signal_monitor_generic_handler (data, ROWS_REORDERED,
276 static SignalMonitor *
277 signal_monitor_new (GtkTreeModel *client)
281 m = g_new0 (SignalMonitor, 1);
282 m->client = g_object_ref (client);
283 m->queue = g_queue_new ();
285 m->signal_ids[ROW_INSERTED] = g_signal_connect (client,
287 G_CALLBACK (signal_monitor_row_inserted),
289 m->signal_ids[ROW_DELETED] = g_signal_connect (client,
291 G_CALLBACK (signal_monitor_row_deleted),
293 m->signal_ids[ROW_CHANGED] = g_signal_connect (client,
295 G_CALLBACK (signal_monitor_row_changed),
297 m->signal_ids[ROW_HAS_CHILD_TOGGLED] = g_signal_connect (client,
298 "row-has-child-toggled",
299 G_CALLBACK (signal_monitor_row_has_child_toggled),
301 m->signal_ids[ROWS_REORDERED] = g_signal_connect (client,
303 G_CALLBACK (signal_monitor_rows_reordered),
310 signal_monitor_free (SignalMonitor *m)
314 for (i = 0; i < LAST_SIGNAL; i++)
315 g_signal_handler_disconnect (m->client, m->signal_ids[i]);
317 g_object_unref (m->client);
320 g_queue_free (m->queue);
326 signal_monitor_assert_is_empty (SignalMonitor *m)
328 g_assert (g_queue_is_empty (m->queue));
332 signal_monitor_append_signal_path (SignalMonitor *m,
338 s = signal_new (signal, path);
339 g_queue_push_head (m->queue, s);
343 signal_monitor_append_signal (SignalMonitor *m,
345 const gchar *path_string)
350 path = gtk_tree_path_new_from_string (path_string);
352 s = signal_new (signal, path);
353 g_queue_push_head (m->queue, s);
355 gtk_tree_path_free (path);
364 GtkWidget *tree_view;
367 GtkTreeModelFilter *filter;
369 SignalMonitor *monitor;
371 guint block_signals : 1;
376 filter_test_store_signal (FilterTest *fixture)
378 if (fixture->block_signals)
379 g_signal_stop_emission_by_name (fixture->store, "row-changed");
384 filter_test_setup_generic (FilterTest *fixture,
385 gconstpointer test_data,
390 const GtkTreePath *vroot = test_data;
391 GtkTreeModel *filter;
393 fixture->store = create_tree_store (depth, !empty);
395 g_signal_connect_swapped (fixture->store, "row-changed",
396 G_CALLBACK (filter_test_store_signal), fixture);
398 /* Please forgive me for casting const away. */
399 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (fixture->store),
400 (GtkTreePath *)vroot);
401 fixture->filter = GTK_TREE_MODEL_FILTER (filter);
404 gtk_tree_model_filter_set_visible_column (fixture->filter, 1);
406 /* We need a tree view that's listening to get ref counting from that
409 fixture->tree_view = gtk_tree_view_new_with_model (filter);
411 fixture->monitor = signal_monitor_new (filter);
415 filter_test_setup (FilterTest *fixture,
416 gconstpointer test_data)
418 filter_test_setup_generic (fixture, test_data, 3, FALSE, FALSE);
422 filter_test_setup_empty (FilterTest *fixture,
423 gconstpointer test_data)
425 filter_test_setup_generic (fixture, test_data, 3, TRUE, FALSE);
429 filter_test_setup_unfiltered (FilterTest *fixture,
430 gconstpointer test_data)
432 filter_test_setup_generic (fixture, test_data, 3, FALSE, TRUE);
436 filter_test_setup_empty_unfiltered (FilterTest *fixture,
437 gconstpointer test_data)
439 filter_test_setup_generic (fixture, test_data, 3, TRUE, TRUE);
443 strip_virtual_root (GtkTreePath *path,
444 GtkTreePath *root_path)
446 GtkTreePath *real_path;
451 int depth = gtk_tree_path_get_depth (path);
452 int root_depth = gtk_tree_path_get_depth (root_path);
454 real_path = gtk_tree_path_new ();
456 for (j = 0; j < depth - root_depth; j++)
457 gtk_tree_path_append_index (real_path,
458 gtk_tree_path_get_indices (path)[root_depth + j]);
461 real_path = gtk_tree_path_copy (path);
467 filter_test_append_refilter_signals_recurse (FilterTest *fixture,
468 GtkTreePath *store_path,
469 GtkTreePath *filter_path,
471 GtkTreePath *root_path)
474 int rows_deleted = 0;
477 gtk_tree_path_down (store_path);
478 gtk_tree_path_down (filter_path);
480 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
483 for (i = 0; i < LEVEL_LENGTH; i++)
486 GtkTreePath *real_path;
488 gtk_tree_model_get (GTK_TREE_MODEL (fixture->store), &iter,
493 (!gtk_tree_path_is_descendant (store_path, root_path)
494 || !gtk_tree_path_compare (store_path, root_path)))
496 if (!gtk_tree_path_compare (store_path, root_path))
499 && gtk_tree_model_iter_has_child (GTK_TREE_MODEL (fixture->store),
502 GtkTreePath *store_copy;
503 GtkTreePath *filter_copy;
505 store_copy = gtk_tree_path_copy (store_path);
506 filter_copy = gtk_tree_path_copy (filter_path);
507 filter_test_append_refilter_signals_recurse (fixture,
512 gtk_tree_path_free (store_copy);
513 gtk_tree_path_free (filter_copy);
517 gtk_tree_path_next (store_path);
518 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
521 gtk_tree_path_next (filter_path);
526 real_path = strip_virtual_root (filter_path, root_path);
530 /* This row will be inserted */
531 signal_monitor_append_signal_path (fixture->monitor, ROW_CHANGED,
533 signal_monitor_append_signal_path (fixture->monitor,
534 ROW_HAS_CHILD_TOGGLED,
538 && gtk_tree_model_iter_has_child (GTK_TREE_MODEL (fixture->store),
541 GtkTreePath *store_copy;
542 GtkTreePath *filter_copy;
544 store_copy = gtk_tree_path_copy (store_path);
545 filter_copy = gtk_tree_path_copy (filter_path);
546 filter_test_append_refilter_signals_recurse (fixture,
551 gtk_tree_path_free (store_copy);
552 gtk_tree_path_free (filter_copy);
555 gtk_tree_path_next (filter_path);
559 /* This row will be deleted */
561 signal_monitor_append_signal_path (fixture->monitor, ROW_DELETED,
565 gtk_tree_path_free (real_path);
567 gtk_tree_path_next (store_path);
568 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
571 if (rows_deleted == LEVEL_LENGTH
572 && gtk_tree_path_get_depth (filter_path) > 1)
574 GtkTreePath *real_path;
576 gtk_tree_path_up (store_path);
577 gtk_tree_path_up (filter_path);
579 /* A row-has-child-toggled will be emitted on the parent */
582 && gtk_tree_path_is_descendant (store_path, root_path)
583 && gtk_tree_path_compare (store_path, root_path)))
585 real_path = strip_virtual_root (filter_path, root_path);
586 signal_monitor_append_signal_path (fixture->monitor,
587 ROW_HAS_CHILD_TOGGLED,
590 gtk_tree_path_free (real_path);
596 filter_test_append_refilter_signals (FilterTest *fixture,
599 /* A special function that walks the tree store like the
600 * model validation functions below.
603 GtkTreePath *filter_path;
605 path = gtk_tree_path_new ();
606 filter_path = gtk_tree_path_new ();
607 filter_test_append_refilter_signals_recurse (fixture,
612 gtk_tree_path_free (path);
613 gtk_tree_path_free (filter_path);
617 filter_test_append_refilter_signals_with_vroot (FilterTest *fixture,
619 GtkTreePath *root_path)
621 /* A special function that walks the tree store like the
622 * model validation functions below.
625 GtkTreePath *filter_path;
627 path = gtk_tree_path_new ();
628 filter_path = gtk_tree_path_new ();
629 filter_test_append_refilter_signals_recurse (fixture,
634 gtk_tree_path_free (path);
635 gtk_tree_path_free (filter_path);
639 filter_test_enable_filter (FilterTest *fixture)
641 gtk_tree_model_filter_set_visible_column (fixture->filter, 1);
642 gtk_tree_model_filter_refilter (fixture->filter);
646 filter_test_block_signals (FilterTest *fixture)
648 fixture->block_signals = TRUE;
652 filter_test_unblock_signals (FilterTest *fixture)
654 fixture->block_signals = FALSE;
658 filter_test_teardown (FilterTest *fixture,
659 gconstpointer test_data)
661 signal_monitor_free (fixture->monitor);
663 g_object_unref (fixture->filter);
664 g_object_unref (fixture->store);
668 * Model structure validation
672 check_filter_model_recurse (FilterTest *fixture,
673 GtkTreePath *store_parent_path,
674 GtkTreePath *filter_parent_path)
677 GtkTreeIter store_iter;
678 GtkTreeIter filter_iter;
679 gboolean store_has_next, filter_has_next;
681 gtk_tree_path_down (store_parent_path);
682 gtk_tree_path_down (filter_parent_path);
684 store_has_next = gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
685 &store_iter, store_parent_path);
686 filter_has_next = gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->filter),
687 &filter_iter, filter_parent_path);
689 for (i = 0; i < LEVEL_LENGTH; i++)
693 g_return_if_fail (store_has_next == TRUE);
695 gtk_tree_model_get (GTK_TREE_MODEL (fixture->store),
703 gchar *filter_str, *store_str;
705 g_return_if_fail (filter_has_next == TRUE);
708 tmp = gtk_tree_model_get_path (GTK_TREE_MODEL (fixture->filter),
710 g_return_if_fail (gtk_tree_path_compare (tmp, filter_parent_path) == 0);
712 /* Verify model content */
713 gtk_tree_model_get (GTK_TREE_MODEL (fixture->store),
717 gtk_tree_model_get (GTK_TREE_MODEL (fixture->filter),
722 g_return_if_fail (g_strcmp0 (store_str, filter_str) == 0);
727 if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (fixture->filter),
730 g_return_if_fail (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (fixture->store), &store_iter));
732 check_filter_model_recurse (fixture,
733 gtk_tree_path_copy (store_parent_path),
737 gtk_tree_path_next (filter_parent_path);
738 filter_has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->filter), &filter_iter);
741 gtk_tree_path_next (store_parent_path);
742 store_has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &store_iter);
745 /* Both models should have no more content! */
746 g_return_if_fail (store_has_next == FALSE);
747 g_return_if_fail (filter_has_next == FALSE);
749 gtk_tree_path_free (store_parent_path);
750 gtk_tree_path_free (filter_parent_path);
754 check_filter_model (FilterTest *fixture)
758 if (fixture->monitor)
759 signal_monitor_assert_is_empty (fixture->monitor);
761 path = gtk_tree_path_new ();
763 check_filter_model_recurse (fixture, path, gtk_tree_path_copy (path));
767 check_filter_model_with_root (FilterTest *fixture,
770 if (fixture->monitor)
771 signal_monitor_assert_is_empty (fixture->monitor);
773 check_filter_model_recurse (fixture,
774 gtk_tree_path_copy (path),
775 gtk_tree_path_new ());
781 check_level_length (GtkTreeModelFilter *filter,
787 int l = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (filter), NULL);
788 g_return_if_fail (l == length);
793 gboolean retrieved_iter = FALSE;
796 retrieved_iter = gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (filter),
798 g_return_if_fail (retrieved_iter);
799 l = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (filter), &iter);
800 g_return_if_fail (l == length);
805 set_path_visibility (FilterTest *fixture,
809 GtkTreeIter store_iter;
811 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store),
813 gtk_tree_store_set (fixture->store, &store_iter,
820 insert_path_with_visibility (FilterTest *fixture,
821 const gchar *path_string,
826 GtkTreeIter parent, iter;
828 path = gtk_tree_path_new_from_string (path_string);
829 position = gtk_tree_path_get_indices (path)[gtk_tree_path_get_depth (path)];
830 gtk_tree_path_up (path);
832 if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &parent, path))
834 gtk_tree_store_insert (fixture->store, &iter, &parent, position);
835 create_tree_store_set_values (fixture->store, &iter, visible);
837 gtk_tree_path_free (path);
846 verify_test_suite (FilterTest *fixture,
847 gconstpointer user_data)
849 check_filter_model (fixture);
853 verify_test_suite_vroot (FilterTest *fixture,
854 gconstpointer user_data)
856 check_filter_model_with_root (fixture, (GtkTreePath *)user_data);
861 filled_hide_root_level (FilterTest *fixture,
862 gconstpointer user_data)
864 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "2");
865 set_path_visibility (fixture, "2", FALSE);
866 check_filter_model (fixture);
867 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
869 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
870 set_path_visibility (fixture, "0", FALSE);
871 check_filter_model (fixture);
872 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
874 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "2");
875 set_path_visibility (fixture, "4", FALSE);
876 check_filter_model (fixture);
877 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 3);
881 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
882 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
884 set_path_visibility (fixture, "1", FALSE);
885 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 4);
887 set_path_visibility (fixture, "3", FALSE);
888 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 5);
890 check_filter_model (fixture);
893 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
894 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
895 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "1");
896 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
898 set_path_visibility (fixture, "1", TRUE);
899 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 4);
901 set_path_visibility (fixture, "3", TRUE);
902 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 3);
904 check_filter_model (fixture);
908 filled_hide_child_levels (FilterTest *fixture,
909 gconstpointer user_data)
911 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0:2");
912 set_path_visibility (fixture, "0:2", FALSE);
913 check_filter_model (fixture);
914 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
915 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 1);
917 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0:3");
918 set_path_visibility (fixture, "0:4", FALSE);
919 check_filter_model (fixture);
920 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
921 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
923 set_path_visibility (fixture, "0:4:3", FALSE);
924 check_filter_model (fixture);
925 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
926 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
928 set_path_visibility (fixture, "0:4:0", FALSE);
929 set_path_visibility (fixture, "0:4:1", FALSE);
930 set_path_visibility (fixture, "0:4:2", FALSE);
931 set_path_visibility (fixture, "0:4:4", FALSE);
932 check_filter_model (fixture);
933 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
934 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
936 /* Since "0:2" is hidden, "0:4" must be "0:3" in the filter model */
937 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:3");
938 /* FIXME: Actually, the filter model should not be emitted the
939 * row-has-child-toggled signal here. *However* an extraneous emission
940 * of this signal does not hurt and is allowed.
942 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:3");
943 set_path_visibility (fixture, "0:4", TRUE);
944 check_filter_model (fixture);
945 check_level_length (fixture->filter, "0:3", 0);
947 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:2");
948 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:2");
949 set_path_visibility (fixture, "0:2", TRUE);
950 check_filter_model (fixture);
951 check_level_length (fixture->filter, "0:2", LEVEL_LENGTH);
952 check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
953 check_level_length (fixture->filter, "0:4", 0);
955 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0");
956 /* Once 0:4:0 got inserted, 0:4 became a parent */
957 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
958 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:0");
959 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1");
960 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:1");
962 set_path_visibility (fixture, "0:4:2", TRUE);
963 set_path_visibility (fixture, "0:4:4", TRUE);
964 signal_monitor_assert_is_empty (fixture->monitor);
965 check_level_length (fixture->filter, "0:4", 2);
970 filled_vroot_hide_root_level (FilterTest *fixture,
971 gconstpointer user_data)
973 GtkTreePath *path = (GtkTreePath *)user_data;
975 /* These changes do not affect the filter's root level */
976 set_path_visibility (fixture, "0", FALSE);
977 check_filter_model_with_root (fixture, path);
978 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
979 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
981 set_path_visibility (fixture, "4", FALSE);
982 check_filter_model_with_root (fixture, path);
983 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
984 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
986 /* Even though we set the virtual root parent node to FALSE,
987 * the virtual root contents remain.
989 set_path_visibility (fixture, "2", FALSE);
990 check_filter_model_with_root (fixture, path);
991 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
992 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
995 set_path_visibility (fixture, "1", FALSE);
996 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
997 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
999 set_path_visibility (fixture, "3", FALSE);
1000 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1001 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1003 check_filter_model_with_root (fixture, path);
1006 set_path_visibility (fixture, "2", TRUE);
1007 check_filter_model_with_root (fixture, path);
1008 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1009 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1011 set_path_visibility (fixture, "1", TRUE);
1012 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1013 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1015 set_path_visibility (fixture, "3", TRUE);
1016 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1017 check_level_length (fixture->filter, "0", LEVEL_LENGTH);
1019 check_filter_model_with_root (fixture, path);
1021 /* Now test changes in the virtual root level */
1022 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "2");
1023 set_path_visibility (fixture, "2:2", FALSE);
1024 check_filter_model_with_root (fixture, path);
1025 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1027 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "3");
1028 set_path_visibility (fixture, "2:4", FALSE);
1029 check_filter_model_with_root (fixture, path);
1030 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
1032 set_path_visibility (fixture, "1:4", FALSE);
1033 check_filter_model_with_root (fixture, path);
1034 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
1036 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "3");
1037 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "3");
1038 set_path_visibility (fixture, "2:4", TRUE);
1039 check_filter_model_with_root (fixture, path);
1040 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1042 set_path_visibility (fixture, "2", FALSE);
1043 check_filter_model_with_root (fixture, path);
1044 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1046 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1047 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1048 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1049 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1050 set_path_visibility (fixture, "2:0", FALSE);
1051 set_path_visibility (fixture, "2:1", FALSE);
1052 set_path_visibility (fixture, "2:2", FALSE);
1053 set_path_visibility (fixture, "2:3", FALSE);
1054 set_path_visibility (fixture, "2:4", FALSE);
1055 check_filter_model_with_root (fixture, path);
1056 check_level_length (fixture->filter, NULL, 0);
1058 set_path_visibility (fixture, "2", TRUE);
1059 check_filter_model_with_root (fixture, path);
1060 check_level_length (fixture->filter, NULL, 0);
1062 set_path_visibility (fixture, "1:4", FALSE);
1063 check_filter_model_with_root (fixture, path);
1064 check_level_length (fixture->filter, NULL, 0);
1066 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1067 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1068 set_path_visibility (fixture, "2:4", TRUE);
1069 check_filter_model_with_root (fixture, path);
1070 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 4);
1072 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1073 set_path_visibility (fixture, "2:4", FALSE);
1074 check_filter_model_with_root (fixture, path);
1075 check_level_length (fixture->filter, NULL, 0);
1077 set_path_visibility (fixture, "2", FALSE);
1078 check_filter_model_with_root (fixture, path);
1079 check_level_length (fixture->filter, NULL, 0);
1081 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1082 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1083 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "1");
1084 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
1085 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "2");
1086 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1087 set_path_visibility (fixture, "2:0", TRUE);
1088 set_path_visibility (fixture, "2:1", TRUE);
1089 set_path_visibility (fixture, "2:2", TRUE);
1090 check_filter_model_with_root (fixture, path);
1091 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
1093 set_path_visibility (fixture, "2", TRUE);
1094 check_filter_model_with_root (fixture, path);
1095 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 2);
1099 filled_vroot_hide_child_levels (FilterTest *fixture,
1100 gconstpointer user_data)
1102 GtkTreePath *path = (GtkTreePath *)user_data;
1104 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0:2");
1105 set_path_visibility (fixture, "2:0:2", FALSE);
1106 check_filter_model_with_root (fixture, path);
1107 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1108 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 1);
1110 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0:3");
1111 set_path_visibility (fixture, "2:0:4", FALSE);
1112 check_filter_model_with_root (fixture, path);
1113 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1114 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1116 set_path_visibility (fixture, "2:0:4:3", FALSE);
1117 check_filter_model_with_root (fixture, path);
1118 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1119 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1121 set_path_visibility (fixture, "2:0:4:0", FALSE);
1122 set_path_visibility (fixture, "2:0:4:1", FALSE);
1123 set_path_visibility (fixture, "2:0:4:2", FALSE);
1124 set_path_visibility (fixture, "2:0:4:4", FALSE);
1125 check_filter_model_with_root (fixture, path);
1126 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1127 check_level_length (fixture->filter, "0", LEVEL_LENGTH - 2);
1129 /* Since "0:2" is hidden, "0:4" must be "0:3" in the filter model */
1130 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:3");
1131 /* FIXME: Actually, the filter model should not be emitted the
1132 * row-has-child-toggled signal here. *However* an extraneous emission
1133 * of this signal does not hurt and is allowed.
1135 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:3");
1136 set_path_visibility (fixture, "2:0:4", TRUE);
1137 check_filter_model_with_root (fixture, path);
1138 check_level_length (fixture->filter, "0:3", 0);
1140 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:2");
1141 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:2");
1142 set_path_visibility (fixture, "2:0:2", TRUE);
1143 check_filter_model_with_root (fixture, path);
1144 check_level_length (fixture->filter, "0:2", LEVEL_LENGTH);
1145 check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
1146 check_level_length (fixture->filter, "0:4", 0);
1148 /* FIXME: Inconsistency! For the non-vroot case we also receive two
1149 * row-has-child-toggled signals here.
1151 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0");
1152 /* Once 0:4:0 got inserted, 0:4 became a parent */
1153 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
1154 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1");
1155 set_path_visibility (fixture, "2:0:4:2", TRUE);
1156 set_path_visibility (fixture, "2:0:4:4", TRUE);
1157 check_level_length (fixture->filter, "0:4", 2);
1162 empty_show_nodes (FilterTest *fixture,
1163 gconstpointer user_data)
1165 check_filter_model (fixture);
1166 check_level_length (fixture->filter, NULL, 0);
1168 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1169 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1170 set_path_visibility (fixture, "3", TRUE);
1171 check_filter_model (fixture);
1172 check_level_length (fixture->filter, NULL, 1);
1173 check_level_length (fixture->filter, "0", 0);
1175 set_path_visibility (fixture, "3:2:2", TRUE);
1176 check_filter_model (fixture);
1177 check_level_length (fixture->filter, NULL, 1);
1178 check_level_length (fixture->filter, "0", 0);
1180 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:0");
1181 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1182 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:0");
1183 set_path_visibility (fixture, "3:2", TRUE);
1184 check_filter_model (fixture);
1185 check_level_length (fixture->filter, NULL, 1);
1186 check_level_length (fixture->filter, "0", 1);
1187 check_level_length (fixture->filter, "0:0", 1);
1188 check_level_length (fixture->filter, "0:0:0", 0);
1190 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1191 set_path_visibility (fixture, "3", FALSE);
1192 check_filter_model (fixture);
1193 check_level_length (fixture->filter, NULL, 0);
1195 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1196 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1197 set_path_visibility (fixture, "3:2:1", TRUE);
1198 set_path_visibility (fixture, "3", TRUE);
1199 check_filter_model (fixture);
1200 check_level_length (fixture->filter, NULL, 1);
1201 check_level_length (fixture->filter, "0", 1);
1202 check_level_length (fixture->filter, "0:0", 2);
1203 check_level_length (fixture->filter, "0:0:0", 0);
1207 empty_show_multiple_nodes (FilterTest *fixture,
1208 gconstpointer user_data)
1211 GtkTreePath *changed_path;
1213 check_filter_model (fixture);
1214 check_level_length (fixture->filter, NULL, 0);
1216 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1217 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1218 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "1");
1219 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
1220 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "1");
1221 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
1223 /* We simulate a change in visible func condition with this. The
1224 * visibility state of multiple nodes changes at once, we emit row-changed
1225 * for these nodes (and others) after that.
1227 filter_test_block_signals (fixture);
1228 set_path_visibility (fixture, "3", TRUE);
1229 set_path_visibility (fixture, "4", TRUE);
1230 filter_test_unblock_signals (fixture);
1232 changed_path = gtk_tree_path_new ();
1233 gtk_tree_path_append_index (changed_path, 2);
1234 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
1235 &iter, changed_path);
1236 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1237 changed_path, &iter);
1239 gtk_tree_path_next (changed_path);
1240 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1241 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1242 changed_path, &iter);
1244 gtk_tree_path_next (changed_path);
1245 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1246 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1247 changed_path, &iter);
1249 gtk_tree_path_free (changed_path);
1251 check_filter_model (fixture);
1252 check_level_length (fixture->filter, NULL, 2);
1253 check_level_length (fixture->filter, "0", 0);
1255 set_path_visibility (fixture, "3:2:2", TRUE);
1256 check_filter_model (fixture);
1257 check_level_length (fixture->filter, NULL, 2);
1258 check_level_length (fixture->filter, "0", 0);
1260 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:0");
1261 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1262 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:0");
1263 set_path_visibility (fixture, "3:2", TRUE);
1264 check_filter_model (fixture);
1265 check_level_length (fixture->filter, NULL, 2);
1266 check_level_length (fixture->filter, "0", 1);
1267 check_level_length (fixture->filter, "0:0", 1);
1268 check_level_length (fixture->filter, "0:0:0", 0);
1270 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1271 set_path_visibility (fixture, "3", FALSE);
1272 check_filter_model (fixture);
1273 check_level_length (fixture->filter, NULL, 1);
1275 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1276 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1277 set_path_visibility (fixture, "3:2:1", TRUE);
1278 set_path_visibility (fixture, "3", TRUE);
1279 check_filter_model (fixture);
1280 check_level_length (fixture->filter, NULL, 2);
1281 check_level_length (fixture->filter, "0", 1);
1282 check_level_length (fixture->filter, "0:0", 2);
1283 check_level_length (fixture->filter, "0:0:0", 0);
1287 empty_vroot_show_nodes (FilterTest *fixture,
1288 gconstpointer user_data)
1290 GtkTreePath *path = (GtkTreePath *)user_data;
1292 check_filter_model_with_root (fixture, path);
1293 check_level_length (fixture->filter, NULL, 0);
1295 set_path_visibility (fixture, "2", TRUE);
1296 check_filter_model_with_root (fixture, path);
1297 check_level_length (fixture->filter, NULL, 0);
1299 set_path_visibility (fixture, "2:2:2", TRUE);
1300 check_filter_model_with_root (fixture, path);
1301 check_level_length (fixture->filter, NULL, 0);
1303 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1304 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1305 set_path_visibility (fixture, "2:2", TRUE);
1306 check_filter_model_with_root (fixture, path);
1307 check_level_length (fixture->filter, NULL, 1);
1308 check_level_length (fixture->filter, "0", 1);
1309 check_level_length (fixture->filter, "0:0", 0);
1311 set_path_visibility (fixture, "3", TRUE);
1312 check_filter_model_with_root (fixture, path);
1313 check_level_length (fixture->filter, NULL, 1);
1315 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1316 set_path_visibility (fixture, "2:2", FALSE);
1317 check_filter_model_with_root (fixture, path);
1318 check_level_length (fixture->filter, NULL, 0);
1320 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1321 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1322 set_path_visibility (fixture, "2:2:1", TRUE);
1323 set_path_visibility (fixture, "2:2", TRUE);
1324 check_filter_model_with_root (fixture, path);
1325 check_level_length (fixture->filter, NULL, 1);
1326 check_level_length (fixture->filter, "0", 2);
1327 check_level_length (fixture->filter, "0:1", 0);
1331 empty_vroot_show_multiple_nodes (FilterTest *fixture,
1332 gconstpointer user_data)
1335 GtkTreePath *changed_path;
1336 GtkTreePath *path = (GtkTreePath *)user_data;
1338 check_filter_model_with_root (fixture, path);
1339 check_level_length (fixture->filter, NULL, 0);
1341 /* We simulate a change in visible func condition with this. The
1342 * visibility state of multiple nodes changes at once, we emit row-changed
1343 * for these nodes (and others) after that.
1345 filter_test_block_signals (fixture);
1346 set_path_visibility (fixture, "2", TRUE);
1347 set_path_visibility (fixture, "3", TRUE);
1348 filter_test_unblock_signals (fixture);
1350 changed_path = gtk_tree_path_new ();
1351 gtk_tree_path_append_index (changed_path, 1);
1352 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
1353 &iter, changed_path);
1354 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1355 changed_path, &iter);
1357 gtk_tree_path_next (changed_path);
1358 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1359 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1360 changed_path, &iter);
1362 gtk_tree_path_next (changed_path);
1363 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1364 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1365 changed_path, &iter);
1367 gtk_tree_path_next (changed_path);
1368 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1369 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1370 changed_path, &iter);
1372 gtk_tree_path_free (changed_path);
1374 check_filter_model_with_root (fixture, path);
1375 check_level_length (fixture->filter, NULL, 0);
1377 set_path_visibility (fixture, "2:2:2", TRUE);
1378 check_filter_model_with_root (fixture, path);
1379 check_level_length (fixture->filter, NULL, 0);
1381 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1382 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1383 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "1");
1384 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "1");
1386 /* Again, we simulate a call to refilter */
1387 filter_test_block_signals (fixture);
1388 set_path_visibility (fixture, "2:2", TRUE);
1389 set_path_visibility (fixture, "2:3", TRUE);
1390 filter_test_unblock_signals (fixture);
1392 changed_path = gtk_tree_path_new ();
1393 gtk_tree_path_append_index (changed_path, 2);
1394 gtk_tree_path_append_index (changed_path, 1);
1395 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
1396 &iter, changed_path);
1397 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1398 changed_path, &iter);
1400 gtk_tree_path_next (changed_path);
1401 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1402 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1403 changed_path, &iter);
1405 gtk_tree_path_next (changed_path);
1406 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1407 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1408 changed_path, &iter);
1410 gtk_tree_path_next (changed_path);
1411 gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store), &iter);
1412 gtk_tree_model_row_changed (GTK_TREE_MODEL (fixture->store),
1413 changed_path, &iter);
1415 gtk_tree_path_free (changed_path);
1417 check_filter_model_with_root (fixture, path);
1418 check_level_length (fixture->filter, NULL, 2);
1419 check_level_length (fixture->filter, "0", 1);
1420 check_level_length (fixture->filter, "0:0", 0);
1422 set_path_visibility (fixture, "3", TRUE);
1423 check_filter_model_with_root (fixture, path);
1424 check_level_length (fixture->filter, NULL, 2);
1426 signal_monitor_append_signal (fixture->monitor, ROW_DELETED, "0");
1427 set_path_visibility (fixture, "2:2", FALSE);
1428 check_filter_model_with_root (fixture, path);
1429 check_level_length (fixture->filter, NULL, 1);
1431 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1432 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1433 set_path_visibility (fixture, "2:2:1", TRUE);
1434 set_path_visibility (fixture, "2:2", TRUE);
1435 check_filter_model_with_root (fixture, path);
1436 check_level_length (fixture->filter, NULL, 2);
1437 check_level_length (fixture->filter, "0", 2);
1438 check_level_length (fixture->filter, "0:1", 0);
1443 unfiltered_hide_single (FilterTest *fixture,
1444 gconstpointer user_data)
1447 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
1448 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1449 set_path_visibility (fixture, "2", FALSE);
1451 signal_monitor_assert_is_empty (fixture->monitor);
1452 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1454 /* The view only shows the root level, so the filter model only has
1455 * the first two levels cached.
1457 filter_test_append_refilter_signals (fixture, 2);
1458 filter_test_enable_filter (fixture);
1460 check_filter_model (fixture);
1461 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1465 unfiltered_hide_single_child (FilterTest *fixture,
1466 gconstpointer user_data)
1469 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1470 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1471 set_path_visibility (fixture, "2:2", FALSE);
1473 signal_monitor_assert_is_empty (fixture->monitor);
1474 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1475 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1477 /* The view only shows the root level, so the filter model only has
1478 * the first two levels cached.
1480 filter_test_append_refilter_signals (fixture, 2);
1481 filter_test_enable_filter (fixture);
1483 check_filter_model (fixture);
1484 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1485 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1489 unfiltered_hide_single_multi_level (FilterTest *fixture,
1490 gconstpointer user_data)
1493 /* This row is not shown, so its signal is not propagated */
1494 set_path_visibility (fixture, "2:2:2", FALSE);
1496 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1497 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1498 set_path_visibility (fixture, "2:2", FALSE);
1500 signal_monitor_assert_is_empty (fixture->monitor);
1501 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1502 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1503 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
1505 /* The view only shows the root level, so the filter model only has
1506 * the first two levels cached.
1508 filter_test_append_refilter_signals (fixture, 2);
1509 filter_test_enable_filter (fixture);
1511 check_filter_model (fixture);
1512 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1513 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1515 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "2:2");
1516 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1517 set_path_visibility (fixture, "2:2", TRUE);
1519 check_filter_model (fixture);
1520 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1521 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1522 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH - 1);
1527 unfiltered_vroot_hide_single (FilterTest *fixture,
1528 gconstpointer user_data)
1531 GtkTreePath *path = (GtkTreePath *)user_data;
1533 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
1534 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1535 set_path_visibility (fixture, "2:2", FALSE);
1537 signal_monitor_assert_is_empty (fixture->monitor);
1538 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1540 /* The view only shows the root level, so the filter model only has
1541 * the first two levels cached. (We add an additional level to
1542 * take the virtual root into account).
1544 filter_test_append_refilter_signals_with_vroot (fixture, 3, path);
1545 filter_test_enable_filter (fixture);
1547 check_filter_model_with_root (fixture, path);
1548 check_level_length (fixture->filter, NULL, LEVEL_LENGTH - 1);
1552 unfiltered_vroot_hide_single_child (FilterTest *fixture,
1553 gconstpointer user_data)
1556 GtkTreePath *path = (GtkTreePath *)user_data;
1558 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1559 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1560 set_path_visibility (fixture, "2:2:2", FALSE);
1562 signal_monitor_assert_is_empty (fixture->monitor);
1563 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1564 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1566 /* The view only shows the root level, so the filter model only has
1567 * the first two levels cached. (We add an additional level to take
1568 * the virtual root into account).
1570 filter_test_append_refilter_signals_with_vroot (fixture, 3, path);
1571 filter_test_enable_filter (fixture);
1573 check_filter_model_with_root (fixture, path);
1574 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1575 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1579 unfiltered_vroot_hide_single_multi_level (FilterTest *fixture,
1580 gconstpointer user_data)
1583 GtkTreePath *path = (GtkTreePath *)user_data;
1585 /* This row is not shown, so its signal is not propagated */
1586 set_path_visibility (fixture, "2:2:2:2", FALSE);
1588 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1589 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1590 set_path_visibility (fixture, "2:2:2", FALSE);
1592 signal_monitor_assert_is_empty (fixture->monitor);
1593 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1594 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1595 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
1597 /* The view only shows the root level, so the filter model only has
1598 * the first two levels cached.
1600 filter_test_append_refilter_signals_with_vroot (fixture, 3, path);
1601 filter_test_enable_filter (fixture);
1603 check_filter_model_with_root (fixture, path);
1604 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1605 check_level_length (fixture->filter, "2", LEVEL_LENGTH - 1);
1607 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "2:2");
1608 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1609 set_path_visibility (fixture, "2:2:2", TRUE);
1611 check_filter_model_with_root (fixture, path);
1612 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1613 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1614 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH - 1);
1620 unfiltered_show_single (FilterTest *fixture,
1621 gconstpointer user_data)
1624 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
1625 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1626 set_path_visibility (fixture, "2", TRUE);
1628 signal_monitor_assert_is_empty (fixture->monitor);
1629 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1631 /* The view only shows the root level, so the filter model only has
1632 * the first two levels cached.
1634 filter_test_append_refilter_signals (fixture, 2);
1635 filter_test_enable_filter (fixture);
1637 check_filter_model (fixture);
1638 check_level_length (fixture->filter, NULL, 1);
1642 unfiltered_show_single_child (FilterTest *fixture,
1643 gconstpointer user_data)
1646 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1647 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1648 set_path_visibility (fixture, "2:2", TRUE);
1650 signal_monitor_assert_is_empty (fixture->monitor);
1651 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1652 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1654 /* The view only shows the root level, so the filter model only has
1655 * the first two levels cached.
1657 filter_test_append_refilter_signals (fixture, 3);
1658 filter_test_enable_filter (fixture);
1660 check_filter_model (fixture);
1661 check_level_length (fixture->filter, NULL, 0);
1663 /* From here we are filtered, "2" in the real model is "0" in the filter
1666 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1667 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1668 set_path_visibility (fixture, "2", TRUE);
1669 signal_monitor_assert_is_empty (fixture->monitor);
1670 check_level_length (fixture->filter, NULL, 1);
1671 check_level_length (fixture->filter, "0", 1);
1675 unfiltered_show_single_multi_level (FilterTest *fixture,
1676 gconstpointer user_data)
1679 /* The view is not showing this row (collapsed state), so it is not
1680 * referenced. The signal should not go through.
1682 set_path_visibility (fixture, "2:2:2", TRUE);
1684 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1685 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1686 set_path_visibility (fixture, "2:2", TRUE);
1688 signal_monitor_assert_is_empty (fixture->monitor);
1689 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1690 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1691 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
1693 /* The view only shows the root level, so the filter model only has
1694 * the first two levels cached.
1696 filter_test_append_refilter_signals (fixture, 3);
1697 filter_test_enable_filter (fixture);
1699 check_filter_model (fixture);
1700 check_level_length (fixture->filter, NULL, 0);
1702 /* From here we are filtered, "2" in the real model is "0" in the filter
1705 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1706 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1707 set_path_visibility (fixture, "2", TRUE);
1708 check_filter_model (fixture);
1709 check_level_length (fixture->filter, NULL, 1);
1710 check_level_length (fixture->filter, "0", 1);
1711 check_level_length (fixture->filter, "0:0", 1);
1716 unfiltered_vroot_show_single (FilterTest *fixture,
1717 gconstpointer user_data)
1720 GtkTreePath *path = (GtkTreePath *)user_data;
1722 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2");
1723 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2");
1724 set_path_visibility (fixture, "2:2", TRUE);
1726 signal_monitor_assert_is_empty (fixture->monitor);
1727 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1729 /* The view only shows the root level, so the filter model only has
1730 * the first two levels cached.
1732 filter_test_append_refilter_signals_with_vroot (fixture, 3, path);
1733 filter_test_enable_filter (fixture);
1735 check_filter_model_with_root (fixture, path);
1736 check_level_length (fixture->filter, NULL, 1);
1740 unfiltered_vroot_show_single_child (FilterTest *fixture,
1741 gconstpointer user_data)
1744 GtkTreePath *path = (GtkTreePath *)user_data;
1746 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1747 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1748 set_path_visibility (fixture, "2:2:2", TRUE);
1750 signal_monitor_assert_is_empty (fixture->monitor);
1751 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1752 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1754 /* The view only shows the root level, so the filter model only has
1755 * the first two levels cached.
1757 filter_test_append_refilter_signals_with_vroot (fixture, 2, path);
1758 filter_test_enable_filter (fixture);
1760 check_filter_model_with_root (fixture, path);
1761 check_level_length (fixture->filter, NULL, 0);
1763 /* From here we are filtered, "2" in the real model is "0" in the filter
1766 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1767 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1768 set_path_visibility (fixture, "2:2", TRUE);
1769 signal_monitor_assert_is_empty (fixture->monitor);
1770 check_level_length (fixture->filter, NULL, 1);
1771 check_level_length (fixture->filter, "0", 1);
1775 unfiltered_vroot_show_single_multi_level (FilterTest *fixture,
1776 gconstpointer user_data)
1779 GtkTreePath *path = (GtkTreePath *)user_data;
1781 /* The view is not showing this row (collapsed state), so it is not
1782 * referenced. The signal should not go through.
1784 set_path_visibility (fixture, "2:2:2:2", TRUE);
1786 signal_monitor_append_signal (fixture->monitor, ROW_CHANGED, "2:2");
1787 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "2:2");
1788 set_path_visibility (fixture, "2:2:2", TRUE);
1790 signal_monitor_assert_is_empty (fixture->monitor);
1791 check_level_length (fixture->filter, NULL, LEVEL_LENGTH);
1792 check_level_length (fixture->filter, "2", LEVEL_LENGTH);
1793 check_level_length (fixture->filter, "2:2", LEVEL_LENGTH);
1795 /* The view only shows the root level, so the filter model only has
1796 * the first two levels cached.
1798 filter_test_append_refilter_signals_with_vroot (fixture, 4, path);
1799 filter_test_enable_filter (fixture);
1801 check_filter_model_with_root (fixture, path);
1802 check_level_length (fixture->filter, NULL, 0);
1804 /* From here we are filtered, "2" in the real model is "0" in the filter
1807 signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0");
1808 signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
1809 set_path_visibility (fixture, "2:2", TRUE);
1810 check_filter_model_with_root (fixture, path);
1811 check_level_length (fixture->filter, NULL, 1);
1812 check_level_length (fixture->filter, "0", 1);
1813 check_level_length (fixture->filter, "0:0", 1);
1818 specific_path_dependent_filter_func (GtkTreeModel *model,
1824 path = gtk_tree_model_get_path (model, iter);
1825 if (gtk_tree_path_get_indices (path)[0] < 4)
1832 specific_path_dependent_filter (void)
1838 GtkTreeModel *filter;
1840 list = gtk_list_store_new (1, G_TYPE_INT);
1841 gtk_list_store_insert_with_values (list, &iter, 0, 0, 1, -1);
1842 gtk_list_store_insert_with_values (list, &iter, 1, 0, 2, -1);
1843 gtk_list_store_insert_with_values (list, &iter, 2, 0, 3, -1);
1844 gtk_list_store_insert_with_values (list, &iter, 3, 0, 4, -1);
1845 gtk_list_store_insert_with_values (list, &iter, 4, 0, 5, -1);
1846 gtk_list_store_insert_with_values (list, &iter, 5, 0, 6, -1);
1847 gtk_list_store_insert_with_values (list, &iter, 6, 0, 7, -1);
1848 gtk_list_store_insert_with_values (list, &iter, 7, 0, 8, -1);
1850 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (list));
1851 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (sort), NULL);
1852 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
1853 specific_path_dependent_filter_func,
1856 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort), 0,
1857 GTK_SORT_DESCENDING);
1859 for (i = 0; i < 4; i++)
1861 if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (list), &iter,
1863 gtk_list_store_remove (list, &iter);
1865 if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (list), &iter,
1867 gtk_list_store_remove (list, &iter);
1873 specific_append_after_collapse_visible_func (GtkTreeModel *model,
1878 gboolean hide_negative_numbers;
1880 gtk_tree_model_get (model, iter, 1, &number, -1);
1881 hide_negative_numbers = GPOINTER_TO_INT (g_object_get_data (data, "private-hide-negative-numbers"));
1883 return (number >= 0 || !hide_negative_numbers);
1887 specific_append_after_collapse (void)
1889 /* This test is based on one of the test cases I found in my
1890 * old test cases directory. I unfortunately do not have a record
1891 * from who this test case originated. -Kris.
1895 * - Show tree, expand, collapse.
1900 GtkTreeIter child_iter;
1901 GtkTreeIter child_iter2;
1902 GtkTreePath *append_path;
1903 GtkTreeStore *store;
1904 GtkTreeModel *filter;
1908 GtkWidget *tree_view;
1910 store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_INT);
1912 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
1913 g_object_set_data (G_OBJECT (filter), "private-hide-negative-numbers",
1914 GINT_TO_POINTER (FALSE));
1915 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
1916 specific_append_after_collapse_visible_func,
1919 sort = gtk_tree_model_sort_new_with_model (filter);
1921 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1922 tree_view = gtk_tree_view_new_with_model (sort);
1923 gtk_container_add (GTK_CONTAINER (window), tree_view);
1924 gtk_widget_realize (tree_view);
1926 while (gtk_events_pending ())
1927 gtk_main_iteration ();
1929 gtk_tree_store_prepend (store, &iter, NULL);
1930 gtk_tree_store_set (store, &iter,
1931 0, "hallo", 1, 1, -1);
1933 gtk_tree_store_append (store, &child_iter, &iter);
1934 gtk_tree_store_set (store, &child_iter,
1935 0, "toemaar", 1, 1, -1);
1937 gtk_tree_store_append (store, &child_iter2, &child_iter);
1938 gtk_tree_store_set (store, &child_iter2,
1939 0, "very deep", 1, 1, -1);
1941 append_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &child_iter2);
1943 gtk_tree_store_append (store, &child_iter, &iter);
1944 gtk_tree_store_set (store, &child_iter,
1945 0, "sja", 1, 1, -1);
1947 gtk_tree_store_append (store, &child_iter, &iter);
1948 gtk_tree_store_set (store, &child_iter,
1949 0, "some word", 1, -1, -1);
1951 /* Expand and collapse the tree */
1952 gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
1953 while (gtk_events_pending ())
1954 gtk_main_iteration ();
1956 gtk_tree_view_collapse_all (GTK_TREE_VIEW (tree_view));
1957 while (gtk_events_pending ())
1958 gtk_main_iteration ();
1960 /* Add another it */
1961 g_object_set_data (G_OBJECT (filter), "private-hide-negative-numbers",
1962 GINT_TO_POINTER (TRUE));
1964 if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, append_path))
1966 gtk_tree_store_append (store, &child_iter, &iter);
1967 gtk_tree_store_set (store, &child_iter,
1968 0, "new new new !!", 1, 1, -1);
1970 gtk_tree_path_free (append_path);
1973 gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
1974 while (gtk_events_pending ())
1975 gtk_main_iteration ();
1980 specific_sort_filter_remove_node_compare_func (GtkTreeModel *model,
1989 specific_sort_filter_remove_node_visible_func (GtkTreeModel *model,
1995 /* Do reference the model */
1996 gtk_tree_model_get (model, iter, 0, &item, -1);
2003 specific_sort_filter_remove_node (void)
2005 /* This test is based on one of the test cases I found in my
2006 * old test cases directory. I unfortunately do not have a record
2007 * from who this test case originated. -Kris.
2010 * - Create tree store, sort, filter models. The sort model has
2011 * a default sort func that is enabled, filter model a visible func
2012 * that defaults to returning FALSE.
2013 * - Remove a node from the tree store.
2017 GtkTreeStore *store;
2018 GtkTreeModel *filter;
2022 GtkWidget *tree_view;
2024 store = gtk_tree_store_new (1, G_TYPE_STRING);
2025 gtk_tree_store_append (store, &iter, NULL);
2026 gtk_tree_store_set (store, &iter, 0, "Hello1", -1);
2028 gtk_tree_store_append (store, &iter, NULL);
2029 gtk_tree_store_set (store, &iter, 0, "Hello2", -1);
2031 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
2032 gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (sort),
2033 specific_sort_filter_remove_node_compare_func, NULL, NULL);
2035 filter = gtk_tree_model_filter_new (sort, NULL);
2036 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
2037 specific_sort_filter_remove_node_visible_func,
2041 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2042 tree_view = gtk_tree_view_new_with_model (filter);
2043 gtk_container_add (GTK_CONTAINER (window), tree_view);
2044 gtk_widget_realize (tree_view);
2046 while (gtk_events_pending ())
2047 gtk_main_iteration ();
2050 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
2051 gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
2052 gtk_tree_store_remove (store, &iter);
2054 while (gtk_events_pending ())
2055 gtk_main_iteration ();
2060 specific_sort_filter_remove_root (void)
2062 /* This test is based on one of the test cases I found in my
2063 * old test cases directory. I unfortunately do not have a record
2064 * from who this test case originated. -Kris.
2067 GtkTreeModel *model, *sort, *filter;
2068 GtkTreeIter root, mid, leaf;
2071 model = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_INT));
2072 gtk_tree_store_append (GTK_TREE_STORE (model), &root, NULL);
2073 gtk_tree_store_append (GTK_TREE_STORE (model), &mid, &root);
2074 gtk_tree_store_append (GTK_TREE_STORE (model), &leaf, &mid);
2076 path = gtk_tree_model_get_path (model, &mid);
2078 sort = gtk_tree_model_sort_new_with_model (model);
2079 filter = gtk_tree_model_filter_new (sort, path);
2081 gtk_tree_store_remove (GTK_TREE_STORE (model), &root);
2083 g_object_unref (filter);
2084 g_object_unref (sort);
2085 g_object_unref (model);
2090 specific_root_mixed_visibility (void)
2093 GtkTreeModel *filter;
2094 /* A bit nasty, apologies */
2097 fixture.store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
2099 for (i = 0; i < LEVEL_LENGTH; i++)
2103 gtk_tree_store_insert (fixture.store, &iter, NULL, i);
2105 create_tree_store_set_values (fixture.store, &iter, TRUE);
2107 create_tree_store_set_values (fixture.store, &iter, FALSE);
2110 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (fixture.store), NULL);
2111 fixture.filter = GTK_TREE_MODEL_FILTER (filter);
2112 fixture.monitor = NULL;
2114 gtk_tree_model_filter_set_visible_column (fixture.filter, 1);
2116 /* In order to trigger the potential bug, we should not access
2117 * the filter model here (so don't call the check functions).
2120 /* Change visibility of an odd row to TRUE */
2121 set_path_visibility (&fixture, "3", TRUE);
2122 check_filter_model (&fixture);
2123 check_level_length (fixture.filter, NULL, 4);
2129 specific_has_child_filter_filter_func (GtkTreeModel *model,
2133 return gtk_tree_model_iter_has_child (model, iter);
2137 specific_has_child_filter (void)
2139 GtkTreeModel *filter;
2140 GtkTreeIter iter, root;
2141 /* A bit nasty, apologies */
2144 fixture.store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
2145 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (fixture.store), NULL);
2146 fixture.filter = GTK_TREE_MODEL_FILTER (filter);
2147 fixture.monitor = NULL;
2149 /* We will filter on parent state using a filter function. We will
2150 * manually keep the boolean column in sync, so that we can use
2151 * check_filter_model() to check the consistency of the model.
2153 /* FIXME: We need a check_filter_model() that is not tied to LEVEL_LENGTH
2154 * to be able to check the structure here. We keep the calls to
2155 * check_filter_model() commented out until then.
2157 gtk_tree_model_filter_set_visible_func (fixture.filter,
2158 specific_has_child_filter_filter_func,
2161 gtk_tree_store_append (fixture.store, &root, NULL);
2162 create_tree_store_set_values (fixture.store, &root, FALSE);
2164 /* check_filter_model (&fixture); */
2165 check_level_length (fixture.filter, NULL, 0);
2167 gtk_tree_store_append (fixture.store, &iter, &root);
2168 create_tree_store_set_values (fixture.store, &iter, TRUE);
2170 /* Parent must now be visible. Do the level length check first,
2171 * to avoid modifying the child model triggering a row-changed to
2174 check_level_length (fixture.filter, NULL, 1);
2175 check_level_length (fixture.filter, "0", 0);
2177 set_path_visibility (&fixture, "0", TRUE);
2178 /* check_filter_model (&fixture); */
2180 gtk_tree_store_append (fixture.store, &root, NULL);
2181 check_level_length (fixture.filter, NULL, 1);
2183 gtk_tree_store_append (fixture.store, &iter, &root);
2184 check_level_length (fixture.filter, NULL, 2);
2185 check_level_length (fixture.filter, "1", 0);
2187 create_tree_store_set_values (fixture.store, &root, TRUE);
2188 create_tree_store_set_values (fixture.store, &iter, TRUE);
2190 /* check_filter_model (&fixture); */
2192 gtk_tree_store_append (fixture.store, &iter, &root);
2193 create_tree_store_set_values (fixture.store, &iter, TRUE);
2194 check_level_length (fixture.filter, NULL, 2);
2195 check_level_length (fixture.filter, "0", 0);
2196 check_level_length (fixture.filter, "1", 0);
2198 /* Now remove one of the remaining child rows */
2199 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture.store),
2201 gtk_tree_store_remove (fixture.store, &iter);
2203 check_level_length (fixture.filter, NULL, 1);
2204 check_level_length (fixture.filter, "0", 0);
2206 set_path_visibility (&fixture, "0", FALSE);
2207 /* check_filter_model (&fixture); */
2212 specific_root_has_child_filter_filter_func (GtkTreeModel *model,
2219 path = gtk_tree_model_get_path (model, iter);
2220 depth = gtk_tree_path_get_depth (path);
2221 gtk_tree_path_free (path);
2226 return gtk_tree_model_iter_has_child (model, iter);
2230 specific_root_has_child_filter (void)
2232 GtkTreeModel *filter;
2233 GtkTreeIter iter, root;
2234 /* A bit nasty, apologies */
2237 /* This is a variation on the above test case wherein the has-child
2238 * check for visibility only applies to root level nodes.
2241 fixture.store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
2242 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (fixture.store), NULL);
2243 fixture.filter = GTK_TREE_MODEL_FILTER (filter);
2244 fixture.monitor = NULL;
2246 /* We will filter on parent state using a filter function. We will
2247 * manually keep the boolean column in sync, so that we can use
2248 * check_filter_model() to check the consistency of the model.
2250 /* FIXME: We need a check_filter_model() that is not tied to LEVEL_LENGTH
2251 * to be able to check the structure here. We keep the calls to
2252 * check_filter_model() commented out until then.
2254 gtk_tree_model_filter_set_visible_func (fixture.filter,
2255 specific_root_has_child_filter_filter_func,
2258 gtk_tree_store_append (fixture.store, &root, NULL);
2259 create_tree_store_set_values (fixture.store, &root, FALSE);
2261 /* check_filter_model (&fixture); */
2262 check_level_length (fixture.filter, NULL, 0);
2264 gtk_tree_store_append (fixture.store, &iter, &root);
2265 create_tree_store_set_values (fixture.store, &iter, TRUE);
2267 /* Parent must now be visible. Do the level length check first,
2268 * to avoid modifying the child model triggering a row-changed to
2271 check_level_length (fixture.filter, NULL, 1);
2272 check_level_length (fixture.filter, "0", 1);
2274 set_path_visibility (&fixture, "0", TRUE);
2275 /* check_filter_model (&fixture); */
2277 gtk_tree_store_append (fixture.store, &root, NULL);
2278 check_level_length (fixture.filter, NULL, 1);
2280 gtk_tree_store_append (fixture.store, &iter, &root);
2281 check_level_length (fixture.filter, NULL, 2);
2282 check_level_length (fixture.filter, "1", 1);
2284 create_tree_store_set_values (fixture.store, &root, TRUE);
2285 create_tree_store_set_values (fixture.store, &iter, TRUE);
2287 /* check_filter_model (&fixture); */
2289 gtk_tree_store_append (fixture.store, &iter, &root);
2290 create_tree_store_set_values (fixture.store, &iter, TRUE);
2291 check_level_length (fixture.filter, NULL, 2);
2292 check_level_length (fixture.filter, "0", 1);
2293 check_level_length (fixture.filter, "1", 2);
2295 /* Now remove one of the remaining child rows */
2296 gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture.store),
2298 gtk_tree_store_remove (fixture.store, &iter);
2300 check_level_length (fixture.filter, NULL, 1);
2301 check_level_length (fixture.filter, "0", 2);
2303 set_path_visibility (&fixture, "0", FALSE);
2304 /* check_filter_model (&fixture); */
2309 specific_filter_add_child (void)
2311 /* This test is based on one of the test cases I found in my
2312 * old test cases directory. I unfortunately do not have a record
2313 * from who this test case originated. -Kris.
2317 GtkTreeIter iter_first;
2319 GtkTreeStore *store;
2320 GtkTreeModel *filter;
2322 store = gtk_tree_store_new (1, G_TYPE_STRING);
2324 gtk_tree_store_append (store, &iter_first, NULL);
2325 gtk_tree_store_set (store, &iter_first, 0, "Hello", -1);
2327 gtk_tree_store_append (store, &iter, NULL);
2328 gtk_tree_store_set (store, &iter, 0, "Hello", -1);
2330 gtk_tree_store_append (store, &iter, NULL);
2331 gtk_tree_store_set (store, &iter, 0, "Hello", -1);
2333 gtk_tree_store_append (store, &iter, NULL);
2334 gtk_tree_store_set (store, &iter, 0, "Hello", -1);
2336 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
2338 gtk_tree_store_set (store, &iter, 0, "Hello", -1);
2339 gtk_tree_store_append (store, &child, &iter_first);
2340 gtk_tree_store_set (store, &child, 0, "Hello", -1);
2344 specific_list_store_clear (void)
2349 GtkTreeModel *filter;
2352 list = gtk_list_store_new (1, G_TYPE_INT);
2353 gtk_list_store_insert_with_values (list, &iter, 0, 0, 1, -1);
2354 gtk_list_store_insert_with_values (list, &iter, 1, 0, 2, -1);
2355 gtk_list_store_insert_with_values (list, &iter, 2, 0, 3, -1);
2356 gtk_list_store_insert_with_values (list, &iter, 3, 0, 4, -1);
2357 gtk_list_store_insert_with_values (list, &iter, 4, 0, 5, -1);
2358 gtk_list_store_insert_with_values (list, &iter, 5, 0, 6, -1);
2359 gtk_list_store_insert_with_values (list, &iter, 6, 0, 7, -1);
2360 gtk_list_store_insert_with_values (list, &iter, 7, 0, 8, -1);
2362 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (list), NULL);
2363 view = gtk_tree_view_new_with_model (filter);
2365 gtk_list_store_clear (list);
2369 specific_bug_300089 (void)
2371 /* Test case for GNOME Bugzilla bug 300089. Written by
2374 GtkTreeModel *sort_model, *child_model;
2376 GtkTreeIter iter, iter2, sort_iter;
2378 child_model = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_STRING));
2380 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
2381 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "A", -1);
2382 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
2383 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "B", -1);
2385 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter2, &iter);
2386 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter2, 0, "D", -1);
2387 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter2, &iter);
2388 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter2, 0, "E", -1);
2390 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
2391 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "C", -1);
2394 sort_model = GTK_TREE_MODEL (gtk_tree_model_sort_new_with_model (child_model));
2395 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
2396 0, GTK_SORT_ASCENDING);
2398 path = gtk_tree_path_new_from_indices (1, 1, -1);
2400 /* make sure a level is constructed */
2401 gtk_tree_model_get_iter (sort_model, &sort_iter, path);
2403 /* change the "E" row in a way that causes it to change position */
2404 gtk_tree_model_get_iter (child_model, &iter, path);
2405 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "A", -1);
2410 specific_bug_301558_sort_func (GtkTreeModel *model,
2417 gtk_tree_model_get (model, a, 0, &i, -1);
2418 gtk_tree_model_get (model, b, 0, &j, -1);
2424 specific_bug_301558 (void)
2426 /* Test case for GNOME Bugzilla bug 301558 provided by
2430 GtkTreeModel *filter;
2432 GtkTreeIter root, iter, iter2;
2437 tree = gtk_tree_store_new (2, G_TYPE_INT, G_TYPE_BOOLEAN);
2438 gtk_tree_store_append (tree, &iter, NULL);
2439 gtk_tree_store_set (tree, &iter, 0, 123, 1, TRUE, -1);
2440 gtk_tree_store_append (tree, &iter2, &iter);
2441 gtk_tree_store_set (tree, &iter2, 0, 73, 1, TRUE, -1);
2443 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (tree));
2444 gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (sort),
2445 specific_bug_301558_sort_func,
2448 filter = gtk_tree_model_filter_new (sort, NULL);
2449 gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (filter), 1);
2451 view = gtk_tree_view_new_with_model (filter);
2453 while (gtk_events_pending ())
2454 gtk_main_iteration ();
2458 for (i = 0; i < 10; i++)
2460 if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tree), &root))
2461 g_assert_not_reached ();
2465 gtk_tree_store_append (tree, &iter, &root);
2466 gtk_tree_store_set (tree, &iter, 0, 456, 1, TRUE, -1);
2471 n = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (tree), &root);
2472 gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (tree), &iter,
2474 gtk_tree_store_remove (tree, &iter);
2483 specific_bug_311955_filter_func (GtkTreeModel *model,
2489 gtk_tree_model_get (model, iter, 0, &value, -1);
2491 return (value != 0);
2495 specific_bug_311955 (void)
2497 /* This is a test case for GNOME Bugzilla bug 311955. It was written
2500 GtkTreeIter iter, child, root;
2501 GtkTreeStore *store;
2503 GtkTreeModel *filter;
2506 GtkWidget *tree_view;
2510 store = gtk_tree_store_new (1, G_TYPE_INT);
2512 gtk_tree_store_append (store, &root, NULL);
2513 gtk_tree_store_set (store, &root, 0, 33, -1);
2515 gtk_tree_store_append (store, &iter, &root);
2516 gtk_tree_store_set (store, &iter, 0, 50, -1);
2518 gtk_tree_store_append (store, &iter, NULL);
2519 gtk_tree_store_set (store, &iter, 0, 22, -1);
2521 sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
2522 filter = gtk_tree_model_filter_new (sort, NULL);
2524 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
2525 specific_bug_311955_filter_func,
2528 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2529 tree_view = gtk_tree_view_new_with_model (filter);
2530 g_object_unref (store);
2532 gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
2534 while (gtk_events_pending ())
2535 gtk_main_iteration ();
2538 for (i = 0; i < 4; i++)
2540 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &root);
2542 gtk_tree_store_append (store, &iter, &root);
2545 gtk_tree_store_set (store, &iter, 0, i, -1);
2549 gtk_tree_store_append (store, &child, &iter);
2550 gtk_tree_store_set (store, &child, 0, 10, -1);
2554 while (gtk_events_pending ())
2555 gtk_main_iteration ();
2557 /* Remove bottommost child from the tree. */
2558 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &root);
2559 n = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), &root);
2561 if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter, &root, n - 2))
2563 if (gtk_tree_model_iter_children (GTK_TREE_MODEL (store), &child, &iter))
2564 gtk_tree_store_remove (store, &child);
2567 g_assert_not_reached ();
2571 specific_bug_346800 (void)
2573 /* This is a test case for GNOME Bugzilla bug 346800. It was written
2574 * by Jonathan Matthew.
2577 GtkTreeIter node_iters[50];
2578 GtkTreeIter child_iters[50];
2579 GtkTreeModel *model;
2580 GtkTreeModelFilter *filter;
2581 GtkTreeStore *store;
2585 columns = g_new (GType, 2);
2586 columns[0] = G_TYPE_STRING;
2587 columns[1] = G_TYPE_BOOLEAN;
2588 store = gtk_tree_store_newv (2, columns);
2589 model = GTK_TREE_MODEL (store);
2591 filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (model, NULL));
2592 gtk_tree_model_filter_set_visible_column (filter, 1);
2594 for (i=0; i<items; i++)
2596 /* allocate random amounts of junk, otherwise the filter model's arrays can expand without moving */
2599 gtk_tree_store_append (store, &node_iters[i], NULL);
2600 gtk_tree_store_set (store, &node_iters[i],
2602 1, ((i%6) == 0) ? FALSE : TRUE,
2606 gtk_tree_store_append (store, &child_iters[i], &node_iters[i]);
2607 gtk_tree_store_set (store, &child_iters[i],
2608 0, "something else",
2611 gtk_tree_model_filter_refilter (filter);
2615 gtk_tree_store_set (GTK_TREE_STORE (model), &child_iters[i-1], 1,
2616 (i & 1) ? TRUE : FALSE, -1);
2617 gtk_tree_model_filter_refilter (filter);
2619 gtk_tree_store_set (GTK_TREE_STORE (model), &child_iters[i-2], 1,
2620 (i & 1) ? FALSE: TRUE, -1);
2621 gtk_tree_model_filter_refilter (filter);
2628 specific_bug_364946 (void)
2630 /* This is a test case for GNOME Bugzilla bug 364946. It was written
2631 * by Andreas Koehler.
2633 GtkTreeStore *store;
2634 GtkTreeIter a, aa, aaa, aab, iter;
2635 GtkTreeModel *s_model;
2637 store = gtk_tree_store_new (1, G_TYPE_STRING);
2639 gtk_tree_store_append (store, &a, NULL);
2640 gtk_tree_store_set (store, &a, 0, "0", -1);
2642 gtk_tree_store_append (store, &aa, &a);
2643 gtk_tree_store_set (store, &aa, 0, "0:0", -1);
2645 gtk_tree_store_append (store, &aaa, &aa);
2646 gtk_tree_store_set (store, &aaa, 0, "0:0:0", -1);
2648 gtk_tree_store_append (store, &aab, &aa);
2649 gtk_tree_store_set (store, &aab, 0, "0:0:1", -1);
2651 s_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
2652 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (s_model), 0,
2653 GTK_SORT_ASCENDING);
2655 gtk_tree_model_get_iter_from_string (s_model, &iter, "0:0:0");
2657 gtk_tree_store_set (store, &aaa, 0, "0:0:0", -1);
2658 gtk_tree_store_remove (store, &aaa);
2659 gtk_tree_store_remove (store, &aab);
2661 gtk_tree_model_sort_clear_cache (GTK_TREE_MODEL_SORT (s_model));
2666 specific_bug_464173_visible_func (GtkTreeModel *model,
2670 gboolean *visible = (gboolean *)data;
2676 specific_bug_464173 (void)
2678 /* Test case for GNOME Bugzilla bug 464173, test case written
2679 * by Andreas Koehler.
2681 GtkTreeStore *model;
2682 GtkTreeModelFilter *f_model;
2683 GtkTreeIter iter1, iter2;
2685 gboolean visible = TRUE;
2687 model = gtk_tree_store_new (1, G_TYPE_STRING);
2688 gtk_tree_store_append (model, &iter1, NULL);
2689 gtk_tree_store_set (model, &iter1, 0, "Foo", -1);
2690 gtk_tree_store_append (model, &iter2, &iter1);
2691 gtk_tree_store_set (model, &iter2, 0, "Bar", -1);
2693 f_model = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (GTK_TREE_MODEL(model), NULL));
2694 gtk_tree_model_filter_set_visible_func (f_model,
2695 specific_bug_464173_visible_func,
2698 view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (f_model));
2701 gtk_tree_model_filter_refilter (f_model);
2706 specific_bug_540201_filter_func (GtkTreeModel *model,
2710 gboolean has_children;
2712 has_children = gtk_tree_model_iter_has_child (model, iter);
2714 return has_children;
2718 specific_bug_540201 (void)
2720 /* Test case for GNOME Bugzilla bug 540201, steps provided by
2723 GtkTreeIter iter, root;
2724 GtkTreeStore *store;
2725 GtkTreeModel *filter;
2727 GtkWidget *tree_view;
2729 store = gtk_tree_store_new (1, G_TYPE_INT);
2731 gtk_tree_store_append (store, &root, NULL);
2732 gtk_tree_store_set (store, &root, 0, 33, -1);
2734 filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
2735 tree_view = gtk_tree_view_new_with_model (filter);
2737 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
2738 specific_bug_540201_filter_func,
2741 gtk_tree_store_append (store, &iter, &root);
2742 gtk_tree_store_set (store, &iter, 0, 50, -1);
2744 gtk_tree_store_append (store, &iter, &root);
2745 gtk_tree_store_set (store, &iter, 0, 22, -1);
2748 gtk_tree_store_append (store, &root, NULL);
2749 gtk_tree_store_set (store, &root, 0, 33, -1);
2751 gtk_tree_store_append (store, &iter, &root);
2752 gtk_tree_store_set (store, &iter, 0, 22, -1);
2757 specific_bug_549287_visible_func (GtkTreeModel *model,
2761 gboolean result = FALSE;
2763 result = gtk_tree_model_iter_has_child (model, iter);
2769 specific_bug_549287 (void)
2771 /* Test case for GNOME Bugzilla bug 529287, provided by Julient Puydt */
2774 GtkTreeStore *store;
2775 GtkTreeModel *filtered;
2778 GtkTreeIter *swap, *parent, *child;
2780 store = gtk_tree_store_new (1, G_TYPE_STRING);
2781 filtered = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
2782 gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filtered),
2783 specific_bug_549287_visible_func,
2786 view = gtk_tree_view_new_with_model (filtered);
2788 for (i = 0; i < 4; i++)
2790 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
2792 parent = gtk_tree_iter_copy (&iter);
2793 child = gtk_tree_iter_copy (&iter);
2795 while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store),
2804 gtk_tree_store_append (store, child, parent);
2805 gtk_tree_store_set (store, child,
2809 gtk_tree_iter_free (parent);
2810 gtk_tree_iter_free (child);
2814 gtk_tree_store_append (store, &iter, NULL);
2815 gtk_tree_store_set (store, &iter,
2820 /* since we inserted something, we changed the visibility conditions: */
2821 gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filtered));
2831 gtk_test_init (&argc, &argv, NULL);
2833 g_test_add ("/FilterModel/self/verify-test-suite",
2837 filter_test_teardown);
2839 g_test_add ("/FilterModel/self/verify-test-suite/vroot/depth-1",
2840 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2842 verify_test_suite_vroot,
2843 filter_test_teardown);
2844 g_test_add ("/FilterModel/self/verify-test-suite/vroot/depth-2",
2845 FilterTest, gtk_tree_path_new_from_indices (2, 3, -1),
2847 verify_test_suite_vroot,
2848 filter_test_teardown);
2851 g_test_add ("/FilterModel/filled/hide-root-level",
2854 filled_hide_root_level,
2855 filter_test_teardown);
2856 g_test_add ("/FilterModel/filled/hide-child-levels",
2859 filled_hide_child_levels,
2860 filter_test_teardown);
2862 g_test_add ("/FilterModel/filled/hide-root-level/vroot",
2863 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2865 filled_vroot_hide_root_level,
2866 filter_test_teardown);
2867 g_test_add ("/FilterModel/filled/hide-child-levels/vroot",
2868 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2870 filled_vroot_hide_child_levels,
2871 filter_test_teardown);
2874 g_test_add ("/FilterModel/empty/show-nodes",
2876 filter_test_setup_empty,
2878 filter_test_teardown);
2879 g_test_add ("/FilterModel/empty/show-multiple-nodes",
2881 filter_test_setup_empty,
2882 empty_show_multiple_nodes,
2883 filter_test_teardown);
2885 g_test_add ("/FilterModel/empty/show-nodes/vroot",
2886 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2887 filter_test_setup_empty,
2888 empty_vroot_show_nodes,
2889 filter_test_teardown);
2890 g_test_add ("/FilterModel/empty/show-multiple-nodes/vroot",
2891 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2892 filter_test_setup_empty,
2893 empty_vroot_show_multiple_nodes,
2894 filter_test_teardown);
2897 g_test_add ("/FilterModel/unfiltered/hide-single",
2899 filter_test_setup_unfiltered,
2900 unfiltered_hide_single,
2901 filter_test_teardown);
2902 g_test_add ("/FilterModel/unfiltered/hide-single-child",
2904 filter_test_setup_unfiltered,
2905 unfiltered_hide_single_child,
2906 filter_test_teardown);
2907 g_test_add ("/FilterModel/unfiltered/hide-single-multi-level",
2909 filter_test_setup_unfiltered,
2910 unfiltered_hide_single_multi_level,
2911 filter_test_teardown);
2913 g_test_add ("/FilterModel/unfiltered/hide-single/vroot",
2914 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2915 filter_test_setup_unfiltered,
2916 unfiltered_vroot_hide_single,
2917 filter_test_teardown);
2918 g_test_add ("/FilterModel/unfiltered/hide-single-child/vroot",
2919 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2920 filter_test_setup_unfiltered,
2921 unfiltered_vroot_hide_single_child,
2922 filter_test_teardown);
2923 g_test_add ("/FilterModel/unfiltered/hide-single-multi-level/vroot",
2924 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2925 filter_test_setup_unfiltered,
2926 unfiltered_vroot_hide_single_multi_level,
2927 filter_test_teardown);
2931 g_test_add ("/FilterModel/unfiltered/show-single",
2933 filter_test_setup_empty_unfiltered,
2934 unfiltered_show_single,
2935 filter_test_teardown);
2936 g_test_add ("/FilterModel/unfiltered/show-single-child",
2938 filter_test_setup_empty_unfiltered,
2939 unfiltered_show_single_child,
2940 filter_test_teardown);
2941 g_test_add ("/FilterModel/unfiltered/show-single-multi-level",
2943 filter_test_setup_empty_unfiltered,
2944 unfiltered_show_single_multi_level,
2945 filter_test_teardown);
2947 g_test_add ("/FilterModel/unfiltered/show-single/vroot",
2948 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2949 filter_test_setup_empty_unfiltered,
2950 unfiltered_vroot_show_single,
2951 filter_test_teardown);
2952 g_test_add ("/FilterModel/unfiltered/show-single-child/vroot",
2953 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2954 filter_test_setup_empty_unfiltered,
2955 unfiltered_vroot_show_single_child,
2956 filter_test_teardown);
2957 g_test_add ("/FilterModel/unfiltered/show-single-multi-level/vroot",
2958 FilterTest, gtk_tree_path_new_from_indices (2, -1),
2959 filter_test_setup_empty_unfiltered,
2960 unfiltered_vroot_show_single_multi_level,
2961 filter_test_teardown);
2964 g_test_add_func ("/FilterModel/specific/path-dependent-filter",
2965 specific_path_dependent_filter);
2966 g_test_add_func ("/FilterModel/specific/append-after-collapse",
2967 specific_append_after_collapse);
2968 g_test_add_func ("/FilterModel/specific/sort-filter-remove-node",
2969 specific_sort_filter_remove_node);
2970 g_test_add_func ("/FilterModel/specific/sort-filter-remove-root",
2971 specific_sort_filter_remove_root);
2972 g_test_add_func ("/FilterModel/specific/root-mixed-visibility",
2973 specific_root_mixed_visibility);
2974 g_test_add_func ("/FilterModel/specific/has-child-filter",
2975 specific_has_child_filter);
2976 g_test_add_func ("/FilterModel/specific/root-has-child-filter",
2977 specific_root_has_child_filter);
2978 g_test_add_func ("/FilterModel/specific/filter-add-child",
2979 specific_filter_add_child);
2980 g_test_add_func ("/FilterModel/specific/list-store-clear",
2981 specific_list_store_clear);
2983 g_test_add_func ("/FilterModel/specific/bug-300089",
2984 specific_bug_300089);
2985 g_test_add_func ("/FilterModel/specific/bug-301558",
2986 specific_bug_301558);
2987 g_test_add_func ("/FilterModel/specific/bug-311955",
2988 specific_bug_311955);
2989 g_test_add_func ("/FilterModel/specific/bug-346800",
2990 specific_bug_346800);
2991 g_test_add_func ("/FilterModel/specific/bug-364946",
2992 specific_bug_364946);
2993 g_test_add_func ("/FilterModel/specific/bug-464173",
2994 specific_bug_464173);
2995 g_test_add_func ("/FilterModel/specific/bug-540201",
2996 specific_bug_540201);
2997 g_test_add_func ("/FilterModel/specific/bug-549287",
2998 specific_bug_549287);
3000 return g_test_run ();