static gboolean test_role (void) { AtkRole role1, role2; G_CONST_RETURN gchar *name; name = atk_role_get_name (ATK_ROLE_PAGE_TAB); g_return_val_if_fail (name, FALSE); if (strcmp (name, "page-tab") != 0) { g_print ("Unexpected name for ATK_ROLE_PAGE_TAB %s\n", name); return FALSE; } name = atk_role_get_name (ATK_ROLE_LAYERED_PANE); g_return_val_if_fail (name, FALSE); if (strcmp (name, "layered-pane") != 0) { g_print ("Unexpected name for ATK_ROLE_LAYERED_PANE %s\n", name); return FALSE; } role1 = atk_role_for_name ("list-item"); if (role1 != ATK_ROLE_LIST_ITEM) { g_print ("Unexpected role for list-item\n"); return FALSE; } role1 = atk_role_register ("test-role"); name = atk_role_get_name (role1); g_return_val_if_fail (name, FALSE); if (strcmp (name, "test-role") != 0) { g_print ("Unexpected name for test-role %s\n", name); return FALSE; } role2 = atk_role_for_name ("test-role"); if (role1 != role2) { g_print ("Unexpected role for test-role\n"); return FALSE; } role2 = atk_role_for_name ("TEST_ROLE"); if (role2 != 0) { g_print ("Unexpected role for TEST_ROLE\n"); return FALSE; } /* * Check that a non-existent role returns NULL */ name = atk_role_get_name (ATK_ROLE_LAST_DEFINED + 2); if (name) { g_print ("Unexpected name for undefined role %s\n", name); return FALSE; } return TRUE; }
/** * Wrapper for atk_role_register(). */ static PyObject* _role_register (PyObject *self, PyObject *args) { char *val; debug ("_role_register\n"); if (!PyArg_ParseTuple (args, "s:atk_role_register", &val)) return NULL; return PyInt_FromLong ((long) atk_role_register (val)); }