Added LoginHelper interface. Fixed test progs to use proper prefixes on
[platform/core/uifw/at-spi2-atk.git] / test / at.c
index 53ff0cf..aa8e8c6 100644 (file)
--- a/test/at.c
+++ b/test/at.c
@@ -2,7 +2,8 @@
  * AT-SPI - Assistive Technology Service Provider Interface
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include <stdlib.h>
 #include <libbonobo.h>
 #include <libspi/Accessibility.h>
-#include "accessible.h"
-#include "listener.h"
-#include "desktop.h"
+#include <libspi/accessible.h>
+#include <libspi/listener.h>
+
+void
+check_ev (CORBA_Environment *ev, char *desc)
+{
+        if (ev->_major != CORBA_NO_EXCEPTION) {
+                fprintf(stderr,
+                ("Accessibility app error: exception during CORBA call %s (%s)\n"),
+                        CORBA_exception_id(ev), desc);
+                CORBA_exception_free(ev);
+                exit(-1);
+        }
+}
 
 int
 main(int argc, char **argv)
@@ -38,11 +50,11 @@ main(int argc, char **argv)
         CORBA_short n_desktops;
         CORBA_long j;
         CORBA_long n_apps;
+       CORBA_string s;
         Accessibility_Desktop desktop;
         Accessibility_Application app;
-
         Accessibility_Registry registry;
-        Listener *listener;
+        SpiListener *listener;
 
         CORBA_exception_init(&ev);
 
@@ -51,9 +63,9 @@ main(int argc, char **argv)
             g_error ("Could not initialize Bonobo");
           }
 
-        obj_id = "OAFIID:Accessibility_Registry:proto0.1";
+        obj_id = "OAFIID:Accessibility_Registry:1.0";
 
-        oclient = oaf_activate_from_id (obj_id, 0, NULL, &ev);
+        oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
         if (ev._major != CORBA_NO_EXCEPTION) {
                 fprintf(stderr,
                 ("Accessibility app error: exception during registry activation from id: %s\n"),
@@ -69,7 +81,7 @@ main(int argc, char **argv)
 
         bonobo_activate ();
 
-        listener = listener_new ();
+        listener = spi_listener_new ();
 
         registry = (Accessibility_Registry) oclient;
 
@@ -77,26 +89,38 @@ main(int argc, char **argv)
                                    (registry,
                                     (Accessibility_EventListener)
                                          bonobo_object_corba_objref (bonobo_object (listener)),
-                                    "test",
+                                    "focus:",
                                     &ev);
-
+        check_ev (&ev, "register:focus");
+        Accessibility_Registry_registerGlobalEventListener
+                                   (registry,
+                                    (Accessibility_EventListener)
+                                         bonobo_object_corba_objref (bonobo_object (listener)),
+                                    "Gtk:GtkWidget:button-press-event",
+                                    &ev);
+        check_ev (&ev, "register:button_press");
         fprintf (stderr, "AT callback registered.\n");
 
-
             n_desktops = Accessibility_Registry_getDesktopCount (registry, &ev);
 
             for (i=0; i<n_desktops; ++i)
               {
                 desktop = Accessibility_Registry_getDesktop (registry, i, &ev);
-                fprintf (stderr, "desktop %d name: %s\n", i,
-                         Accessibility_Desktop__get_name (desktop, &ev));
+               s = Accessibility_Desktop__get_name (desktop, &ev);
+                fprintf (stderr, "desktop %d name: %s\n", i, s);
+               CORBA_free (s);  
+                check_ev (&ev, "desktop:name");
                 n_apps = Accessibility_Desktop__get_childCount (desktop, &ev);
+                check_ev (&ev, "desktop:childCount");
                 fprintf (stderr, "desktop has %d apps:\n", n_apps);
                 for (j=0; j<n_apps; ++j)
                   {
                     app = (Accessibility_Application) Accessibility_Desktop_getChildAtIndex (desktop, j, &ev);
-                    fprintf (stderr, "app %d name: %s\n", j,
-                             Accessibility_Application__get_name (app, &ev));
+                    check_ev (&ev, "desktop:getChildAtIndex");
+                    s = Accessibility_Application__get_name (app, &ev);
+                   fprintf (stderr, "app %d name: %s\n", j, s);
+                   CORBA_free (s);
+                    check_ev (&ev, "app:getName");
                   }
               }