AdgEntity: added "destroy" signal
[adg.git] / src / adg / tests / test-toy-text.c
bloba3dac4763bcba17fc258dc90c27a24139dd65a67
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2010,2011 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"
24 static void
25 _adg_test_font_dress(void)
27 AdgToyText *toy_text;
28 AdgTextual *textual;
29 AdgDress valid_dress_1, valid_dress_2, incompatible_dress;
30 AdgDress font_dress;
32 toy_text = adg_toy_text_new(NULL);
33 textual = (AdgTextual *) toy_text;
34 valid_dress_1 = ADG_DRESS_FONT_QUOTE_ANNOTATION;
35 valid_dress_2 = ADG_DRESS_FONT;
36 incompatible_dress = ADG_DRESS_LINE;
38 /* Using the public APIs */
39 adg_textual_set_font_dress(textual, valid_dress_1);
40 font_dress = adg_textual_get_font_dress(textual);
41 g_assert_cmpint(font_dress, ==, valid_dress_1);
43 adg_textual_set_font_dress(textual, incompatible_dress);
44 font_dress = adg_textual_get_font_dress(textual);
45 g_assert_cmpint(font_dress, ==, valid_dress_1);
47 adg_textual_set_font_dress(textual, valid_dress_2);
48 font_dress = adg_textual_get_font_dress(textual);
49 g_assert_cmpint(font_dress, ==, valid_dress_2);
51 /* Using GObject property methods */
52 g_object_set(toy_text, "font-dress", valid_dress_1, NULL);
53 g_object_get(toy_text, "font-dress", &font_dress, NULL);
54 g_assert_cmpint(font_dress, ==, valid_dress_1);
56 g_object_set(toy_text, "font-dress", incompatible_dress, NULL);
57 g_object_get(toy_text, "font-dress", &font_dress, NULL);
58 g_assert_cmpint(font_dress, ==, valid_dress_1);
60 g_object_set(toy_text, "font-dress", valid_dress_2, NULL);
61 g_object_get(toy_text, "font-dress", &font_dress, NULL);
62 g_assert_cmpint(font_dress, ==, valid_dress_2);
64 adg_entity_destroy(ADG_ENTITY(toy_text));
67 static void
68 _adg_test_text(void)
70 AdgToyText *toy_text;
71 AdgTextual *textual;
72 const gchar *valid_text, *latin1_text;
73 gchar *text;
75 toy_text = adg_toy_text_new(NULL);
76 textual = (AdgTextual *) toy_text;
77 valid_text = "This is some text...";
78 latin1_text = "This is some àèìòù Latin1 text...";
80 /* Using the public APIs */
81 adg_textual_set_text(textual, valid_text);
82 text = adg_textual_dup_text(textual);
83 g_assert_cmpstr(text, ==, valid_text);
84 g_free(text);
86 adg_textual_set_text(textual, latin1_text);
87 text = adg_textual_dup_text(textual);
88 g_assert_cmpstr(text, ==, latin1_text);
89 g_free(text);
91 adg_textual_set_text(textual, NULL);
92 text = adg_textual_dup_text(textual);
93 g_assert(text == NULL);
94 g_free(text);
96 /* Using GObject property methods */
97 g_object_set(toy_text, "text", valid_text, NULL);
98 g_object_get(toy_text, "text", &text, NULL);
99 g_assert_cmpstr(text, ==, valid_text);
100 g_free(text);
102 g_object_set(toy_text, "text", latin1_text, NULL);
103 g_object_get(toy_text, "text", &text, NULL);
104 g_assert_cmpstr(text, ==, latin1_text);
105 g_free(text);
107 g_object_set(toy_text, "text", NULL, NULL);
108 g_object_get(toy_text, "text", &text, NULL);
109 g_assert(text == NULL);
111 adg_entity_destroy(ADG_ENTITY(toy_text));
116 main(int argc, char *argv[])
118 adg_test_init(&argc, &argv);
120 adg_test_add_func("/adg/toy-text/font-dress", _adg_test_font_dress);
121 adg_test_add_func("/adg/toy-text/text", _adg_test_text);
123 return g_test_run();