1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2015 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.
26 _adg_test_local_mix(void)
31 /* Check default local mix method */
32 toy_text
= adg_toy_text_new("");
33 entity
= (AdgEntity
*) toy_text
;
34 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_ANCESTORS_NORMALIZED
);
35 adg_entity_destroy(entity
);
37 /* Check local mix method overriding */
38 toy_text
= g_object_new(ADG_TYPE_TOY_TEXT
, "local-mix", ADG_MIX_DISABLED
, NULL
);
39 entity
= (AdgEntity
*) toy_text
;
40 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_DISABLED
);
41 adg_entity_destroy(entity
);
43 /* Check default mix using GObject methods */
44 toy_text
= g_object_new(ADG_TYPE_TOY_TEXT
, NULL
);
45 entity
= (AdgEntity
*) toy_text
;
46 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_ANCESTORS_NORMALIZED
);
47 adg_entity_destroy(entity
);
51 _adg_test_font_dress(void)
55 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
58 toy_text
= adg_toy_text_new(NULL
);
59 textual
= (AdgTextual
*) toy_text
;
60 valid_dress_1
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
61 valid_dress_2
= ADG_DRESS_FONT
;
62 incompatible_dress
= ADG_DRESS_LINE
;
64 /* Using the public APIs */
65 adg_textual_set_font_dress(textual
, valid_dress_1
);
66 font_dress
= adg_textual_get_font_dress(textual
);
67 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
69 adg_textual_set_font_dress(textual
, incompatible_dress
);
70 font_dress
= adg_textual_get_font_dress(textual
);
71 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
73 adg_textual_set_font_dress(textual
, valid_dress_2
);
74 font_dress
= adg_textual_get_font_dress(textual
);
75 g_assert_cmpint(font_dress
, ==, valid_dress_2
);
77 /* Using GObject property methods */
78 g_object_set(toy_text
, "font-dress", valid_dress_1
, NULL
);
79 g_object_get(toy_text
, "font-dress", &font_dress
, NULL
);
80 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
82 g_object_set(toy_text
, "font-dress", incompatible_dress
, NULL
);
83 g_object_get(toy_text
, "font-dress", &font_dress
, NULL
);
84 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
86 g_object_set(toy_text
, "font-dress", valid_dress_2
, NULL
);
87 g_object_get(toy_text
, "font-dress", &font_dress
, NULL
);
88 g_assert_cmpint(font_dress
, ==, valid_dress_2
);
90 adg_entity_destroy(ADG_ENTITY(toy_text
));
98 const gchar
*valid_text
, *latin1_text
;
101 toy_text
= adg_toy_text_new(NULL
);
102 textual
= (AdgTextual
*) toy_text
;
103 valid_text
= "This is some text...";
104 latin1_text
= "This is some àèìòù Latin1 text...";
106 /* Using the public APIs */
107 adg_textual_set_text(textual
, valid_text
);
108 text
= adg_textual_dup_text(textual
);
109 g_assert_cmpstr(text
, ==, valid_text
);
112 adg_textual_set_text(textual
, latin1_text
);
113 text
= adg_textual_dup_text(textual
);
114 g_assert_cmpstr(text
, ==, latin1_text
);
117 adg_textual_set_text(textual
, NULL
);
118 text
= adg_textual_dup_text(textual
);
122 /* Using GObject property methods */
123 g_object_set(toy_text
, "text", valid_text
, NULL
);
124 g_object_get(toy_text
, "text", &text
, NULL
);
125 g_assert_cmpstr(text
, ==, valid_text
);
128 g_object_set(toy_text
, "text", latin1_text
, NULL
);
129 g_object_get(toy_text
, "text", &text
, NULL
);
130 g_assert_cmpstr(text
, ==, latin1_text
);
133 g_object_set(toy_text
, "text", NULL
, NULL
);
134 g_object_get(toy_text
, "text", &text
, NULL
);
137 adg_entity_destroy(ADG_ENTITY(toy_text
));
142 main(int argc
, char *argv
[])
144 adg_test_init(&argc
, &argv
);
146 adg_test_add_object_checks("/adg/toy-text/type/object", ADG_TYPE_TOY_TEXT
);
147 adg_test_add_entity_checks("/adg/toy-text/type/entity", ADG_TYPE_TOY_TEXT
);
149 adg_test_add_global_space_checks("/adg/toy-text/behavior/global-space", adg_toy_text_new("Testing"));
151 adg_test_add_func("/adg/toy-text/property/local-mix", _adg_test_local_mix
);
152 adg_test_add_func("/adg/toy-text/property/font-dress", _adg_test_font_dress
);
153 adg_test_add_func("/adg/toy-text/property/text", _adg_test_text
);