AdgEntity: added "destroy" signal
[adg.git] / src / adg / tests / test-stroke.c
blobcd6d0757fc7fa1e5d137becf1ce5bd34d2b1f6ac
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_line_dress(void)
27 AdgStroke *stroke;
28 AdgDress valid_dress_1, valid_dress_2, incompatible_dress;
29 AdgDress line_dress;
31 stroke = adg_stroke_new(NULL);
32 valid_dress_1 = ADG_DRESS_LINE_GRID;
33 valid_dress_2 = ADG_DRESS_LINE_DIMENSION;
34 incompatible_dress = ADG_DRESS_FONT_ANNOTATION;
36 /* Using the public APIs */
37 adg_stroke_set_line_dress(stroke, valid_dress_1);
38 line_dress = adg_stroke_get_line_dress(stroke);
39 g_assert_cmpint(line_dress, ==, valid_dress_1);
41 adg_stroke_set_line_dress(stroke, incompatible_dress);
42 line_dress = adg_stroke_get_line_dress(stroke);
43 g_assert_cmpint(line_dress, ==, valid_dress_1);
45 adg_stroke_set_line_dress(stroke, valid_dress_2);
46 line_dress = adg_stroke_get_line_dress(stroke);
47 g_assert_cmpint(line_dress, ==, valid_dress_2);
49 /* Using GObject property methods */
50 g_object_set(stroke, "line-dress", valid_dress_1, NULL);
51 g_object_get(stroke, "line-dress", &line_dress, NULL);
52 g_assert_cmpint(line_dress, ==, valid_dress_1);
54 g_object_set(stroke, "line-dress", incompatible_dress, NULL);
55 g_object_get(stroke, "line-dress", &line_dress, NULL);
56 g_assert_cmpint(line_dress, ==, valid_dress_1);
58 g_object_set(stroke, "line-dress", valid_dress_2, NULL);
59 g_object_get(stroke, "line-dress", &line_dress, NULL);
60 g_assert_cmpint(line_dress, ==, valid_dress_2);
62 adg_entity_destroy(ADG_ENTITY(stroke));
65 static void
66 _adg_test_trail(void)
68 AdgStroke *stroke;
69 AdgTrail *valid_trail, *invalid_trail, *trail;
71 stroke = adg_stroke_new(NULL);
72 valid_trail = ADG_TRAIL(adg_path_new());
73 invalid_trail = adg_test_invalid_pointer();
75 g_object_ref(valid_trail);
77 /* Using the public APIs */
78 adg_stroke_set_trail(stroke, NULL);
79 trail = adg_stroke_get_trail(stroke);
80 g_assert(trail == NULL);
82 adg_stroke_set_trail(stroke, valid_trail);
83 trail = adg_stroke_get_trail(stroke);
84 g_assert(trail == valid_trail);
86 adg_stroke_set_trail(stroke, invalid_trail);
87 trail = adg_stroke_get_trail(stroke);
88 g_assert(trail == valid_trail);
90 adg_stroke_set_trail(stroke, NULL);
91 trail = adg_stroke_get_trail(stroke);
92 g_assert(trail == NULL);
94 /* Using GObject property methods */
95 g_object_set(stroke, "trail", NULL, NULL);
96 g_object_get(stroke, "trail", &trail, NULL);
97 g_assert(trail == NULL);
99 g_object_set(stroke, "trail", valid_trail, NULL);
100 g_object_get(stroke, "trail", &trail, NULL);
101 g_assert(trail == valid_trail);
102 g_object_unref(trail);
104 g_object_set(stroke, "trail", invalid_trail, NULL);
105 g_object_get(stroke, "trail", &trail, NULL);
106 g_assert(trail == valid_trail);
107 g_object_unref(trail);
109 g_object_set(stroke, "trail", NULL, NULL);
110 g_object_get(stroke, "trail", &trail, NULL);
111 g_assert(trail == NULL);
113 adg_entity_destroy(ADG_ENTITY(stroke));
114 g_object_unref(valid_trail);
119 main(int argc, char *argv[])
121 adg_test_init(&argc, &argv);
123 adg_test_add_func("/adg/stroke/line-dress", _adg_test_line_dress);
124 adg_test_add_func("/adg/stroke/trail", _adg_test_trail);
126 return g_test_run();