forked from AuroraMiddleware/gtk
sortlistmodel: Add a test
Add a test to prove that additions and removals in the underlying model show up as expected.
This commit is contained in:
parent
7b815768e0
commit
2ed954d307
@ -543,6 +543,29 @@ test_out_of_bounds_access (void)
|
|||||||
g_object_unref (sort);
|
g_object_unref (sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_add_remove_item (void)
|
||||||
|
{
|
||||||
|
GtkSortListModel *sort;
|
||||||
|
GListStore *store;
|
||||||
|
|
||||||
|
store = new_store ((guint[]) { 4, 8, 2, 6, 10, 0 });
|
||||||
|
sort = new_model (store);
|
||||||
|
assert_model (sort, "2 4 6 8 10");
|
||||||
|
assert_changes (sort, "");
|
||||||
|
|
||||||
|
add (store, 3);
|
||||||
|
assert_model (sort, "2 3 4 6 8 10");
|
||||||
|
assert_changes (sort, "+1*");
|
||||||
|
|
||||||
|
g_list_store_remove (store, 5);
|
||||||
|
assert_model (sort, "2 4 6 8 10");
|
||||||
|
assert_changes (sort, "-1*");
|
||||||
|
|
||||||
|
g_object_unref (store);
|
||||||
|
g_object_unref (sort);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -563,6 +586,7 @@ main (int argc, char *argv[])
|
|||||||
g_test_add_func ("/sortlistmodel/stability", test_stability);
|
g_test_add_func ("/sortlistmodel/stability", test_stability);
|
||||||
g_test_add_func ("/sortlistmodel/incremental/remove", test_incremental_remove);
|
g_test_add_func ("/sortlistmodel/incremental/remove", test_incremental_remove);
|
||||||
g_test_add_func ("/sortlistmodel/oob-access", test_out_of_bounds_access);
|
g_test_add_func ("/sortlistmodel/oob-access", test_out_of_bounds_access);
|
||||||
|
g_test_add_func ("/sortlistmodel/add-remove-item", test_add_remove_item);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user