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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
/*
* 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_window_title_title (void)
{
AdwWindowTitle *window_title = g_object_ref_sink (ADW_WINDOW_TITLE (adw_window_title_new ("Some title", NULL)));
char *title;
int notified = 0;
g_assert_nonnull (window_title);
g_signal_connect_swapped (window_title, "notify::title", G_CALLBACK (increment), ¬ified);
g_object_get (window_title, "title", &title, NULL);
g_assert_cmpstr (title, ==, "Some title");
adw_window_title_set_title (window_title, "Some title");
g_assert_cmpint (notified, ==, 0);
adw_window_title_set_title (window_title, "Another title");
g_assert_cmpstr (adw_window_title_get_title (window_title), ==, "Another title");
g_assert_cmpint (notified, ==, 1);
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_free (title);
g_assert_finalize_object (window_title);
}
static void
test_adw_window_title_subtitle (void)
{
AdwWindowTitle *window_title = g_object_ref_sink (ADW_WINDOW_TITLE (adw_window_title_new (NULL, "Some subtitle")));
char *subtitle;
int notified = 0;
g_assert_nonnull (window_title);
g_signal_connect_swapped (window_title, "notify::subtitle", G_CALLBACK (increment), ¬ified);
g_object_get (window_title, "subtitle", &subtitle, NULL);
g_assert_cmpstr (subtitle, ==, "Some subtitle");
adw_window_title_set_subtitle (window_title, "Some subtitle");
g_assert_cmpint (notified, ==, 0);
adw_window_title_set_subtitle (window_title, "Another subtitle");
g_assert_cmpstr (adw_window_title_get_subtitle (window_title), ==, "Another subtitle");
g_assert_cmpint (notified, ==, 1);
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_free (subtitle);
g_assert_finalize_object (window_title);
}
int
main (int argc,
char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
adw_init ();
g_test_add_func ("/Adwaita/WindowTitle/title", test_adw_window_title_title);
g_test_add_func ("/Adwaita/WindowTitle/subtitle", test_adw_window_title_subtitle);
return g_test_run ();
}
|