|
Packit Service |
fb6fa5 |
/* Extensive GtkListStore tests.
|
|
Packit Service |
fb6fa5 |
* Copyright (C) 2007 Imendio AB
|
|
Packit Service |
fb6fa5 |
* Authors: Kristian Rietveld <kris@imendio.com>
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
fb6fa5 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
fb6fa5 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
fb6fa5 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
fb6fa5 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
fb6fa5 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
fb6fa5 |
* Lesser General Public License for more details.
|
|
Packit Service |
fb6fa5 |
*
|
|
Packit Service |
fb6fa5 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
fb6fa5 |
* License along with this library; if not, write to the
|
|
Packit Service |
fb6fa5 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit Service |
fb6fa5 |
* Boston, MA 02111-1307, USA.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* To do:
|
|
Packit Service |
fb6fa5 |
* - Test implementations of the interfaces: DnD, sortable, buildable
|
|
Packit Service |
fb6fa5 |
* and the tree model interface itself?
|
|
Packit Service |
fb6fa5 |
* - Need to check if the emitted signals are right.
|
|
Packit Service |
fb6fa5 |
* - Needs analysis with the code coverage tool once it is there.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
#include <gtk/gtk.h>
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static inline gboolean
|
|
Packit Service |
fb6fa5 |
iters_equal (GtkTreeIter *a,
|
|
Packit Service |
fb6fa5 |
GtkTreeIter *b)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
if (a->stamp != b->stamp)
|
|
Packit Service |
fb6fa5 |
return FALSE;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
if (a->user_data != b->user_data)
|
|
Packit Service |
fb6fa5 |
return FALSE;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* user_data2 and user_data3 are not used in GtkListStore */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
return TRUE;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static gboolean
|
|
Packit Service |
fb6fa5 |
iter_position (GtkListStore *store,
|
|
Packit Service |
fb6fa5 |
GtkTreeIter *iter,
|
|
Packit Service |
fb6fa5 |
int n)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
gboolean ret = TRUE;
|
|
Packit Service |
fb6fa5 |
GtkTreePath *path;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter);
|
|
Packit Service |
fb6fa5 |
if (!path)
|
|
Packit Service |
fb6fa5 |
return FALSE;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
if (gtk_tree_path_get_indices (path)[0] != n)
|
|
Packit Service |
fb6fa5 |
ret = FALSE;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_tree_path_free (path);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
return ret;
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/*
|
|
Packit Service |
fb6fa5 |
* Fixture
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
typedef struct
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter[5];
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
} ListStore;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_setup (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer test_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
int i;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
fixture->store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
for (i = 0; i < 5; i++)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
gtk_list_store_insert (fixture->store, &fixture->iter[i], i);
|
|
Packit Service |
fb6fa5 |
gtk_list_store_set (fixture->store, &fixture->iter[i], 0, i, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_teardown (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer test_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
g_object_unref (fixture->store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/*
|
|
Packit Service |
fb6fa5 |
* The actual tests.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
check_model (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gint *new_order,
|
|
Packit Service |
fb6fa5 |
gint skip)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
int i;
|
|
Packit Service |
fb6fa5 |
GtkTreePath *path;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
path = gtk_tree_path_new ();
|
|
Packit Service |
fb6fa5 |
gtk_tree_path_down (path);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Check validity of the model and validity of the iters-persistent
|
|
Packit Service |
fb6fa5 |
* claim.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
for (i = 0; i < 5; i++)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
if (i == skip)
|
|
Packit Service |
fb6fa5 |
continue;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* The saved iterator at new_order[i] should match the iterator
|
|
Packit Service |
fb6fa5 |
* at i.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store),
|
|
Packit Service |
fb6fa5 |
&iter, path);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (fixture->store, &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &fixture->iter[new_order[i]]));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_tree_path_next (path);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_tree_path_free (path);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* insertion */
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_high_values (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, iter2;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_insert (store, &iter, 1234);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 1);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_insert (store, &iter2, 765);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter2));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 2);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Walk over the model */
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter2, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_append (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, iter2;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 1);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter2);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter2));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 2);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Walk over the model */
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter2, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_prepend (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, iter2;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_prepend (store, &iter);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 1);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_prepend (store, &iter2);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter2));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 2);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Walk over the model */
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter2, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_after (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, iter2, iter3;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter);
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter2);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_insert_after (store, &iter3, &iter);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter3));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 3);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter3, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter3, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Walk over the model */
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter_copy, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter3, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter_copy, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter_copy, 2));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_after_NULL (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, iter2;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* move_after NULL is basically a prepend */
|
|
Packit Service |
fb6fa5 |
gtk_list_store_insert_after (store, &iter2, NULL);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter2));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 2);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Walk over the model */
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter2, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 0));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_before (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, iter2, iter3;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter);
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter2);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_insert_before (store, &iter3, &iter2);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter3));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 3);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter3, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter3, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Walk over the model */
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter_copy, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter3, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter_copy, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter_copy, 2));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter3, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_before_NULL (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, iter2;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* move_before NULL is basically an append */
|
|
Packit Service |
fb6fa5 |
gtk_list_store_insert_before (store, &iter2, NULL);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (store, &iter2));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) == 2);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Walk over the model */
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter, 0));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (iter_position (store, &iter2, 1));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &iter_copy, NULL, 1));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter2, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* removal */
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_remove_begin (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { -1, 1, 2, 3, 4 };
|
|
Packit Service |
fb6fa5 |
GtkTreePath *path;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Remove node at 0 */
|
|
Packit Service |
fb6fa5 |
path = gtk_tree_path_new_from_indices (0, -1);
|
|
Packit Service |
fb6fa5 |
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &iter, path);
|
|
Packit Service |
fb6fa5 |
gtk_tree_path_free (path);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_remove (fixture->store, &iter) == TRUE);
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_list_store_iter_is_valid (fixture->store, &fixture->iter[0]));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &fixture->iter[1]));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, 0);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_remove_middle (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, -1, 3, 4 };
|
|
Packit Service |
fb6fa5 |
GtkTreePath *path;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Remove node at 2 */
|
|
Packit Service |
fb6fa5 |
path = gtk_tree_path_new_from_indices (2, -1);
|
|
Packit Service |
fb6fa5 |
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &iter, path);
|
|
Packit Service |
fb6fa5 |
gtk_tree_path_free (path);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_remove (fixture->store, &iter) == TRUE);
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_list_store_iter_is_valid (fixture->store, &fixture->iter[2]));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &fixture->iter[3]));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, 2);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_remove_end (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 2, 3, -1 };
|
|
Packit Service |
fb6fa5 |
GtkTreePath *path;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Remove node at 4 */
|
|
Packit Service |
fb6fa5 |
path = gtk_tree_path_new_from_indices (4, -1);
|
|
Packit Service |
fb6fa5 |
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &iter, path);
|
|
Packit Service |
fb6fa5 |
gtk_tree_path_free (path);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_remove (fixture->store, &iter) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_list_store_iter_is_valid (fixture->store, &fixture->iter[4]));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, 4);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_clear (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
int i;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_clear (fixture->store);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (fixture->store), NULL) == 0);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
for (i = 0; i < 5; i++)
|
|
Packit Service |
fb6fa5 |
g_assert (!gtk_list_store_iter_is_valid (fixture->store, &fixture->iter[i]));
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* reorder */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_reorder (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 4, 1, 0, 2, 3 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_reorder (fixture->store, new_order);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* swapping */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_swap_begin (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We swap nodes 0 and 1 at the beginning */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 1, 0, 2, 3, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_a;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_b;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "0"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "1"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_swap (fixture->store, &iter_a, &iter_b);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_swap_middle_next (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We swap nodes 2 and 3 in the middle that are next to each other */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 3, 2, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_a;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_b;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "2"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "3"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_swap (fixture->store, &iter_a, &iter_b);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_swap_middle_apart (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We swap nodes 1 and 3 in the middle that are apart from each other */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 3, 2, 1, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_a;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_b;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "1"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "3"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_swap (fixture->store, &iter_a, &iter_b);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_swap_end (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We swap nodes 3 and 4 at the end */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 2, 4, 3 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_a;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_b;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_a, "3"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter_b, "4"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_swap (fixture->store, &iter_a, &iter_b);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_swap_single (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Check if swap on a store with a single node does not corrupt
|
|
Packit Service |
fb6fa5 |
* the store.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter);
|
|
Packit Service |
fb6fa5 |
iter_copy = iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_swap (store, &iter, &iter);
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* move after */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_from_start (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 0 after 2 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 1, 2, 0, 3, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "0"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_next (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 2 after 3 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 3, 2, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_apart (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 1 after 3 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 2, 3, 1, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "1"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_end (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 2 after 4 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 3, 4, 2 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "4"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_from_end (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 4 after 1 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 4, 2, 3 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "1"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_change_ends (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move 0 after 4, this will cause both the head and tail ends to
|
|
Packit Service |
fb6fa5 |
* change.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 1, 2, 3, 4, 0 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "0"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "4"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_NULL (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 2, NULL should prepend */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 2, 0, 1, 3, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (fixture->store, &iter, NULL);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_single (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Check if move-after on a store with a single node does not corrupt
|
|
Packit Service |
fb6fa5 |
* the store.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter);
|
|
Packit Service |
fb6fa5 |
iter_copy = iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (store, &iter, NULL);
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_after (store, &iter, &iter);
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* move before */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_before_next (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 3 before 2 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 3, 2, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "3"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_before (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_before_apart (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 1 before 3 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 2, 1, 3, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "1"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "3"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_before (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_before_to_start (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 2 before 0 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 2, 0, 1, 3, 4 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "0"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_before (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_before_from_end (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 4 before 2 (replace end) */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 4, 2, 3 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "2"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_before (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_before_change_ends (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 4 before 0 */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 4, 0, 1, 2, 3 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter position;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "4"));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &position, "0"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_before (fixture->store, &iter, &position);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_before_NULL (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
/* We move node 2, NULL should append */
|
|
Packit Service |
fb6fa5 |
int new_order[5] = { 0, 1, 3, 4, 2 };
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (fixture->store), &iter, "2"));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_before (fixture->store, &iter, NULL);
|
|
Packit Service |
fb6fa5 |
check_model (fixture, new_order, -1);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_move_before_single (void)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter_copy;
|
|
Packit Service |
fb6fa5 |
GtkListStore *store;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
store = gtk_list_store_new (1, G_TYPE_INT);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* Check if move-before on a store with a single node does not corrupt
|
|
Packit Service |
fb6fa5 |
* the store.
|
|
Packit Service |
fb6fa5 |
*/
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_append (store, &iter);
|
|
Packit Service |
fb6fa5 |
iter_copy = iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_before (store, &iter, NULL);
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_list_store_move_before (store, &iter, &iter);
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
|
|
Packit Service |
fb6fa5 |
g_assert (iters_equal (&iter, &iter_copy));
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_object_unref (store);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* iter invalidation */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_iter_next_invalid (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreePath *path;
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
path = gtk_tree_path_new_from_indices (4, -1);
|
|
Packit Service |
fb6fa5 |
gtk_tree_model_get_iter (GTK_TREE_MODEL (fixture->store), &iter, path);
|
|
Packit Service |
fb6fa5 |
gtk_tree_path_free (path);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (fixture->store),
|
|
Packit Service |
fb6fa5 |
&iter) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (fixture->store, &iter) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (iter.stamp == 0);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_iter_children_invalid (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, child;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), &iter);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (fixture->store, &iter) == TRUE);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_children (GTK_TREE_MODEL (fixture->store),
|
|
Packit Service |
fb6fa5 |
&child, &iter) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (fixture->store, &child) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (child.stamp == 0);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_iter_nth_child_invalid (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, child;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), &iter);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (fixture->store, &iter) == TRUE);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (fixture->store),
|
|
Packit Service |
fb6fa5 |
&child, &iter, 0) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (fixture->store, &child) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (child.stamp == 0);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
static void
|
|
Packit Service |
fb6fa5 |
list_store_test_iter_parent_invalid (ListStore *fixture,
|
|
Packit Service |
fb6fa5 |
gconstpointer user_data)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
GtkTreeIter iter, child;
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (fixture->store), &child);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (fixture->store, &child) == TRUE);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_tree_model_iter_parent (GTK_TREE_MODEL (fixture->store),
|
|
Packit Service |
fb6fa5 |
&iter, &child) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (gtk_list_store_iter_is_valid (fixture->store, &iter) == FALSE);
|
|
Packit Service |
fb6fa5 |
g_assert (iter.stamp == 0);
|
|
Packit Service |
fb6fa5 |
}
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* main */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
int
|
|
Packit Service |
fb6fa5 |
main (int argc,
|
|
Packit Service |
fb6fa5 |
char **argv)
|
|
Packit Service |
fb6fa5 |
{
|
|
Packit Service |
fb6fa5 |
gtk_test_init (&argc, &argv, NULL);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* insertion */
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/insert-high-values",
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_high_values);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/append",
|
|
Packit Service |
fb6fa5 |
list_store_test_append);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/prepend",
|
|
Packit Service |
fb6fa5 |
list_store_test_prepend);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/insert-after",
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_after);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/insert-after-NULL",
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_after_NULL);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/insert-before",
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_before);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/insert-before-NULL",
|
|
Packit Service |
fb6fa5 |
list_store_test_insert_before_NULL);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* setting values (FIXME) */
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* removal */
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/remove-begin", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_remove_begin,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/remove-middle", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_remove_middle,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/remove-end", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_remove_end,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/clear", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_clear,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* reordering */
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/reorder", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_reorder,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* swapping */
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/swap-begin", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_swap_begin,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/swap-middle-next", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_swap_middle_next,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/swap-middle-apart", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_swap_middle_apart,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/swap-end", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_swap_end,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/swap-single",
|
|
Packit Service |
fb6fa5 |
list_store_test_swap_single);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* moving */
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-after-from-start", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_after_from_start,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-after-next", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_after_next,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-after-apart", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_after_apart,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-after-end", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_after_end,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-after-from-end", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_after_from_end,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-after-change-ends", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_after_change_ends,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-after-NULL", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_after_NULL,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/move-after-single",
|
|
Packit Service |
fb6fa5 |
list_store_test_move_after_single);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-before-next", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_before_next,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-before-apart", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_before_apart,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-before-to-start", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_before_to_start,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-before-from-end", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_before_from_end,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-before-change-ends", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_before_change_ends,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/move-before-NULL", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_move_before_NULL,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add_func ("/list-store/move-before-single",
|
|
Packit Service |
fb6fa5 |
list_store_test_move_before_single);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
/* iter invalidation */
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/iter-next-invalid", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_iter_next_invalid,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/iter-children-invalid", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_iter_children_invalid,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/iter-nth-child-invalid", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_iter_nth_child_invalid,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
g_test_add ("/list-store/iter-parent-invalid", ListStore, NULL,
|
|
Packit Service |
fb6fa5 |
list_store_setup, list_store_test_iter_parent_invalid,
|
|
Packit Service |
fb6fa5 |
list_store_teardown);
|
|
Packit Service |
fb6fa5 |
|
|
Packit Service |
fb6fa5 |
return g_test_run ();
|
|
Packit Service |
fb6fa5 |
}
|