/* Known bugs */
-#undef KEY_IMPL_WORKS
#define WHOLE_STRING -1
static void validate_accessible (Accessible *accessible,
#define WINDOW_MAGIC 0x123456a
#define TEST_STRING_A "A test string"
+#define TEST_STRING_A_OBJECT "A_test_string_object"
#define TEST_STRING_B "Another test string"
static int print_tree_depth = 0;
static gboolean print_tree = FALSE;
static gboolean do_poke = FALSE;
+static gboolean key_press_received = FALSE;
+static gboolean key_release_received = FALSE;
typedef struct {
gulong magic;
{
TestWindow *win = g_new0 (TestWindow, 1);
GtkWidget *widget, *vbox;
+ AtkObject *obj;
win->magic = WINDOW_MAGIC;
win->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
widget = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (widget), TEST_STRING_A);
+ obj = gtk_widget_get_accessible (widget);
+ atk_object_set_name (obj, TEST_STRING_A_OBJECT);
+
test_window_add_and_show (GTK_CONTAINER (vbox), widget);
widget = gtk_button_new_with_label ("_Foobar");
GTK_ICON_SIZE_LARGE_TOOLBAR);
test_window_add_and_show (GTK_CONTAINER (vbox), widget);
- widget = g_object_new (GTK_TYPE_RANGE, NULL);
+ widget = g_object_new (GTK_TYPE_HSCALE, NULL);
gtk_range_set_range (GTK_RANGE (widget), 0.0, 100.0);
test_window_add_and_show (GTK_CONTAINER (vbox), widget);
for (i = -1; i < 1000; i++)
g_assert (AccessibleRole_getName (i) != NULL);
- g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_FILE_CHOOSER), "file chooser"));
- g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_RADIO_BUTTON), "radiobutton"));
+ g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_FILE_CHOOSER), "file-chooser"));
+ g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_RADIO_BUTTON), "radio-button"));
g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_TABLE), "table"));
g_assert (!strcmp (AccessibleRole_getName (SPI_ROLE_WINDOW), "window"));
}
g_assert (tmp != NULL);
if (print_tree)
fprintf (stderr, "Te");
- else
- test_text (tmp);
+ else {
+ if (strcmp (name, TEST_STRING_A_OBJECT) == 0)
+ test_text (tmp);
+ }
AccessibleText_unref (tmp);
}
AccessibleApplication_unref (application);
print_tree = FALSE;
+
validate_accessible (event->source, TRUE, TRUE);
+ fprintf (stderr, "quitting mainloop.\n");
gtk_main_quit ();
}
validate_accessible (event->source, TRUE, TRUE);
}
-#ifdef KEY_IMPL_WORKS
static SPIBoolean
key_listener_cb (const AccessibleKeystroke *stroke,
void *user_data)
{
AccessibleKeystroke *s = user_data;
-
+
*s = *stroke;
-
+
+ if (s->type == SPI_KEY_PRESSED)
+ key_press_received = TRUE;
+ else if (s->type == SPI_KEY_RELEASED)
+ key_release_received = TRUE;
+
return TRUE;
}
-#endif
+
static void
test_keylisteners (void)
{
-#ifdef KEY_IMPL_WORKS
int i;
AccessibleKeystroke stroke;
AccessibleKeystrokeListener *key_listener;
AccessibleKeySet *test_keyset;
-#endif
fprintf (stderr, "Testing keyboard listeners ...\n");
-#ifdef KEY_IMPL_WORKS
key_listener = SPI_createAccessibleKeystrokeListener (
key_listener_cb, &stroke);
test_keyset = SPI_createAccessibleKeySet (1, "=", NULL, NULL);
-
+
g_assert (SPI_registerAccessibleKeystrokeListener (
key_listener,
test_keyset,
for (i = 0; i < 3; i++) {
memset (&stroke, 0, sizeof (AccessibleKeystroke));
g_assert (SPI_generateKeyboardEvent ('=', NULL, SPI_KEY_SYM));
- while (!(stroke.type & SPI_KEY_PRESSED))
+ while (!(key_press_received))
g_main_context_iteration (NULL, TRUE);
fprintf (stderr, "p");
- while (!(stroke.type & SPI_KEY_RELEASED))
+ g_assert (!strcmp (stroke.keystring, "="));
+ while (!(key_release_received))
g_main_context_iteration (NULL, TRUE);
fprintf (stderr, "r ");
+ key_press_received = FALSE;
+ key_release_received = FALSE;
}
g_assert (SPI_deregisterAccessibleKeystrokeListener (key_listener, 0));
SPI_freeAccessibleKeySet (test_keyset);
- g_assert (!strcmp (stroke.keystring, "="));
fprintf (stderr, "\n");
AccessibleKeystrokeListener_unref (key_listener);
-#else
- fprintf (stderr, " key impl. impossibly broken\n");
-#endif
g_assert (SPI_generateMouseEvent (100, 100, "rel"));
g_assert (SPI_generateMouseEvent (-50, -50, "rel"));
win = create_test_window ();
global_listener = SPI_createAccessibleEventListener (global_listener_cb, win);
+
g_assert (SPI_registerGlobalEventListener (global_listener, "focus:"));
fprintf (stderr, "Waiting for focus event ...\n");
/* Wait for any pending events from the registry */
g_usleep (500*1000);
for (i = 0; i < 100; i++)
- linc_main_iteration (FALSE);
+ CORBA_ORB_perform_work (NULL, NULL);
if ((leaked = SPI_exit ()))
g_error ("Leaked %d SPI handles", leaked);