1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
/*
* Copyright (C) 2021 Purism SPC
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* Author: Alice Mikhaylenko <alice.mikhaylenko@puri.sm>
*/
#include <adwaita.h>
static void
increment (int *data)
{
(*data)++;
}
static void
test_adw_bin_child (void)
{
AdwBin *bin = g_object_ref_sink (ADW_BIN (adw_bin_new ()));
GtkWidget *widget = NULL;
int notified = 0;
g_assert_nonnull (bin);
g_signal_connect_swapped (bin, "notify::child", G_CALLBACK (increment), ¬ified);
g_object_get (bin, "child", &widget, NULL);
g_assert_null (widget);
adw_bin_set_child (bin, NULL);
g_assert_cmpint (notified, ==, 0);
widget = gtk_button_new ();
adw_bin_set_child (bin, widget);
g_assert_true (adw_bin_get_child (bin) == widget);
g_assert_cmpint (notified, ==, 1);
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
main (int argc,
char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
adw_init ();
g_test_add_func ("/Adwaita/Bin/child", test_adw_bin_child);
return g_test_run ();
}
|