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.
24 static gboolean test_relation (void);
25 static gboolean test_role (void);
30 AtkRelationType type1, type2;
31 G_CONST_RETURN gchar *name;
33 name = atk_relation_type_get_name (ATK_RELATION_LABEL_FOR);
34 g_return_val_if_fail (name, FALSE);
35 if (strcmp (name, "label-for") != 0)
37 g_print ("Unexpected name for ATK_RELATION_LABEL_FOR %s\n", name);
41 name = atk_relation_type_get_name (ATK_RELATION_NODE_CHILD_OF);
42 g_return_val_if_fail (name, FALSE);
43 if (strcmp (name, "node-child-of") != 0)
45 g_print ("Unexpected name for ATK_RELATION_NODE_CHILD_OF %s\n", name);
49 type1 = atk_relation_type_for_name ("controlled-by");
50 if (type1 != ATK_RELATION_CONTROLLED_BY)
52 g_print ("Unexpected type for focused\n");
56 type1 = atk_relation_type_register ("test-state");
57 name = atk_relation_type_get_name (type1);
58 g_return_val_if_fail (name, FALSE);
59 if (strcmp (name, "test-state") != 0)
61 g_print ("Unexpected name for test-state %s\n", name);
64 type2 = atk_relation_type_for_name ("test-state");
67 g_print ("Unexpected type for test-state\n");
70 type2 = atk_relation_type_for_name ("TEST_STATE");
73 g_print ("Unexpected type for TEST_STATE\n");
77 * Check that a non-existent type returns NULL
79 name = atk_relation_type_get_name (ATK_RELATION_LAST_DEFINED + 2);
82 g_print ("Unexpected name for undefined type %s\n", name);
92 G_CONST_RETURN gchar *name;
94 name = atk_role_get_name (ATK_ROLE_PAGE_TAB);
95 g_return_val_if_fail (name, FALSE);
96 if (strcmp (name, "page-tab") != 0)
98 g_print ("Unexpected name for ATK_ROLE_PAGE_TAB %s\n", name);
102 name = atk_role_get_name (ATK_ROLE_LAYERED_PANE);
103 g_return_val_if_fail (name, FALSE);
104 if (strcmp (name, "layered-pane") != 0)
106 g_print ("Unexpected name for ATK_ROLE_LAYERED_PANE %s\n", name);
110 role1 = atk_role_for_name ("list-item");
111 if (role1 != ATK_ROLE_LIST_ITEM)
113 g_print ("Unexpected role for list-item\n");
117 role1 = atk_role_register ("test-role");
118 name = atk_role_get_name (role1);
119 g_return_val_if_fail (name, FALSE);
120 if (strcmp (name, "test-role") != 0)
122 g_print ("Unexpected name for test-role %s\n", name);
125 role2 = atk_role_for_name ("test-role");
128 g_print ("Unexpected role for test-role\n");
131 role2 = atk_role_for_name ("TEST_ROLE");
134 g_print ("Unexpected role for TEST_ROLE\n");
138 * Check that a non-existent role returns NULL
140 name = atk_role_get_name (ATK_ROLE_LAST_DEFINED + 2);
143 g_print ("Unexpected name for undefined role %s\n", name);
150 test_text_attr (void)
152 AtkTextAttribute attr1, attr2;
153 G_CONST_RETURN gchar *name;
155 name = atk_attribute_get_name (ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP);
156 g_return_val_if_fail (name, FALSE);
157 if (strcmp (name, "pixels-inside-wrap") != 0)
159 g_print ("Unexpected name for ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP %s\n", name);
163 name = atk_attribute_get_name (ATK_TEXT_ATTR_BG_STIPPLE);
164 g_return_val_if_fail (name, FALSE);
165 if (strcmp (name, "bg-stipple") != 0)
167 g_print ("Unexpected name for ATK_TEXT_ATTR_BG_STIPPLE %s\n", name);
171 attr1 = atk_attribute_for_name ("left-margin");
172 if (attr1 != ATK_TEXT_ATTR_LEFT_MARGIN)
174 g_print ("Unexpected attribute for left-margin\n");
178 attr1 = atk_attribute_register ("test-attribute");
179 name = atk_attribute_get_name (attr1);
180 g_return_val_if_fail (name, FALSE);
181 if (strcmp (name, "test-attribute") != 0)
183 g_print ("Unexpected name for test-attribute %s\n", name);
186 attr2 = atk_attribute_for_name ("test-attribute");
189 g_print ("Unexpected attribute for test-attribute\n");
192 attr2 = atk_attribute_for_name ("TEST_ATTR");
195 g_print ("Unexpected attribute for TEST_ATTR\n");
199 * Check that a non-existent attribute returns NULL
201 name = atk_attribute_get_name (ATK_TEXT_ATTR_LAST_DEFINED + 2);
204 g_print ("Unexpected name for undefined attribute %s\n", name);
211 gtk_module_init (gint argc,
216 g_print("Relation test module loaded\n");
218 b_ret = test_relation ();
220 g_print ("Relation tests succeeded\n");
222 g_print ("Relation tests failed\n");
223 b_ret = test_role ();
225 g_print ("Role tests succeeded\n");
227 g_print ("Role tests failed\n");
228 b_ret = test_text_attr ();
230 g_print ("Text Attribute tests succeeded\n");
232 g_print ("Text Attribute tests failed\n");