Commit 935d9a65 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

test the move and swap functions on a store with only one node.

2007-12-13  Kristian Rietveld  <kris@imendio.com>

	* gtk/tests/liststore.c:
	* gtk/tests/treestore.c: test the move and swap functions on a
	store with only one node.


svn path=/trunk/; revision=19172
parent 6900ad4b
2007-12-13 Kristian Rietveld <kris@imendio.com>
* gtk/tests/liststore.c:
* gtk/tests/treestore.c: test the move and swap functions on a
store with only one node.
2007-12-13 Kristian Rietveld <kris@imendio.com>
* gtk/gtktestutils.c (gtk_test_init): add a call to
......
......@@ -19,8 +19,6 @@
*/
/* To do:
* - We probably want to do all move and swap tests on a 1-item list store
* also.
* - Test implementations of the interfaces: DnD, sortable, buildable
* and the tree model interface itself?
* - Need to check if the emitted signals are right.
......@@ -273,6 +271,30 @@ list_store_test_swap_end (ListStore *fixture,
check_model (fixture, new_order, -1);
}
static void
list_store_test_swap_single (void)
{
GtkTreeIter iter;
GtkTreeIter iter_copy;
GtkListStore *store;
store = gtk_list_store_new (1, G_TYPE_INT);
/* Check if swap on a store with a single node does not corrupt
* the store.
*/
gtk_list_store_append (store, &iter);
iter_copy = iter;
gtk_list_store_swap (store, &iter, &iter);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
g_object_unref (store);
}
/* move after */
static void
......@@ -394,6 +416,35 @@ list_store_test_move_after_NULL (ListStore *fixture,
check_model (fixture, new_order, -1);
}
static void
list_store_test_move_after_single (void)
{
GtkTreeIter iter;
GtkTreeIter iter_copy;
GtkListStore *store;
store = gtk_list_store_new (1, G_TYPE_INT);
/* Check if move-after on a store with a single node does not corrupt
* the store.
*/
gtk_list_store_append (store, &iter);
iter_copy = iter;
gtk_list_store_move_after (store, &iter, NULL);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
gtk_list_store_move_after (store, &iter, &iter);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
g_object_unref (store);
}
/* move before */
static void
......@@ -496,6 +547,35 @@ list_store_test_move_before_NULL (ListStore *fixture,
check_model (fixture, new_order, -1);
}
static void
list_store_test_move_before_single (void)
{
GtkTreeIter iter;
GtkTreeIter iter_copy;
GtkListStore *store;
store = gtk_list_store_new (1, G_TYPE_INT);
/* Check if move-before on a store with a single node does not corrupt
* the store.
*/
gtk_list_store_append (store, &iter);
iter_copy = iter;
gtk_list_store_move_before (store, &iter, NULL);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
gtk_list_store_move_before (store, &iter, &iter);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
g_object_unref (store);
}
/* main */
int
......@@ -541,6 +621,8 @@ main (int argc,
g_test_add ("/list-store/swap-end", ListStore, NULL,
list_store_setup, list_store_test_swap_end,
list_store_teardown);
g_test_add_func ("/list-store/swap-single",
list_store_test_swap_single);
/* moving */
g_test_add ("/list-store/move-after-from-start", ListStore, NULL,
......@@ -564,6 +646,8 @@ main (int argc,
g_test_add ("/list-store/move-after-NULL", ListStore, NULL,
list_store_setup, list_store_test_move_after_NULL,
list_store_teardown);
g_test_add_func ("/list-store/move-after-single",
list_store_test_move_after_single);
g_test_add ("/list-store/move-before-next", ListStore, NULL,
list_store_setup, list_store_test_move_before_next,
......@@ -583,6 +667,8 @@ main (int argc,
g_test_add ("/list-store/move-before-NULL", ListStore, NULL,
list_store_setup, list_store_test_move_before_NULL,
list_store_teardown);
g_test_add_func ("/list-store/move-before-single",
list_store_test_move_before_single);
return g_test_run ();
}
......@@ -271,6 +271,30 @@ tree_store_test_swap_end (TreeStore *fixture,
check_model (fixture, new_order, -1);
}
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);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
g_object_unref (store);
}
/* move after */
static void
......@@ -392,6 +416,35 @@ tree_store_test_move_after_NULL (TreeStore *fixture,
check_model (fixture, new_order, -1);
}
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);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
gtk_tree_store_move_after (store, &iter, &iter);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
g_object_unref (store);
}
/* move before */
static void
......@@ -494,6 +547,35 @@ tree_store_test_move_before_NULL (TreeStore *fixture,
check_model (fixture, new_order, -1);
}
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);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
gtk_tree_store_move_before (store, &iter, &iter);
g_assert (iters_equal (&iter, &iter_copy));
g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter));
g_assert (iters_equal (&iter, &iter_copy));
g_object_unref (store);
}
/* main */
int
......@@ -539,6 +621,8 @@ main (int argc,
g_test_add ("/tree-store/swap-end", TreeStore, NULL,
tree_store_setup, tree_store_test_swap_end,
tree_store_teardown);
g_test_add_func ("/tree-store/swap-single",
tree_store_test_swap_single);
/* moving */
g_test_add ("/tree-store/move-after-from-start", TreeStore, NULL,
......@@ -562,6 +646,8 @@ main (int argc,
g_test_add ("/tree-store/move-after-NULL", TreeStore, NULL,
tree_store_setup, tree_store_test_move_after_NULL,
tree_store_teardown);
g_test_add_func ("/tree-store/move-after-single",
tree_store_test_move_after_single);
g_test_add ("/tree-store/move-before-next", TreeStore, NULL,
tree_store_setup, tree_store_test_move_before_next,
......@@ -581,6 +667,8 @@ main (int argc,
g_test_add ("/tree-store/move-before-NULL", TreeStore, NULL,
tree_store_setup, tree_store_test_move_before_NULL,
tree_store_teardown);
g_test_add_func ("/tree-store/move-before-single",
tree_store_test_move_before_single);
return g_test_run ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment