diff options
author | Federico Mena Quintero <federico@gnome.org> | 2022-12-07 00:26:16 +0000 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2022-12-07 00:26:16 +0000 |
commit | 214b28a483f55b6aaf8228499d544627cbbff0ed (patch) | |
tree | 362a5f57f655af243e7722a1183507794885eb21 | |
parent | e925d0feb9cb18b144f4a454774da83629d07355 (diff) | |
parent | 7c4d8087f55d99e9b963c8270ed22acd3ecceb75 (diff) | |
download | at-spi2-core-214b28a483f55b6aaf8228499d544627cbbff0ed.tar.gz |
Merge branch 'registry-test-coverage' into 'main'
A little more test coverage for registry.c
See merge request GNOME/at-spi2-core!118
-rw-r--r-- | registryd/deviceeventcontroller-x11.c | 2 | ||||
-rw-r--r-- | registryd/deviceeventcontroller-x11.h | 7 | ||||
-rw-r--r-- | registryd/deviceeventcontroller.c | 5 | ||||
-rw-r--r-- | registryd/deviceeventcontroller.h | 10 | ||||
-rw-r--r-- | tests/registryd/conftest.py | 7 | ||||
-rw-r--r-- | tests/registryd/test_introspection.py | 38 | ||||
-rw-r--r-- | tests/registryd/test_root.py | 7 | ||||
-rw-r--r-- | tests/registryd/test_root_introspectable.py | 20 |
8 files changed, 60 insertions, 36 deletions
diff --git a/registryd/deviceeventcontroller-x11.c b/registryd/deviceeventcontroller-x11.c index bf984d4a..689191f7 100644 --- a/registryd/deviceeventcontroller-x11.c +++ b/registryd/deviceeventcontroller-x11.c @@ -49,8 +49,8 @@ #include "display.h" #include "event-source.h" -#include "deviceeventcontroller-x11.h" #include "deviceeventcontroller.h" +#include "deviceeventcontroller-x11.h" #include "reentrant-list.h" static void spi_dec_x11_emit_modifier_event (SpiDEController *controller, diff --git a/registryd/deviceeventcontroller-x11.h b/registryd/deviceeventcontroller-x11.h index 62e29843..e66799e4 100644 --- a/registryd/deviceeventcontroller-x11.h +++ b/registryd/deviceeventcontroller-x11.h @@ -25,4 +25,11 @@ typedef struct { guint reserved_reset_timeout; } SpiDEControllerPrivate; +#ifdef HAVE_X11 +void spi_dec_setup_x11 (SpiDEControllerClass *klass); +#endif + +long ucs2keysym (long ucs); +long keysym2ucs(long keysym); + #endif /* _DEVICEEVENTCONTROLLER_X11_H_ */ diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index 57b19f55..c5d7b9c5 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -49,13 +49,8 @@ #ifdef HAVE_X11 #include "deviceeventcontroller-x11.h" -#include "display.h" -#include "event-source.h" #endif -#define CHECK_RELEASE_DELAY 20 -#define BIT(c, x) (c[x/8]&(1<<(x%8))) - /* Our parent Gtk object type */ #define PARENT_TYPE G_TYPE_OBJECT diff --git a/registryd/deviceeventcontroller.h b/registryd/deviceeventcontroller.h index e7f00670..a080a13e 100644 --- a/registryd/deviceeventcontroller.h +++ b/registryd/deviceeventcontroller.h @@ -24,9 +24,6 @@ #ifndef SPI_DEVICE_EVENT_CONTROLLER_H_ #define SPI_DEVICE_EVENT_CONTROLLER_H_ -#ifdef HAVE_X11 -#include <X11/Xlib.h> -#endif #include <dbus/dbus.h> typedef struct _SpiDEController SpiDEController; @@ -159,13 +156,6 @@ gboolean spi_dec_synth_keysym (SpiDEController *controller, long keysym); void spi_dec_dbus_emit(SpiDEController *controller, const char *interface, const char *name, const char *minor, int a1, int a2); -#ifdef HAVE_X11 -void spi_dec_setup_x11 (SpiDEControllerClass *klass); -#endif - -long ucs2keysym (long ucs); -long keysym2ucs(long keysym); - G_END_DECLS #endif /* DEVICEEVENTCONTROLLER_H_ */ diff --git a/tests/registryd/conftest.py b/tests/registryd/conftest.py index 9ce267d9..6bb7d3c9 100644 --- a/tests/registryd/conftest.py +++ b/tests/registryd/conftest.py @@ -79,3 +79,10 @@ def registry_root(main_loop, session_manager): a11y_bus = dbus.bus.BusConnection(a11y_address) return a11y_bus.get_object('org.a11y.atspi.Registry', '/org/a11y/atspi/accessible/root') + +@pytest.fixture +def registry_registry(main_loop, session_manager): + a11y_address = get_accesssibility_bus_address() + a11y_bus = dbus.bus.BusConnection(a11y_address) + + return a11y_bus.get_object('org.a11y.atspi.Registry', '/org/a11y/atspi/registry') diff --git a/tests/registryd/test_introspection.py b/tests/registryd/test_introspection.py new file mode 100644 index 00000000..8cd70525 --- /dev/null +++ b/tests/registryd/test_introspection.py @@ -0,0 +1,38 @@ +import pytest +import dbus +import xml.etree.ElementTree as ElementTree + +INTROSPECTABLE_IFACE = 'org.freedesktop.DBus.Introspectable' + +# obj: a dbus proxy object to introspect +# expected_ifaces: sequence of interface names as strings +def check_object_supports_interfaces(obj, expected_ifaces): + xml_str = str(obj.Introspect(dbus_interface=INTROSPECTABLE_IFACE)) + root = ElementTree.fromstring(xml_str) + assert root.tag == 'node' + + interface_elements = root.findall('./interface') + iface_names = map(lambda e: e.attrib['name'], interface_elements) + iface_names = list(iface_names) + iface_names.sort() + + expected_ifaces.sort() + + assert iface_names == expected_ifaces + +# Test that the root object at /org/a11y/atspi/accessible/root advertises the correct interfaces +def test_introspect_root(registry_root, session_manager): + check_object_supports_interfaces( + registry_root, + ['org.a11y.atspi.Accessible', + 'org.a11y.atspi.Component', + 'org.a11y.atspi.Socket', + ] + ) + +# Test that the registry object at /org/a11y/atspi/registry advertises the correct interfaces +def test_introspect_registry(registry_registry, session_manager): + check_object_supports_interfaces( + registry_registry, + ['org.a11y.atspi.Registry'] + ) diff --git a/tests/registryd/test_root.py b/tests/registryd/test_root.py new file mode 100644 index 00000000..d4eff51d --- /dev/null +++ b/tests/registryd/test_root.py @@ -0,0 +1,7 @@ +import pytest +import dbus + +from utils import check_unknown_property_yields_error + +def test_root_property_on_invalid_interface(registry_root, session_manager): + check_unknown_property_yields_error(registry_root, 'this.is.not.a.supported.interface') diff --git a/tests/registryd/test_root_introspectable.py b/tests/registryd/test_root_introspectable.py deleted file mode 100644 index 64845630..00000000 --- a/tests/registryd/test_root_introspectable.py +++ /dev/null @@ -1,20 +0,0 @@ -import pytest -import dbus -import xml.etree.ElementTree as ElementTree - -INTROSPECTABLE_IFACE = 'org.freedesktop.DBus.Introspectable' - -def test_introspect(registry_root, session_manager): - xml_str = str(registry_root.Introspect(dbus_interface=INTROSPECTABLE_IFACE)) - root = ElementTree.fromstring(xml_str) - assert root.tag == 'node' - - interface_elements = root.findall('./interface') - iface_names = map(lambda e: e.attrib['name'], interface_elements) - iface_names = list(iface_names) - iface_names.sort() - - assert iface_names == ['org.a11y.atspi.Accessible', - 'org.a11y.atspi.Component', - 'org.a11y.atspi.Socket', - ] |