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
|
/*
* Copyright (C) 2020 Alice Mikhaylenko <alicem@gnome.org>
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <adwaita.h>
static void
increment (int *data)
{
(*data)++;
}
static void
test_adw_carousel_indicator_lines_carousel (void)
{
AdwCarouselIndicatorLines *lines = g_object_ref_sink (ADW_CAROUSEL_INDICATOR_LINES (adw_carousel_indicator_lines_new ()));
AdwCarousel *carousel;
int notified = 0;
g_assert_nonnull (lines);
g_signal_connect_swapped (lines, "notify::carousel", G_CALLBACK (increment), ¬ified);
carousel = g_object_ref_sink (ADW_CAROUSEL (adw_carousel_new ()));
g_assert_nonnull (carousel);
g_assert_null (adw_carousel_indicator_lines_get_carousel (lines));
g_assert_cmpint (notified, ==, 0);
adw_carousel_indicator_lines_set_carousel (lines, carousel);
g_assert (adw_carousel_indicator_lines_get_carousel (lines) == carousel);
g_assert_cmpint (notified, ==, 1);
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
main (int argc,
char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
adw_init ();
g_test_add_func("/Adwaita/CarouselInidicatorLines/carousel", test_adw_carousel_indicator_lines_carousel);
return g_test_run();
}
|