[gtk/flatten-fail] add a test for flattening list model
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/flatten-fail] add a test for flattening list model
- Date: Mon, 1 Jul 2019 23:59:17 +0000 (UTC)
commit 456e928ca1650b64aa3c56a9185c4d0dea831a2a
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jul 1 23:57:20 2019 +0000
add a test for flattening list model
This one was observed while playing with
list models for constraints and guides.
testsuite/gtk/flattenlistmodel.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
---
diff --git a/testsuite/gtk/flattenlistmodel.c b/testsuite/gtk/flattenlistmodel.c
index 94de2490ef..79921e5042 100644
--- a/testsuite/gtk/flattenlistmodel.c
+++ b/testsuite/gtk/flattenlistmodel.c
@@ -300,6 +300,44 @@ test_submodel_add (void)
g_object_unref (flat);
}
+static void
+test_submodel_add2 (void)
+{
+ GtkFlattenListModel *flat;
+ GListStore *model, *store[2];
+
+ model = g_list_store_new (G_TYPE_LIST_MODEL);
+ flat = new_model (model);
+ assert_model (flat, "");
+ assert_changes (flat, "");
+
+ store[0] = add_store (model, 1, 0, 0);
+ store[1] = add_store (model, 1, 0, 0);
+ store[2] = add_store (model, 1, 0, 0);
+
+ assert_model (flat, "");
+ assert_changes (flat, "");
+
+ add (store[0], 1);
+ assert_model (flat, "1");
+ assert_changes (flat, "+0");
+
+ add (store[1], 3);
+ assert_model (flat, "1 3");
+ assert_changes (flat, "+1");
+
+ add (store[0], 2);
+ assert_model (flat, "1 2 3");
+ assert_changes (flat, "+1");
+
+ add (store[1], 4);
+ assert_model (flat, "1 2 3 4");
+ assert_changes (flat, "+3");
+
+ g_object_unref (model);
+ g_object_unref (flat);
+}
+
static void
test_model_remove (void)
{
@@ -365,6 +403,7 @@ main (int argc, char *argv[])
g_test_add_func ("/flattenlistmodel/model/add", test_model_add);
#if GLIB_CHECK_VERSION (2, 58, 0) /* g_list_store_splice() is broken before 2.58 */
g_test_add_func ("/flattenlistmodel/submodel/add", test_submodel_add);
+ g_test_add_func ("/flattenlistmodel/submodel/add2", test_submodel_add2);
g_test_add_func ("/flattenlistmodel/model/remove", test_model_remove);
g_test_add_func ("/flattenlistmodel/submodel/remove", test_submodel_remove);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]