doc: extend atk_focus_tracker_notify deprecation documentation
[atk.git] / tests / testrole.c
bloba50f0968a59b8785b300735c85a8d0ee121fc2e9
1 /* ATK - Accessibility Toolkit
2 * Copyright (C) 2013 Igalia, S.L.
4 * Author: Alejandro PiƱeiro Iglesias <apinheiro@igalia.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
21 #include <atk/atk.h>
22 #include <string.h>
24 static gboolean
25 test_role (void)
27 AtkRole role1, role2;
28 const gchar *name;
29 gboolean result = TRUE;
31 name = atk_role_get_name (ATK_ROLE_PAGE_TAB);
32 if (!name || strcmp (name, "page tab") != 0)
34 g_print ("Unexpected name for ATK_ROLE_PAGE_TAB."
35 " Expected 'page tab', received '%s'\n", name);
36 result = FALSE;
39 name = atk_role_get_name (ATK_ROLE_LAYERED_PANE);
40 if (!name || strcmp (name, "layered pane") != 0)
42 g_print ("Unexpected name for ATK_ROLE_LAYERED_PANE."
43 " Expected 'layered pane', received '%s'\n", name);
44 result = FALSE;
47 role1 = atk_role_for_name ("list item");
48 if (role1 != ATK_ROLE_LIST_ITEM)
50 g_print ("Unexpected role for list item."
51 " Expected %i, received %i\n", ATK_ROLE_LIST_ITEM, role1);
52 result = FALSE;
55 role2 = atk_role_for_name ("TEST_ROLE");
56 if (role2 != ATK_ROLE_INVALID)
58 g_print ("Unexpected role for TEST_ROLE. Expected %i, received %i\n", ATK_ROLE_INVALID, role2);
59 result = FALSE;
62 * Check that a non-existent role returns NULL
64 name = atk_role_get_name (ATK_ROLE_LAST_DEFINED + 2);
65 if (name)
67 g_print ("Unexpected name for undefined role %s\n", name);
68 result = FALSE;
71 return result;
74 static void
75 print_roles()
77 AtkRole role;
79 g_print("(Role, name, localized name) defined by the ATK library:\n");
81 for (role = ATK_ROLE_INVALID; role < ATK_ROLE_LAST_DEFINED; role++)
82 g_print ("(%i, %s, %s)\n", role,
83 atk_role_get_name(role), atk_role_get_localized_name(role));
85 g_print("(Role, name, localized name) for the extra roles:\n");
86 for (;atk_role_get_name(role) != NULL; role++)
87 g_print ("(%i, %s, %s)\n", role,
88 atk_role_get_name(role), atk_role_get_localized_name(role));
92 int
93 main (int argc, char **argv)
95 gboolean b_ret;
97 g_print ("Starting Role test suite\n");
99 b_ret = test_role ();
101 print_roles();
103 if (b_ret)
104 g_print ("Role tests succeeded\n");
105 else
106 g_print ("Role tests failed\n");
108 return 0;