1 /* Extensive GtkTreeModelSort 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.
22 #include "treemodel.h"
25 specific_bug_300089 (void)
27 /* Test case for GNOME Bugzilla bug 300089. Written by
30 GtkTreeModel *sort_model, *child_model;
32 GtkTreeIter iter, iter2, sort_iter;
34 g_test_bug ("300089");
36 child_model = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_STRING));
38 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
39 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "A", -1);
40 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
41 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "B", -1);
43 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter2, &iter);
44 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter2, 0, "D", -1);
45 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter2, &iter);
46 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter2, 0, "E", -1);
48 gtk_tree_store_append (GTK_TREE_STORE (child_model), &iter, NULL);
49 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "C", -1);
52 sort_model = GTK_TREE_MODEL (gtk_tree_model_sort_new_with_model (child_model));
53 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
54 0, GTK_SORT_ASCENDING);
56 path = gtk_tree_path_new_from_indices (1, 1, -1);
58 /* make sure a level is constructed */
59 gtk_tree_model_get_iter (sort_model, &sort_iter, path);
61 /* change the "E" row in a way that causes it to change position */
62 gtk_tree_model_get_iter (child_model, &iter, path);
63 gtk_tree_store_set (GTK_TREE_STORE (child_model), &iter, 0, "A", -1);
67 specific_bug_364946 (void)
69 /* This is a test case for GNOME Bugzilla bug 364946. It was written
73 GtkTreeIter a, aa, aaa, aab, iter;
74 GtkTreeModel *s_model;
76 g_test_bug ("364946");
78 store = gtk_tree_store_new (1, G_TYPE_STRING);
80 gtk_tree_store_append (store, &a, NULL);
81 gtk_tree_store_set (store, &a, 0, "0", -1);
83 gtk_tree_store_append (store, &aa, &a);
84 gtk_tree_store_set (store, &aa, 0, "0:0", -1);
86 gtk_tree_store_append (store, &aaa, &aa);
87 gtk_tree_store_set (store, &aaa, 0, "0:0:0", -1);
89 gtk_tree_store_append (store, &aab, &aa);
90 gtk_tree_store_set (store, &aab, 0, "0:0:1", -1);
92 s_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
93 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (s_model), 0,
96 gtk_tree_model_get_iter_from_string (s_model, &iter, "0:0:0");
98 gtk_tree_store_set (store, &aaa, 0, "0:0:0", -1);
99 gtk_tree_store_remove (store, &aaa);
100 gtk_tree_store_remove (store, &aab);
102 gtk_tree_model_sort_clear_cache (GTK_TREE_MODEL_SORT (s_model));
108 register_sort_model_tests (void)
110 g_test_add_func ("/TreeModelSort/specific/bug-300089",
111 specific_bug_300089);
112 g_test_add_func ("/TreeModelSort/specific/bug-364946",
113 specific_bug_364946);