diff options
author | Mike Gorse <mgorse@suse.com> | 2019-08-26 20:27:39 +0000 |
---|---|---|
committer | Mike Gorse <mgorse@suse.com> | 2019-08-26 20:27:39 +0000 |
commit | eb5fbf7d9f3dff1fe014fe03d347d61b4f964d2f (patch) | |
tree | f4657cda85a6a7a38f1e0e19e5737db6255620fb /tests | |
parent | e032abac5cc3406965ccbe9b7ff274c54aaa316b (diff) | |
parent | c633a9d18495910ff9fc57b192779b486ec640b2 (diff) | |
download | at-spi2-atk-eb5fbf7d9f3dff1fe014fe03d347d61b4f964d2f.tar.gz |
Merge branch 'tests' into 'master'
tests: Fix running atk-test
See merge request GNOME/at-spi2-atk!9
Diffstat (limited to 'tests')
-rw-r--r-- | tests/atk_test_accessible.c | 2 | ||||
-rw-r--r-- | tests/atk_test_action.c | 2 | ||||
-rw-r--r-- | tests/atk_test_collection.c | 2 | ||||
-rw-r--r-- | tests/atk_test_component.c | 2 | ||||
-rw-r--r-- | tests/atk_test_document.c | 2 | ||||
-rw-r--r-- | tests/atk_test_editable_text.c | 2 | ||||
-rw-r--r-- | tests/atk_test_hyperlink.c | 2 | ||||
-rw-r--r-- | tests/atk_test_hypertext.c | 2 | ||||
-rw-r--r-- | tests/atk_test_image.c | 2 | ||||
-rw-r--r-- | tests/atk_test_selection.c | 2 | ||||
-rw-r--r-- | tests/atk_test_state_set.c | 2 | ||||
-rw-r--r-- | tests/atk_test_table.c | 2 | ||||
-rw-r--r-- | tests/atk_test_table_cell.c | 2 | ||||
-rw-r--r-- | tests/atk_test_text.c | 2 | ||||
-rw-r--r-- | tests/atk_test_util.c | 76 | ||||
-rw-r--r-- | tests/atk_test_util.h | 1 | ||||
-rw-r--r-- | tests/atk_test_value.c | 10 | ||||
-rw-r--r-- | tests/data/test-value.xml | 2 | ||||
-rw-r--r-- | tests/meson.build | 9 |
19 files changed, 89 insertions, 37 deletions
diff --git a/tests/atk_test_accessible.c b/tests/atk_test_accessible.c index 1028739..89d1575 100644 --- a/tests/atk_test_accessible.c +++ b/tests/atk_test_accessible.c @@ -28,7 +28,7 @@ static void teardown_accessible_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_action.c b/tests/atk_test_action.c index fa79d1e..2c6a378 100644 --- a/tests/atk_test_action.c +++ b/tests/atk_test_action.c @@ -28,7 +28,7 @@ static void teardown_action_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_collection.c b/tests/atk_test_collection.c index 9ac69d7..219113a 100644 --- a/tests/atk_test_collection.c +++ b/tests/atk_test_collection.c @@ -29,7 +29,7 @@ static void teardown_collection_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_component.c b/tests/atk_test_component.c index f3ea30b..2aa4457 100644 --- a/tests/atk_test_component.c +++ b/tests/atk_test_component.c @@ -28,7 +28,7 @@ static void teardown_component_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_document.c b/tests/atk_test_document.c index 4a2342d..12fa5c7 100644 --- a/tests/atk_test_document.c +++ b/tests/atk_test_document.c @@ -28,7 +28,7 @@ static void teardown_document_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_editable_text.c b/tests/atk_test_editable_text.c index e0c0701..e529df5 100644 --- a/tests/atk_test_editable_text.c +++ b/tests/atk_test_editable_text.c @@ -28,7 +28,7 @@ static void teardown_editable_text_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_hyperlink.c b/tests/atk_test_hyperlink.c index b0b2821..b6e2c01 100644 --- a/tests/atk_test_hyperlink.c +++ b/tests/atk_test_hyperlink.c @@ -142,7 +142,7 @@ atk_test_hyperlink_is_valid (gpointer fixture, gconstpointer user_data) static void teardown_hyperlink_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } void diff --git a/tests/atk_test_hypertext.c b/tests/atk_test_hypertext.c index 4696a06..a316874 100644 --- a/tests/atk_test_hypertext.c +++ b/tests/atk_test_hypertext.c @@ -80,7 +80,7 @@ atk_test_hypertext_get_link_index (gpointer fixture, gconstpointer user_data) static void teardown_hypertext_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } void diff --git a/tests/atk_test_image.c b/tests/atk_test_image.c index ce3bc3e..71d5af7 100644 --- a/tests/atk_test_image.c +++ b/tests/atk_test_image.c @@ -28,7 +28,7 @@ static void teardown_image_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_selection.c b/tests/atk_test_selection.c index 1f89b57..8a60ee6 100644 --- a/tests/atk_test_selection.c +++ b/tests/atk_test_selection.c @@ -28,7 +28,7 @@ static void teardown_selection_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_state_set.c b/tests/atk_test_state_set.c index ea0e9ce..f895c68 100644 --- a/tests/atk_test_state_set.c +++ b/tests/atk_test_state_set.c @@ -28,7 +28,7 @@ static void teardown_state_set_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } static void diff --git a/tests/atk_test_table.c b/tests/atk_test_table.c index e22db4c..c0330ed 100644 --- a/tests/atk_test_table.c +++ b/tests/atk_test_table.c @@ -417,7 +417,7 @@ atk_test_table_is_selected (gpointer fixture, gconstpointer user_data) static void teardown_table_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } void diff --git a/tests/atk_test_table_cell.c b/tests/atk_test_table_cell.c index 6b629b8..d3051ee 100644 --- a/tests/atk_test_table_cell.c +++ b/tests/atk_test_table_cell.c @@ -181,7 +181,7 @@ atk_test_table_cell_get_table (gpointer fixture, gconstpointer user_data) static void teardown_table_cell_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } void diff --git a/tests/atk_test_text.c b/tests/atk_test_text.c index b9e29dc..14a33dd 100644 --- a/tests/atk_test_text.c +++ b/tests/atk_test_text.c @@ -432,7 +432,7 @@ atk_test_text_get_bounded_ranges (gpointer fixture, gconstpointer user_data) static void teardown_text_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } void diff --git a/tests/atk_test_util.c b/tests/atk_test_util.c index c776ae1..c932df8 100644 --- a/tests/atk_test_util.c +++ b/tests/atk_test_util.c @@ -38,8 +38,8 @@ run_app (const char *file_name) { child_pid = fork (); if (child_pid == 0) { - execlp ("./app-test", - "./app-test", + execlp (TESTS_BUILD_DIR "/app-test", + TESTS_BUILD_DIR "/app-test", "--test-data-file", file_name, NULL); @@ -47,33 +47,77 @@ run_app (const char *file_name) } } -AtspiAccessible * get_root_obj (const char *file_name) +static AtspiAccessible *try_get_root_obj (AtspiAccessible *obj) { int i; - AtspiAccessible *obj = NULL; - - run_app (file_name); - - /* sleep is needed to wait for fored test application*/ - sleep (1); - obj = atspi_get_desktop (0); gint child_count = atspi_accessible_get_child_count (obj, NULL); if (child_count < 1) { - g_test_message ("Fail, test application not found\n"); - g_test_fail (); - kill (child_pid, SIGTERM); return NULL; } for (i=0; i<child_count; i++) { AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,i, NULL); - if (!strcmp (atspi_accessible_get_name (child, NULL), "root_object")) + if (child && !strcmp (atspi_accessible_get_name (child, NULL), "root_object")) return child; } - g_test_message ("test object not found\n"); - g_test_fail (); + return NULL; +} + +AtspiAccessible * get_root_obj (const char *file_name) +{ + int tries = 0; + AtspiAccessible *child; + struct timespec timeout = { .tv_sec = 0, .tv_nsec = 10 * 1000000 }; + AtspiAccessible *obj = NULL; + + run_app (file_name); + + obj = atspi_get_desktop (0); + + /* Wait for application to start, up to 100 times 10ms. */ + while (++tries <= 100) + { + child = try_get_root_obj (obj); + if (child) + return child; + + nanosleep(&timeout, NULL); + } + + if (atspi_accessible_get_child_count (obj, NULL) < 1) { + g_test_message ("Fail, test application not found\n"); + } else { + g_test_message ("test object not found\n"); + } + g_test_fail (); kill (child_pid, SIGTERM); return NULL; } + +void terminate_app (void) +{ + int tries = 0; + + AtspiAccessible *child; + struct timespec timeout = { .tv_sec = 0, .tv_nsec = 10 * 1000000 }; + AtspiAccessible *obj = NULL; + + kill (child_pid, SIGTERM); + + obj = atspi_get_desktop (0); + + /* Wait for application to stop, up to 100 times 10ms. */ + while (++tries <= 100) + { + child = try_get_root_obj (obj); + if (child == NULL) + return; + + nanosleep(&timeout, NULL); + } + + g_test_message ("Fail, test application still running\n"); + g_test_fail (); +} diff --git a/tests/atk_test_util.h b/tests/atk_test_util.h index b2376d5..9fb7480 100644 --- a/tests/atk_test_util.h +++ b/tests/atk_test_util.h @@ -40,6 +40,7 @@ pid_t child_pid; void run_app (const char *file_name); AtspiAccessible *get_root_obj (const char *file_name); +void terminate_app (void); void clean_exit_on_fail (); #endif /* _ATK_TEST_UTIL_H */ diff --git a/tests/atk_test_value.c b/tests/atk_test_value.c index c5f2c06..0911603 100644 --- a/tests/atk_test_value.c +++ b/tests/atk_test_value.c @@ -43,7 +43,7 @@ atk_test_value_get_minimum_value (gpointer fixture, gconstpointer user_data) g_assert (child); AtspiValue *obj = atspi_accessible_get_value_iface (child); gdouble val = atspi_value_get_minimum_value (obj, NULL); - g_assert_cmpfloat (val, ==, 1.1); + g_assert_cmpfloat (val, ==, 1.25); } static void @@ -55,7 +55,7 @@ atk_test_value_get_current_value (gpointer fixture, gconstpointer user_data) g_assert (child); AtspiValue *obj = atspi_accessible_get_value_iface (child); gdouble val = atspi_value_get_current_value (obj, NULL); - g_assert_cmpfloat (val, ==, 2.1); + g_assert_cmpfloat (val, ==, 2.25); } static void @@ -67,7 +67,7 @@ atk_test_value_get_maximum_value (gpointer fixture, gconstpointer user_data) g_assert (child); AtspiValue *obj = atspi_accessible_get_value_iface (child); gdouble val = atspi_value_get_maximum_value (obj, NULL); - g_assert_cmpfloat (val, ==, 3.1); + g_assert_cmpfloat (val, ==, 3.25); } static void @@ -92,13 +92,13 @@ atk_test_value_get_minimum_increment (gpointer fixture, gconstpointer user_data) g_assert (child); AtspiValue *obj = atspi_accessible_get_value_iface (child); gdouble val = atspi_value_get_minimum_increment (obj, NULL); - g_assert_cmpfloat (val, ==, 0.1); + g_assert_cmpfloat (val, ==, 0.25); } static void teardown_value_test (gpointer fixture, gconstpointer user_data) { - kill (child_pid, SIGTERM); + terminate_app (); } void diff --git a/tests/data/test-value.xml b/tests/data/test-value.xml index 83172d5..1f5ae6c 100644 --- a/tests/data/test-value.xml +++ b/tests/data/test-value.xml @@ -1,6 +1,6 @@ <?xml version="1.0" ?> <accessible description="Root of the accessible tree" name="root_object" role="accelerator label"> <accessible_value description="first child" name="obj0" role="alert"> - <value_node min="1.1" current="2.1" max="3.1" step="0.1"/> + <value_node min="1.25" current="2.25" max="3.25" step="0.25"/> </accessible_value> </accessible> diff --git a/tests/meson.build b/tests/meson.build index 8bb9b8a..64ed994 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -7,7 +7,8 @@ xmlloader_dep = declare_dependency(link_with: xmlloader) testutils = static_library('testutils', [ 'atk_test_util.c' ], dependencies: [ glib_dep, atspi_dep ], - include_directories: [ root_inc, include_directories('.') ]) + include_directories: [ root_inc, include_directories('.') ], + c_args: ['-DTESTS_BUILD_DIR="@0@"'.format(meson.current_build_dir()) ] ) testutils_dep = declare_dependency(link_with: testutils) # tests: @@ -72,4 +73,10 @@ foreach t: tests '-DTESTS_SRC_DIR="@0@"'.format(meson.current_source_dir()), '-DTESTS_DATA_DIR="@0@"'.format(join_paths(meson.current_source_dir(), 'data')), ]) + + if test_name == 'atk-test' + atk_test_bin = test_bin + endif endforeach + +test('atk-test', atk_test_bin, timeout: 120) |