Improve test coverage for list models
authorMatthias Clasen <mclasen@redhat.com>
Fri, 12 May 2023 03:24:23 +0000 (23:24 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 12 May 2023 03:24:23 +0000 (23:24 -0400)
testsuite/gtk/multiselection.c
testsuite/gtk/singleselection.c
testsuite/gtk/slicelistmodel.c

index 270cddd63eaf508aa525528d623aef8a0710dc1e..f6fffcb814b87bbe7f3abf0abceba7be579e6fcd 100644 (file)
@@ -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);
index 4465879d826a8829ae8a5e6072221d34790b36f1..faad2d681d4bb989e84cc50d36da6dd83ca1d8a1 100644 (file)
@@ -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");
 
index 0c4cd7e78dbd830adb28b7e1d7b45b2f2ca51c60..e86abd69e7407561ff668a0d6d57310b560abbf0 100644 (file)
@@ -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);
 }