mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 01:58:01 +02:00
test: keep the announced interface as local variable
This will be more prominent as we add new interface versions and hooking it up via the right signals is better than analyzing the calllog. Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/317>
This commit is contained in:
parent
0cf12a889d
commit
c169ac63b8
1 changed files with 18 additions and 22 deletions
|
|
@ -126,6 +126,7 @@ class Ei:
|
|||
sock: socket.socket = attr.ib()
|
||||
context: Context = attr.ib()
|
||||
connection: Optional[EiConnection] = attr.ib(default=None)
|
||||
interface_versions: dict[str, int] = attr.ib(init=False, default=attr.Factory(dict))
|
||||
seats: list[EiSeat] = attr.ib(init=False, default=attr.Factory(list))
|
||||
object_ids: Generator[int, None, None] = attr.ib(
|
||||
init=False, default=attr.Factory(lambda: itertools.count(3))
|
||||
|
|
@ -167,9 +168,19 @@ class Ei:
|
|||
self.send(setup.HandshakeVersion(VERSION_V(1)))
|
||||
self.send(setup.ContextType(EiHandshake.EiContextType.SENDER))
|
||||
self.send(setup.Name("test client"))
|
||||
|
||||
def on_interface_version(_, name, version):
|
||||
logger.debug(f"Interface {name} v{version}")
|
||||
assert version <= self.interface_versions[name]
|
||||
self.interface_versions[name] = version
|
||||
|
||||
self.handshake.connect("InterfaceVersion", on_interface_version)
|
||||
|
||||
for iname in filter(lambda i: i != InterfaceName.EI_HANDSHAKE, InterfaceName):
|
||||
version = interface_versions.get(iname, VERSION_V(1))
|
||||
self.interface_versions[iname] = version
|
||||
self.send(setup.InterfaceVersion(iname, version))
|
||||
|
||||
self.send(setup.Finish())
|
||||
self.dispatch()
|
||||
|
||||
|
|
@ -397,23 +408,16 @@ class TestEiProtocol:
|
|||
ei = eis.ei
|
||||
ei.dispatch()
|
||||
|
||||
setup = ei.handshake
|
||||
|
||||
ei.init_default_sender_connection()
|
||||
ei.dispatch()
|
||||
ei.wait_for_connection()
|
||||
|
||||
announced_interfaces = []
|
||||
|
||||
for call in setup.calllog:
|
||||
if call.name == "InterfaceVersion":
|
||||
announced_interfaces.append((call.args["name"], call.args["version"]))
|
||||
|
||||
assert (InterfaceName.EI_CALLBACK, VERSION_V(1)) in announced_interfaces
|
||||
assert ei.interface_versions[InterfaceName.EI_CALLBACK] == VERSION_V(1)
|
||||
|
||||
# Right now all our versions are 1, so let's ensure that's true
|
||||
for _, version in announced_interfaces:
|
||||
assert version == VERSION_V(1)
|
||||
for name, version in ei.interface_versions.items():
|
||||
print(name, version)
|
||||
assert version == VERSION_V(1), f"For interface {name}"
|
||||
|
||||
eis.terminate()
|
||||
|
||||
|
|
@ -421,8 +425,6 @@ class TestEiProtocol:
|
|||
ei = eis.ei
|
||||
ei.dispatch()
|
||||
|
||||
setup = ei.handshake
|
||||
|
||||
# Assign a random high number of the interfaces we claim to support
|
||||
interface_versions: dict[str, int] = {
|
||||
iface.name: idx + 3
|
||||
|
|
@ -434,17 +436,11 @@ class TestEiProtocol:
|
|||
ei.dispatch()
|
||||
ei.wait_for_connection()
|
||||
|
||||
announced_interfaces = []
|
||||
|
||||
for call in setup.calllog:
|
||||
if call.name == "InterfaceVersion":
|
||||
announced_interfaces.append((call.args["name"], call.args["version"]))
|
||||
|
||||
assert (InterfaceName.EI_CALLBACK, VERSION_V(1)) in announced_interfaces
|
||||
assert ei.interface_versions[InterfaceName.EI_CALLBACK] == VERSION_V(1)
|
||||
|
||||
# Right now all our EIS versions are 1, despite whatever we announce
|
||||
for _, version in announced_interfaces:
|
||||
assert version == VERSION_V(1)
|
||||
for name, version in ei.interface_versions.items():
|
||||
assert version == VERSION_V(1), f"For interface {name}"
|
||||
|
||||
eis.terminate()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue