* ******** Do not copy this code as an example *********
*/
-/* UGLY HACK for (unutterable_horror) */
-#include <libspi/libspi.h>
-
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <cspi/spi.h>
g_object_unref (G_OBJECT (aobject));
- /* Pull focus away and then back - thus sucks */
return FALSE;
}
application = Accessible_getChildAtIndex (desktop, 0);
g_assert (application != NULL);
+ AccessibleApplication_unref (application);
Accessible_unref (desktop);
}
}
static void
+test_value (AccessibleValue *value)
+{
+ char *str;
+ float original_value;
+
+ /* Note: test_value assertions are known not to work as of Dec 09 */
+
+ fprintf (stderr, "Testing value ...\n");
+
+ original_value = AccessibleValue_getCurrentValue (value);
+
+ g_assert (AccessibleValue_getCurrentValue (value) <=
+ AccessibleValue_getMaximumValue (value));
+
+ g_assert (AccessibleValue_getCurrentValue (value) >=
+ AccessibleValue_getMinimumValue (value));
+
+ AccessibleValue_setCurrentValue (value,
+ AccessibleValue_getMinimumValue (value));
+
+ g_assert (AccessibleValue_getCurrentValue (value) ==
+ AccessibleValue_getMinimumValue (value));
+
+ AccessibleValue_setCurrentValue (value,
+ AccessibleValue_getMaximumValue (value));
+
+ g_assert (AccessibleValue_getCurrentValue (value) ==
+ AccessibleValue_getMaximumValue (value));
+
+ AccessibleValue_setCurrentValue (value, original_value);
+
+ g_assert (AccessibleValue_getCurrentValue (value) == original_value);
+}
+
+static void
test_component (AccessibleComponent *component)
{
long x, y, width, height;
g_assert (parent != NULL);
index = Accessible_getIndexInParent (accessible);
- g_assert (index >= 0);
+ g_assert (index >= 0);
child_at_index = Accessible_getChildAtIndex (parent, index);
AccessibleText_unref (tmp);
}
+ if (Accessible_isValue (accessible)) {
+ tmp = Accessible_getValue (accessible);
+ g_assert (tmp != NULL);
+ if (print_tree)
+ fprintf (stderr, "Va");
+ else
+ ; /* test_value (tmp); */
+ AccessibleValue_unref (tmp);
+ }
+
if (print_tree)
fprintf (stderr, " ] '%s' (%s) - %s:\n", name, descr, role);
SPI_freeString (NULL);
}
-#ifdef UNUTTERABLY_HORRIFIC
-static void
-unutterable_horror (void)
-{
- /* Brutal ugliness to de-register ourself and exit cleanly */
- CORBA_Environment ev;
- Accessible *desktop;
- Accessible *app_access;
- Accessibility_Accessible app;
- Accessibility_Registry registry;
-
- fprintf (stderr, "Unutterable horror ...\n");
-
- /* First get the application ! - gack */
- desktop = getDesktop (0);
- app_access = Accessible_getChildAtIndex (desktop, 0);
-
- /* Good grief */
- app = *(Accessibility_Accessible *) app_access;
-
- CORBA_exception_init (&ev);
-
- registry = bonobo_activation_activate_from_id (
- "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
-
- Accessibility_Registry_deregisterApplication (
- registry, app, &ev);
-
- bonobo_object_release_unref (registry, &ev); /* the original ref */
- bonobo_object_release_unref (registry, &ev); /* taken by the bridge */
- bonobo_object_release_unref (registry, &ev); /* taken by spi_main.c */
-
- Accessible_unref (desktop);
- Accessible_unref (app_access);
-
- /* Urgh ! - get a pointer to app */
- bonobo_object_unref (bonobo_object (ORBit_small_get_servant (app)));
-}
-#endif
-
-static void
-utterable_normal_derefs (void)
-{
- /* Normal cleanup to exit cleanly */
- CORBA_Environment ev;
- Accessibility_Registry registry;
-
- CORBA_exception_init (&ev);
-
- registry = bonobo_activation_activate_from_id (
- "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
-
- bonobo_object_release_unref (registry, &ev); /* the ref above */
- bonobo_object_release_unref (registry, &ev); /* taken by spi_main.c */
-
- /* Yes, it would be nicer to have both SPI_main_quit and SPI_shutdown,
- then the above code could be dispensed with */
-}
-
static void
global_listener_cb (AccessibleEvent *event,
void *user_data)
fprintf (stderr, "Fielded focus event ...\n");
- /* The application is now registered - this happens idly */
-
desktop = getDesktop (0);
application = Accessible_getChildAtIndex (desktop, 0);
g_assert (application != NULL);
int
main (int argc, char **argv)
{
+ int leaked;
TestWindow *win;
+ const char *modules, *tmp;
AccessibleEventListener *global_listener;
- gtk_init (&argc, &argv);
+ modules = g_getenv ("GTK_MODULES");
+ if (!modules || modules [0] == '\0')
+ putenv ("GTK_MODULES=gail:at-bridge");
+ modules = NULL;
- if (!g_getenv ("GTK_MODULES") ||
- !strstr (g_getenv ("GTK_MODULES"), "gail:at-bridge")) {
- g_error ("You need to export GTK_MODULES='gail:at-bridge'");
- }
+ gtk_init (&argc, &argv);
- g_assert (!SPI_init (TRUE));
- g_assert (SPI_init (TRUE));
+ g_assert (!SPI_init ());
+ g_assert (SPI_init ());
g_assert (getDesktopCount () == 1);
test_roles ();
fprintf (stderr, "Waiting for focus event ...\n");
gtk_main ();
- /* First de-register myself - we only want the toplevel of ourself */
g_assert (deregisterGlobalEventListenerAll (global_listener));
+ AccessibleEventListener_unref (global_listener);
test_window_destroy (win);
-/* FIXME: we need to resolve the exit / quit mainloop function */
-/* SPI_exit ();
- SPI_exit (); */
-/* unutterable_horror (); ! */
- utterable_normal_derefs ();
+ if ((leaked = SPI_exit ()))
+ g_error ("Leaked %d SPI handles", leaked);
+
+ g_assert (!SPI_exit ());
fprintf (stderr, "All tests passed\n");
- return bonobo_debug_shutdown ();
+ if (g_getenv ("_MEMPROF_SOCKET")) {
+ fprintf (stderr, "Waiting for memprof\n");
+ gtk_main ();
+ }
+
+ putenv ("AT_BRIDGE_SHUTDOWN=1");
+
+ return 0;
}