2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility)
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
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 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #include "atk_test_util.h"
28 static void assert_clean_exit (int sig)
30 kill (child_pid, SIGTERM);
33 void clean_exit_on_fail ()
35 signal (SIGABRT, assert_clean_exit);
39 run_app (const char *file_name)
43 execlp (TESTS_BUILD_DIR "/app-test",
44 TESTS_BUILD_DIR "/app-test",
50 if (child_pid) fprintf(stderr, "child_pid %d\n", child_pid);
53 static AtspiAccessible *try_get_root_obj (AtspiAccessible *obj)
57 gint child_count = atspi_accessible_get_child_count (obj, NULL);
58 if (child_count < 1) {
62 for (i=0; i<child_count; i++) {
63 AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,i, NULL);
64 if (child && !strcmp (atspi_accessible_get_name (child, NULL), "root_object"))
71 AtspiAccessible * get_root_obj (const char *file_name)
74 AtspiAccessible *child;
75 struct timespec timeout = { .tv_sec = 0, .tv_nsec = 10 * 1000000 };
76 AtspiAccessible *obj = NULL;
78 fprintf(stderr, "run_app: %s\n", file_name);
81 obj = atspi_get_desktop (0);
83 /* Wait for application to start, up to 100 times 10ms. */
84 while (++tries <= 100)
86 child = try_get_root_obj (obj);
90 nanosleep(&timeout, NULL);
93 if (atspi_accessible_get_child_count (obj, NULL) < 1) {
94 g_test_message ("Fail, test application not found\n");
96 g_test_message ("test object not found\n");
99 kill (child_pid, SIGTERM);
103 void terminate_app (void)
107 AtspiAccessible *child;
108 struct timespec timeout = { .tv_sec = 0, .tv_nsec = 10 * 1000000 };
109 AtspiAccessible *obj = NULL;
111 kill (child_pid, SIGTERM);
113 obj = atspi_get_desktop (0);
115 /* Wait for application to stop, up to 100 times 10ms. */
116 while (++tries <= 100)
118 child = try_get_root_obj (obj);
122 nanosleep(&timeout, NULL);
125 g_test_message ("Fail, test application still running\n");