2007-12-13 12:59:01 +00:00
|
|
|
/* Extensive GtkTreeStore tests.
|
|
|
|
* Copyright (C) 2007 Imendio AB
|
|
|
|
* Authors: Kristian Rietveld <kris@imendio.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-12-13 12:59:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* To do:
|
|
|
|
* - All the to do items from liststore.c, plus:
|
2007-12-14 00:52:04 +00:00
|
|
|
* - Finish up the insertion tests; things aren't as nicely refactored
|
|
|
|
* here as in GtkListStore, so we need to check for corner cases on
|
|
|
|
* all insertion functions separately.
|
2007-12-13 12:59:01 +00:00
|
|
|
* - We only test in the root level, we also need all tests "duplicated"
|
|
|
|
* for child levels.
|
|
|
|
* - And we also need tests for creating these child levels, etc.
|
|
|
|
*/
|
|
|
|
|
2012-10-02 17:30:50 +00:00
|
|
|
#include "treemodel.h"
|
|
|
|
|
2007-12-13 12:59:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static inline gboolean
|
|
|
|
iters_equal (GtkTreeIter *a,
|
|
|
|
GtkTreeIter *b)
|
|
|
|
{
|
|
|
|
if (a->stamp != b->stamp)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (a->user_data != b->user_data)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* user_data2 and user_data3 are not used in GtkTreeStore */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-12-14 00:52:04 +00:00
|
|
|
static gboolean
|
|
|
|
iter_position (GtkTreeStore *store,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
int n)
|
|
|
|
{
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter);
|
|
|
|
if (!path)
|
|
|
|
return FALSE;
|
|
|
|
|
2010-06-28 18:15:10 +00:00
|
|
|
if (gtk_tree_path_get_indices (path)[0] != n)
|
2007-12-14 00:52:04 +00:00
|
|
|
ret = FALSE;
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-12-13 12:59:01 +00:00
|
|
|
/*
|
|
|
|
* Fixture
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GtkTreeIter iter[5];
|
|
|
|
GtkTreeStore *store;
|
|
|
|
} TreeStore;
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_setup (TreeStore *fixture,
|
|
|
|
gconstpointer test_data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
fixture->store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
gtk_tree_store_insert (fixture->store, &fixture->iter[i], NULL, i);
|
|
|
|
gtk_tree_store_set (fixture->store, &fixture->iter[i], 0, i, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_teardown (TreeStore *fixture,
|
|
|
|
gconstpointer test_data)
|
|
|
|
{
|
|
|
|
g_object_unref (fixture->store);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The actual tests.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_model (TreeStore *fixture,
|
2020-07-24 13:54:49 +00:00
|
|
|
int *new_order,
|
|
|
|
int skip)
|
2007-12-13 12:59:01 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
path = gtk_tree_path_new ();
|
|
|
|
gtk_tree_path_down (path);
|
|
|
|
|
|
|
|
/* Check validity of the model and validity of the iters-persistent
|
|
|
|
* claim.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
if (i == skip)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* The saved iterator at new_order[i] should match the iterator
|
|
|
|
* at i.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
|
|
|
|
&iter, path);
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (fixture->store, &iter));
|
|
|
|
g_assert_true (iters_equal (&iter, &fixture->iter[new_order[i]]));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_path_next (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2007-12-14 00:52:04 +00:00
|
|
|
/* insertion */
|
|
|
|
static void
|
|
|
|
tree_store_test_insert_high_values (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, iter2;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
gtk_tree_store_insert (store, &iter, NULL, 1234);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 1);
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
gtk_tree_store_insert (store, &iter2, NULL, 765);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
/* Walk over the model */
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 1));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_append (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, iter2;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 1);
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter2, NULL);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
/* Walk over the model */
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 1));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_prepend (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, iter2;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
gtk_tree_store_prepend (store, &iter, NULL);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 1);
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
gtk_tree_store_prepend (store, &iter2, NULL);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
/* Walk over the model */
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 1));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 0));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_insert_after (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, iter2, iter3;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
gtk_tree_store_append (store, &iter2, NULL);
|
|
|
|
|
|
|
|
gtk_tree_store_insert_after (store, &iter3, NULL, &iter);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter3));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 3);
|
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
|
|
g_assert_true (iters_equal (&iter3, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter3, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
/* Walk over the model */
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter_copy, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter3, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter_copy, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter_copy, 2));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 2));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 2));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter3, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter3, 1));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2007-12-14 00:52:04 +00:00
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_insert_after_NULL (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, iter2;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
|
|
|
|
/* move_after NULL is basically a prepend */
|
|
|
|
gtk_tree_store_insert_after (store, &iter2, NULL, NULL);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
/* Walk over the model */
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 0));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 1));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 0));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2007-12-14 00:52:04 +00:00
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_insert_before (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, iter2, iter3;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
gtk_tree_store_append (store, &iter2, NULL);
|
|
|
|
|
|
|
|
gtk_tree_store_insert_before (store, &iter3, NULL, &iter2);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter3));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 3);
|
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
|
|
g_assert_true (iters_equal (&iter3, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter3, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
/* Walk over the model */
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter_copy, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter3, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter_copy, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter_copy, 2));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
|
|
g_assert_true (iters_equal (&iter3, &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 2));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 2));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter3, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter3, 1));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2007-12-14 00:52:04 +00:00
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_insert_before_NULL (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, iter2;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
|
|
|
|
/* move_before NULL is basically an append */
|
|
|
|
gtk_tree_store_insert_before (store, &iter2, NULL, NULL);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (store, &iter2));
|
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL), ==, 2);
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
/* Walk over the model */
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 1));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
|
|
g_assert_true (iters_equal (&iter2, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter2, 1));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (iter_position (store, &iter, 0));
|
2011-01-06 04:39:11 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_previous (GTK_TREE_MODEL (store), &iter_copy));
|
2007-12-14 00:52:04 +00:00
|
|
|
|
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
2012-06-07 20:41:18 +00:00
|
|
|
/* setting values */
|
|
|
|
static void
|
|
|
|
tree_store_set_gvalue_to_transform (void)
|
|
|
|
{
|
|
|
|
GtkTreeStore *store;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
/* https://bugzilla.gnome.org/show_bug.cgi?id=677649 */
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_LONG);
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
|
|
|
|
g_value_init (&value, G_TYPE_INT);
|
|
|
|
g_value_set_int (&value, 42);
|
|
|
|
gtk_tree_store_set_value (store, &iter, 0, &value);
|
|
|
|
}
|
|
|
|
|
2007-12-13 12:59:01 +00:00
|
|
|
/* removal */
|
|
|
|
static void
|
|
|
|
tree_store_test_remove_begin (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
int new_order[5] = { -1, 1, 2, 3, 4 };
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
/* Remove node at 0 */
|
|
|
|
path = gtk_tree_path_new_from_indices (0, -1);
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &iter, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_remove (fixture->store, &iter) == TRUE);
|
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &fixture->iter[0]));
|
|
|
|
g_assert_true (iters_equal (&iter, &fixture->iter[1]));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
check_model (fixture, new_order, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_remove_middle (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
int new_order[5] = { 0, 1, -1, 3, 4 };
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
/* Remove node at 2 */
|
|
|
|
path = gtk_tree_path_new_from_indices (2, -1);
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &iter, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_remove (fixture->store, &iter));
|
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &fixture->iter[2]));
|
|
|
|
g_assert_true (iters_equal (&iter, &fixture->iter[3]));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
check_model (fixture, new_order, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_remove_end (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
int new_order[5] = { 0, 1, 2, 3, -1 };
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
/* Remove node at 4 */
|
|
|
|
path = gtk_tree_path_new_from_indices (4, -1);
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &iter, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_store_remove (fixture->store, &iter));
|
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &fixture->iter[4]));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
check_model (fixture, new_order, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_clear (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
gtk_tree_store_clear (fixture->store);
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_cmpint (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (fixture->store), NULL), ==, 0);
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &fixture->iter[i]));
|
2007-12-13 12:59:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reorder */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_reorder (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
int new_order[5] = { 4, 1, 0, 2, 3 };
|
|
|
|
|
|
|
|
gtk_tree_store_reorder (fixture->store, NULL, new_order);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* swapping */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_swap_begin (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We swap nodes 0 and 1 at the beginning */
|
|
|
|
int new_order[5] = { 1, 0, 2, 3, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter_a;
|
|
|
|
GtkTreeIter iter_b;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "0"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "1"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_swap (fixture->store, &iter_a, &iter_b);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_swap_middle_next (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We swap nodes 2 and 3 in the middle that are next to each other */
|
|
|
|
int new_order[5] = { 0, 1, 3, 2, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter_a;
|
|
|
|
GtkTreeIter iter_b;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "2"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "3"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_swap (fixture->store, &iter_a, &iter_b);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_swap_middle_apart (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We swap nodes 1 and 3 in the middle that are apart from each other */
|
|
|
|
int new_order[5] = { 0, 3, 2, 1, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter_a;
|
|
|
|
GtkTreeIter iter_b;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "1"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "3"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_swap (fixture->store, &iter_a, &iter_b);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_swap_end (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We swap nodes 3 and 4 at the end */
|
|
|
|
int new_order[5] = { 0, 1, 2, 4, 3 };
|
|
|
|
|
|
|
|
GtkTreeIter iter_a;
|
|
|
|
GtkTreeIter iter_b;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "3"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "4"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_swap (fixture->store, &iter_a, &iter_b);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
2007-12-13 16:28:12 +00:00
|
|
|
static void
|
|
|
|
tree_store_test_swap_single (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
/* Check if swap on a store with a single node does not corrupt
|
|
|
|
* the store.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
iter_copy = iter;
|
|
|
|
|
|
|
|
gtk_tree_store_swap (store, &iter, &iter);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
2007-12-13 16:28:12 +00:00
|
|
|
|
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
2007-12-13 12:59:01 +00:00
|
|
|
/* move after */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_after_from_start (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 0 after 2 */
|
|
|
|
int new_order[5] = { 1, 2, 0, 3, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "0"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_after (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_after_next (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 2 after 3 */
|
|
|
|
int new_order[5] = { 0, 1, 3, 2, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_after (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_after_apart (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 1 after 3 */
|
|
|
|
int new_order[5] = { 0, 2, 3, 1, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "1"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_after (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_after_end (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 2 after 4 */
|
|
|
|
int new_order[5] = { 0, 1, 3, 4, 2 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "4"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_after (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_after_from_end (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 4 after 1 */
|
|
|
|
int new_order[5] = { 0, 1, 4, 2, 3 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "1"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_after (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_after_change_ends (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move 0 after 4, this will cause both the head and tail ends to
|
|
|
|
* change.
|
|
|
|
*/
|
|
|
|
int new_order[5] = { 1, 2, 3, 4, 0 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "0"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "4"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_after (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_after_NULL (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 2, NULL should prepend */
|
|
|
|
int new_order[5] = { 2, 0, 1, 3, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_after (fixture->store, &iter, NULL);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
2007-12-13 16:28:12 +00:00
|
|
|
static void
|
|
|
|
tree_store_test_move_after_single (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
/* Check if move-after on a store with a single node does not corrupt
|
|
|
|
* the store.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
iter_copy = iter;
|
|
|
|
|
|
|
|
gtk_tree_store_move_after (store, &iter, NULL);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
2007-12-13 16:28:12 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_after (store, &iter, &iter);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
2007-12-13 16:28:12 +00:00
|
|
|
|
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
2007-12-13 12:59:01 +00:00
|
|
|
/* move before */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_before_next (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 3 before 2 */
|
|
|
|
int new_order[5] = { 0, 1, 3, 2, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "3"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_before (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_before_apart (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 1 before 3 */
|
|
|
|
int new_order[5] = { 0, 2, 1, 3, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "1"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_before (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_before_to_start (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 2 before 0 */
|
|
|
|
int new_order[5] = { 2, 0, 1, 3, 4 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "0"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_before (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_before_from_end (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 4 before 2 (replace end) */
|
|
|
|
int new_order[5] = { 0, 1, 4, 2, 3 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_before (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_before_change_ends (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 4 before 0 */
|
|
|
|
int new_order[5] = { 4, 0, 1, 2, 3 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter position;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "0"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_before (fixture->store, &iter, &position);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_move_before_NULL (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
/* We move node 2, NULL should append */
|
|
|
|
int new_order[5] = { 0, 1, 3, 4, 2 };
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_before (fixture->store, &iter, NULL);
|
|
|
|
check_model (fixture, new_order, -1);
|
|
|
|
}
|
|
|
|
|
2007-12-13 16:28:12 +00:00
|
|
|
static void
|
|
|
|
tree_store_test_move_before_single (void)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter_copy;
|
|
|
|
GtkTreeStore *store;
|
|
|
|
|
|
|
|
store = gtk_tree_store_new (1, G_TYPE_INT);
|
|
|
|
|
|
|
|
/* Check if move-after on a store with a single node does not corrupt
|
|
|
|
* the store.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
iter_copy = iter;
|
|
|
|
|
|
|
|
gtk_tree_store_move_before (store, &iter, NULL);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
2007-12-13 16:28:12 +00:00
|
|
|
|
|
|
|
gtk_tree_store_move_before (store, &iter, &iter);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
|
|
|
g_assert_true (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
|
|
g_assert_true (iters_equal (&iter, &iter_copy));
|
2007-12-13 16:28:12 +00:00
|
|
|
|
|
|
|
g_object_unref (store);
|
|
|
|
}
|
|
|
|
|
2009-07-30 19:23:47 +00:00
|
|
|
|
|
|
|
/* iter invalidation */
|
|
|
|
|
2011-01-06 04:39:11 +00:00
|
|
|
static void
|
|
|
|
tree_store_test_iter_previous_invalid (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), &iter);
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_model_iter_previous (GTK_TREE_MODEL (fixture->store),
|
2011-01-06 04:39:11 +00:00
|
|
|
&iter) == FALSE);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &iter));
|
|
|
|
g_assert_cmpint (iter.stamp, ==, 0);
|
2011-01-06 04:39:11 +00:00
|
|
|
}
|
|
|
|
|
2009-07-30 19:23:47 +00:00
|
|
|
static void
|
|
|
|
tree_store_test_iter_next_invalid (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_indices (4, -1);
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &iter, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store),
|
|
|
|
&iter));
|
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &iter));
|
|
|
|
g_assert_cmpint (iter.stamp, ==, 0);
|
2009-07-30 19:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_iter_children_invalid (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, child;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), &iter);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (fixture->store, &iter));
|
2009-07-30 19:23:47 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_children (GTK_TREE_MODEL (fixture->store),
|
|
|
|
&child, &iter));
|
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &child));
|
|
|
|
g_assert_cmpint (child.stamp, ==, 0);
|
2009-07-30 19:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_iter_nth_child_invalid (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, child;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), &iter);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (fixture->store, &iter));
|
2009-07-30 19:23:47 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (fixture->store),
|
|
|
|
&child, &iter, 0));
|
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &child));
|
|
|
|
g_assert_cmpint (child.stamp, ==, 0);
|
2009-07-30 19:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_store_test_iter_parent_invalid (TreeStore *fixture,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, child;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), &child);
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_true (gtk_tree_store_iter_is_valid (fixture->store, &child));
|
2009-07-30 19:23:47 +00:00
|
|
|
|
2021-04-12 20:12:25 +00:00
|
|
|
g_assert_false (gtk_tree_model_iter_parent (GTK_TREE_MODEL (fixture->store),
|
|
|
|
&iter, &child));
|
|
|
|
g_assert_false (gtk_tree_store_iter_is_valid (fixture->store, &iter));
|
|
|
|
g_assert_cmpint (iter.stamp, ==, 0);
|
2009-07-30 19:23:47 +00:00
|
|
|
}
|
|
|
|
|
2011-05-09 06:50:45 +00:00
|
|
|
/* specific bugs */
|
|
|
|
static void
|
|
|
|
specific_bug_77977 (void)
|
|
|
|
{
|
|
|
|
GtkTreeStore *tree_store;
|
|
|
|
GtkTreeIter iter1, iter2, iter3;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeRowReference *row_ref;
|
|
|
|
|
|
|
|
/* Stripped down version of test case for bug 77977 by Damon Chaplin */
|
|
|
|
|
2019-05-10 13:00:12 +00:00
|
|
|
/*http://bugzilla.gnome.org/show_bug.cgi?id=77977 */
|
2011-05-09 06:50:45 +00:00
|
|
|
|
|
|
|
tree_store = gtk_tree_store_new (1, G_TYPE_STRING);
|
|
|
|
|
|
|
|
gtk_tree_store_append (tree_store, &iter1, NULL);
|
|
|
|
gtk_tree_store_set (tree_store, &iter1, 0, "Window1", -1);
|
|
|
|
|
|
|
|
gtk_tree_store_append (tree_store, &iter2, &iter1);
|
|
|
|
gtk_tree_store_set (tree_store, &iter2, 0, "Table1", -1);
|
|
|
|
|
|
|
|
gtk_tree_store_append (tree_store, &iter3, &iter2);
|
|
|
|
gtk_tree_store_set (tree_store, &iter3, 0, "Button1", -1);
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_indices (0, 0, 0, -1);
|
|
|
|
row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (tree_store), path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
gtk_tree_store_remove (tree_store, &iter1);
|
|
|
|
|
2011-08-20 19:51:14 +00:00
|
|
|
gtk_tree_row_reference_free (row_ref);
|
2011-05-09 06:50:45 +00:00
|
|
|
g_object_unref (tree_store);
|
|
|
|
}
|
2009-07-30 19:23:47 +00:00
|
|
|
|
2016-08-06 21:10:43 +00:00
|
|
|
static GLogWriterOutput
|
|
|
|
log_writer_drop_warnings (GLogLevelFlags log_level,
|
|
|
|
const GLogField *fields,
|
|
|
|
gsize n_fields,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
return G_LOG_WRITER_HANDLED;
|
|
|
|
}
|
|
|
|
|
2014-05-13 15:55:01 +00:00
|
|
|
static void
|
|
|
|
specific_bug_698396 (void)
|
|
|
|
{
|
|
|
|
GtkTreeStore *tree_store;
|
2020-07-24 13:54:49 +00:00
|
|
|
int new_order[1] = { 0 };
|
2014-05-13 15:55:01 +00:00
|
|
|
|
2019-05-10 13:00:12 +00:00
|
|
|
/*http://bugzilla.gnome.org/show_bug.cgi?id=698396 */
|
2014-05-13 15:55:01 +00:00
|
|
|
|
|
|
|
tree_store = gtk_tree_store_new (1, G_TYPE_STRING);
|
|
|
|
|
2016-08-06 21:10:43 +00:00
|
|
|
g_log_set_writer_func (log_writer_drop_warnings, NULL, NULL);
|
2014-05-13 15:55:01 +00:00
|
|
|
gtk_tree_store_reorder (tree_store, NULL, new_order);
|
2016-08-06 21:10:43 +00:00
|
|
|
g_log_set_writer_func (g_log_writer_default, NULL, NULL);
|
2014-05-13 15:55:01 +00:00
|
|
|
|
|
|
|
g_object_unref (tree_store);
|
|
|
|
}
|
|
|
|
|
2007-12-13 12:59:01 +00:00
|
|
|
/* main */
|
|
|
|
|
2011-05-09 06:25:27 +00:00
|
|
|
void
|
|
|
|
register_tree_store_tests (void)
|
2007-12-13 12:59:01 +00:00
|
|
|
{
|
2007-12-14 00:52:04 +00:00
|
|
|
/* insertion */
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/insert-high-values",
|
2007-12-14 00:52:04 +00:00
|
|
|
tree_store_test_insert_high_values);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/append",
|
2007-12-14 00:52:04 +00:00
|
|
|
tree_store_test_append);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/prepend",
|
2007-12-14 00:52:04 +00:00
|
|
|
tree_store_test_prepend);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/insert-after",
|
2007-12-14 00:52:04 +00:00
|
|
|
tree_store_test_insert_after);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/insert-after-NULL",
|
2007-12-14 00:52:04 +00:00
|
|
|
tree_store_test_insert_after_NULL);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/insert-before",
|
2007-12-14 00:52:04 +00:00
|
|
|
tree_store_test_insert_before);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/insert-before-NULL",
|
2007-12-14 00:52:04 +00:00
|
|
|
tree_store_test_insert_before_NULL);
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
/* setting values (FIXME) */
|
2012-06-07 20:41:18 +00:00
|
|
|
g_test_add_func ("/TreeStore/set-gvalue-to-transform",
|
|
|
|
tree_store_set_gvalue_to_transform);
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
/* removal */
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/remove-begin", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_remove_begin,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/remove-middle", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_remove_middle,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/remove-end", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_remove_end,
|
|
|
|
tree_store_teardown);
|
|
|
|
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/clear", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_clear,
|
|
|
|
tree_store_teardown);
|
|
|
|
|
|
|
|
/* reordering */
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/reorder", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_reorder,
|
|
|
|
tree_store_teardown);
|
|
|
|
|
|
|
|
/* swapping */
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/swap-begin", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_swap_begin,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/swap-middle-next", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_swap_middle_next,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/swap-middle-apart", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_swap_middle_apart,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/swap-end", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_swap_end,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/swap-single",
|
2007-12-13 16:28:12 +00:00
|
|
|
tree_store_test_swap_single);
|
2007-12-13 12:59:01 +00:00
|
|
|
|
|
|
|
/* moving */
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-after-from-start", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_after_from_start,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-after-next", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_after_next,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-after-apart", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_after_apart,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-after-end", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_after_end,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-after-from-end", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_after_from_end,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-after-change-ends", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_after_change_ends,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-after-NULL", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_after_NULL,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/move-after-single",
|
2007-12-13 16:28:12 +00:00
|
|
|
tree_store_test_move_after_single);
|
2007-12-13 12:59:01 +00:00
|
|
|
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-before-next", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_before_next,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-before-apart", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_before_apart,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-before-to-start", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_before_to_start,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-before-from-end", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_before_from_end,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-before-change-ends", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_before_change_ends,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/move-before-NULL", TreeStore, NULL,
|
2007-12-13 12:59:01 +00:00
|
|
|
tree_store_setup, tree_store_test_move_before_NULL,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add_func ("/TreeStore/move-before-single",
|
2007-12-13 16:28:12 +00:00
|
|
|
tree_store_test_move_before_single);
|
2007-12-13 12:59:01 +00:00
|
|
|
|
2009-07-30 19:23:47 +00:00
|
|
|
/* iter invalidation */
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/iter-prev-invalid", TreeStore, NULL,
|
2011-01-06 04:39:11 +00:00
|
|
|
tree_store_setup, tree_store_test_iter_previous_invalid,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/iter-next-invalid", TreeStore, NULL,
|
2009-07-30 19:23:47 +00:00
|
|
|
tree_store_setup, tree_store_test_iter_next_invalid,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/iter-children-invalid", TreeStore, NULL,
|
2009-07-30 19:23:47 +00:00
|
|
|
tree_store_setup, tree_store_test_iter_children_invalid,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/iter-nth-child-invalid", TreeStore, NULL,
|
2009-07-30 19:23:47 +00:00
|
|
|
tree_store_setup, tree_store_test_iter_nth_child_invalid,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:32:11 +00:00
|
|
|
g_test_add ("/TreeStore/iter-parent-invalid", TreeStore, NULL,
|
2009-07-30 19:23:47 +00:00
|
|
|
tree_store_setup, tree_store_test_iter_parent_invalid,
|
|
|
|
tree_store_teardown);
|
2011-05-09 06:50:45 +00:00
|
|
|
|
|
|
|
/* specific bugs */
|
|
|
|
g_test_add_func ("/TreeStore/bug-77977", specific_bug_77977);
|
2014-05-13 15:55:01 +00:00
|
|
|
g_test_add_func ("/TreeStore/bug-698396", specific_bug_698396);
|
2007-12-13 12:59:01 +00:00
|
|
|
}
|