#include <atk/atk.h>
-static gboolean test_state_set();
+#include <string.h>
+
+static gboolean test_state_set (void);
+static gboolean test_state (void);
static gboolean
-test_state_set()
+test_state_set (void)
{
AtkStateSet *state_set1, *state_set2, *state_set3;
AtkStateType state_array[3];
gboolean b_val;
- state_set1 = atk_state_set_new();
+ state_set1 = atk_state_set_new ();
b_val = atk_state_set_is_empty (state_set1);
- if (b_val)
+ if (!b_val)
{
g_print ("New state set is not empty\n");
return FALSE;
}
b_val = atk_state_set_is_empty (state_set1);
- if (!b_val)
+ if (b_val)
{
g_print ("New state set is empty when it should not be\n");
return FALSE;
}
+static gboolean
+test_state (void)
+{
+ AtkStateType type1, type2;
+ const gchar *name;
+
+ name = atk_state_type_get_name (ATK_STATE_VISIBLE);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "visible") != 0)
+ {
+ g_print ("Unexpected name for ATK_STATE_VISIBLE %s\n", name);
+ return FALSE;
+ }
+
+ name = atk_state_type_get_name (ATK_STATE_MODAL);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "modal") != 0)
+ {
+ g_print ("Unexpected name for ATK_STATE_MODAL %s\n", name);
+ return FALSE;
+ }
+
+ type1 = atk_state_type_for_name ("focused");
+ if (type1 != ATK_STATE_FOCUSED)
+ {
+ g_print ("Unexpected type for focused\n");
+ return FALSE;
+ }
+
+ type1 = atk_state_type_register ("test-state");
+ name = atk_state_type_get_name (type1);
+ g_return_val_if_fail (name, FALSE);
+ if (strcmp (name, "test-state") != 0)
+ {
+ g_print ("Unexpected name for test-state %s\n", name);
+ return FALSE;
+ }
+ type2 = atk_state_type_for_name ("test-state");
+ g_return_val_if_fail (name, FALSE);
+ if (type1 != type2)
+ {
+ g_print ("Unexpected type for test-state %d %d\n", type1, type2);
+ return FALSE;
+ }
+ type2 = atk_state_type_for_name ("TEST_STATE");
+ if (type2 != 0)
+ {
+ g_print ("Unexpected type for TEST_STATE\n");
+ return FALSE;
+ }
+ /*
+ * Check that a non-existent type returns NULL
+ */
+ name = atk_state_type_get_name (ATK_STATE_LAST_DEFINED +2);
+ if (name)
+ {
+ g_print ("Unexpected name for undefined type\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
int
-gtk_module_init(gint argc, char* argv[])
+main (gint argc, char* argv[])
{
gboolean b_ret;
- g_print("State Set test module loaded\n");
-
- b_ret = test_state_set();
+ g_print("Starting State Set test suite\n");
+ b_ret = test_state_set ();
if (b_ret)
{
g_print ("State Set tests succeeded\n");
{
g_print ("State Set tests failed\n");
}
+ b_ret = test_state ();
+ if (b_ret)
+ {
+ g_print ("State tests succeeded\n");
+ }
+ else
+ {
+ g_print ("State tests failed\n");
+ }
return 0;
}