[libadwaita/wip/exalm/new-glib: 14/16] tests: Use g_assert_finalize_object() across the board




commit 466509f6120866005ea2e8c2cdb2ddb83a39cc40
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Nov 2 21:33:12 2021 +0500

    tests: Use g_assert_finalize_object() across the board
    
    Verify we don't leak things. And, turns out, we do - so fix them:
    
    - We were treating GtkWindow as a floating ref
    - We were leaking avatars
    - We were leaking strings and objects with g_object_get()
    
    This also drastically reduces the amount of g_autoptr we're using, and
    makes it possible to support MSVC later on.

 tests/test-action-row.c               |  36 +++---
 tests/test-application-window.c       |   6 +-
 tests/test-avatar.c                   |  12 +-
 tests/test-bin.c                      |   5 +-
 tests/test-button-content.c           |  52 ++++----
 tests/test-carousel-indicator-dots.c  |   8 +-
 tests/test-carousel-indicator-lines.c |   8 +-
 tests/test-carousel.c                 |  30 +++--
 tests/test-combo-row.c                |  19 +--
 tests/test-expander-row.c             |  30 +++--
 tests/test-flap.c                     |  70 ++++++-----
 tests/test-header-bar.c               |  30 +++--
 tests/test-leaflet.c                  |  36 +++---
 tests/test-preferences-group.c        |  15 ++-
 tests/test-preferences-page.c         |  20 +--
 tests/test-preferences-row.c          |  10 +-
 tests/test-preferences-window.c       |   5 +-
 tests/test-split-button.c             |  52 ++++----
 tests/test-squeezer.c                 |  40 +++---
 tests/test-status-page.c              |  19 +--
 tests/test-tab-bar.c                  |  41 ++++---
 tests/test-tab-view.c                 | 225 +++++++++++++++++++---------------
 tests/test-view-switcher-bar.c        |  10 +-
 tests/test-view-switcher.c            |  10 +-
 tests/test-window-title.c             |  14 ++-
 tests/test-window.c                   |   6 +-
 26 files changed, 463 insertions(+), 346 deletions(-)
---
diff --git a/tests/test-action-row.c b/tests/test-action-row.c
index ff9283d3..eac0aaa2 100644
--- a/tests/test-action-row.c
+++ b/tests/test-action-row.c
@@ -18,10 +18,9 @@ activated_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_action_row_add_remove (void)
 {
-  g_autoptr (AdwActionRow) row = NULL;
+  AdwActionRow *row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
   GtkWidget *prefix, *suffix;
 
-  row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
   g_assert_nonnull (row);
 
   prefix = gtk_check_button_new ();
@@ -35,45 +34,44 @@ test_adw_action_row_add_remove (void)
 
   adw_action_row_remove (row, prefix);
   adw_action_row_remove (row, suffix);
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_action_row_subtitle (void)
 {
-  g_autoptr (AdwActionRow) row = NULL;
-
-  row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
+  AdwActionRow *row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_cmpstr (adw_action_row_get_subtitle (row), ==, "");
 
   adw_action_row_set_subtitle (row, "Dummy subtitle");
   g_assert_cmpstr (adw_action_row_get_subtitle (row), ==, "Dummy subtitle");
-}
 
+  g_assert_finalize_object (row);
+}
 
 static void
 test_adw_action_row_icon_name (void)
 {
-  g_autoptr (AdwActionRow) row = NULL;
-
-  row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
+  AdwActionRow *row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_null (adw_action_row_get_icon_name (row));
 
   adw_action_row_set_icon_name (row, "dummy-icon-name");
   g_assert_cmpstr (adw_action_row_get_icon_name (row), ==, "dummy-icon-name");
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_action_row_title_lines (void)
 {
-  g_autoptr (AdwActionRow) row = NULL;
-
-  row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
+  AdwActionRow *row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_cmpint (adw_action_row_get_title_lines (row), ==, 0);
@@ -86,15 +84,15 @@ test_adw_action_row_title_lines (void)
 
   adw_action_row_set_title_lines (row, 1);
   g_assert_cmpint (adw_action_row_get_title_lines (row), ==, 1);
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_action_row_subtitle_lines (void)
 {
-  g_autoptr (AdwActionRow) row = NULL;
-
-  row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
+  AdwActionRow *row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_cmpint (adw_action_row_get_subtitle_lines (row), ==, 0);
@@ -107,15 +105,15 @@ test_adw_action_row_subtitle_lines (void)
 
   adw_action_row_set_subtitle_lines (row, 1);
   g_assert_cmpint (adw_action_row_get_subtitle_lines (row), ==, 1);
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_action_row_activate (void)
 {
-  g_autoptr (AdwActionRow) row = NULL;
-
-  row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
+  AdwActionRow *row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
   g_assert_nonnull (row);
 
   activated = 0;
@@ -123,6 +121,8 @@ test_adw_action_row_activate (void)
 
   adw_action_row_activate (row);
   g_assert_cmpint (activated, ==, 1);
+
+  g_assert_finalize_object (row);
 }
 
 
diff --git a/tests/test-application-window.c b/tests/test-application-window.c
index 5936974a..a08d2830 100644
--- a/tests/test-application-window.c
+++ b/tests/test-application-window.c
@@ -10,10 +10,10 @@
 static void
 test_adw_application_window_new (void)
 {
-  g_autoptr (GtkWidget) window = NULL;
-
-  window = g_object_ref_sink (adw_application_window_new (NULL));
+  GtkWidget *window = adw_application_window_new (NULL);
   g_assert_nonnull (window);
+
+  g_assert_finalize_object (window);
 }
 
 
diff --git a/tests/test-avatar.c b/tests/test-avatar.c
index 91e27ece..3d4396b0 100644
--- a/tests/test-avatar.c
+++ b/tests/test-avatar.c
@@ -14,31 +14,37 @@
 static void
 test_adw_avatar_icon_name (void)
 {
-  AdwAvatar *avatar = ADW_AVATAR (adw_avatar_new (128, NULL, TRUE));
+  AdwAvatar *avatar = g_object_ref_sink (ADW_AVATAR (adw_avatar_new (128, NULL, TRUE)));
 
   g_assert_null (adw_avatar_get_icon_name (avatar));
   adw_avatar_set_icon_name (avatar, TEST_ICON_NAME);
   g_assert_cmpstr (adw_avatar_get_icon_name (avatar), ==, TEST_ICON_NAME);
+
+  g_assert_finalize_object (avatar);
 }
 
 static void
 test_adw_avatar_text (void)
 {
-  AdwAvatar *avatar = ADW_AVATAR (adw_avatar_new (128, NULL, TRUE));
+  AdwAvatar *avatar = g_object_ref_sink (ADW_AVATAR (adw_avatar_new (128, NULL, TRUE)));
 
   g_assert_cmpstr (adw_avatar_get_text (avatar), ==, "");
   adw_avatar_set_text (avatar, TEST_STRING);
   g_assert_cmpstr (adw_avatar_get_text (avatar), ==, TEST_STRING);
+
+  g_assert_finalize_object (avatar);
 }
 
 static void
 test_adw_avatar_size (void)
 {
-  AdwAvatar *avatar = ADW_AVATAR (adw_avatar_new (TEST_SIZE, NULL, TRUE));
+  AdwAvatar *avatar = g_object_ref_sink (ADW_AVATAR (adw_avatar_new (TEST_SIZE, NULL, TRUE)));
 
   g_assert_cmpint (adw_avatar_get_size (avatar), ==, TEST_SIZE);
   adw_avatar_set_size (avatar, TEST_SIZE / 2);
   g_assert_cmpint (adw_avatar_get_size (avatar), ==, TEST_SIZE / 2);
+
+  g_assert_finalize_object (avatar);
 }
 
 int
diff --git a/tests/test-bin.c b/tests/test-bin.c
index dd61b87f..f84233d7 100644
--- a/tests/test-bin.c
+++ b/tests/test-bin.c
@@ -19,10 +19,9 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_bin_child (void)
 {
-  g_autoptr (AdwBin) bin = NULL;
+  AdwBin *bin = g_object_ref_sink (ADW_BIN (adw_bin_new ()));
   GtkWidget *widget = NULL;
 
-  bin = g_object_ref_sink (ADW_BIN (adw_bin_new ()));
   g_assert_nonnull (bin);
 
   notified = 0;
@@ -42,6 +41,8 @@ test_adw_bin_child (void)
   g_object_set (bin, "child", NULL, NULL);
   g_assert_null (adw_bin_get_child (bin));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (bin);
 }
 
 int
diff --git a/tests/test-button-content.c b/tests/test-button-content.c
index 0a8fecad..5d5ba196 100644
--- a/tests/test-button-content.c
+++ b/tests/test-button-content.c
@@ -19,10 +19,9 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_button_content_icon_name (void)
 {
-  g_autoptr (AdwButtonContent) content = NULL;
-  const char *icon_name;
+  AdwButtonContent *content = g_object_ref_sink (ADW_BUTTON_CONTENT (adw_button_content_new ()));
+  g_autofree char *icon_name = NULL;
 
-  content = g_object_ref_sink (ADW_BUTTON_CONTENT (adw_button_content_new ()));
   g_assert_nonnull (content);
 
   notified = 0;
@@ -34,7 +33,6 @@ test_adw_button_content_icon_name (void)
   adw_button_content_set_icon_name (content, "");
   g_assert_cmpint (notified, ==, 0);
 
-
   adw_button_content_set_icon_name (content, "document-open-symbolic");
   g_assert_cmpstr (adw_button_content_get_icon_name (content), ==, "document-open-symbolic");
   g_assert_cmpint (notified, ==, 1);
@@ -42,15 +40,16 @@ test_adw_button_content_icon_name (void)
   g_object_set (content, "icon-name", "", NULL);
   g_assert_cmpstr (adw_button_content_get_icon_name (content), ==, "");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (content);
 }
 
 static void
 test_adw_button_content_label (void)
 {
-  g_autoptr (AdwButtonContent) content = NULL;
-  const char *label;
+  AdwButtonContent *content = g_object_ref_sink (ADW_BUTTON_CONTENT (adw_button_content_new ()));
+  g_autofree char *label = NULL;
 
-  content = g_object_ref_sink (ADW_BUTTON_CONTENT (adw_button_content_new ()));
   g_assert_nonnull (content);
 
   notified = 0;
@@ -62,7 +61,6 @@ test_adw_button_content_label (void)
   adw_button_content_set_label (content, "");
   g_assert_cmpint (notified, ==, 0);
 
-
   adw_button_content_set_label (content, "Open");
   g_assert_cmpstr (adw_button_content_get_label (content), ==, "Open");
   g_assert_cmpint (notified, ==, 1);
@@ -70,15 +68,16 @@ test_adw_button_content_label (void)
   g_object_set (content, "label", "", NULL);
   g_assert_cmpstr (adw_button_content_get_label (content), ==, "");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (content);
 }
 
 static void
 test_adw_button_content_use_underline (void)
 {
-  g_autoptr (AdwButtonContent) content = NULL;
+  AdwButtonContent *content = g_object_ref_sink (ADW_BUTTON_CONTENT (adw_button_content_new ()));
   gboolean use_underline;
 
-  content = g_object_ref_sink (ADW_BUTTON_CONTENT (adw_button_content_new ()));
   g_assert_nonnull (content);
 
   notified = 0;
@@ -90,7 +89,6 @@ test_adw_button_content_use_underline (void)
   adw_button_content_set_use_underline (content, FALSE);
   g_assert_cmpint (notified, ==, 0);
 
-
   adw_button_content_set_use_underline (content, TRUE);
   g_assert_true (adw_button_content_get_use_underline (content));
   g_assert_cmpint (notified, ==, 1);
@@ -98,54 +96,50 @@ test_adw_button_content_use_underline (void)
   g_object_set (content, "use-underline", FALSE, NULL);
   g_assert_false (adw_button_content_get_use_underline (content));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (content);
 }
 
 static void
 test_adw_button_content_style_class_button (void)
 {
-  g_autoptr (GtkWidget) window = NULL;
-  GtkWidget *button;
-  AdwButtonContent *content;
+  GtkWidget *window = gtk_window_new ();
+  GtkWidget *button = gtk_button_new ();
+  AdwButtonContent *content = ADW_BUTTON_CONTENT (adw_button_content_new ());
 
-  window = g_object_ref_sink (gtk_window_new ());
+  g_assert_nonnull (content);
 
-  button = gtk_button_new ();
   gtk_window_set_child (GTK_WINDOW (window), button);
-
   gtk_window_present (GTK_WINDOW (window));
 
-  content = ADW_BUTTON_CONTENT (adw_button_content_new ());
-  g_assert_nonnull (content);
-
   gtk_button_set_child (GTK_BUTTON (button), GTK_WIDGET (content));
   g_assert_true (gtk_widget_has_css_class (button, "image-text-button"));
 
   gtk_button_set_child (GTK_BUTTON (button), NULL);
   g_assert_false (gtk_widget_has_css_class (button, "image-text-button"));
+
+  g_assert_finalize_object (window);
 }
 
 static void
 test_adw_button_content_style_class_split_button (void)
 {
-  g_autoptr (GtkWidget) window = NULL;
-  GtkWidget *button;
-  AdwButtonContent *content;
+  GtkWidget *window = gtk_window_new ();
+  GtkWidget *button = adw_split_button_new ();
+  AdwButtonContent *content = ADW_BUTTON_CONTENT (adw_button_content_new ());
 
-  window = g_object_ref_sink (gtk_window_new ());
+  g_assert_nonnull (content);
 
-  button = adw_split_button_new ();
   gtk_window_set_child (GTK_WINDOW (window), button);
-
   gtk_window_present (GTK_WINDOW (window));
 
-  content = ADW_BUTTON_CONTENT (adw_button_content_new ());
-  g_assert_nonnull (content);
-
   adw_split_button_set_child (ADW_SPLIT_BUTTON (button), GTK_WIDGET (content));
   g_assert_true (gtk_widget_has_css_class (button, "image-text-button"));
 
   adw_split_button_set_child (ADW_SPLIT_BUTTON (button), NULL);
   g_assert_false (gtk_widget_has_css_class (button, "image-text-button"));
+
+  g_assert_finalize_object (window);
 }
 
 int
diff --git a/tests/test-carousel-indicator-dots.c b/tests/test-carousel-indicator-dots.c
index 09ff42e2..b422456c 100644
--- a/tests/test-carousel-indicator-dots.c
+++ b/tests/test-carousel-indicator-dots.c
@@ -17,16 +17,15 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_carousel_indicator_dots_carousel (void)
 {
-  g_autoptr (AdwCarouselIndicatorDots) dots = NULL;
+  AdwCarouselIndicatorDots *dots = g_object_ref_sink (ADW_CAROUSEL_INDICATOR_DOTS 
(adw_carousel_indicator_dots_new ()));
   AdwCarousel *carousel;
 
-  dots = g_object_ref_sink (ADW_CAROUSEL_INDICATOR_DOTS (adw_carousel_indicator_dots_new ()));
   g_assert_nonnull (dots);
 
   notified = 0;
   g_signal_connect (dots, "notify::carousel", G_CALLBACK (notify_cb), NULL);
 
-  carousel = ADW_CAROUSEL (adw_carousel_new ());
+  carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   g_assert_nonnull (carousel);
 
   g_assert_null (adw_carousel_indicator_dots_get_carousel (dots));
@@ -39,6 +38,9 @@ test_adw_carousel_indicator_dots_carousel (void)
   adw_carousel_indicator_dots_set_carousel (dots, NULL);
   g_assert_null (adw_carousel_indicator_dots_get_carousel (dots));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (dots);
+  g_assert_finalize_object (carousel);
 }
 
 int
diff --git a/tests/test-carousel-indicator-lines.c b/tests/test-carousel-indicator-lines.c
index f37416cb..af3f2fdc 100644
--- a/tests/test-carousel-indicator-lines.c
+++ b/tests/test-carousel-indicator-lines.c
@@ -17,16 +17,15 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_carousel_indicator_lines_carousel (void)
 {
-  g_autoptr (AdwCarouselIndicatorLines) lines = NULL;
+  AdwCarouselIndicatorLines *lines = g_object_ref_sink (ADW_CAROUSEL_INDICATOR_LINES 
(adw_carousel_indicator_lines_new ()));
   AdwCarousel *carousel;
 
-  lines = g_object_ref_sink (ADW_CAROUSEL_INDICATOR_LINES (adw_carousel_indicator_lines_new ()));
   g_assert_nonnull (lines);
 
   notified = 0;
   g_signal_connect (lines, "notify::carousel", G_CALLBACK (notify_cb), NULL);
 
-  carousel = ADW_CAROUSEL (adw_carousel_new ());
+  carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   g_assert_nonnull (carousel);
 
   g_assert_null (adw_carousel_indicator_lines_get_carousel (lines));
@@ -39,6 +38,9 @@ test_adw_carousel_indicator_lines_carousel (void)
   adw_carousel_indicator_lines_set_carousel (lines, NULL);
   g_assert_null (adw_carousel_indicator_lines_get_carousel (lines));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (lines);
+  g_assert_finalize_object (carousel);
 }
 
 int
diff --git a/tests/test-carousel.c b/tests/test-carousel.c
index 4c6ac11a..017fec78 100644
--- a/tests/test-carousel.c
+++ b/tests/test-carousel.c
@@ -17,11 +17,9 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_carousel_add_remove (void)
 {
-  AdwCarousel *carousel;
+  AdwCarousel *carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   GtkWidget *child1, *child2, *child3;
 
-  carousel = ADW_CAROUSEL (adw_carousel_new ());
-
   child1 = gtk_label_new ("");
   child2 = gtk_label_new ("");
   child3 = gtk_label_new ("");
@@ -59,13 +57,13 @@ test_adw_carousel_add_remove (void)
   g_assert_cmpuint (adw_carousel_get_n_pages (carousel), ==, 0);
   g_assert_cmpint (notified, ==, 6);
 
-  g_object_unref (carousel);
+  g_assert_finalize_object (carousel);
 }
 
 static void
 test_adw_carousel_interactive (void)
 {
-  AdwCarousel *carousel = ADW_CAROUSEL (adw_carousel_new ());
+  AdwCarousel *carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   gboolean interactive;
 
   notified = 0;
@@ -86,12 +84,14 @@ test_adw_carousel_interactive (void)
   /* Setting the same value should not notify */
   adw_carousel_set_interactive (carousel, TRUE);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (carousel);
 }
 
 static void
 test_adw_carousel_spacing (void)
 {
-  AdwCarousel *carousel = ADW_CAROUSEL (adw_carousel_new ());
+  AdwCarousel *carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   guint spacing;
 
   notified = 0;
@@ -112,12 +112,14 @@ test_adw_carousel_spacing (void)
   /* Setting the same value should not notify */
   adw_carousel_set_spacing (carousel, 6);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (carousel);
 }
 
 static void
 test_adw_carousel_animation_duration (void)
 {
-  AdwCarousel *carousel = ADW_CAROUSEL (adw_carousel_new ());
+  AdwCarousel *carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   guint duration;
 
   notified = 0;
@@ -138,12 +140,14 @@ test_adw_carousel_animation_duration (void)
   /* Setting the same value should not notify */
   adw_carousel_set_animation_duration (carousel, 500);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (carousel);
 }
 
 static void
 test_adw_carousel_allow_mouse_drag (void)
 {
-  AdwCarousel *carousel = ADW_CAROUSEL (adw_carousel_new ());
+  AdwCarousel *carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   gboolean allow_mouse_drag;
 
   notified = 0;
@@ -164,12 +168,14 @@ test_adw_carousel_allow_mouse_drag (void)
   /* Setting the same value should not notify */
   adw_carousel_set_allow_mouse_drag (carousel, TRUE);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (carousel);
 }
 
 static void
 test_adw_carousel_allow_long_swipes (void)
 {
-  AdwCarousel *carousel = ADW_CAROUSEL (adw_carousel_new ());
+  AdwCarousel *carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   gboolean allow_long_swipes;
 
   notified = 0;
@@ -190,12 +196,14 @@ test_adw_carousel_allow_long_swipes (void)
   /* Setting the same value should not notify */
   adw_carousel_set_allow_long_swipes (carousel, FALSE);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (carousel);
 }
 
 static void
 test_adw_carousel_reveal_duration (void)
 {
-  AdwCarousel *carousel = ADW_CAROUSEL (adw_carousel_new ());
+  AdwCarousel *carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
   guint duration;
 
   notified = 0;
@@ -216,6 +224,8 @@ test_adw_carousel_reveal_duration (void)
   /* Setting the same value should not notify */
   adw_carousel_set_reveal_duration (carousel, 500);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (carousel);
 }
 
 int
diff --git a/tests/test-combo-row.c b/tests/test-combo-row.c
index 2c7cc819..7831622d 100644
--- a/tests/test-combo-row.c
+++ b/tests/test-combo-row.c
@@ -17,14 +17,12 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_combo_row_set_for_enum (void)
 {
-  g_autoptr (AdwComboRow) row = NULL;
+  AdwComboRow *row = g_object_ref_sink (ADW_COMBO_ROW (adw_combo_row_new ()));
   GtkExpression *expr = NULL;
   GListModel *model;
   AdwEnumListItem *item;
 
-  row = g_object_ref_sink (ADW_COMBO_ROW (adw_combo_row_new ()));
   g_assert_nonnull (row);
-
   g_assert_null (adw_combo_row_get_model (row));
 
   expr = gtk_property_expression_new (ADW_TYPE_ENUM_LIST_ITEM, NULL, "nick");
@@ -47,16 +45,17 @@ test_adw_combo_row_set_for_enum (void)
   item = g_list_model_get_item (model, 1);
   g_assert_true (ADW_IS_ENUM_LIST_ITEM (item));
   g_assert_cmpstr (adw_enum_list_item_get_nick (item), ==, "vertical");
+
+  g_assert_finalize_object (row);
 }
 
 static void
 test_adw_combo_row_selected (void)
 {
-  g_autoptr (AdwComboRow) row = NULL;
-  g_autoptr (GListModel) model = NULL;
+  AdwComboRow *row = g_object_ref_sink (ADW_COMBO_ROW (adw_combo_row_new ()));
+  GListModel *model;
   int selected = 0;
 
-  row = ADW_COMBO_ROW (g_object_ref_sink (adw_combo_row_new ()));
   g_assert_nonnull (row);
 
   notified = 0;
@@ -82,15 +81,17 @@ test_adw_combo_row_selected (void)
   g_object_set (row, "selected", 1, NULL);
   g_assert_cmpint (adw_combo_row_get_selected (row), ==, 1);
   g_assert_cmpint (notified, ==, 3);
+
+  g_assert_finalize_object (row);
+  g_assert_finalize_object (model);
 }
 
 static void
 test_adw_combo_row_use_subtitle (void)
 {
-  g_autoptr (AdwComboRow) row = NULL;
+  AdwComboRow *row = g_object_ref_sink (ADW_COMBO_ROW (adw_combo_row_new ()));
   gboolean use_subtitle = FALSE;
 
-  row = g_object_ref_sink (ADW_COMBO_ROW (adw_combo_row_new ()));
   g_assert_nonnull (row);
 
   notified = 0;
@@ -109,6 +110,8 @@ test_adw_combo_row_use_subtitle (void)
   g_object_get (row, "use-subtitle", &use_subtitle, NULL);
   g_assert_false (use_subtitle);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (row);
 }
 
 
diff --git a/tests/test-expander-row.c b/tests/test-expander-row.c
index 9d82e350..730a25c8 100644
--- a/tests/test-expander-row.c
+++ b/tests/test-expander-row.c
@@ -10,10 +10,9 @@
 static void
 test_adw_expander_row_add_remove (void)
 {
-  g_autoptr (AdwExpanderRow) row = NULL;
+  AdwExpanderRow *row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
   GtkWidget *child;
 
-  row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
   g_assert_nonnull (row);
 
   child = gtk_list_box_row_new ();
@@ -21,45 +20,48 @@ test_adw_expander_row_add_remove (void)
 
   adw_expander_row_add_row (row, child);
   adw_expander_row_remove (row, child);
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_expander_row_subtitle (void)
 {
-  g_autoptr (AdwExpanderRow) row = NULL;
+  AdwExpanderRow *row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
 
-  row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_cmpstr (adw_expander_row_get_subtitle (row), ==, "");
 
   adw_expander_row_set_subtitle (row, "Dummy subtitle");
   g_assert_cmpstr (adw_expander_row_get_subtitle (row), ==, "Dummy subtitle");
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_expander_row_icon_name (void)
 {
-  g_autoptr (AdwExpanderRow) row = NULL;
+  AdwExpanderRow *row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
 
-  row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_null (adw_expander_row_get_icon_name (row));
 
   adw_expander_row_set_icon_name (row, "dummy-icon-name");
   g_assert_cmpstr (adw_expander_row_get_icon_name (row), ==, "dummy-icon-name");
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_expander_row_expanded (void)
 {
-  g_autoptr (AdwExpanderRow) row = NULL;
+  AdwExpanderRow *row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
 
-  row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_false (adw_expander_row_get_expanded (row));
@@ -69,15 +71,16 @@ test_adw_expander_row_expanded (void)
 
   adw_expander_row_set_expanded (row, FALSE);
   g_assert_false (adw_expander_row_get_expanded (row));
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_expander_row_enable_expansion (void)
 {
-  g_autoptr (AdwExpanderRow) row = NULL;
+  AdwExpanderRow *row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
 
-  row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_true (adw_expander_row_get_enable_expansion (row));
@@ -96,15 +99,16 @@ test_adw_expander_row_enable_expansion (void)
   adw_expander_row_set_enable_expansion (row, TRUE);
   g_assert_true (adw_expander_row_get_enable_expansion (row));
   g_assert_true (adw_expander_row_get_expanded (row));
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_expander_row_show_enable_switch (void)
 {
-  g_autoptr (AdwExpanderRow) row = NULL;
+  AdwExpanderRow *row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
 
-  row = g_object_ref_sink (ADW_EXPANDER_ROW (adw_expander_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_false (adw_expander_row_get_show_enable_switch (row));
@@ -114,6 +118,8 @@ test_adw_expander_row_show_enable_switch (void)
 
   adw_expander_row_set_show_enable_switch (row, FALSE);
   g_assert_false (adw_expander_row_get_show_enable_switch (row));
+
+  g_assert_finalize_object (row);
 }
 
 
diff --git a/tests/test-flap.c b/tests/test-flap.c
index 9e9bf450..77d38f4c 100644
--- a/tests/test-flap.c
+++ b/tests/test-flap.c
@@ -19,10 +19,9 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_flap_flap (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   GtkWidget *widget = NULL;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   notified = 0;
@@ -42,15 +41,16 @@ test_adw_flap_flap (void)
   g_object_set (flap, "flap", NULL, NULL);
   g_assert_null (adw_flap_get_flap (flap));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_separator (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   GtkWidget *widget = NULL;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   notified = 0;
@@ -70,15 +70,16 @@ test_adw_flap_separator (void)
   g_object_set (flap, "separator", NULL, NULL);
   g_assert_null (adw_flap_get_separator (flap));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_flap_position (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   GtkPackType position;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   notified = 0;
@@ -97,15 +98,16 @@ test_adw_flap_flap_position (void)
   g_object_set (flap, "flap-position", GTK_PACK_START, NULL);
   g_assert_cmpint (adw_flap_get_flap_position (flap), ==, GTK_PACK_START);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_reveal_flap (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   gboolean reveal;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   adw_flap_set_flap (flap, gtk_button_new ());
@@ -126,15 +128,16 @@ test_adw_flap_reveal_flap (void)
   g_object_set (flap, "reveal-flap", TRUE, NULL);
   g_assert_true (adw_flap_get_reveal_flap (flap));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_reveal_duration (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   guint duration;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   notified = 0;
@@ -153,15 +156,16 @@ test_adw_flap_reveal_duration (void)
   g_object_set (flap, "reveal-duration", 100, NULL);
   g_assert_cmpint (adw_flap_get_reveal_duration (flap), ==, 100);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_reveal_progress (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   double progress;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   notified = 0;
@@ -177,15 +181,16 @@ test_adw_flap_reveal_progress (void)
   adw_flap_set_reveal_flap (flap, TRUE);
   g_assert_cmpint (adw_flap_get_reveal_progress (flap), ==, 1.0);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_fold_policy (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   AdwFlapFoldPolicy policy;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   notified = 0;
@@ -204,15 +209,16 @@ test_adw_flap_fold_policy (void)
   g_object_set (flap, "fold-policy", ADW_FLAP_FOLD_POLICY_ALWAYS, NULL);
   g_assert_cmpint (adw_flap_get_fold_policy (flap), ==, ADW_FLAP_FOLD_POLICY_ALWAYS);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_fold_duration (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   guint duration;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   notified = 0;
@@ -231,15 +237,16 @@ test_adw_flap_fold_duration (void)
   g_object_set (flap, "fold-duration", 100, NULL);
   g_assert_cmpint (adw_flap_get_fold_duration (flap), ==, 100);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_folded (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   gboolean folded;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   adw_flap_set_flap (flap, gtk_button_new ());
@@ -254,15 +261,16 @@ test_adw_flap_folded (void)
   adw_flap_set_fold_policy (flap, ADW_FLAP_FOLD_POLICY_ALWAYS);
   g_assert_true (adw_flap_get_folded (flap));
   g_assert_cmpint (notified, ==, 1);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_locked (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   gboolean locked;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   adw_flap_set_flap (flap, gtk_button_new ());
@@ -283,15 +291,16 @@ test_adw_flap_locked (void)
   g_object_set (flap, "locked", FALSE, NULL);
   g_assert_false (adw_flap_get_locked (flap));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_transition_type (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   AdwFlapTransitionType policy;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   notified = 0;
@@ -310,15 +319,16 @@ test_adw_flap_transition_type (void)
   g_object_set (flap, "transition-type", ADW_FLAP_TRANSITION_TYPE_UNDER, NULL);
   g_assert_cmpint (adw_flap_get_transition_type (flap), ==, ADW_FLAP_TRANSITION_TYPE_UNDER);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_modal (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   gboolean modal;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   adw_flap_set_flap (flap, gtk_button_new ());
@@ -339,15 +349,16 @@ test_adw_flap_modal (void)
   g_object_set (flap, "modal", TRUE, NULL);
   g_assert_true (adw_flap_get_modal (flap));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_swipe_to_open (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   gboolean swipe_to_open;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   adw_flap_set_flap (flap, gtk_button_new ());
@@ -368,15 +379,16 @@ test_adw_flap_swipe_to_open (void)
   g_object_set (flap, "swipe-to-open", TRUE, NULL);
   g_assert_true (adw_flap_get_swipe_to_open (flap));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 static void
 test_adw_flap_swipe_to_close (void)
 {
-  g_autoptr (AdwFlap) flap = NULL;
+  AdwFlap *flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   gboolean swipe_to_close;
 
-  flap = g_object_ref_sink (ADW_FLAP (adw_flap_new ()));
   g_assert_nonnull (flap);
 
   adw_flap_set_flap (flap, gtk_button_new ());
@@ -397,6 +409,8 @@ test_adw_flap_swipe_to_close (void)
   g_object_set (flap, "swipe-to-close", TRUE, NULL);
   g_assert_true (adw_flap_get_swipe_to_close (flap));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (flap);
 }
 
 int
diff --git a/tests/test-header-bar.c b/tests/test-header-bar.c
index c03a08bc..7fb31b8b 100644
--- a/tests/test-header-bar.c
+++ b/tests/test-header-bar.c
@@ -10,10 +10,9 @@
 static void
 test_adw_header_bar_pack (void)
 {
-  g_autoptr (AdwHeaderBar) bar = NULL;
+  AdwHeaderBar *bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
   GtkWidget *widget;
 
-  bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
   g_assert_nonnull (bar);
 
   widget = gtk_switch_new ();
@@ -25,16 +24,17 @@ test_adw_header_bar_pack (void)
   g_assert_nonnull (widget);
 
   adw_header_bar_pack_end (bar, widget);
+
+  g_assert_finalize_object (bar);
 }
 
 
 static void
 test_adw_header_bar_title_widget (void)
 {
-  g_autoptr (AdwHeaderBar) bar = NULL;
+  AdwHeaderBar *bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
   GtkWidget *widget;
 
-  bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
   g_assert_nonnull (bar);
 
   g_assert_null (adw_header_bar_get_title_widget (bar));
@@ -46,15 +46,16 @@ test_adw_header_bar_title_widget (void)
 
   adw_header_bar_set_title_widget (bar, NULL);
   g_assert_null (adw_header_bar_get_title_widget (bar));
+
+  g_assert_finalize_object (bar);
 }
 
 
 static void
 test_adw_header_bar_show_start_title_buttons (void)
 {
-  g_autoptr (AdwHeaderBar) bar = NULL;
+  AdwHeaderBar *bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
 
-  bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
   g_assert_nonnull (bar);
 
   g_assert_true (adw_header_bar_get_show_start_title_buttons (bar));
@@ -64,15 +65,16 @@ test_adw_header_bar_show_start_title_buttons (void)
 
   adw_header_bar_set_show_start_title_buttons (bar, TRUE);
   g_assert_true (adw_header_bar_get_show_start_title_buttons (bar));
+
+  g_assert_finalize_object (bar);
 }
 
 
 static void
 test_adw_header_bar_show_end_title_buttons (void)
 {
-  g_autoptr (AdwHeaderBar) bar = NULL;
+  AdwHeaderBar *bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
 
-  bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
   g_assert_nonnull (bar);
 
   g_assert_true (adw_header_bar_get_show_end_title_buttons (bar));
@@ -82,15 +84,16 @@ test_adw_header_bar_show_end_title_buttons (void)
 
   adw_header_bar_set_show_end_title_buttons (bar, TRUE);
   g_assert_true (adw_header_bar_get_show_end_title_buttons (bar));
+
+  g_assert_finalize_object (bar);
 }
 
 
 static void
 test_adw_header_bar_decoration_layout (void)
 {
-  g_autoptr (AdwHeaderBar) bar = NULL;
+  AdwHeaderBar *bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
 
-  bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
   g_assert_nonnull (bar);
 
   g_assert_null (adw_header_bar_get_decoration_layout (bar));
@@ -100,15 +103,16 @@ test_adw_header_bar_decoration_layout (void)
 
   adw_header_bar_set_decoration_layout (bar, NULL);
   g_assert_null (adw_header_bar_get_decoration_layout (bar));
+
+  g_assert_finalize_object (bar);
 }
 
 
 static void
 test_adw_header_bar_centering_policy (void)
 {
-  g_autoptr (AdwHeaderBar) bar = NULL;
+  AdwHeaderBar *bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
 
-  bar = g_object_ref_sink (ADW_HEADER_BAR (adw_header_bar_new ()));
   g_assert_nonnull (bar);
 
   g_assert_cmpint (adw_header_bar_get_centering_policy (bar), ==, ADW_CENTERING_POLICY_LOOSE);
@@ -118,6 +122,8 @@ test_adw_header_bar_centering_policy (void)
 
   adw_header_bar_set_centering_policy (bar, ADW_CENTERING_POLICY_LOOSE);
   g_assert_cmpint (adw_header_bar_get_centering_policy (bar), ==, ADW_CENTERING_POLICY_LOOSE);
+
+  g_assert_finalize_object (bar);
 }
 
 
diff --git a/tests/test-leaflet.c b/tests/test-leaflet.c
index 93c9d4ea..39f7aeed 100644
--- a/tests/test-leaflet.c
+++ b/tests/test-leaflet.c
@@ -23,12 +23,11 @@ assert_page_position (GtkSelectionModel *pages,
 static void
 test_adw_leaflet_adjacent_child (void)
 {
-  g_autoptr (AdwLeaflet) leaflet = NULL;
+  AdwLeaflet *leaflet = g_object_ref_sink (ADW_LEAFLET (adw_leaflet_new ()));
   GtkWidget *children[3];
   int i;
   GtkWidget *result;
 
-  leaflet = ADW_LEAFLET (adw_leaflet_new ());
   g_assert_nonnull (leaflet);
 
   for (i = 0; i < 3; i++) {
@@ -66,18 +65,19 @@ test_adw_leaflet_adjacent_child (void)
 
   result = adw_leaflet_get_adjacent_child (leaflet, ADW_NAVIGATION_DIRECTION_FORWARD);
   g_assert_null (result);
+
+  g_assert_finalize_object (leaflet);
 }
 
 
 static void
 test_adw_leaflet_navigate (void)
 {
-  g_autoptr (AdwLeaflet) leaflet = NULL;
+  AdwLeaflet *leaflet = g_object_ref_sink (ADW_LEAFLET (adw_leaflet_new ()));
   GtkWidget *children[3];
   int i;
   gboolean result;
 
-  leaflet = ADW_LEAFLET (adw_leaflet_new ());
   g_assert_nonnull (leaflet);
 
   result = adw_leaflet_navigate (leaflet, ADW_NAVIGATION_DIRECTION_BACK);
@@ -113,18 +113,19 @@ test_adw_leaflet_navigate (void)
   result = adw_leaflet_navigate (leaflet, ADW_NAVIGATION_DIRECTION_BACK);
   g_assert_true (result);
   g_assert_true (adw_leaflet_get_visible_child (leaflet) == children[0]);
+
+  g_assert_finalize_object (leaflet);
 }
 
 
 static void
 test_adw_leaflet_prepend (void)
 {
-  g_autoptr (AdwLeaflet) leaflet = NULL;
+  AdwLeaflet *leaflet = g_object_ref_sink (ADW_LEAFLET (adw_leaflet_new ()));
   GtkWidget *labels[2];
   int i;
-  g_autoptr (GtkSelectionModel) pages = NULL;
+  GtkSelectionModel *pages;
 
-  leaflet = ADW_LEAFLET (adw_leaflet_new ());
   g_assert_nonnull (leaflet);
 
   for (i = 0; i < 2; i++) {
@@ -140,18 +141,20 @@ test_adw_leaflet_prepend (void)
   adw_leaflet_prepend (leaflet, labels[0]);
   assert_page_position (pages, labels[0], 0);
   assert_page_position (pages, labels[1], 1);
+
+  g_assert_finalize_object (leaflet);
+  g_assert_finalize_object (pages);
 }
 
 
 static void
 test_adw_leaflet_insert_child_after (void)
 {
-  g_autoptr (AdwLeaflet) leaflet = NULL;
+  AdwLeaflet *leaflet = g_object_ref_sink (ADW_LEAFLET (adw_leaflet_new ()));
   GtkWidget *labels[3];
   int i;
-  g_autoptr (GtkSelectionModel) pages = NULL;
+  GtkSelectionModel *pages;
 
-  leaflet = ADW_LEAFLET (adw_leaflet_new ());
   g_assert_nonnull (leaflet);
 
   for (i = 0; i < 3; i++) {
@@ -165,8 +168,6 @@ test_adw_leaflet_insert_child_after (void)
 
   assert_page_position (pages, labels[2], 0);
 
-  pages = adw_leaflet_get_pages (leaflet);
-
   adw_leaflet_insert_child_after (leaflet, labels[0], NULL);
   assert_page_position (pages, labels[0], 0);
   assert_page_position (pages, labels[2], 1);
@@ -175,18 +176,20 @@ test_adw_leaflet_insert_child_after (void)
   assert_page_position (pages, labels[0], 0);
   assert_page_position (pages, labels[1], 1);
   assert_page_position (pages, labels[2], 2);
+
+  g_assert_finalize_object (leaflet);
+  g_assert_finalize_object (pages);
 }
 
 
 static void
 test_adw_leaflet_reorder_child_after (void)
 {
-  g_autoptr (AdwLeaflet) leaflet = NULL;
+  AdwLeaflet *leaflet = g_object_ref_sink (ADW_LEAFLET (adw_leaflet_new ()));
   GtkWidget *labels[3];
   int i;
-  g_autoptr (GtkSelectionModel) pages = NULL;
+  GtkSelectionModel *pages;
 
-  leaflet = ADW_LEAFLET (adw_leaflet_new ());
   g_assert_nonnull (leaflet);
 
   for (i = 0; i < 3; i++) {
@@ -211,6 +214,9 @@ test_adw_leaflet_reorder_child_after (void)
   assert_page_position (pages, labels[2], 0);
   assert_page_position (pages, labels[1], 1);
   assert_page_position (pages, labels[0], 2);
+
+  g_assert_finalize_object (leaflet);
+  g_assert_finalize_object (pages);
 }
 
 
diff --git a/tests/test-preferences-group.c b/tests/test-preferences-group.c
index bc77d54c..0fb5d115 100644
--- a/tests/test-preferences-group.c
+++ b/tests/test-preferences-group.c
@@ -10,11 +10,10 @@
 static void
 test_adw_preferences_group_add_remove (void)
 {
-  g_autoptr (AdwPreferencesGroup) group = NULL;
+  AdwPreferencesGroup *group = g_object_ref_sink (ADW_PREFERENCES_GROUP (adw_preferences_group_new ()));
   AdwPreferencesRow *row;
   GtkWidget *widget;
 
-  group = g_object_ref_sink (ADW_PREFERENCES_GROUP (adw_preferences_group_new ()));
   g_assert_nonnull (group);
 
   row = ADW_PREFERENCES_ROW (adw_preferences_row_new ());
@@ -30,15 +29,16 @@ test_adw_preferences_group_add_remove (void)
 
   adw_preferences_group_remove (group, GTK_WIDGET (row));
   adw_preferences_group_remove (group, widget);
+
+  g_assert_finalize_object (group);
 }
 
 
 static void
 test_adw_preferences_group_title (void)
 {
-  g_autoptr (AdwPreferencesGroup) group = NULL;
+  AdwPreferencesGroup *group = g_object_ref_sink (ADW_PREFERENCES_GROUP (adw_preferences_group_new ()));
 
-  group = g_object_ref_sink (ADW_PREFERENCES_GROUP (adw_preferences_group_new ()));
   g_assert_nonnull (group);
 
   g_assert_cmpstr (adw_preferences_group_get_title (group), ==, "");
@@ -48,15 +48,16 @@ test_adw_preferences_group_title (void)
 
   adw_preferences_group_set_title (group, NULL);
   g_assert_cmpstr (adw_preferences_group_get_title (group), ==, "");
+
+  g_assert_finalize_object (group);
 }
 
 
 static void
 test_adw_preferences_group_description (void)
 {
-  g_autoptr (AdwPreferencesGroup) group = NULL;
+  AdwPreferencesGroup *group = g_object_ref_sink (ADW_PREFERENCES_GROUP (adw_preferences_group_new ()));
 
-  group = g_object_ref_sink (ADW_PREFERENCES_GROUP (adw_preferences_group_new ()));
   g_assert_nonnull (group);
 
   g_assert_cmpstr (adw_preferences_group_get_description (group), ==, "");
@@ -66,6 +67,8 @@ test_adw_preferences_group_description (void)
 
   adw_preferences_group_set_description (group, NULL);
   g_assert_cmpstr (adw_preferences_group_get_description (group), ==, "");
+
+  g_assert_finalize_object (group);
 }
 
 
diff --git a/tests/test-preferences-page.c b/tests/test-preferences-page.c
index a37d80aa..2944d90e 100644
--- a/tests/test-preferences-page.c
+++ b/tests/test-preferences-page.c
@@ -10,10 +10,9 @@
 static void
 test_adw_preferences_page_add_remove (void)
 {
-  g_autoptr (AdwPreferencesPage) page = NULL;
+  AdwPreferencesPage *page = g_object_ref_sink (ADW_PREFERENCES_PAGE (adw_preferences_page_new ()));
   AdwPreferencesGroup *group;
 
-  page = g_object_ref_sink (ADW_PREFERENCES_PAGE (adw_preferences_page_new ()));
   g_assert_nonnull (page);
 
   group = ADW_PREFERENCES_GROUP (adw_preferences_group_new ());
@@ -21,15 +20,16 @@ test_adw_preferences_page_add_remove (void)
   adw_preferences_page_add (page, group);
 
   adw_preferences_page_remove (page, group);
+
+  g_assert_finalize_object (page);
 }
 
 
 static void
 test_adw_preferences_page_title (void)
 {
-  g_autoptr (AdwPreferencesPage) page = NULL;
+  AdwPreferencesPage *page = g_object_ref_sink (ADW_PREFERENCES_PAGE (adw_preferences_page_new ()));
 
-  page = g_object_ref_sink (ADW_PREFERENCES_PAGE (adw_preferences_page_new ()));
   g_assert_nonnull (page);
 
   g_assert_cmpstr (adw_preferences_page_get_title (page), ==, "");
@@ -39,15 +39,16 @@ test_adw_preferences_page_title (void)
 
   adw_preferences_page_set_title (page, NULL);
   g_assert_cmpstr (adw_preferences_page_get_title (page), ==, "");
+
+  g_assert_finalize_object (page);
 }
 
 
 static void
 test_adw_preferences_page_icon_name (void)
 {
-  g_autoptr (AdwPreferencesPage) page = NULL;
+  AdwPreferencesPage *page = g_object_ref_sink (ADW_PREFERENCES_PAGE (adw_preferences_page_new ()));
 
-  page = g_object_ref_sink (ADW_PREFERENCES_PAGE (adw_preferences_page_new ()));
   g_assert_nonnull (page);
 
   g_assert_null (adw_preferences_page_get_icon_name (page));
@@ -57,15 +58,16 @@ test_adw_preferences_page_icon_name (void)
 
   adw_preferences_page_set_icon_name (page, NULL);
   g_assert_null (adw_preferences_page_get_icon_name (page));
+
+  g_assert_finalize_object (page);
 }
 
 
 static void
 test_adw_preferences_page_use_underline (void)
 {
-  g_autoptr (AdwPreferencesPage) page = NULL;
+  AdwPreferencesPage *page = g_object_ref_sink (ADW_PREFERENCES_PAGE (adw_preferences_page_new ()));
 
-  page = g_object_ref_sink (ADW_PREFERENCES_PAGE (adw_preferences_page_new ()));
   g_assert_nonnull (page);
 
   g_assert_false (adw_preferences_page_get_use_underline (page));
@@ -75,6 +77,8 @@ test_adw_preferences_page_use_underline (void)
 
   adw_preferences_page_set_use_underline (page, FALSE);
   g_assert_false (adw_preferences_page_get_use_underline (page));
+
+  g_assert_finalize_object (page);
 }
 
 
diff --git a/tests/test-preferences-row.c b/tests/test-preferences-row.c
index 1b04f356..fdf47105 100644
--- a/tests/test-preferences-row.c
+++ b/tests/test-preferences-row.c
@@ -10,9 +10,8 @@
 static void
 test_adw_preferences_row_title (void)
 {
-  g_autoptr (AdwPreferencesRow) row = NULL;
+  AdwPreferencesRow *row = g_object_ref_sink (ADW_PREFERENCES_ROW (adw_preferences_row_new ()));
 
-  row = g_object_ref_sink (ADW_PREFERENCES_ROW (adw_preferences_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_cmpstr (adw_preferences_row_get_title (row), ==, "");
@@ -22,15 +21,16 @@ test_adw_preferences_row_title (void)
 
   adw_preferences_row_set_title (row, NULL);
   g_assert_cmpstr (adw_preferences_row_get_title (row), ==, "");
+
+  g_assert_finalize_object (row);
 }
 
 
 static void
 test_adw_preferences_row_use_undeline (void)
 {
-  g_autoptr (AdwPreferencesRow) row = NULL;
+  AdwPreferencesRow *row = g_object_ref_sink (ADW_PREFERENCES_ROW (adw_preferences_row_new ()));
 
-  row = g_object_ref_sink (ADW_PREFERENCES_ROW (adw_preferences_row_new ()));
   g_assert_nonnull (row);
 
   g_assert_false (adw_preferences_row_get_use_underline (row));
@@ -40,6 +40,8 @@ test_adw_preferences_row_use_undeline (void)
 
   adw_preferences_row_set_use_underline (row, FALSE);
   g_assert_false (adw_preferences_row_get_use_underline (row));
+
+  g_assert_finalize_object (row);
 }
 
 
diff --git a/tests/test-preferences-window.c b/tests/test-preferences-window.c
index 98c35d77..d6dabc4f 100644
--- a/tests/test-preferences-window.c
+++ b/tests/test-preferences-window.c
@@ -10,10 +10,9 @@
 static void
 test_adw_preferences_window_add_remove (void)
 {
-  g_autoptr (AdwPreferencesWindow) window = NULL;
+  AdwPreferencesWindow *window = ADW_PREFERENCES_WINDOW (adw_preferences_window_new ());
   AdwPreferencesPage *page;
 
-  window = g_object_ref_sink (ADW_PREFERENCES_WINDOW (adw_preferences_window_new ()));
   g_assert_nonnull (window);
 
   page = ADW_PREFERENCES_PAGE (adw_preferences_page_new ());
@@ -21,6 +20,8 @@ test_adw_preferences_window_add_remove (void)
   adw_preferences_window_add (window, page);
 
   adw_preferences_window_remove (window, page);
+
+  g_assert_finalize_object (window);
 }
 
 
diff --git a/tests/test-split-button.c b/tests/test-split-button.c
index 884102aa..0348f5d4 100644
--- a/tests/test-split-button.c
+++ b/tests/test-split-button.c
@@ -19,10 +19,9 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_split_button_icon_name (void)
 {
-  g_autoptr (AdwSplitButton) button = NULL;
+  AdwSplitButton *button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   const char *icon_name;
 
-  button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   g_assert_nonnull (button);
 
   notified = 0;
@@ -53,15 +52,16 @@ test_adw_split_button_icon_name (void)
   adw_split_button_set_child (button, gtk_button_new ());
   g_assert_null (adw_split_button_get_icon_name (button));
   g_assert_cmpint (notified, ==, 5);
+
+  g_assert_finalize_object (button);
 }
 
 static void
 test_adw_split_button_label (void)
 {
-  g_autoptr (AdwSplitButton) button = NULL;
+  AdwSplitButton *button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   const char *label;
 
-  button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   g_assert_nonnull (button);
 
   notified = 0;
@@ -92,15 +92,16 @@ test_adw_split_button_label (void)
   adw_split_button_set_child (button, gtk_button_new ());
   g_assert_null (adw_split_button_get_label (button));
   g_assert_cmpint (notified, ==, 5);
+
+  g_assert_finalize_object (button);
 }
 
 static void
 test_adw_split_button_use_underline (void)
 {
-  g_autoptr (AdwSplitButton) button = NULL;
+  AdwSplitButton *button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   gboolean use_underline;
 
-  button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   g_assert_nonnull (button);
 
   notified = 0;
@@ -119,15 +120,16 @@ test_adw_split_button_use_underline (void)
   g_object_set (button, "use-underline", FALSE, NULL);
   g_assert_false (adw_split_button_get_use_underline (button));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (button);
 }
 
 static void
 test_adw_split_button_child (void)
 {
-  g_autoptr (AdwSplitButton) button = NULL;
+  AdwSplitButton *button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   GtkWidget *child1, *child2, *child3, *child;
 
-  button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   g_assert_nonnull (button);
 
   child1 = gtk_button_new ();
@@ -165,17 +167,18 @@ test_adw_split_button_child (void)
   adw_split_button_set_icon_name (button, "document-open-symbolic");
   g_assert_false (adw_split_button_get_child (button) == child3);
   g_assert_cmpint (notified, ==, 5);
+
+  g_assert_finalize_object (button);
 }
 
 static void
 test_adw_split_button_menu_model (void)
 {
-  g_autoptr (AdwSplitButton) button = NULL;
-  GMenuModel *model = NULL;
-  g_autoptr (GMenuModel) model1 = G_MENU_MODEL (g_menu_new ());
-  g_autoptr (GMenuModel) model2 = G_MENU_MODEL (g_menu_new ());
+  AdwSplitButton *button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
+  GMenuModel *model;
+  GMenuModel *model1 = G_MENU_MODEL (g_menu_new ());
+  GMenuModel *model2 = G_MENU_MODEL (g_menu_new ());
 
-  button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   g_assert_nonnull (button);
 
   notified = 0;
@@ -186,8 +189,7 @@ test_adw_split_button_menu_model (void)
   g_assert_cmpint (notified, ==, 0);
 
   adw_split_button_set_menu_model (button, model1);
-  g_object_get (button, "menu-model", &model, NULL);
-  g_assert_true (model == model1);
+  g_assert_true (adw_split_button_get_menu_model (button) == model1);
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (button, "menu-model", model2, NULL);
@@ -197,16 +199,19 @@ test_adw_split_button_menu_model (void)
   adw_split_button_set_popover (button, GTK_POPOVER (gtk_popover_new ()));
   g_assert_null (adw_split_button_get_menu_model (button));
   g_assert_cmpint (notified, ==, 3);
+
+  g_assert_finalize_object (button);
+  g_assert_finalize_object (model1);
+  g_assert_finalize_object (model2);
 }
 
 static void
 test_adw_split_button_popover (void)
 {
-  g_autoptr (AdwSplitButton) button = NULL;
+  AdwSplitButton *button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   GtkPopover *popover, *popover1, *popover2;
-  g_autoptr (GMenuModel) model = NULL;
+  GMenuModel *model;
 
-  button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   g_assert_nonnull (button);
 
   popover1 = GTK_POPOVER (gtk_popover_new ());
@@ -220,8 +225,7 @@ test_adw_split_button_popover (void)
   g_assert_cmpint (notified, ==, 0);
 
   adw_split_button_set_popover (button, popover1);
-  g_object_get (button, "popover", &popover, NULL);
-  g_assert_true (popover == popover1);
+  g_assert_true (adw_split_button_get_popover (button) == popover1);
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (button, "popover", popover2, NULL);
@@ -235,15 +239,17 @@ test_adw_split_button_popover (void)
    * sure is it's not the same one as we had just set */
   g_assert_false (adw_split_button_get_popover (button) == popover2);
   g_assert_cmpint (notified, ==, 3);
+
+  g_assert_finalize_object (button);
+  g_assert_finalize_object (model);
 }
 
 static void
 test_adw_split_button_direction (void)
 {
-  g_autoptr (AdwSplitButton) button = NULL;
+  AdwSplitButton *button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   GtkArrowType direction;
 
-  button = g_object_ref_sink (ADW_SPLIT_BUTTON (adw_split_button_new ()));
   g_assert_nonnull (button);
 
   notified = 0;
@@ -262,6 +268,8 @@ test_adw_split_button_direction (void)
   g_object_set (button, "direction", GTK_ARROW_DOWN, NULL);
   g_assert_cmpint (adw_split_button_get_direction (button), ==, GTK_ARROW_DOWN);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (button);
 }
 
 int
diff --git a/tests/test-squeezer.c b/tests/test-squeezer.c
index 51d77af2..f6830988 100644
--- a/tests/test-squeezer.c
+++ b/tests/test-squeezer.c
@@ -10,9 +10,8 @@
 static void
 test_adw_squeezer_homogeneous (void)
 {
-  g_autoptr (AdwSqueezer) squeezer = NULL;
+  AdwSqueezer *squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
 
-  squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   g_assert_nonnull (squeezer);
 
   g_assert_true (adw_squeezer_get_homogeneous (squeezer));
@@ -22,15 +21,16 @@ test_adw_squeezer_homogeneous (void)
 
   adw_squeezer_set_homogeneous (squeezer, TRUE);
   g_assert_true (adw_squeezer_get_homogeneous (squeezer));
+
+  g_assert_finalize_object (squeezer);
 }
 
 
 static void
 test_adw_squeezer_allow_none (void)
 {
-  g_autoptr (AdwSqueezer) squeezer = NULL;
+  AdwSqueezer *squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
 
-  squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   g_assert_nonnull (squeezer);
 
   g_assert_false (adw_squeezer_get_allow_none (squeezer));
@@ -40,15 +40,16 @@ test_adw_squeezer_allow_none (void)
 
   adw_squeezer_set_allow_none (squeezer, FALSE);
   g_assert_false (adw_squeezer_get_allow_none (squeezer));
+
+  g_assert_finalize_object (squeezer);
 }
 
 
 static void
 test_adw_squeezer_transition_duration (void)
 {
-  g_autoptr (AdwSqueezer) squeezer = NULL;
+  AdwSqueezer *squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
 
-  squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   g_assert_nonnull (squeezer);
 
   g_assert_cmpuint (adw_squeezer_get_transition_duration (squeezer), ==, 200);
@@ -58,15 +59,16 @@ test_adw_squeezer_transition_duration (void)
 
   adw_squeezer_set_transition_duration (squeezer, -1);
   g_assert_cmpuint (adw_squeezer_get_transition_duration (squeezer), ==, G_MAXUINT);
+
+  g_assert_finalize_object (squeezer);
 }
 
 
 static void
 test_adw_squeezer_transition_type (void)
 {
-  g_autoptr (AdwSqueezer) squeezer = NULL;
+  AdwSqueezer *squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
 
-  squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   g_assert_nonnull (squeezer);
 
   g_assert_cmpuint (adw_squeezer_get_transition_type (squeezer), ==, ADW_SQUEEZER_TRANSITION_TYPE_NONE);
@@ -76,28 +78,30 @@ test_adw_squeezer_transition_type (void)
 
   adw_squeezer_set_transition_type (squeezer, ADW_SQUEEZER_TRANSITION_TYPE_NONE);
   g_assert_cmpuint (adw_squeezer_get_transition_type (squeezer), ==, ADW_SQUEEZER_TRANSITION_TYPE_NONE);
+
+  g_assert_finalize_object (squeezer);
 }
 
 
 static void
 test_adw_squeezer_transition_running (void)
 {
-  g_autoptr (AdwSqueezer) squeezer = NULL;
+  AdwSqueezer *squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
 
-  squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   g_assert_nonnull (squeezer);
 
   g_assert_false (adw_squeezer_get_transition_running (squeezer));
+
+  g_assert_finalize_object (squeezer);
 }
 
 
 static void
 test_adw_squeezer_show_hide_child (void)
 {
-  g_autoptr (AdwSqueezer) squeezer = NULL;
+  AdwSqueezer *squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   GtkWidget *child;
 
-  squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   g_assert_nonnull (squeezer);
 
   g_assert_null (adw_squeezer_get_visible_child (squeezer));
@@ -114,15 +118,16 @@ test_adw_squeezer_show_hide_child (void)
 
   adw_squeezer_remove (squeezer, child);
   g_assert_null (adw_squeezer_get_visible_child (squeezer));
+
+  g_assert_finalize_object (squeezer);
 }
 
 
 static void
 test_adw_squeezer_interpolate_size (void)
 {
-  g_autoptr (AdwSqueezer) squeezer = NULL;
+  AdwSqueezer *squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
 
-  squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   g_assert_nonnull (squeezer);
 
   g_assert_false (adw_squeezer_get_interpolate_size (squeezer));
@@ -132,17 +137,18 @@ test_adw_squeezer_interpolate_size (void)
 
   adw_squeezer_set_interpolate_size (squeezer, FALSE);
   g_assert_false (adw_squeezer_get_interpolate_size (squeezer));
+
+  g_assert_finalize_object (squeezer);
 }
 
 
 static void
 test_adw_squeezer_page_enabled (void)
 {
-  g_autoptr (AdwSqueezer) squeezer = NULL;
+  AdwSqueezer *squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   GtkWidget *child;
   AdwSqueezerPage *page;
 
-  squeezer = g_object_ref_sink (ADW_SQUEEZER (adw_squeezer_new ()));
   g_assert_nonnull (squeezer);
 
   child = gtk_label_new ("");
@@ -154,6 +160,8 @@ test_adw_squeezer_page_enabled (void)
 
   adw_squeezer_page_set_enabled (page, TRUE);
   g_assert_true (adw_squeezer_page_get_enabled (page));
+
+  g_assert_finalize_object (squeezer);
 }
 
 
diff --git a/tests/test-status-page.c b/tests/test-status-page.c
index a1e0dbaf..7a497961 100644
--- a/tests/test-status-page.c
+++ b/tests/test-status-page.c
@@ -17,10 +17,9 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_status_page_icon_name (void)
 {
-  g_autoptr (AdwStatusPage) status_page = NULL;
+  AdwStatusPage *status_page = ADW_STATUS_PAGE (g_object_ref_sink (adw_status_page_new ()));
   const char *icon_name = NULL;
 
-  status_page = ADW_STATUS_PAGE (g_object_ref_sink (adw_status_page_new ()));
   g_assert_nonnull (status_page);
 
   notified = 0;
@@ -39,15 +38,16 @@ test_adw_status_page_icon_name (void)
   g_object_set (status_page, "icon-name", "other-icon-symbolic", NULL);
   g_assert_cmpstr (adw_status_page_get_icon_name (status_page), ==, "other-icon-symbolic");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (status_page);
 }
 
 static void
 test_adw_status_page_title (void)
 {
-  g_autoptr (AdwStatusPage) status_page = NULL;
-  const char *title = NULL;
+  AdwStatusPage *status_page = ADW_STATUS_PAGE (g_object_ref_sink (adw_status_page_new ()));
+  g_autofree char *title = NULL;
 
-  status_page = ADW_STATUS_PAGE (g_object_ref_sink (adw_status_page_new ()));
   g_assert_nonnull (status_page);
 
   notified = 0;
@@ -66,15 +66,16 @@ test_adw_status_page_title (void)
   g_object_set (status_page, "title", "Other Title", NULL);
   g_assert_cmpstr (adw_status_page_get_title (status_page), ==, "Other Title");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (status_page);
 }
 
 static void
 test_adw_status_page_description (void)
 {
-  g_autoptr (AdwStatusPage) status_page = NULL;
-  const char *description = NULL;
+  AdwStatusPage *status_page = ADW_STATUS_PAGE (g_object_ref_sink (adw_status_page_new ()));
+  g_autofree char *description = NULL;
 
-  status_page = ADW_STATUS_PAGE (g_object_ref_sink (adw_status_page_new ()));
   g_assert_nonnull (status_page);
 
   notified = 0;
@@ -93,6 +94,8 @@ test_adw_status_page_description (void)
   g_object_set (status_page, "description", "Other description", NULL);
   g_assert_cmpstr (adw_status_page_get_description (status_page), ==, "Other description");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (status_page);
 }
 
 int
diff --git a/tests/test-tab-bar.c b/tests/test-tab-bar.c
index cd7e8b5e..59658eb6 100644
--- a/tests/test-tab-bar.c
+++ b/tests/test-tab-bar.c
@@ -19,10 +19,9 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_tab_bar_view (void)
 {
-  g_autoptr (AdwTabBar) bar = NULL;
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabBar *bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
+  AdwTabView *view;
 
-  bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   g_assert_nonnull (bar);
 
   notified = 0;
@@ -42,15 +41,17 @@ test_adw_tab_bar_view (void)
   g_object_set (bar, "view", NULL, NULL);
   g_assert_null (adw_tab_bar_get_view (bar));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (bar);
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_bar_start_action_widget (void)
 {
-  g_autoptr (AdwTabBar) bar = NULL;
+  AdwTabBar *bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   GtkWidget *widget = NULL;
 
-  bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   g_assert_nonnull (bar);
 
   notified = 0;
@@ -70,15 +71,16 @@ test_adw_tab_bar_start_action_widget (void)
   g_object_set (bar, "start-action-widget", NULL, NULL);
   g_assert_null (adw_tab_bar_get_start_action_widget (bar));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (bar);
 }
 
 static void
 test_adw_tab_bar_end_action_widget (void)
 {
-  g_autoptr (AdwTabBar) bar = NULL;
+  AdwTabBar *bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   GtkWidget *widget = NULL;
 
-  bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   g_assert_nonnull (bar);
 
   notified = 0;
@@ -98,15 +100,16 @@ test_adw_tab_bar_end_action_widget (void)
   g_object_set (bar, "end-action-widget", NULL, NULL);
   g_assert_null (adw_tab_bar_get_end_action_widget (bar));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (bar);
 }
 
 static void
 test_adw_tab_bar_autohide (void)
 {
-  g_autoptr (AdwTabBar) bar = NULL;
+  AdwTabBar *bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   gboolean autohide = FALSE;
 
-  bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   g_assert_nonnull (bar);
 
   notified = 0;
@@ -125,17 +128,18 @@ test_adw_tab_bar_autohide (void)
   g_object_set (bar, "autohide", TRUE, NULL);
   g_assert_true (adw_tab_bar_get_autohide (bar));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (bar);
 }
 
 static void
 test_adw_tab_bar_tabs_revealed (void)
 {
-  g_autoptr (AdwTabBar) bar = NULL;
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabBar *bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
+  AdwTabView *view;
   gboolean tabs_revealed = FALSE;
   AdwTabPage *page;
 
-  bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   g_assert_nonnull (bar);
 
   notified = 0;
@@ -178,15 +182,17 @@ test_adw_tab_bar_tabs_revealed (void)
   adw_tab_bar_set_autohide (bar, FALSE);
   g_assert_true (adw_tab_bar_get_tabs_revealed (bar));
   g_assert_cmpint (notified, ==, 7);
+
+  g_assert_finalize_object (bar);
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_bar_expand_tabs (void)
 {
-  g_autoptr (AdwTabBar) bar = NULL;
+  AdwTabBar *bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   gboolean expand_tabs = FALSE;
 
-  bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   g_assert_nonnull (bar);
 
   notified = 0;
@@ -205,15 +211,16 @@ test_adw_tab_bar_expand_tabs (void)
   g_object_set (bar, "expand-tabs", TRUE, NULL);
   g_assert_true (adw_tab_bar_get_expand_tabs (bar));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (bar);
 }
 
 static void
 test_adw_tab_bar_inverted (void)
 {
-  g_autoptr (AdwTabBar) bar = NULL;
+  AdwTabBar *bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   gboolean inverted = FALSE;
 
-  bar = g_object_ref_sink (ADW_TAB_BAR (adw_tab_bar_new ()));
   g_assert_nonnull (bar);
 
   notified = 0;
@@ -232,6 +239,8 @@ test_adw_tab_bar_inverted (void)
   g_object_set (bar, "inverted", FALSE, NULL);
   g_assert_false (adw_tab_bar_get_inverted (bar));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (bar);
 }
 
 int
diff --git a/tests/test-tab-view.c b/tests/test-tab-view.c
index eaeb0012..70d21531 100644
--- a/tests/test-tab-view.c
+++ b/tests/test-tab-view.c
@@ -77,11 +77,10 @@ check_selection_null (AdwTabView *view)
 static void
 test_adw_tab_view_n_pages (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
   int n_pages;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   notified = 0;
@@ -111,16 +110,17 @@ test_adw_tab_view_n_pages (void)
   adw_tab_view_close_page (view, page);
   g_assert_cmpint (adw_tab_view_get_n_pages (view), ==, 2);
   g_assert_cmpint (notified, ==, 4);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_n_pinned_pages (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
   int n_pages;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   notified = 0;
@@ -150,47 +150,48 @@ test_adw_tab_view_n_pinned_pages (void)
   adw_tab_view_set_page_pinned (view, page, FALSE);
   g_assert_cmpint (adw_tab_view_get_n_pinned_pages (view), ==, 1);
   g_assert_cmpint (notified, ==, 3);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_default_icon (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
-  GIcon *icon = NULL;
-  g_autoptr (GIcon) icon1 = g_themed_icon_new ("go-previous-symbolic");
-  g_autoptr (GIcon) icon2 = g_themed_icon_new ("go-next-symbolic");
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
+  GIcon *icon1 = g_themed_icon_new ("go-previous-symbolic");
+  GIcon *icon2 = g_themed_icon_new ("go-next-symbolic");
   g_autofree char *icon_str = NULL;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   notified = 0;
   g_signal_connect (view, "notify::default-icon", G_CALLBACK (notify_cb), NULL);
 
-  g_object_get (view, "default-icon", &icon, NULL);
-  icon_str = g_icon_to_string (icon);
+  icon_str = g_icon_to_string (adw_tab_view_get_default_icon (view));
   g_assert_cmpstr (icon_str, ==, "adw-tab-icon-missing-symbolic");
   g_assert_cmpint (notified, ==, 0);
 
   adw_tab_view_set_default_icon (view, icon1);
-  g_object_get (view, "default-icon", &icon, NULL);
-  g_assert_true (icon == icon1);
+  g_assert_true (adw_tab_view_get_default_icon (view) == icon1);
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (view, "default-icon", icon2, NULL);
   g_assert_true (adw_tab_view_get_default_icon (view) == icon2);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
+  g_assert_finalize_object (icon1);
+  g_assert_finalize_object (icon2);
 }
 
 static void
 test_adw_tab_view_menu_model (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
-  GMenuModel *model = NULL;
-  g_autoptr (GMenuModel) model1 = G_MENU_MODEL (g_menu_new ());
-  g_autoptr (GMenuModel) model2 = G_MENU_MODEL (g_menu_new ());
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
+  GMenuModel *model;
+  GMenuModel *model1 = G_MENU_MODEL (g_menu_new ());
+  GMenuModel *model2 = G_MENU_MODEL (g_menu_new ());
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   notified = 0;
@@ -201,24 +202,26 @@ test_adw_tab_view_menu_model (void)
   g_assert_cmpint (notified, ==, 0);
 
   adw_tab_view_set_menu_model (view, model1);
-  g_object_get (view, "menu-model", &model, NULL);
-  g_assert_true (model == model1);
+  g_assert_true (adw_tab_view_get_menu_model (view) == model1);
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (view, "menu-model", model2, NULL);
   g_assert_true (adw_tab_view_get_menu_model (view) == model2);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
+  g_assert_finalize_object (model1);
+  g_assert_finalize_object (model2);
 }
 
 static void
 test_adw_tab_view_shortcut_widget (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
-  GtkWidget *widget = NULL;
-  g_autoptr (GtkWidget) widget1 = g_object_ref_sink (gtk_button_new ());
-  g_autoptr (GtkWidget) widget2 = g_object_ref_sink (gtk_button_new ());
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
+  GtkWidget *widget;
+  GtkWidget *widget1 = g_object_ref_sink (gtk_button_new ());
+  GtkWidget *widget2 = g_object_ref_sink (gtk_button_new ());
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   notified = 0;
@@ -229,23 +232,25 @@ test_adw_tab_view_shortcut_widget (void)
   g_assert_cmpint (notified, ==, 0);
 
   adw_tab_view_set_shortcut_widget (view, widget1);
-  g_object_get (view, "shortcut-widget", &widget, NULL);
-  g_assert_true (widget == widget1);
+  g_assert_true (adw_tab_view_get_shortcut_widget (view) == widget1);
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (view, "shortcut-widget", widget2, NULL);
   g_assert_true (adw_tab_view_get_shortcut_widget (view) == widget2);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
+  g_assert_finalize_object (widget1);
+  g_assert_finalize_object (widget2);
 }
 
 static void
 test_adw_tab_view_get_page (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   GtkWidget *child1, *child2, *child3;
   AdwTabPage *page1, *page2, *page3;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   child1 = gtk_button_new ();
@@ -271,16 +276,17 @@ test_adw_tab_view_get_page (void)
   g_assert_true (adw_tab_page_get_child (page1) == child1);
   g_assert_true (adw_tab_page_get_child (page2) == child2);
   g_assert_true (adw_tab_page_get_child (page3) == child3);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_select (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page1, *page2, *selected_page;
   gboolean ret;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   notified = 0;
@@ -290,8 +296,6 @@ test_adw_tab_view_select (void)
   g_assert_null (selected_page);
 
   page1 = adw_tab_view_append (view, gtk_button_new ());
-  g_object_get (view, "selected-page", &selected_page, NULL);
-  g_assert_true (selected_page == page1);
   g_assert_true (adw_tab_view_get_selected_page (view) == page1);
   g_assert_true (adw_tab_page_get_selected (page1));
   g_assert_cmpint (notified, ==, 1);
@@ -329,15 +333,16 @@ test_adw_tab_view_select (void)
   g_assert_true (adw_tab_view_get_selected_page (view) == page1);
   g_assert_true (ret);
   g_assert_cmpint (notified, ==, 5);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_add_basic (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[6];
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   pages[0] = adw_tab_view_append (view, gtk_button_new ());
@@ -363,15 +368,16 @@ test_adw_tab_view_add_basic (void)
   pages[5] = adw_tab_view_insert_pinned (view, gtk_button_new (), 1);
   assert_page_positions (view, pages, 6, 3,
                          3, 5, 4, 1, 2, 0);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_add_auto (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[17];
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   add_pages (view, pages, 3, 3);
@@ -455,16 +461,17 @@ test_adw_tab_view_add_auto (void)
   g_assert_true (adw_tab_page_get_parent (pages[16]) == pages[5]);
   assert_page_positions (view, pages, 17, 3,
                          0, 1, 2, 15, 14, 11, 12, 13, 3, 4, 6, 8, 9, 7, 10, 5, 16);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_reorder (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[6];
   gboolean ret;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   add_pages (view, pages, 6, 3);
@@ -501,16 +508,17 @@ test_adw_tab_view_reorder (void)
   g_assert_true (ret);
   assert_page_positions (view, pages, 6, 3,
                          0, 1, 2, 3, 4, 5);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_reorder_first_last (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[6];
   gboolean ret;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   add_pages (view, pages, 6, 3);
@@ -557,16 +565,17 @@ test_adw_tab_view_reorder_first_last (void)
   g_assert_true (ret);
   assert_page_positions (view, pages, 6, 3,
                          0, 1, 2, 3, 4, 5);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_reorder_forward_backward (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[6];
   gboolean ret;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   add_pages (view, pages, 6, 3);
@@ -613,15 +622,16 @@ test_adw_tab_view_reorder_forward_backward (void)
   g_assert_true (ret);
   assert_page_positions (view, pages, 6, 3,
                          1, 2, 0, 4, 5, 3);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_pin (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[4];
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   /* Test specifically pinning with only 1 page */
@@ -661,15 +671,16 @@ test_adw_tab_view_pin (void)
   adw_tab_view_set_page_pinned (view, pages[1], FALSE);
   assert_page_positions (view, pages, 4, 2,
                          2, 0, 1, 3);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_close (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[3];
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   add_pages (view, pages, 3, 0);
@@ -692,15 +703,16 @@ test_adw_tab_view_close (void)
   adw_tab_view_close_page (view, pages[0]);
   assert_page_positions (view, pages, 0, 0);
   g_assert_null (adw_tab_view_get_selected_page (view));
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_close_other (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[6];
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   add_pages (view, pages, 6, 3);
@@ -714,15 +726,16 @@ test_adw_tab_view_close_other (void)
   adw_tab_view_close_other_pages (view, pages[2]);
   assert_page_positions (view, pages, 3, 3,
                          0, 1, 2);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_close_before_after (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[10];
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   add_pages (view, pages, 10, 3);
@@ -744,6 +757,8 @@ test_adw_tab_view_close_before_after (void)
   adw_tab_view_close_pages_after (view, pages[0]);
   assert_page_positions (view, pages, 3, 3,
                          0, 1, 2);
+
+  g_assert_finalize_object (view);
 }
 
 static gboolean
@@ -760,11 +775,10 @@ close_page_position_cb (AdwTabView *view,
 static void
 test_adw_tab_view_close_signal (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[10];
   gulong handler;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   /* Allow closing pages with odd positions, including pinned */
@@ -800,16 +814,15 @@ test_adw_tab_view_close_signal (void)
   assert_page_positions (view, pages, 5, 1,
                          2, 4, 5, 6, 8);
 
-  g_signal_handler_disconnect (view, handler);
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_close_select (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages[14];
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   add_pages (view, pages, 9, 3);
@@ -873,19 +886,18 @@ test_adw_tab_view_close_select (void)
 
   adw_tab_view_close_page (view, pages[12]);
   g_assert_true (adw_tab_view_get_selected_page (view) == pages[1]);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_view_transfer (void)
 {
-  g_autoptr (AdwTabView) view1 = NULL;
-  g_autoptr (AdwTabView) view2 = NULL;
+  AdwTabView *view1 = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
+  AdwTabView *view2 = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *pages1[4], *pages2[4];
 
-  view1 = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view1);
-
-  view2 = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view2);
 
   add_pages (view1, pages1, 4, 2);
@@ -909,16 +921,18 @@ test_adw_tab_view_transfer (void)
   assert_page_positions (view2, pages2, 4, 3,
                          0, -1, 1, 2);
   g_assert_true (adw_tab_view_get_nth_page (view1, 2) == pages2[3]);
+
+  g_assert_finalize_object (view1);
+  g_assert_finalize_object (view2);
 }
 
 static void
 test_adw_tab_view_pages (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
-  g_autoptr (GtkSelectionModel) model = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
+  GtkSelectionModel* model;
   AdwTabPage *pages[2];
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   model = adw_tab_view_get_pages (view);
@@ -939,17 +953,17 @@ test_adw_tab_view_pages (void)
 
   adw_tab_view_close_page (view, pages[1]);
 
-  g_signal_handlers_disconnect_by_func (model, G_CALLBACK (check_selection_null), view);
+  g_assert_finalize_object (view);
+  g_assert_finalize_object (model);
 }
 
 static void
 test_adw_tab_page_title (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
-  const char *title;
+  g_autofree char *title = NULL;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   page = adw_tab_view_append (view, gtk_button_new ());
@@ -963,23 +977,23 @@ test_adw_tab_page_title (void)
   g_assert_cmpint (notified, ==, 0);
 
   adw_tab_page_set_title (page, "Some title");
-  g_object_get (page, "title", &title, NULL);
-  g_assert_cmpstr (title, ==, "Some title");
+  g_assert_cmpstr (adw_tab_page_get_title (page), ==, "Some title");
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (page, "title", "Some other title", NULL);
   g_assert_cmpstr (adw_tab_page_get_title (page), ==, "Some other title");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_page_tooltip (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
-  const char *tooltip;
+  g_autofree char *tooltip = NULL;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   page = adw_tab_view_append (view, gtk_button_new ());
@@ -993,25 +1007,25 @@ test_adw_tab_page_tooltip (void)
   g_assert_cmpint (notified, ==, 0);
 
   adw_tab_page_set_tooltip (page, "Some tooltip");
-  g_object_get (page, "tooltip", &tooltip, NULL);
-  g_assert_cmpstr (tooltip, ==, "Some tooltip");
+  g_assert_cmpstr (adw_tab_page_get_tooltip (page), ==, "Some tooltip");
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (page, "tooltip", "Some other tooltip", NULL);
   g_assert_cmpstr (adw_tab_page_get_tooltip (page), ==, "Some other tooltip");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_page_icon (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
-  GIcon *icon = NULL;
-  g_autoptr (GIcon) icon1 = g_themed_icon_new ("go-previous-symbolic");
-  g_autoptr (GIcon) icon2 = g_themed_icon_new ("go-next-symbolic");
+  GIcon *icon;
+  GIcon *icon1 = g_themed_icon_new ("go-previous-symbolic");
+  GIcon *icon2 = g_themed_icon_new ("go-next-symbolic");
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   page = adw_tab_view_append (view, gtk_button_new ());
@@ -1025,23 +1039,25 @@ test_adw_tab_page_icon (void)
   g_assert_cmpint (notified, ==, 0);
 
   adw_tab_page_set_icon (page, icon1);
-  g_object_get (page, "icon", &icon, NULL);
-  g_assert_true (icon == icon1);
+  g_assert_true (adw_tab_page_get_icon (page) == icon1);
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (page, "icon", icon2, NULL);
   g_assert_true (adw_tab_page_get_icon (page) == icon2);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
+  g_assert_finalize_object (icon1);
+  g_assert_finalize_object (icon2);
 }
 
 static void
 test_adw_tab_page_loading (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
   gboolean loading;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   page = adw_tab_view_append (view, gtk_button_new ());
@@ -1062,18 +1078,19 @@ test_adw_tab_page_loading (void)
   g_object_set (page, "loading", FALSE, NULL);
   g_assert_false (adw_tab_page_get_loading (page));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_page_indicator_icon (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
-  GIcon *icon = NULL;
-  g_autoptr (GIcon) icon1 = g_themed_icon_new ("go-previous-symbolic");
-  g_autoptr (GIcon) icon2 = g_themed_icon_new ("go-next-symbolic");
+  GIcon *icon;
+  GIcon *icon1 = g_themed_icon_new ("go-previous-symbolic");
+  GIcon *icon2 = g_themed_icon_new ("go-next-symbolic");
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   page = adw_tab_view_append (view, gtk_button_new ());
@@ -1087,23 +1104,25 @@ test_adw_tab_page_indicator_icon (void)
   g_assert_cmpint (notified, ==, 0);
 
   adw_tab_page_set_indicator_icon (page, icon1);
-  g_object_get (page, "indicator-icon", &icon, NULL);
-  g_assert_true (icon == icon1);
+  g_assert_true (adw_tab_page_get_indicator_icon (page) == icon1);
   g_assert_cmpint (notified, ==, 1);
 
   g_object_set (page, "indicator-icon", icon2, NULL);
   g_assert_true (adw_tab_page_get_indicator_icon (page) == icon2);
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
+  g_assert_finalize_object (icon1);
+  g_assert_finalize_object (icon2);
 }
 
 static void
 test_adw_tab_page_indicator_activatable (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
   gboolean activatable;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   page = adw_tab_view_append (view, gtk_button_new ());
@@ -1124,16 +1143,17 @@ test_adw_tab_page_indicator_activatable (void)
   g_object_set (page, "indicator-activatable", FALSE, NULL);
   g_assert_false (adw_tab_page_get_indicator_activatable (page));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
 }
 
 static void
 test_adw_tab_page_needs_attention (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   AdwTabPage *page;
   gboolean needs_attention;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
 
   page = adw_tab_view_append (view, gtk_button_new ());
@@ -1154,6 +1174,8 @@ test_adw_tab_page_needs_attention (void)
   g_object_set (page, "needs-attention", FALSE, NULL);
   g_assert_false (adw_tab_page_get_needs_attention (page));
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (view);
 }
 
 static void
@@ -1193,16 +1215,13 @@ test_adw_tab_view_pages_to_list_view_unbind (GtkSignalListItemFactory *factory,
 static void
 test_adw_tab_view_pages_to_list_view (void)
 {
-  g_autoptr (AdwTabView) view = NULL;
-  g_autoptr (GtkSelectionModel) pages = NULL;
-  g_autoptr (GtkListView) list_view = NULL;
+  AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
+  GtkListView *list_view = g_object_ref_sink (GTK_LIST_VIEW (gtk_list_view_new (NULL, NULL)));
+  GtkSelectionModel *pages;
   GtkListItemFactory *factory;
   GtkLabel *label;
 
-  view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
   g_assert_nonnull (view);
-
-  list_view = g_object_ref_sink (GTK_LIST_VIEW (gtk_list_view_new (NULL, NULL)));
   g_assert_nonnull (list_view);
 
   pages = adw_tab_view_get_pages (view);
@@ -1221,6 +1240,10 @@ test_adw_tab_view_pages_to_list_view (void)
   adw_tab_view_append (view, GTK_WIDGET (label));
 
   g_clear_object (&factory);
+
+  g_assert_finalize_object (list_view);
+  g_assert_finalize_object (view);
+  g_assert_finalize_object (pages);
 }
 
 int
diff --git a/tests/test-view-switcher-bar.c b/tests/test-view-switcher-bar.c
index e44ee5bd..25f2e233 100644
--- a/tests/test-view-switcher-bar.c
+++ b/tests/test-view-switcher-bar.c
@@ -10,10 +10,9 @@
 static void
 test_adw_view_switcher_bar_stack (void)
 {
-  g_autoptr (AdwViewSwitcherBar) bar = NULL;
+  AdwViewSwitcherBar *bar = g_object_ref_sink (ADW_VIEW_SWITCHER_BAR (adw_view_switcher_bar_new ()));
   AdwViewStack *stack;
 
-  bar = g_object_ref_sink (ADW_VIEW_SWITCHER_BAR (adw_view_switcher_bar_new ()));
   g_assert_nonnull (bar);
 
   stack = ADW_VIEW_STACK (adw_view_stack_new ());
@@ -26,15 +25,16 @@ test_adw_view_switcher_bar_stack (void)
 
   adw_view_switcher_bar_set_stack (bar, NULL);
   g_assert_null (adw_view_switcher_bar_get_stack (bar));
+
+  g_assert_finalize_object (bar);
 }
 
 
 static void
 test_adw_view_switcher_bar_reveal (void)
 {
-  g_autoptr (AdwViewSwitcherBar) bar = NULL;
+  AdwViewSwitcherBar *bar = g_object_ref_sink (ADW_VIEW_SWITCHER_BAR (adw_view_switcher_bar_new ()));
 
-  bar = g_object_ref_sink (ADW_VIEW_SWITCHER_BAR (adw_view_switcher_bar_new ()));
   g_assert_nonnull (bar);
 
   g_assert_false (adw_view_switcher_bar_get_reveal (bar));
@@ -44,6 +44,8 @@ test_adw_view_switcher_bar_reveal (void)
 
   adw_view_switcher_bar_set_reveal (bar, FALSE);
   g_assert_false (adw_view_switcher_bar_get_reveal (bar));
+
+  g_assert_finalize_object (bar);
 }
 
 
diff --git a/tests/test-view-switcher.c b/tests/test-view-switcher.c
index dafc5463..c5936fe3 100644
--- a/tests/test-view-switcher.c
+++ b/tests/test-view-switcher.c
@@ -10,9 +10,8 @@
 static void
 test_adw_view_switcher_policy (void)
 {
-  g_autoptr (AdwViewSwitcher) view_switcher = NULL;
+  AdwViewSwitcher *view_switcher = g_object_ref_sink (ADW_VIEW_SWITCHER (adw_view_switcher_new ()));
 
-  view_switcher = g_object_ref_sink (ADW_VIEW_SWITCHER (adw_view_switcher_new ()));
   g_assert_nonnull (view_switcher);
 
   g_assert_cmpint (adw_view_switcher_get_policy (view_switcher), ==, ADW_VIEW_SWITCHER_POLICY_NARROW);
@@ -22,16 +21,17 @@ test_adw_view_switcher_policy (void)
 
   adw_view_switcher_set_policy (view_switcher, ADW_VIEW_SWITCHER_POLICY_NARROW);
   g_assert_cmpint (adw_view_switcher_get_policy (view_switcher), ==, ADW_VIEW_SWITCHER_POLICY_NARROW);
+
+  g_assert_finalize_object (view_switcher);
 }
 
 
 static void
 test_adw_view_switcher_stack (void)
 {
-  g_autoptr (AdwViewSwitcher) view_switcher = NULL;
+  AdwViewSwitcher *view_switcher = g_object_ref_sink (ADW_VIEW_SWITCHER (adw_view_switcher_new ()));
   AdwViewStack *stack;
 
-  view_switcher = g_object_ref_sink (ADW_VIEW_SWITCHER (adw_view_switcher_new ()));
   g_assert_nonnull (view_switcher);
 
   stack = ADW_VIEW_STACK (adw_view_stack_new ());
@@ -44,6 +44,8 @@ test_adw_view_switcher_stack (void)
 
   adw_view_switcher_set_stack (view_switcher, NULL);
   g_assert_null (adw_view_switcher_get_stack (view_switcher));
+
+  g_assert_finalize_object (view_switcher);
 }
 
 
diff --git a/tests/test-window-title.c b/tests/test-window-title.c
index 24c45cbe..0a5616fc 100644
--- a/tests/test-window-title.c
+++ b/tests/test-window-title.c
@@ -19,10 +19,9 @@ notify_cb (GtkWidget *widget, gpointer data)
 static void
 test_adw_window_title_title (void)
 {
-  g_autoptr (AdwWindowTitle) window_title = NULL;
-  const char *title;
+  AdwWindowTitle *window_title = g_object_ref_sink (ADW_WINDOW_TITLE (adw_window_title_new ("Some title", 
NULL)));
+  g_autofree char *title = NULL;
 
-  window_title = g_object_ref_sink (ADW_WINDOW_TITLE (adw_window_title_new ("Some title", NULL)));
   g_assert_nonnull (window_title);
 
   notified = 0;
@@ -41,15 +40,16 @@ test_adw_window_title_title (void)
   g_object_set (window_title, "title", "Yet another title", NULL);
   g_assert_cmpstr (adw_window_title_get_title (window_title), ==, "Yet another title");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (window_title);
 }
 
 static void
 test_adw_window_title_subtitle (void)
 {
-  g_autoptr (AdwWindowTitle) window_title = NULL;
-  const char *subtitle;
+  AdwWindowTitle *window_title = g_object_ref_sink (ADW_WINDOW_TITLE (adw_window_title_new (NULL, "Some 
subtitle")));
+  g_autofree char *subtitle = NULL;
 
-  window_title = g_object_ref_sink (ADW_WINDOW_TITLE (adw_window_title_new (NULL, "Some subtitle")));
   g_assert_nonnull (window_title);
 
   notified = 0;
@@ -68,6 +68,8 @@ test_adw_window_title_subtitle (void)
   g_object_set (window_title, "subtitle", "Yet another subtitle", NULL);
   g_assert_cmpstr (adw_window_title_get_subtitle (window_title), ==, "Yet another subtitle");
   g_assert_cmpint (notified, ==, 2);
+
+  g_assert_finalize_object (window_title);
 }
 
 int
diff --git a/tests/test-window.c b/tests/test-window.c
index 01a04354..25524302 100644
--- a/tests/test-window.c
+++ b/tests/test-window.c
@@ -10,10 +10,10 @@
 static void
 test_adw_window_new (void)
 {
-  g_autoptr (GtkWidget) window = NULL;
-
-  window = g_object_ref_sink (adw_window_new ());
+  GtkWidget *window = adw_window_new ();
   g_assert_nonnull (window);
+
+  g_assert_finalize_object (window);
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]