mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-08 21:00:15 +01:00
test: ensure all returned interface versions are 1
Even where our client pretends to have higher interface versions, we always send back version 1 from the EIS implementation. This test probably won't really trigger anything useful until we switch to version 2 somewhere, so let's hope the code works...
This commit is contained in:
parent
97a5538258
commit
39e6c93c8b
1 changed files with 41 additions and 3 deletions
|
|
@ -160,13 +160,16 @@ class Ei:
|
|||
assert isinstance(setup, EiHandshake)
|
||||
return setup
|
||||
|
||||
def init_default_sender_connection(self) -> None:
|
||||
def init_default_sender_connection(
|
||||
self, interface_versions: dict[str, int] = {}
|
||||
) -> None:
|
||||
setup = self.handshake
|
||||
self.send(setup.HandshakeVersion(VERSION_V(1)))
|
||||
self.send(setup.ContextType(EiHandshake.EiContextType.SENDER))
|
||||
self.send(setup.Name("test client"))
|
||||
for iname in filter(lambda i: i != InterfaceName.EI_HANDSHAKE, InterfaceName):
|
||||
self.send(setup.InterfaceVersion(iname, VERSION_V(1)))
|
||||
version = interface_versions.get(iname, VERSION_V(1))
|
||||
self.send(setup.InterfaceVersion(iname, version))
|
||||
self.send(setup.Finish())
|
||||
self.dispatch()
|
||||
|
||||
|
|
@ -406,7 +409,42 @@ class TestEiProtocol:
|
|||
if call.name == "InterfaceVersion":
|
||||
announced_interfaces.append((call.args["name"], call.args["version"]))
|
||||
|
||||
assert (InterfaceName.EI_CALLBACK, 1) in announced_interfaces
|
||||
assert (InterfaceName.EI_CALLBACK, VERSION_V(1)) in announced_interfaces
|
||||
|
||||
# Right now all our versions are 1, so let's ensure that's true
|
||||
for _, version in announced_interfaces:
|
||||
assert version == VERSION_V(1)
|
||||
|
||||
eis.terminate()
|
||||
|
||||
def test_server_sends_min_interface_version(self, eis):
|
||||
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
|
||||
for idx, iface in enumerate(InterfaceName)
|
||||
if iface != InterfaceName.EI_HANDSHAKE
|
||||
}
|
||||
|
||||
ei.init_default_sender_connection(interface_versions=interface_versions)
|
||||
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
|
||||
|
||||
# Right now all our EIS versions are 1, despite whatever we announce
|
||||
for _, version in announced_interfaces:
|
||||
assert version == VERSION_V(1)
|
||||
|
||||
eis.terminate()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue