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 table
= adg_table_new();
32 entity
= (AdgEntity
*) table
;
33 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_DISABLED
);
34 adg_entity_destroy(entity
);
36 /* Check local mix method overriding */
37 table
= g_object_new(ADG_TYPE_TABLE
, "local-mix", ADG_MIX_ANCESTORS_NORMALIZED
, NULL
);
38 entity
= (AdgEntity
*) table
;
39 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_ANCESTORS_NORMALIZED
);
40 adg_entity_destroy(entity
);
42 /* Check default mix using GObject methods */
43 table
= g_object_new(ADG_TYPE_TABLE
, NULL
);
44 entity
= (AdgEntity
*) table
;
45 g_assert_cmpint(adg_entity_get_local_mix(entity
), ==, ADG_MIX_DISABLED
);
46 adg_entity_destroy(entity
);
50 _adg_test_table_dress(void)
53 AdgDress valid_dress
, incompatible_dress
;
56 table
= adg_table_new();
57 valid_dress
= ADG_DRESS_TABLE
;
58 incompatible_dress
= ADG_DRESS_LINE
;
60 /* Using the public APIs */
61 adg_table_set_table_dress(table
, valid_dress
);
62 table_dress
= adg_table_get_table_dress(table
);
63 g_assert_cmpint(table_dress
, ==, valid_dress
);
65 adg_table_set_table_dress(table
, incompatible_dress
);
66 table_dress
= adg_table_get_table_dress(table
);
67 g_assert_cmpint(table_dress
, ==, valid_dress
);
69 /* Using GObject property methods */
70 g_object_set(table
, "table-dress", valid_dress
, NULL
);
71 g_object_get(table
, "table-dress", &table_dress
, NULL
);
72 g_assert_cmpint(table_dress
, ==, valid_dress
);
74 g_object_set(table
, "table-dress", incompatible_dress
, NULL
);
75 g_object_get(table
, "table-dress", &table_dress
, NULL
);
76 g_assert_cmpint(table_dress
, ==, valid_dress
);
78 adg_entity_destroy(ADG_ENTITY(table
));
82 _adg_test_has_frame(void)
85 gboolean invalid_boolean
;
88 table
= adg_table_new();
89 invalid_boolean
= (gboolean
) 1234;
91 /* Using the public APIs */
92 adg_table_switch_frame(table
, FALSE
);
93 has_frame
= adg_table_has_frame(table
);
96 adg_table_switch_frame(table
, invalid_boolean
);
97 has_frame
= adg_table_has_frame(table
);
100 adg_table_switch_frame(table
, TRUE
);
101 has_frame
= adg_table_has_frame(table
);
104 /* Using GObject property methods */
105 g_object_set(table
, "has-frame", FALSE
, NULL
);
106 g_object_get(table
, "has-frame", &has_frame
, NULL
);
107 g_assert(!has_frame
);
109 g_object_set(table
, "has-frame", invalid_boolean
, NULL
);
110 g_object_get(table
, "has-frame", &has_frame
, NULL
);
111 g_assert(!has_frame
);
113 g_object_set(table
, "has-frame", TRUE
, NULL
);
114 g_object_get(table
, "has-frame", &has_frame
, NULL
);
117 adg_entity_destroy(ADG_ENTITY(table
));
122 main(int argc
, char *argv
[])
124 adg_test_init(&argc
, &argv
);
126 adg_test_add_func("/adg/table/local-mix", _adg_test_local_mix
);
127 adg_test_add_func("/adg/table/table-dress", _adg_test_table_dress
);
128 adg_test_add_func("/adg/table/has-frame", _adg_test_has_frame
);