1/* Extensive GtkTreeStore tests.
2 * Copyright (C) 2007 Imendio AB
3 * Authors: Kristian Rietveld <kris@imendio.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/* To do:
20 * - All the to do items from liststore.c, plus:
21 * - Finish up the insertion tests; things aren't as nicely refactored
22 * here as in GtkListStore, so we need to check for corner cases on
23 * all insertion functions separately.
24 * - We only test in the root level, we also need all tests "duplicated"
25 * for child levels.
26 * - And we also need tests for creating these child levels, etc.
27 */
28
29#include "treemodel.h"
30
31#include <gtk/gtk.h>
32
33static inline gboolean
34iters_equal (GtkTreeIter *a,
35 GtkTreeIter *b)
36{
37 if (a->stamp != b->stamp)
38 return FALSE;
39
40 if (a->user_data != b->user_data)
41 return FALSE;
42
43 /* user_data2 and user_data3 are not used in GtkTreeStore */
44
45 return TRUE;
46}
47
48static gboolean
49iter_position (GtkTreeStore *store,
50 GtkTreeIter *iter,
51 int n)
52{
53 gboolean ret = TRUE;
54 GtkTreePath *path;
55
56 path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter);
57 if (!path)
58 return FALSE;
59
60 if (gtk_tree_path_get_indices (path)[0] != n)
61 ret = FALSE;
62
63 gtk_tree_path_free (path);
64
65 return ret;
66}
67
68/*
69 * Fixture
70 */
71typedef struct
72{
73 GtkTreeIter iter[5];
74 GtkTreeStore *store;
75} TreeStore;
76
77static void
78tree_store_setup (TreeStore *fixture,
79 gconstpointer test_data)
80{
81 int i;
82
83 fixture->store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
84
85 for (i = 0; i < 5; i++)
86 {
87 gtk_tree_store_insert (tree_store: fixture->store, iter: &fixture->iter[i], NULL, position: i);
88 gtk_tree_store_set (tree_store: fixture->store, iter: &fixture->iter[i], 0, i, -1);
89 }
90}
91
92static void
93tree_store_teardown (TreeStore *fixture,
94 gconstpointer test_data)
95{
96 g_object_unref (object: fixture->store);
97}
98
99/*
100 * The actual tests.
101 */
102
103static void
104check_model (TreeStore *fixture,
105 int *new_order,
106 int skip)
107{
108 int i;
109 GtkTreePath *path;
110
111 path = gtk_tree_path_new ();
112 gtk_tree_path_down (path);
113
114 /* Check validity of the model and validity of the iters-persistent
115 * claim.
116 */
117 for (i = 0; i < 5; i++)
118 {
119 GtkTreeIter iter;
120
121 if (i == skip)
122 continue;
123
124 /* The saved iterator at new_order[i] should match the iterator
125 * at i.
126 */
127
128 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
129 iter: &iter, path);
130
131 g_assert_true (gtk_tree_store_iter_is_valid (fixture->store, &iter));
132 g_assert_true (iters_equal (&iter, &fixture->iter[new_order[i]]));
133
134 gtk_tree_path_next (path);
135 }
136
137 gtk_tree_path_free (path);
138}
139
140/* insertion */
141static void
142tree_store_test_insert_high_values (void)
143{
144 GtkTreeIter iter, iter2;
145 GtkTreeIter iter_copy;
146 GtkTreeStore *store;
147
148 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
149
150 gtk_tree_store_insert (tree_store: store, iter: &iter, NULL, position: 1234);
151 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter));
152 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 1);
153 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
154 g_assert_true (iters_equal (&iter, &iter_copy));
155 g_assert_true (iter_position (store, &iter, 0));
156
157 gtk_tree_store_insert (tree_store: store, iter: &iter2, NULL, position: 765);
158 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
159 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
160
161 /* Walk over the model */
162 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
163 g_assert_true (iters_equal (&iter, &iter_copy));
164 g_assert_true (iter_position (store, &iter, 0));
165
166 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
167 g_assert_true (iters_equal (&iter2, &iter_copy));
168 g_assert_true (iter_position (store, &iter2, 1));
169
170 g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
171
172 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
173 g_assert_true (iters_equal (&iter2, &iter_copy));
174 g_assert_true (iter_position (store, &iter2, 1));
175
176 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
177 g_assert_true (iters_equal (&iter, &iter_copy));
178 g_assert_true (iter_position (store, &iter, 0));
179
180 g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
181
182 g_object_unref (object: store);
183}
184
185static void
186tree_store_test_append (void)
187{
188 GtkTreeIter iter, iter2;
189 GtkTreeIter iter_copy;
190 GtkTreeStore *store;
191
192 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
193
194 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
195 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter));
196 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 1);
197 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
198 g_assert_true (iters_equal (&iter, &iter_copy));
199 g_assert_true (iter_position (store, &iter, 0));
200
201 gtk_tree_store_append (tree_store: store, iter: &iter2, NULL);
202 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
203 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
204
205 /* Walk over the model */
206 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
207 g_assert_true (iters_equal (&iter, &iter_copy));
208 g_assert_true (iter_position (store, &iter, 0));
209
210 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
211 g_assert_true (iters_equal (&iter2, &iter_copy));
212 g_assert_true (iter_position (store, &iter2, 1));
213
214 g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
215
216 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
217 g_assert_true (iters_equal (&iter2, &iter_copy));
218 g_assert_true (iter_position (store, &iter2, 1));
219
220 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
221 g_assert_true (iters_equal (&iter, &iter_copy));
222 g_assert_true (iter_position (store, &iter, 0));
223
224 g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
225
226 g_object_unref (object: store);
227}
228
229static void
230tree_store_test_prepend (void)
231{
232 GtkTreeIter iter, iter2;
233 GtkTreeIter iter_copy;
234 GtkTreeStore *store;
235
236 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
237
238 gtk_tree_store_prepend (tree_store: store, iter: &iter, NULL);
239 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter));
240 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 1);
241 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
242 g_assert_true (iters_equal (&iter, &iter_copy));
243 g_assert_true (iter_position (store, &iter, 0));
244
245 gtk_tree_store_prepend (tree_store: store, iter: &iter2, NULL);
246 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
247 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
248
249 /* Walk over the model */
250 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
251 g_assert_true (iters_equal (&iter2, &iter_copy));
252 g_assert_true (iter_position (store, &iter2, 0));
253
254 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
255 g_assert_true (iters_equal (&iter, &iter_copy));
256 g_assert_true (iter_position (store, &iter, 1));
257
258 g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
259
260 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
261 g_assert_true (iters_equal (&iter, &iter_copy));
262 g_assert_true (iter_position (store, &iter, 1));
263
264 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
265 g_assert_true (iters_equal (&iter2, &iter_copy));
266 g_assert_true (iter_position (store, &iter2, 0));
267
268 g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
269
270 g_object_unref (object: store);
271}
272
273static void
274tree_store_test_insert_after (void)
275{
276 GtkTreeIter iter, iter2, iter3;
277 GtkTreeIter iter_copy;
278 GtkTreeStore *store;
279
280 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
281
282 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
283 gtk_tree_store_append (tree_store: store, iter: &iter2, NULL);
284
285 gtk_tree_store_insert_after (tree_store: store, iter: &iter3, NULL, sibling: &iter);
286 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter3));
287 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 3);
288 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
289 g_assert_true (iters_equal (&iter3, &iter_copy));
290 g_assert_true (iter_position (store, &iter3, 1));
291
292 /* Walk over the model */
293 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
294 g_assert_true (iters_equal (&iter, &iter_copy));
295 g_assert_true (iter_position (store, &iter_copy, 0));
296
297 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
298 g_assert_true (iters_equal (&iter3, &iter_copy));
299 g_assert_true (iter_position (store, &iter_copy, 1));
300
301 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
302 g_assert_true (iters_equal (&iter2, &iter_copy));
303 g_assert_true (iter_position (store, &iter_copy, 2));
304
305 g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
306
307 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 2));
308 g_assert_true (iters_equal (&iter2, &iter_copy));
309 g_assert_true (iter_position (store, &iter2, 2));
310
311 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
312 g_assert_true (iters_equal (&iter3, &iter_copy));
313 g_assert_true (iter_position (store, &iter3, 1));
314
315 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
316 g_assert_true (iters_equal (&iter, &iter_copy));
317 g_assert_true (iter_position (store, &iter, 0));
318
319 g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
320
321 g_object_unref (object: store);
322}
323
324static void
325tree_store_test_insert_after_NULL (void)
326{
327 GtkTreeIter iter, iter2;
328 GtkTreeIter iter_copy;
329 GtkTreeStore *store;
330
331 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
332
333 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
334
335 /* move_after NULL is basically a prepend */
336 gtk_tree_store_insert_after (tree_store: store, iter: &iter2, NULL, NULL);
337 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
338 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
339
340 /* Walk over the model */
341 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
342 g_assert_true (iters_equal (&iter2, &iter_copy));
343 g_assert_true (iter_position (store, &iter2, 0));
344
345 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
346 g_assert_true (iters_equal (&iter, &iter_copy));
347 g_assert_true (iter_position (store, &iter, 1));
348
349 g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
350
351 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 0));
352 g_assert_true (iters_equal (&iter2, &iter_copy));
353
354 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
355 g_assert_true (iters_equal (&iter, &iter_copy));
356 g_assert_true (iter_position (store, &iter, 1));
357
358 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
359 g_assert_true (iters_equal (&iter2, &iter_copy));
360 g_assert_true (iter_position (store, &iter2, 0));
361
362 g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
363
364 g_object_unref (object: store);
365}
366
367static void
368tree_store_test_insert_before (void)
369{
370 GtkTreeIter iter, iter2, iter3;
371 GtkTreeIter iter_copy;
372 GtkTreeStore *store;
373
374 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
375
376 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
377 gtk_tree_store_append (tree_store: store, iter: &iter2, NULL);
378
379 gtk_tree_store_insert_before (tree_store: store, iter: &iter3, NULL, sibling: &iter2);
380 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter3));
381 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 3);
382 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
383 g_assert_true (iters_equal (&iter3, &iter_copy));
384 g_assert_true (iter_position (store, &iter3, 1));
385
386 /* Walk over the model */
387 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
388 g_assert_true (iters_equal (&iter, &iter_copy));
389 g_assert_true (iter_position (store, &iter_copy, 0));
390
391 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
392 g_assert_true (iters_equal (&iter3, &iter_copy));
393 g_assert_true (iter_position (store, &iter_copy, 1));
394
395 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
396 g_assert_true (iters_equal (&iter2, &iter_copy));
397 g_assert_true (iter_position (store, &iter_copy, 2));
398
399 g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
400
401 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
402 g_assert_true (iters_equal (&iter3, &iter_copy));
403
404 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 2));
405 g_assert_true (iters_equal (&iter2, &iter_copy));
406 g_assert_true (iter_position (store, &iter2, 2));
407
408 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
409 g_assert_true (iters_equal (&iter3, &iter_copy));
410 g_assert_true (iter_position (store, &iter3, 1));
411
412 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
413 g_assert_true (iters_equal (&iter, &iter_copy));
414 g_assert_true (iter_position (store, &iter, 0));
415
416 g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
417
418 g_object_unref (object: store);
419}
420
421static void
422tree_store_test_insert_before_NULL (void)
423{
424 GtkTreeIter iter, iter2;
425 GtkTreeIter iter_copy;
426 GtkTreeStore *store;
427
428 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
429
430 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
431
432 /* move_before NULL is basically an append */
433 gtk_tree_store_insert_before (tree_store: store, iter: &iter2, NULL, NULL);
434 g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
435 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
436
437 /* Walk over the model */
438 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
439 g_assert_true (iters_equal (&iter, &iter_copy));
440 g_assert_true (iter_position (store, &iter, 0));
441
442 g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
443 g_assert_true (iters_equal (&iter2, &iter_copy));
444 g_assert_true (iter_position (store, &iter2, 1));
445
446 g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
447
448 g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
449 g_assert_true (iters_equal (&iter2, &iter_copy));
450 g_assert_true (iter_position (store, &iter2, 1));
451
452 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
453 g_assert_true (iters_equal (&iter, &iter_copy));
454 g_assert_true (iter_position (store, &iter, 0));
455
456 g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
457
458 g_object_unref (object: store);
459}
460
461/* setting values */
462static void
463tree_store_set_gvalue_to_transform (void)
464{
465 GtkTreeStore *store;
466 GtkTreeIter iter;
467 GValue value = G_VALUE_INIT;
468
469 /* https://bugzilla.gnome.org/show_bug.cgi?id=677649 */
470 store = gtk_tree_store_new (n_columns: 1, G_TYPE_LONG);
471 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
472
473 g_value_init (value: &value, G_TYPE_INT);
474 g_value_set_int (value: &value, v_int: 42);
475 gtk_tree_store_set_value (tree_store: store, iter: &iter, column: 0, value: &value);
476}
477
478/* removal */
479static void
480tree_store_test_remove_begin (TreeStore *fixture,
481 gconstpointer user_data)
482{
483 int new_order[5] = { -1, 1, 2, 3, 4 };
484 GtkTreePath *path;
485 GtkTreeIter iter;
486
487 /* Remove node at 0 */
488 path = gtk_tree_path_new_from_indices (first_index: 0, -1);
489 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), iter: &iter, path);
490 gtk_tree_path_free (path);
491
492 g_assert_true (gtk_tree_store_remove (fixture->store, &iter) == TRUE);
493 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &fixture->iter[0]));
494 g_assert_true (iters_equal (&iter, &fixture->iter[1]));
495
496 check_model (fixture, new_order, skip: 0);
497}
498
499static void
500tree_store_test_remove_middle (TreeStore *fixture,
501 gconstpointer user_data)
502{
503 int new_order[5] = { 0, 1, -1, 3, 4 };
504 GtkTreePath *path;
505 GtkTreeIter iter;
506
507 /* Remove node at 2 */
508 path = gtk_tree_path_new_from_indices (first_index: 2, -1);
509 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), iter: &iter, path);
510 gtk_tree_path_free (path);
511
512 g_assert_true (gtk_tree_store_remove (fixture->store, &iter));
513 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &fixture->iter[2]));
514 g_assert_true (iters_equal (&iter, &fixture->iter[3]));
515
516 check_model (fixture, new_order, skip: 2);
517}
518
519static void
520tree_store_test_remove_end (TreeStore *fixture,
521 gconstpointer user_data)
522{
523 int new_order[5] = { 0, 1, 2, 3, -1 };
524 GtkTreePath *path;
525 GtkTreeIter iter;
526
527 /* Remove node at 4 */
528 path = gtk_tree_path_new_from_indices (first_index: 4, -1);
529 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), iter: &iter, path);
530 gtk_tree_path_free (path);
531
532 g_assert_false (gtk_tree_store_remove (fixture->store, &iter));
533 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &fixture->iter[4]));
534
535 check_model (fixture, new_order, skip: 4);
536}
537
538static void
539tree_store_test_clear (TreeStore *fixture,
540 gconstpointer user_data)
541{
542 int i;
543
544 gtk_tree_store_clear (tree_store: fixture->store);
545
546 g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (fixture->store), NULL), ==, 0);
547
548 for (i = 0; i < 5; i++)
549 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &fixture->iter[i]));
550}
551
552/* reorder */
553
554static void
555tree_store_test_reorder (TreeStore *fixture,
556 gconstpointer user_data)
557{
558 int new_order[5] = { 4, 1, 0, 2, 3 };
559
560 gtk_tree_store_reorder (tree_store: fixture->store, NULL, new_order);
561 check_model (fixture, new_order, skip: -1);
562}
563
564/* swapping */
565
566static void
567tree_store_test_swap_begin (TreeStore *fixture,
568 gconstpointer user_data)
569{
570 /* We swap nodes 0 and 1 at the beginning */
571 int new_order[5] = { 1, 0, 2, 3, 4 };
572
573 GtkTreeIter iter_a;
574 GtkTreeIter iter_b;
575
576 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "0"));
577 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "1"));
578
579 gtk_tree_store_swap (tree_store: fixture->store, a: &iter_a, b: &iter_b);
580 check_model (fixture, new_order, skip: -1);
581}
582
583static void
584tree_store_test_swap_middle_next (TreeStore *fixture,
585 gconstpointer user_data)
586{
587 /* We swap nodes 2 and 3 in the middle that are next to each other */
588 int new_order[5] = { 0, 1, 3, 2, 4 };
589
590 GtkTreeIter iter_a;
591 GtkTreeIter iter_b;
592
593 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "2"));
594 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "3"));
595
596 gtk_tree_store_swap (tree_store: fixture->store, a: &iter_a, b: &iter_b);
597 check_model (fixture, new_order, skip: -1);
598}
599
600static void
601tree_store_test_swap_middle_apart (TreeStore *fixture,
602 gconstpointer user_data)
603{
604 /* We swap nodes 1 and 3 in the middle that are apart from each other */
605 int new_order[5] = { 0, 3, 2, 1, 4 };
606
607 GtkTreeIter iter_a;
608 GtkTreeIter iter_b;
609
610 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "1"));
611 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "3"));
612
613 gtk_tree_store_swap (tree_store: fixture->store, a: &iter_a, b: &iter_b);
614 check_model (fixture, new_order, skip: -1);
615}
616
617static void
618tree_store_test_swap_end (TreeStore *fixture,
619 gconstpointer user_data)
620{
621 /* We swap nodes 3 and 4 at the end */
622 int new_order[5] = { 0, 1, 2, 4, 3 };
623
624 GtkTreeIter iter_a;
625 GtkTreeIter iter_b;
626
627 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "3"));
628 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "4"));
629
630 gtk_tree_store_swap (tree_store: fixture->store, a: &iter_a, b: &iter_b);
631 check_model (fixture, new_order, skip: -1);
632}
633
634static void
635tree_store_test_swap_single (void)
636{
637 GtkTreeIter iter;
638 GtkTreeIter iter_copy;
639 GtkTreeStore *store;
640
641 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
642
643 /* Check if swap on a store with a single node does not corrupt
644 * the store.
645 */
646
647 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
648 iter_copy = iter;
649
650 gtk_tree_store_swap (tree_store: store, a: &iter, b: &iter);
651 g_assert_true (iters_equal (&iter, &iter_copy));
652 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
653 g_assert_true (iters_equal (&iter, &iter_copy));
654
655 g_object_unref (object: store);
656}
657
658/* move after */
659
660static void
661tree_store_test_move_after_from_start (TreeStore *fixture,
662 gconstpointer user_data)
663{
664 /* We move node 0 after 2 */
665 int new_order[5] = { 1, 2, 0, 3, 4 };
666
667 GtkTreeIter iter;
668 GtkTreeIter position;
669
670 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "0"));
671 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
672
673 gtk_tree_store_move_after (tree_store: fixture->store, iter: &iter, position: &position);
674 check_model (fixture, new_order, skip: -1);
675}
676
677static void
678tree_store_test_move_after_next (TreeStore *fixture,
679 gconstpointer user_data)
680{
681 /* We move node 2 after 3 */
682 int new_order[5] = { 0, 1, 3, 2, 4 };
683
684 GtkTreeIter iter;
685 GtkTreeIter position;
686
687 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
688 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
689
690 gtk_tree_store_move_after (tree_store: fixture->store, iter: &iter, position: &position);
691 check_model (fixture, new_order, skip: -1);
692}
693
694static void
695tree_store_test_move_after_apart (TreeStore *fixture,
696 gconstpointer user_data)
697{
698 /* We move node 1 after 3 */
699 int new_order[5] = { 0, 2, 3, 1, 4 };
700
701 GtkTreeIter iter;
702 GtkTreeIter position;
703
704 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "1"));
705 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
706
707 gtk_tree_store_move_after (tree_store: fixture->store, iter: &iter, position: &position);
708 check_model (fixture, new_order, skip: -1);
709}
710
711static void
712tree_store_test_move_after_end (TreeStore *fixture,
713 gconstpointer user_data)
714{
715 /* We move node 2 after 4 */
716 int new_order[5] = { 0, 1, 3, 4, 2 };
717
718 GtkTreeIter iter;
719 GtkTreeIter position;
720
721 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
722 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "4"));
723
724 gtk_tree_store_move_after (tree_store: fixture->store, iter: &iter, position: &position);
725 check_model (fixture, new_order, skip: -1);
726}
727
728static void
729tree_store_test_move_after_from_end (TreeStore *fixture,
730 gconstpointer user_data)
731{
732 /* We move node 4 after 1 */
733 int new_order[5] = { 0, 1, 4, 2, 3 };
734
735 GtkTreeIter iter;
736 GtkTreeIter position;
737
738 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
739 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "1"));
740
741 gtk_tree_store_move_after (tree_store: fixture->store, iter: &iter, position: &position);
742 check_model (fixture, new_order, skip: -1);
743}
744
745static void
746tree_store_test_move_after_change_ends (TreeStore *fixture,
747 gconstpointer user_data)
748{
749 /* We move 0 after 4, this will cause both the head and tail ends to
750 * change.
751 */
752 int new_order[5] = { 1, 2, 3, 4, 0 };
753
754 GtkTreeIter iter;
755 GtkTreeIter position;
756
757 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "0"));
758 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "4"));
759
760 gtk_tree_store_move_after (tree_store: fixture->store, iter: &iter, position: &position);
761 check_model (fixture, new_order, skip: -1);
762}
763
764static void
765tree_store_test_move_after_NULL (TreeStore *fixture,
766 gconstpointer user_data)
767{
768 /* We move node 2, NULL should prepend */
769 int new_order[5] = { 2, 0, 1, 3, 4 };
770
771 GtkTreeIter iter;
772
773 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
774
775 gtk_tree_store_move_after (tree_store: fixture->store, iter: &iter, NULL);
776 check_model (fixture, new_order, skip: -1);
777}
778
779static void
780tree_store_test_move_after_single (void)
781{
782 GtkTreeIter iter;
783 GtkTreeIter iter_copy;
784 GtkTreeStore *store;
785
786 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
787
788 /* Check if move-after on a store with a single node does not corrupt
789 * the store.
790 */
791
792 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
793 iter_copy = iter;
794
795 gtk_tree_store_move_after (tree_store: store, iter: &iter, NULL);
796 g_assert_true (iters_equal (&iter, &iter_copy));
797 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
798 g_assert_true (iters_equal (&iter, &iter_copy));
799
800 gtk_tree_store_move_after (tree_store: store, iter: &iter, position: &iter);
801 g_assert_true (iters_equal (&iter, &iter_copy));
802 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
803 g_assert_true (iters_equal (&iter, &iter_copy));
804
805 g_object_unref (object: store);
806}
807
808/* move before */
809
810static void
811tree_store_test_move_before_next (TreeStore *fixture,
812 gconstpointer user_data)
813{
814 /* We move node 3 before 2 */
815 int new_order[5] = { 0, 1, 3, 2, 4 };
816
817 GtkTreeIter iter;
818 GtkTreeIter position;
819
820 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "3"));
821 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
822
823 gtk_tree_store_move_before (tree_store: fixture->store, iter: &iter, position: &position);
824 check_model (fixture, new_order, skip: -1);
825}
826
827static void
828tree_store_test_move_before_apart (TreeStore *fixture,
829 gconstpointer user_data)
830{
831 /* We move node 1 before 3 */
832 int new_order[5] = { 0, 2, 1, 3, 4 };
833
834 GtkTreeIter iter;
835 GtkTreeIter position;
836
837 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "1"));
838 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
839
840 gtk_tree_store_move_before (tree_store: fixture->store, iter: &iter, position: &position);
841 check_model (fixture, new_order, skip: -1);
842}
843
844static void
845tree_store_test_move_before_to_start (TreeStore *fixture,
846 gconstpointer user_data)
847{
848 /* We move node 2 before 0 */
849 int new_order[5] = { 2, 0, 1, 3, 4 };
850
851 GtkTreeIter iter;
852 GtkTreeIter position;
853
854 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
855 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "0"));
856
857 gtk_tree_store_move_before (tree_store: fixture->store, iter: &iter, position: &position);
858 check_model (fixture, new_order, skip: -1);
859}
860
861static void
862tree_store_test_move_before_from_end (TreeStore *fixture,
863 gconstpointer user_data)
864{
865 /* We move node 4 before 2 (replace end) */
866 int new_order[5] = { 0, 1, 4, 2, 3 };
867
868 GtkTreeIter iter;
869 GtkTreeIter position;
870
871 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
872 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
873
874 gtk_tree_store_move_before (tree_store: fixture->store, iter: &iter, position: &position);
875 check_model (fixture, new_order, skip: -1);
876}
877
878static void
879tree_store_test_move_before_change_ends (TreeStore *fixture,
880 gconstpointer user_data)
881{
882 /* We move node 4 before 0 */
883 int new_order[5] = { 4, 0, 1, 2, 3 };
884
885 GtkTreeIter iter;
886 GtkTreeIter position;
887
888 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
889 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "0"));
890
891 gtk_tree_store_move_before (tree_store: fixture->store, iter: &iter, position: &position);
892 check_model (fixture, new_order, skip: -1);
893}
894
895static void
896tree_store_test_move_before_NULL (TreeStore *fixture,
897 gconstpointer user_data)
898{
899 /* We move node 2, NULL should append */
900 int new_order[5] = { 0, 1, 3, 4, 2 };
901
902 GtkTreeIter iter;
903
904 g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
905
906 gtk_tree_store_move_before (tree_store: fixture->store, iter: &iter, NULL);
907 check_model (fixture, new_order, skip: -1);
908}
909
910static void
911tree_store_test_move_before_single (void)
912{
913 GtkTreeIter iter;
914 GtkTreeIter iter_copy;
915 GtkTreeStore *store;
916
917 store = gtk_tree_store_new (n_columns: 1, G_TYPE_INT);
918
919 /* Check if move-after on a store with a single node does not corrupt
920 * the store.
921 */
922
923 gtk_tree_store_append (tree_store: store, iter: &iter, NULL);
924 iter_copy = iter;
925
926 gtk_tree_store_move_before (tree_store: store, iter: &iter, NULL);
927 g_assert_true (iters_equal (&iter, &iter_copy));
928 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
929 g_assert_true (iters_equal (&iter, &iter_copy));
930
931 gtk_tree_store_move_before (tree_store: store, iter: &iter, position: &iter);
932 g_assert_true (iters_equal (&iter, &iter_copy));
933 g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
934 g_assert_true (iters_equal (&iter, &iter_copy));
935
936 g_object_unref (object: store);
937}
938
939
940/* iter invalidation */
941
942static void
943tree_store_test_iter_previous_invalid (TreeStore *fixture,
944 gconstpointer user_data)
945{
946 GtkTreeIter iter;
947
948 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), iter: &iter);
949
950 g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (fixture->store),
951 &iter) == FALSE);
952 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &iter));
953 g_assert_cmpint (iter.stamp, ==, 0);
954}
955
956static void
957tree_store_test_iter_next_invalid (TreeStore *fixture,
958 gconstpointer user_data)
959{
960 GtkTreePath *path;
961 GtkTreeIter iter;
962
963 path = gtk_tree_path_new_from_indices (first_index: 4, -1);
964 gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), iter: &iter, path);
965 gtk_tree_path_free (path);
966
967 g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store),
968 &iter));
969 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &iter));
970 g_assert_cmpint (iter.stamp, ==, 0);
971}
972
973static void
974tree_store_test_iter_children_invalid (TreeStore *fixture,
975 gconstpointer user_data)
976{
977 GtkTreeIter iter, child;
978
979 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), iter: &iter);
980 g_assert_true (gtk_tree_store_iter_is_valid (fixture->store, &iter));
981
982 g_assert_false (gtk_tree_model_iter_children (GTK_TREE_MODEL (fixture->store),
983 &child, &iter));
984 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &child));
985 g_assert_cmpint (child.stamp, ==, 0);
986}
987
988static void
989tree_store_test_iter_nth_child_invalid (TreeStore *fixture,
990 gconstpointer user_data)
991{
992 GtkTreeIter iter, child;
993
994 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), iter: &iter);
995 g_assert_true (gtk_tree_store_iter_is_valid (fixture->store, &iter));
996
997 g_assert_false (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (fixture->store),
998 &child, &iter, 0));
999 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &child));
1000 g_assert_cmpint (child.stamp, ==, 0);
1001}
1002
1003static void
1004tree_store_test_iter_parent_invalid (TreeStore *fixture,
1005 gconstpointer user_data)
1006{
1007 GtkTreeIter iter, child;
1008
1009 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), iter: &child);
1010 g_assert_true (gtk_tree_store_iter_is_valid (fixture->store, &child));
1011
1012 g_assert_false (gtk_tree_model_iter_parent (GTK_TREE_MODEL (fixture->store),
1013 &iter, &child));
1014 g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &iter));
1015 g_assert_cmpint (iter.stamp, ==, 0);
1016}
1017
1018/* specific bugs */
1019static void
1020specific_bug_77977 (void)
1021{
1022 GtkTreeStore *tree_store;
1023 GtkTreeIter iter1, iter2, iter3;
1024 GtkTreePath *path;
1025 GtkTreeRowReference *row_ref;
1026
1027 /* Stripped down version of test case for bug 77977 by Damon Chaplin */
1028
1029 /*http://bugzilla.gnome.org/show_bug.cgi?id=77977 */
1030
1031 tree_store = gtk_tree_store_new (n_columns: 1, G_TYPE_STRING);
1032
1033 gtk_tree_store_append (tree_store, iter: &iter1, NULL);
1034 gtk_tree_store_set (tree_store, iter: &iter1, 0, "Window1", -1);
1035
1036 gtk_tree_store_append (tree_store, iter: &iter2, parent: &iter1);
1037 gtk_tree_store_set (tree_store, iter: &iter2, 0, "Table1", -1);
1038
1039 gtk_tree_store_append (tree_store, iter: &iter3, parent: &iter2);
1040 gtk_tree_store_set (tree_store, iter: &iter3, 0, "Button1", -1);
1041
1042 path = gtk_tree_path_new_from_indices (first_index: 0, 0, 0, -1);
1043 row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (tree_store), path);
1044 gtk_tree_path_free (path);
1045
1046 gtk_tree_store_remove (tree_store, iter: &iter1);
1047
1048 gtk_tree_row_reference_free (reference: row_ref);
1049 g_object_unref (object: tree_store);
1050}
1051
1052static void
1053specific_bug_698396 (void)
1054{
1055 /*http://bugzilla.gnome.org/show_bug.cgi?id=698396 */
1056
1057 if (g_test_subprocess ())
1058 {
1059 GtkTreeStore *tree_store;
1060 int new_order[1] = { 0 };
1061
1062 tree_store = gtk_tree_store_new (n_columns: 1, G_TYPE_STRING);
1063 gtk_tree_store_reorder (tree_store, NULL, new_order);
1064 g_object_unref (object: tree_store);
1065
1066 return;
1067 }
1068
1069 g_test_trap_subprocess (NULL, usec_timeout: 0, test_flags: 0);
1070 g_test_trap_assert_stderr ("*Cannot reorder, parent has no children*");
1071 g_test_trap_assert_failed ();
1072}
1073
1074/* main */
1075
1076void
1077register_tree_store_tests (void)
1078{
1079 /* insertion */
1080 g_test_add_func (testpath: "/TreeStore/insert-high-values",
1081 test_func: tree_store_test_insert_high_values);
1082 g_test_add_func (testpath: "/TreeStore/append",
1083 test_func: tree_store_test_append);
1084 g_test_add_func (testpath: "/TreeStore/prepend",
1085 test_func: tree_store_test_prepend);
1086 g_test_add_func (testpath: "/TreeStore/insert-after",
1087 test_func: tree_store_test_insert_after);
1088 g_test_add_func (testpath: "/TreeStore/insert-after-NULL",
1089 test_func: tree_store_test_insert_after_NULL);
1090 g_test_add_func (testpath: "/TreeStore/insert-before",
1091 test_func: tree_store_test_insert_before);
1092 g_test_add_func (testpath: "/TreeStore/insert-before-NULL",
1093 test_func: tree_store_test_insert_before_NULL);
1094
1095 /* setting values (FIXME) */
1096 g_test_add_func (testpath: "/TreeStore/set-gvalue-to-transform",
1097 test_func: tree_store_set_gvalue_to_transform);
1098
1099 /* removal */
1100 g_test_add ("/TreeStore/remove-begin", TreeStore, NULL,
1101 tree_store_setup, tree_store_test_remove_begin,
1102 tree_store_teardown);
1103 g_test_add ("/TreeStore/remove-middle", TreeStore, NULL,
1104 tree_store_setup, tree_store_test_remove_middle,
1105 tree_store_teardown);
1106 g_test_add ("/TreeStore/remove-end", TreeStore, NULL,
1107 tree_store_setup, tree_store_test_remove_end,
1108 tree_store_teardown);
1109
1110 g_test_add ("/TreeStore/clear", TreeStore, NULL,
1111 tree_store_setup, tree_store_test_clear,
1112 tree_store_teardown);
1113
1114 /* reordering */
1115 g_test_add ("/TreeStore/reorder", TreeStore, NULL,
1116 tree_store_setup, tree_store_test_reorder,
1117 tree_store_teardown);
1118
1119 /* swapping */
1120 g_test_add ("/TreeStore/swap-begin", TreeStore, NULL,
1121 tree_store_setup, tree_store_test_swap_begin,
1122 tree_store_teardown);
1123 g_test_add ("/TreeStore/swap-middle-next", TreeStore, NULL,
1124 tree_store_setup, tree_store_test_swap_middle_next,
1125 tree_store_teardown);
1126 g_test_add ("/TreeStore/swap-middle-apart", TreeStore, NULL,
1127 tree_store_setup, tree_store_test_swap_middle_apart,
1128 tree_store_teardown);
1129 g_test_add ("/TreeStore/swap-end", TreeStore, NULL,
1130 tree_store_setup, tree_store_test_swap_end,
1131 tree_store_teardown);
1132 g_test_add_func (testpath: "/TreeStore/swap-single",
1133 test_func: tree_store_test_swap_single);
1134
1135 /* moving */
1136 g_test_add ("/TreeStore/move-after-from-start", TreeStore, NULL,
1137 tree_store_setup, tree_store_test_move_after_from_start,
1138 tree_store_teardown);
1139 g_test_add ("/TreeStore/move-after-next", TreeStore, NULL,
1140 tree_store_setup, tree_store_test_move_after_next,
1141 tree_store_teardown);
1142 g_test_add ("/TreeStore/move-after-apart", TreeStore, NULL,
1143 tree_store_setup, tree_store_test_move_after_apart,
1144 tree_store_teardown);
1145 g_test_add ("/TreeStore/move-after-end", TreeStore, NULL,
1146 tree_store_setup, tree_store_test_move_after_end,
1147 tree_store_teardown);
1148 g_test_add ("/TreeStore/move-after-from-end", TreeStore, NULL,
1149 tree_store_setup, tree_store_test_move_after_from_end,
1150 tree_store_teardown);
1151 g_test_add ("/TreeStore/move-after-change-ends", TreeStore, NULL,
1152 tree_store_setup, tree_store_test_move_after_change_ends,
1153 tree_store_teardown);
1154 g_test_add ("/TreeStore/move-after-NULL", TreeStore, NULL,
1155 tree_store_setup, tree_store_test_move_after_NULL,
1156 tree_store_teardown);
1157 g_test_add_func (testpath: "/TreeStore/move-after-single",
1158 test_func: tree_store_test_move_after_single);
1159
1160 g_test_add ("/TreeStore/move-before-next", TreeStore, NULL,
1161 tree_store_setup, tree_store_test_move_before_next,
1162 tree_store_teardown);
1163 g_test_add ("/TreeStore/move-before-apart", TreeStore, NULL,
1164 tree_store_setup, tree_store_test_move_before_apart,
1165 tree_store_teardown);
1166 g_test_add ("/TreeStore/move-before-to-start", TreeStore, NULL,
1167 tree_store_setup, tree_store_test_move_before_to_start,
1168 tree_store_teardown);
1169 g_test_add ("/TreeStore/move-before-from-end", TreeStore, NULL,
1170 tree_store_setup, tree_store_test_move_before_from_end,
1171 tree_store_teardown);
1172 g_test_add ("/TreeStore/move-before-change-ends", TreeStore, NULL,
1173 tree_store_setup, tree_store_test_move_before_change_ends,
1174 tree_store_teardown);
1175 g_test_add ("/TreeStore/move-before-NULL", TreeStore, NULL,
1176 tree_store_setup, tree_store_test_move_before_NULL,
1177 tree_store_teardown);
1178 g_test_add_func (testpath: "/TreeStore/move-before-single",
1179 test_func: tree_store_test_move_before_single);
1180
1181 /* iter invalidation */
1182 g_test_add ("/TreeStore/iter-prev-invalid", TreeStore, NULL,
1183 tree_store_setup, tree_store_test_iter_previous_invalid,
1184 tree_store_teardown);
1185 g_test_add ("/TreeStore/iter-next-invalid", TreeStore, NULL,
1186 tree_store_setup, tree_store_test_iter_next_invalid,
1187 tree_store_teardown);
1188 g_test_add ("/TreeStore/iter-children-invalid", TreeStore, NULL,
1189 tree_store_setup, tree_store_test_iter_children_invalid,
1190 tree_store_teardown);
1191 g_test_add ("/TreeStore/iter-nth-child-invalid", TreeStore, NULL,
1192 tree_store_setup, tree_store_test_iter_nth_child_invalid,
1193 tree_store_teardown);
1194 g_test_add ("/TreeStore/iter-parent-invalid", TreeStore, NULL,
1195 tree_store_setup, tree_store_test_iter_parent_invalid,
1196 tree_store_teardown);
1197
1198 /* specific bugs */
1199 g_test_add_func (testpath: "/TreeStore/bug-77977", test_func: specific_bug_77977);
1200 g_test_add_func (testpath: "/TreeStore/bug-698396", test_func: specific_bug_698396);
1201}
1202

source code of gtk/testsuite/gtk/treestore.c