1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010,2011,2012,2013 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.
21 #include "test-internal.h"
25 _adg_test_local_mix(void)
30 /* Check default local mix method */
31 text
= adg_text_new("");
32 entity
= (AdgEntity
*) text
;
33 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_ANCESTORS_NORMALIZED
);
34 adg_entity_destroy(entity
);
36 /* Check local mix method overriding */
37 text
= g_object_new(ADG_TYPE_TEXT
, "local-mix", ADG_MIX_DISABLED
, NULL
);
38 entity
= (AdgEntity
*) text
;
39 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_DISABLED
);
40 adg_entity_destroy(entity
);
42 /* Check default mix using GObject methods */
43 text
= g_object_new(ADG_TYPE_TEXT
, NULL
);
44 entity
= (AdgEntity
*) text
;
45 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_ANCESTORS_NORMALIZED
);
46 adg_entity_destroy(entity
);
50 _adg_test_font_dress(void)
54 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
57 text
= adg_text_new(NULL
);
58 textual
= (AdgTextual
*) text
;
59 valid_dress_1
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
60 valid_dress_2
= ADG_DRESS_FONT
;
61 incompatible_dress
= ADG_DRESS_LINE
;
63 /* Using the public APIs */
64 adg_textual_set_font_dress(textual
, valid_dress_1
);
65 font_dress
= adg_textual_get_font_dress(textual
);
66 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
68 adg_textual_set_font_dress(textual
, incompatible_dress
);
69 font_dress
= adg_textual_get_font_dress(textual
);
70 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
72 adg_textual_set_font_dress(textual
, valid_dress_2
);
73 font_dress
= adg_textual_get_font_dress(textual
);
74 g_assert_cmpint(font_dress
, ==, valid_dress_2
);
76 /* Using GObject property methods */
77 g_object_set(text
, "font-dress", valid_dress_1
, NULL
);
78 g_object_get(text
, "font-dress", &font_dress
, NULL
);
79 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
81 g_object_set(text
, "font-dress", incompatible_dress
, NULL
);
82 g_object_get(text
, "font-dress", &font_dress
, NULL
);
83 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
85 g_object_set(text
, "font-dress", valid_dress_2
, NULL
);
86 g_object_get(text
, "font-dress", &font_dress
, NULL
);
87 g_assert_cmpint(font_dress
, ==, valid_dress_2
);
89 adg_entity_destroy(ADG_ENTITY(text
));
97 const gchar
*valid_text
, *latin1_text
;
100 text
= adg_text_new(NULL
);
101 textual
= (AdgTextual
*) text
;
102 valid_text
= "This is some string...";
103 latin1_text
= "This is some àèìòù Latin1 string...";
105 /* Using the public APIs */
106 adg_textual_set_text(textual
, valid_text
);
107 string
= adg_textual_dup_text(textual
);
108 g_assert_cmpstr(string
, ==, valid_text
);
111 adg_textual_set_text(textual
, latin1_text
);
112 string
= adg_textual_dup_text(textual
);
113 g_assert_cmpstr(string
, ==, latin1_text
);
116 adg_textual_set_text(textual
, NULL
);
117 string
= adg_textual_dup_text(textual
);
118 g_assert(string
== NULL
);
121 /* Using GObject property methods */
122 g_object_set(text
, "text", valid_text
, NULL
);
123 g_object_get(text
, "text", &string
, NULL
);
124 g_assert_cmpstr(string
, ==, valid_text
);
127 g_object_set(text
, "text", latin1_text
, NULL
);
128 g_object_get(text
, "text", &string
, NULL
);
129 g_assert_cmpstr(string
, ==, latin1_text
);
132 g_object_set(text
, "text", NULL
, NULL
);
133 g_object_get(text
, "text", &string
, NULL
);
134 g_assert(string
== NULL
);
136 adg_entity_destroy(ADG_ENTITY(text
));
141 main(int argc
, char *argv
[])
143 adg_test_init(&argc
, &argv
);
145 adg_test_add_func("/adg/text/local-mix", _adg_test_local_mix
);
146 adg_test_add_func("/adg/text/font-dress", _adg_test_font_dress
);
147 adg_test_add_func("/adg/text/string", _adg_test_text
);