summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-05-11 23:24:23 -0400
committerMatthias Clasen <mclasen@redhat.com>2023-05-11 23:24:23 -0400
commita3ebc0329d65c374f44aea5e51171e747d5503b3 (patch)
treef95d6f8ce26887d2b3c7b9b94daf9f525235e985
parentba64e5588db74e5a82295d8cd27bbdc6c9ebbe3b (diff)
downloadgtk+-a3ebc0329d65c374f44aea5e51171e747d5503b3.tar.gz
Improve test coverage for list models
-rw-r--r--testsuite/gtk/multiselection.c12
-rw-r--r--testsuite/gtk/singleselection.c11
-rw-r--r--testsuite/gtk/slicelistmodel.c4
3 files changed, 24 insertions, 3 deletions
diff --git a/testsuite/gtk/multiselection.c b/testsuite/gtk/multiselection.c
index 270cddd63e..f6fffcb814 100644
--- a/testsuite/gtk/multiselection.c
+++ b/testsuite/gtk/multiselection.c
@@ -296,7 +296,8 @@ test_create (void)
{
GtkSelectionModel *selection;
GListStore *store;
-
+ guint start, end;
+
store = new_store (1, 5, 2);
selection = new_model (store);
@@ -311,6 +312,12 @@ test_create (void)
assert_selection (selection, "");
assert_selection_changes (selection, "");
+ g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (selection)) == G_TYPE_OBJECT);
+ g_assert_true (gtk_multi_selection_get_model (GTK_MULTI_SELECTION (selection)) == G_LIST_MODEL (store));
+ gtk_section_model_get_section (GTK_SECTION_MODEL (selection), 0, &start, &end);
+ g_assert_cmpint (start, ==, 0);
+ g_assert_cmpint (end, ==, G_MAXUINT);
+
g_object_unref (selection);
}
@@ -634,6 +641,9 @@ test_selection_filter (void)
assert_model (filter, "2 3 4");
assert_changes (filter, "");
+ g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (filter)) == G_TYPE_OBJECT);
+ g_assert_true (gtk_selection_filter_model_get_model (filter) == selection);
+
g_object_unref (store);
g_object_unref (selection);
g_object_unref (filter);
diff --git a/testsuite/gtk/singleselection.c b/testsuite/gtk/singleselection.c
index 4465879d82..faad2d681d 100644
--- a/testsuite/gtk/singleselection.c
+++ b/testsuite/gtk/singleselection.c
@@ -287,7 +287,8 @@ test_create (void)
{
GtkSelectionModel *selection;
GListStore *store;
-
+ guint start, end;
+
if (glib_check_version (2, 59, 0) != NULL)
{
g_test_skip ("g_list_store_get_item() has overflow issues before GLIB 2.59.0");
@@ -310,6 +311,12 @@ test_create (void)
assert_selection (selection, "");
assert_selection_changes (selection, "");
+ g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (selection)) == G_TYPE_OBJECT);
+ g_assert_true (gtk_single_selection_get_model (GTK_SINGLE_SELECTION (selection)) == G_LIST_MODEL (store));
+ gtk_section_model_get_section (GTK_SECTION_MODEL (selection), 0, &start, &end);
+ g_assert_cmpint (start, ==, 0);
+ g_assert_cmpint (end, ==, G_MAXUINT);
+
g_object_unref (selection);
}
@@ -701,7 +708,7 @@ test_set_model (void)
assert_selection (selection, "");
assert_selection_changes (selection, "");
- gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (selection), 4);
+ g_object_set (selection, "selected", 4, NULL);
assert_selection (selection, "5");
assert_selection_changes (selection, "4:1");
diff --git a/testsuite/gtk/slicelistmodel.c b/testsuite/gtk/slicelistmodel.c
index 0c4cd7e78d..e86abd69e7 100644
--- a/testsuite/gtk/slicelistmodel.c
+++ b/testsuite/gtk/slicelistmodel.c
@@ -238,6 +238,8 @@ test_create (void)
assert_model (slice, "1 3 5");
assert_changes (slice, "");
+ g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (slice)) == G_TYPE_OBJECT);
+
g_object_unref (slice);
}
@@ -287,6 +289,8 @@ test_set_slice (void)
assert_model (slice, "3 5 7");
assert_changes (slice, "+2*");
+ g_assert_cmpuint (gtk_slice_list_model_get_offset (slice), ==, 1);
+
g_object_unref (store);
g_object_unref (slice);
}