1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2021 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
24 #define ADG_TYPE_DUMMY (adg_dummy_get_type())
27 typedef GObject AdgDummy
;
28 typedef GObjectClass AdgDummyClass
;
31 adg_dummy_class_init(AdgDummyClass
*klass
)
36 _adg_dummy_iface_init(AdgTextualIface
*iface
)
38 iface
->set_font_dress
= NULL
;
39 iface
->get_font_dress
= NULL
;
40 iface
->set_text
= NULL
;
41 iface
->dup_text
= NULL
;
42 iface
->text_changed
= NULL
;
46 adg_dummy_init(AdgDummy
*dummy
)
50 G_DEFINE_TYPE_WITH_CODE(AdgDummy
, adg_dummy
, G_TYPE_OBJECT
,
51 G_IMPLEMENT_INTERFACE(ADG_TYPE_TEXTUAL
,
52 _adg_dummy_iface_init
))
56 _adg_behavior_misc(void)
58 AdgDummy
*dummy
= g_object_new(ADG_TYPE_DUMMY
, NULL
);
60 /* Ensure NULL virtual methods do not crash the process */
61 adg_textual_set_font_dress(ADG_TEXTUAL(dummy
), ADG_DRESS_TABLE
);
62 g_assert_cmpint(adg_textual_get_font_dress(ADG_TEXTUAL(dummy
)), ==, ADG_DRESS_UNDEFINED
);
63 adg_textual_set_text(ADG_TEXTUAL(dummy
), "dummy");
64 g_assert_null(adg_textual_dup_text(ADG_TEXTUAL(dummy
)));
66 g_object_unref(dummy
);
70 _adg_method_text_changed(void)
72 AdgDummy
*dummy
= g_object_new(ADG_TYPE_DUMMY
, NULL
);
74 adg_test_signal(dummy
, "text-changed");
75 adg_textual_text_changed(ADG_TEXTUAL(dummy
), "old text");
76 g_assert_true(adg_test_signal_check(TRUE
));
78 g_object_unref(dummy
);
83 main(int argc
, char *argv
[])
85 adg_test_init(&argc
, &argv
);
87 g_test_add_func("/adg/textual/behavior/misc", _adg_behavior_misc
);
89 g_test_add_func("/adg/textual/method/text-changed", _adg_method_text_changed
);