From 8372af9cd70e156fe122a51a19528d9001fd5a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 10 Dec 2021 23:39:50 +0100 Subject: [PATCH] tests/mock/logind: Add mock seat and session Will be needed for KMS testing in KVM. Part-of: --- src/tests/meta-dbus-runner.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/tests/meta-dbus-runner.py b/src/tests/meta-dbus-runner.py index 5663fce10..69daa0af2 100755 --- a/src/tests/meta-dbus-runner.py +++ b/src/tests/meta-dbus-runner.py @@ -5,6 +5,7 @@ import sys import os import fcntl import subprocess +import getpass from collections import OrderedDict from dbusmock import DBusTestCase from dbus.mainloop.glib import DBusGMainLoop @@ -39,12 +40,14 @@ class MutterDBusTestCase(DBusTestCase): (klass.mocks_manager, klass.mock_obj) = klass.start_from_local_template( 'meta-mocks-manager', {'templates-dir': get_templates_dir()}) - klass.start_from_template('logind') + logind = klass.start_from_template('logind') klass.start_from_local_template('localed') klass.system_bus_con = klass.get_dbus(system_bus=True) klass.session_bus_con = klass.get_dbus(system_bus=False) + klass.add_logind_session(logind) + if klass.session_bus_con.name_has_owner('org.gnome.Mutter.DisplayConfig'): raise Exception( 'org.gnome.Mutter.DisplayConfig already has owner on the session bus, bailing') @@ -101,6 +104,15 @@ class MutterDBusTestCase(DBusTestCase): assert klass.mocks.setdefault(mock_class, mocks) == mocks return mocks + @classmethod + def add_logind_session(klass, logind): + [p_mock, obj] = logind + mock_iface = 'org.freedesktop.DBus.Mock' + obj.AddSeat('seat0', dbus_interface=mock_iface) + obj.AddSession('dummy', 'seat0', + dbus.types.UInt32(os.getuid()), getpass.getuser(), + True, dbus_interface=mock_iface) + def wrap_call(self, args): env = {} env.update(os.environ)