*** empty log message ***
[platform/core/uifw/at-spi2-atk.git] / test / test-simple.c
index 279e53c..b85e2a9 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <locale.h>
 #include <gtk/gtk.h>
 #include <cspi/spi.h>
 #include <libbonobo.h>
@@ -41,6 +42,7 @@ 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;
@@ -105,6 +107,7 @@ create_test_window (void)
 {
        TestWindow *win = g_new0 (TestWindow, 1);
        GtkWidget  *widget, *vbox;
+       AtkObject *obj;
 
        win->magic  = WINDOW_MAGIC;
        win->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -117,6 +120,9 @@ create_test_window (void)
 
        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");
@@ -129,7 +135,7 @@ create_test_window (void)
                                           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);
 
@@ -157,8 +163,8 @@ test_roles (void)
        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"));
 }
@@ -228,6 +234,10 @@ test_application (Accessible *application)
        g_assert (!strcmp (str, "GAIL"));
        SPI_freeString (str);
 
+       str = AccessibleApplication_getLocale (application, LC_MESSAGES);
+       g_assert (!strcmp (str, setlocale (LC_MESSAGES, NULL)));
+        SPI_freeString (str);
+
        str = AccessibleApplication_getVersion (application);
        g_assert (str != NULL);
        SPI_freeString (str);
@@ -600,8 +610,10 @@ validate_accessible (Accessible *accessible,
                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);
        }
 
@@ -661,8 +673,10 @@ global_listener_cb (const AccessibleEvent *event,
                AccessibleApplication_unref (application);
                
                print_tree = FALSE;
+
                validate_accessible (event->source, TRUE, TRUE);
 
+               fprintf (stderr, "quitting mainloop.\n");
                gtk_main_quit ();
        }
 
@@ -678,8 +692,10 @@ key_listener_cb (const AccessibleKeystroke *stroke,
        
        *s = *stroke;
        
-       if (s->type == SPI_KEY_PRESSED) key_press_received = TRUE;
-       else if (s->type == SPI_KEY_RELEASED) key_release_received = TRUE;
+       if (s->type == SPI_KEY_PRESSED)
+               key_press_received = TRUE;
+       else if (s->type == SPI_KEY_RELEASED)
+               key_release_received = TRUE;
        
        return TRUE;
 }
@@ -699,7 +715,7 @@ test_keylisteners (void)
                key_listener_cb, &stroke);
 
        test_keyset = SPI_createAccessibleKeySet (1, "=", NULL, NULL);
-       
+
        g_assert (SPI_registerAccessibleKeystrokeListener (
                key_listener,
                test_keyset,
@@ -765,6 +781,7 @@ main (int argc, char **argv)
        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");
@@ -778,7 +795,7 @@ main (int argc, char **argv)
        /* 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);