diff --git a/testsuite/gtk/filterlistmodel.c b/testsuite/gtk/filterlistmodel.c index d35b73f74b..174b6ac9f5 100644 --- a/testsuite/gtk/filterlistmodel.c +++ b/testsuite/gtk/filterlistmodel.c @@ -414,6 +414,36 @@ test_empty (void) g_object_unref (filter); } +static void +test_add_remove_item (void) +{ + GtkFilterListModel *filter; + GListStore *store; + + filter = new_model (10, is_smaller_than, GUINT_TO_POINTER (7)); + assert_model (filter, "1 2 3 4 5 6"); + assert_changes (filter, ""); + + store = G_LIST_STORE (gtk_filter_list_model_get_model (filter)); + add (store, 9); + assert_model (filter, "1 2 3 4 5 6"); + assert_changes (filter, ""); + + add (store, 1); + assert_model (filter, "1 2 3 4 5 6 1"); + assert_changes (filter, "+6*"); + + g_list_store_remove (store, 10); + assert_model (filter, "1 2 3 4 5 6 1"); + assert_changes (filter, ""); + + g_list_store_remove (store, 10); + assert_model (filter, "1 2 3 4 5 6"); + assert_changes (filter, "-6*"); + + g_object_unref (filter); +} + int main (int argc, char *argv[]) { @@ -428,6 +458,7 @@ main (int argc, char *argv[]) g_test_add_func ("/filterlistmodel/change_filter", test_change_filter); g_test_add_func ("/filterlistmodel/incremental", test_incremental); g_test_add_func ("/filterlistmodel/empty", test_empty); + g_test_add_func ("/filterlistmodel/add_remove_item", test_add_remove_item); return g_test_run (); } diff --git a/testsuite/gtk/slicelistmodel.c b/testsuite/gtk/slicelistmodel.c index da87c8bd30..84a4ac72ba 100644 --- a/testsuite/gtk/slicelistmodel.c +++ b/testsuite/gtk/slicelistmodel.c @@ -305,6 +305,15 @@ test_changes (void) g_list_store_remove (store, 19); assert_changes (slice, ""); + splice (store, 1, 1, (guint[]) { 111 }, 1); + assert_changes (slice, ""); + + splice (store, 18, 1, (guint[]) { 19, 20 }, 2); + assert_changes (slice, ""); + + g_list_store_remove (store, 19); + assert_changes (slice, ""); + g_list_store_remove (store, 1); assert_model (slice, "12 13 14 15 16"); assert_changes (slice, "0-5+5"); diff --git a/testsuite/gtk/sortlistmodel.c b/testsuite/gtk/sortlistmodel.c index fa8915df8f..454cae32e1 100644 --- a/testsuite/gtk/sortlistmodel.c +++ b/testsuite/gtk/sortlistmodel.c @@ -543,6 +543,29 @@ test_out_of_bounds_access (void) 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 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/incremental/remove", test_incremental_remove); 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 (); }