fdc0f8ec0ba83a8b9090236935cb9506d090dc05
[platform/core/uifw/at-spi2-atk.git] / test / stress-test.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <stdlib.h>
24 #include "../cspi/spi-private.h" /* A hack for now */
25 #include <glib-object.h>
26 #include <gtk/gtk.h>
27 #include <atk/atk.h>
28 #include <atk/atknoopobject.h>
29 #include <bonobo-activation/bonobo-activation-register.h>
30 #include <libspi.h>
31
32 int
33 main (int argc, char **argv)
34 {
35         int i;
36         Accessibility_Event e;
37         Accessibility_Registry registry;
38         CORBA_Environment ev;
39         SpiAccessible *source;
40         GObject *object;
41         AtkObject *atko;
42         GTimer *timer;
43         gdouble elapsed_time;
44
45         gtk_init (&argc, &argv);
46         SPI_init ();
47         object = g_object_new (GTK_TYPE_BUTTON, NULL);
48         atko = atk_no_op_object_new (object);
49
50         sleep (1);
51
52         g_print ("starting stress test...\n");
53
54         CORBA_exception_init (&ev);
55         
56         registry = bonobo_activation_activate_from_id (
57                 "OAFIID:Accessibility_Registry:1.0", 0, NULL, &ev);
58   
59   if (ev._major != CORBA_NO_EXCEPTION)
60     {
61       g_error ("Accessibility app error: exception during "
62                "registry activation from id: %s\n",
63                CORBA_exception_id (&ev));
64       CORBA_exception_free (&ev);
65     }
66
67   if (registry == CORBA_OBJECT_NIL)
68     {
69       g_error ("Could not locate registry");
70     }
71
72         bonobo_activate ();
73
74         source = spi_accessible_new (atko);
75         
76         e.type = "focus:";
77         e.source = BONOBO_OBJREF (source);
78         e.detail1 = 0;
79         e.detail2 = 0;
80
81         timer = g_timer_new ();
82         g_timer_start (timer);
83
84         for (i = 0; i < 10000; ++i) {
85                 Accessibility_Accessible_ref (e.source, &ev);
86                 Accessibility_Registry_notifyEvent (registry, &e, &ev);
87         }
88         g_timer_stop (timer);
89         g_print ("%d notifications sent in  %f sec.\n", i,
90                  g_timer_elapsed (timer, NULL));
91
92         SPI_event_main ();
93
94         sleep (15);
95         
96   return SPI_exit ();
97 }
98