[gtk/matthiasc/for-main: 1/2] filterlistmodel: Add a test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-main: 1/2] filterlistmodel: Add a test
- Date: Sun, 17 Jul 2022 10:24:00 +0000 (UTC)
commit 7b815768e009a2ec3e2502a3a430b1acc166f1b6
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 17 06:05:15 2022 -0400
filterlistmodel: Add a test
Test that items added in the underlying model show
up in the filter model (if they pass the filter).
Test removals as well.
See #5050
testsuite/gtk/filterlistmodel.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
---
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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]