1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
27 AtkRelationType type1, type2;
32 AtkRelation *relation;
36 name = atk_relation_type_get_name (ATK_RELATION_LABEL_FOR);
37 g_return_val_if_fail (name, FALSE);
38 if (strcmp (name, "label-for") != 0)
40 g_print ("Unexpected name for ATK_RELATION_LABEL_FOR %s\n", name);
44 name = atk_relation_type_get_name (ATK_RELATION_NODE_CHILD_OF);
45 g_return_val_if_fail (name, FALSE);
46 if (strcmp (name, "node-child-of") != 0)
48 g_print ("Unexpected name for ATK_RELATION_NODE_CHILD_OF %s\n", name);
52 name = atk_relation_type_get_name (ATK_RELATION_EMBEDS);
53 g_return_val_if_fail (name, FALSE);
54 if (strcmp (name, "embeds") != 0)
56 g_print ("Unexpected name for ATK_RELATION_EMBEDS %s\n", name);
60 type1 = atk_relation_type_for_name ("embedded-by");
61 if (type1 != ATK_RELATION_EMBEDDED_BY)
63 g_print ("Unexpected role for ATK_RELATION_EMBEDDED_BY\n");
67 type1 = atk_relation_type_for_name ("controlled-by");
68 if (type1 != ATK_RELATION_CONTROLLED_BY)
70 g_print ("Unexpected name for ATK_RELATION_CONTROLLED_BY\n");
74 type1 = atk_relation_type_register ("test-state");
75 name = atk_relation_type_get_name (type1);
76 g_return_val_if_fail (name, FALSE);
77 if (strcmp (name, "test-state") != 0)
79 g_print ("Unexpected name for test-state %s\n", name);
82 type2 = atk_relation_type_for_name ("test-state");
85 g_print ("Unexpected type for test-state\n");
88 type2 = atk_relation_type_for_name ("TEST_STATE");
91 g_print ("Unexpected type for TEST_STATE\n");
95 * Check that a non-existent type returns NULL
97 name = atk_relation_type_get_name (ATK_RELATION_LAST_DEFINED + 2);
100 g_print ("Unexpected name for undefined type %s\n", name);
104 obj = g_object_new (ATK_TYPE_OBJECT, NULL);
105 ret_value = atk_object_add_relationship (obj, ATK_RELATION_LABEL_FOR, obj);
108 g_print ("Unexpected return value for atk_object_add_relationship\n");
111 set = atk_object_ref_relation_set (obj);
114 g_print ("Unexpected return value for atk_object_ref_relation_set\n");
117 n_relations = atk_relation_set_get_n_relations (set);
118 if (n_relations != 1)
120 g_print ("Unexpected return value (%d) for atk_relation_set_get_n_relations expected value: %d\n", n_relations, 1);
123 relation = atk_relation_set_get_relation (set, 0);
126 g_print ("Unexpected return value for atk_object_relation_set_get_relation\n");
129 type1 = atk_relation_get_relation_type (relation);
130 if (type1 != ATK_RELATION_LABEL_FOR)
132 g_print ("Unexpected return value for atk_relation_get_relation_type\n");
135 array = atk_relation_get_target (relation);
136 if (obj != g_ptr_array_index (array, 0))
138 g_print ("Unexpected return value for atk_relation_get_target\n");
141 g_object_unref (set);
142 ret_value = atk_object_remove_relationship (obj, ATK_RELATION_LABEL_FOR, obj);
145 g_print ("Unexpected return value for atk_object_remove_relationship\n");
148 set = atk_object_ref_relation_set (obj);
151 g_print ("Unexpected return value for atk_object_ref_relation_set\n");
154 n_relations = atk_relation_set_get_n_relations (set);
155 if (n_relations != 0)
157 g_print ("Unexpected return value (%d) for atk_relation_set_get_n_relations expected value: %d\n", n_relations, 0);
160 g_object_unref (set);
161 g_object_unref (obj);
166 test_text_attr (void)
168 AtkTextAttribute attr1, attr2;
171 name = atk_text_attribute_get_name (ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP);
172 g_return_val_if_fail (name, FALSE);
173 if (strcmp (name, "pixels-inside-wrap") != 0)
175 g_print ("Unexpected name for ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP %s\n", name);
179 name = atk_text_attribute_get_name (ATK_TEXT_ATTR_BG_STIPPLE);
180 g_return_val_if_fail (name, FALSE);
181 if (strcmp (name, "bg-stipple") != 0)
183 g_print ("Unexpected name for ATK_TEXT_ATTR_BG_STIPPLE %s\n", name);
187 attr1 = atk_text_attribute_for_name ("left-margin");
188 if (attr1 != ATK_TEXT_ATTR_LEFT_MARGIN)
190 g_print ("Unexpected attribute for left-margin\n");
194 attr1 = atk_text_attribute_register ("test-attribute");
195 name = atk_text_attribute_get_name (attr1);
196 g_return_val_if_fail (name, FALSE);
197 if (strcmp (name, "test-attribute") != 0)
199 g_print ("Unexpected name for test-attribute %s\n", name);
202 attr2 = atk_text_attribute_for_name ("test-attribute");
205 g_print ("Unexpected attribute for test-attribute\n");
208 attr2 = atk_text_attribute_for_name ("TEST_ATTR");
211 g_print ("Unexpected attribute for TEST_ATTR\n");
215 * Check that a non-existent attribute returns NULL
217 name = atk_text_attribute_get_name (ATK_TEXT_ATTR_LAST_DEFINED + 2);
220 g_print ("Unexpected name for undefined attribute %s\n", name);
232 g_print("Starting Relation test suite\n");
234 b_ret = test_relation ();
236 g_print ("Relation tests succeeded\n");
238 g_print ("Relation tests failed\n");
240 b_ret = test_text_attr ();
242 g_print ("Text Attribute tests succeeded\n");
244 g_print ("Text Attribute tests failed\n");