1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2010 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_font_dress(void)
28 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
31 toy_text
= adg_toy_text_new(NULL
);
32 valid_dress_1
= ADG_DRESS_TEXT_VALUE
;
33 valid_dress_2
= ADG_DRESS_TEXT_LIMIT
;
34 incompatible_dress
= ADG_DRESS_LINE
;
36 /* Using the public APIs */
37 adg_toy_text_set_font_dress(toy_text
, valid_dress_1
);
38 font_dress
= adg_toy_text_get_font_dress(toy_text
);
39 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
41 adg_toy_text_set_font_dress(toy_text
, incompatible_dress
);
42 font_dress
= adg_toy_text_get_font_dress(toy_text
);
43 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
45 adg_toy_text_set_font_dress(toy_text
, valid_dress_2
);
46 font_dress
= adg_toy_text_get_font_dress(toy_text
);
47 g_assert_cmpint(font_dress
, ==, valid_dress_2
);
49 /* Using GObject property methods */
50 g_object_set(toy_text
, "font-dress", valid_dress_1
, NULL
);
51 g_object_get(toy_text
, "font-dress", &font_dress
, NULL
);
52 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
54 g_object_set(toy_text
, "font-dress", incompatible_dress
, NULL
);
55 g_object_get(toy_text
, "font-dress", &font_dress
, NULL
);
56 g_assert_cmpint(font_dress
, ==, valid_dress_1
);
58 g_object_set(toy_text
, "font-dress", valid_dress_2
, NULL
);
59 g_object_get(toy_text
, "font-dress", &font_dress
, NULL
);
60 g_assert_cmpint(font_dress
, ==, valid_dress_2
);
62 g_object_unref(toy_text
);
69 const gchar
*valid_text
, *latin1_text
;
73 toy_text
= adg_toy_text_new(NULL
);
74 valid_text
= "This is some text...";
75 latin1_text
= "This is some àèìòù Latin1 text...";
77 /* Using the public APIs */
78 adg_toy_text_set_label(toy_text
, valid_text
);
79 label
= adg_toy_text_get_label(toy_text
);
80 g_assert_cmpstr(label
, ==, valid_text
);
82 adg_toy_text_set_label(toy_text
, latin1_text
);
83 label
= adg_toy_text_get_label(toy_text
);
84 g_assert_cmpstr(label
, ==, latin1_text
);
86 adg_toy_text_set_label(toy_text
, NULL
);
87 label
= adg_toy_text_get_label(toy_text
);
88 g_assert(label
== NULL
);
90 /* Using GObject property methods */
91 g_object_set(toy_text
, "label", valid_text
, NULL
);
92 g_object_get(toy_text
, "label", &label_dup
, NULL
);
93 g_assert_cmpstr(label_dup
, ==, valid_text
);
96 g_object_set(toy_text
, "label", latin1_text
, NULL
);
97 g_object_get(toy_text
, "label", &label_dup
, NULL
);
98 g_assert_cmpstr(label_dup
, ==, latin1_text
);
101 g_object_set(toy_text
, "label", NULL
, NULL
);
102 g_object_get(toy_text
, "label", &label_dup
, NULL
);
103 g_assert(label_dup
== NULL
);
105 g_object_unref(toy_text
);
110 main(int argc
, char *argv
[])
112 adg_test_init(&argc
, &argv
);
114 adg_test_add_func("/adg/toy-text/font-dress", _adg_test_font_dress
);
115 adg_test_add_func("/adg/toy-text/label", _adg_test_label
);