tests: Add dbus runner
This adds a dbus-runner ala meta-dbus-runner.py. It extends the one used in mutter, and adds various mocked services needed by gnome-shell. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>
This commit is contained in:
parent
65a6ceddca
commit
c628b9f6bc
13
tests/gnome-shell-dbus-runner.py.in
Executable file
13
tests/gnome-shell-dbus-runner.py.in
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(1, '@MUTTER_TEST_PKGDATADIR@')
|
||||
sys.path.insert(2, '@SRCDIR@')
|
||||
|
||||
from mutter_dbusrunner import meta_run
|
||||
from gnomeshell_dbusrunner import GnomeShellDBusRunner
|
||||
|
||||
if __name__ == '__main__':
|
||||
result = meta_run(GnomeShellDBusRunner)
|
||||
sys.exit(result)
|
116
tests/gnomeshell_dbusrunner.py
Normal file
116
tests/gnomeshell_dbusrunner.py
Normal file
@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import dbus
|
||||
import pwd
|
||||
#import dbus.lowlevel
|
||||
import dbusmock
|
||||
|
||||
from mutter_dbusrunner import MutterDBusRunner
|
||||
|
||||
class MockDisplayManager:
|
||||
BUS_NAME = 'org.gnome.DisplayManager'
|
||||
MAIN_OBJ = '/org/gnome/DisplayManager/Manager'
|
||||
MAIN_IFACE = 'org.gnome.DisplayManager.Manager'
|
||||
SYSTEM_BUS = True
|
||||
|
||||
@staticmethod
|
||||
def load(mock, parameters={}):
|
||||
mock.AddMethods(MockDisplayManager.MAIN_IFACE,
|
||||
[('RegisterSession', 'a{sv}', '', '')])
|
||||
|
||||
class MockPermissionStore:
|
||||
BUS_NAME = 'org.freedesktop.impl.portal.PermissionStore'
|
||||
MAIN_OBJ = '/org/freedesktop/impl/portal/PermissionStore'
|
||||
MAIN_IFACE = 'org.freedesktop.impl.portal.PermissionStore'
|
||||
SYSTEM_BUS = False
|
||||
|
||||
@staticmethod
|
||||
def load(mock, parameters={}):
|
||||
mock.AddMethod(MockPermissionStore.MAIN_IFACE, 'Lookup', 'ss', 'a{sas}v',
|
||||
'ret = (dbus.Dictionary([], signature="sas"), dbus.String("NONE", variant_level=2))')
|
||||
|
||||
@staticmethod
|
||||
def lookup_permission(self, table, id):
|
||||
return dbus.Struct([])
|
||||
|
||||
class MockSessionManager:
|
||||
BUS_NAME = 'org.gnome.SessionManager'
|
||||
MAIN_OBJ = '/org/gnome/SessionManager'
|
||||
MAIN_IFACE = 'org.gnome.SessionManager'
|
||||
SYSTEM_BUS = False
|
||||
|
||||
@staticmethod
|
||||
def load(mock, parameters={}):
|
||||
mock.AddMethods(MockSessionManager.MAIN_IFACE,
|
||||
[('Setenv', 'ss', '', '')])
|
||||
|
||||
class MockGeoClue:
|
||||
BUS_NAME = 'org.freedesktop.GeoClue2'
|
||||
MAIN_OBJ = '/org/freedesktop/GeoClue2/Manager'
|
||||
MAIN_IFACE = 'org.freedesktop.GeoClue2.Manager'
|
||||
SYSTEM_BUS = True
|
||||
|
||||
@staticmethod
|
||||
def load(mock, parameters={}):
|
||||
mock.AddMethods(MockGeoClue.MAIN_IFACE,
|
||||
[('AddAgent', 's', '', '')])
|
||||
|
||||
class MockGnomeShellCalendarServer:
|
||||
BUS_NAME = 'org.gnome.Shell.CalendarServer'
|
||||
MAIN_OBJ = '/org/gnome/Shell/CalendarServer'
|
||||
MAIN_IFACE = 'org.gnome.Shell.CalendarServer'
|
||||
SYSTEM_BUS = False
|
||||
|
||||
@staticmethod
|
||||
def load(mock, parameters={}):
|
||||
mock.AddMethods(MockGnomeShellCalendarServer.MAIN_IFACE,
|
||||
[('SetTimeRange', 'xxb', '', '')])
|
||||
|
||||
class MockParentalControls:
|
||||
BUS_NAME = 'com.endlessm.ParentalControls.AccountInfo'
|
||||
MAIN_OBJ = '/com/endlessm/ParentalControls/AccountInfo'
|
||||
MAIN_IFACE = 'com.endlessm.ParentalControls.AccountInfo'
|
||||
SYSTEM_BUS = False
|
||||
|
||||
@staticmethod
|
||||
def load(mock, parameters={}):
|
||||
pass
|
||||
|
||||
|
||||
class GnomeShellDBusRunner(MutterDBusRunner):
|
||||
@classmethod
|
||||
def setUpClass(klass, enable_kvm, launch):
|
||||
MutterDBusRunner.setUpClass(enable_kvm, launch)
|
||||
|
||||
klass.add_template_dir(os.path.join(os.path.dirname(__file__),
|
||||
'dbusmock-templates'))
|
||||
|
||||
systemd_system = klass.start_from_template('systemd', system_bus=True)
|
||||
systemd_user = klass.start_from_template('systemd', system_bus=False)
|
||||
klass.start_from_template('upower')
|
||||
klass.start_from_template('networkmanager')
|
||||
klass.start_from_template('polkitd')
|
||||
klass.start_from_template('power_profiles_daemon')
|
||||
|
||||
accounts_service = klass.start_from_local_template('accounts_service')
|
||||
empty_dict = dbus.Dictionary({}, signature='sv')
|
||||
accounts_service[1].AddUser(os.getuid(),
|
||||
pwd.getpwuid(os.getuid()).pw_name,
|
||||
'',
|
||||
empty_dict)
|
||||
|
||||
klass.start_from_class(MockDisplayManager)
|
||||
klass.start_from_class(MockSessionManager)
|
||||
klass.start_from_class(MockGeoClue)
|
||||
klass.start_from_class(MockPermissionStore)
|
||||
klass.start_from_class(MockParentalControls)
|
||||
klass.start_from_class(MockGnomeShellCalendarServer)
|
||||
|
||||
systemd_mock = dbus.Interface(systemd_user[1], dbusmock.MOCK_IFACE)
|
||||
systemd_mock.AddMockUnit('org.freedesktop.IBus.session.GNOME.service')
|
||||
systemd_mock.AddMockUnit('org.gnome.Shell.CalendarServer.service')
|
||||
|
||||
accounts_service_mock = dbus.Interface(accounts_service[1], dbusmock.MOCK_IFACE)
|
@ -7,6 +7,17 @@ run_test = configure_file(
|
||||
configuration: testconf
|
||||
)
|
||||
|
||||
mutter_tests_datadir = mutter_test_dep.get_variable('tests_datadir')
|
||||
dbusrunnerconf = configuration_data()
|
||||
dbusrunnerconf.set('MUTTER_TEST_PKGDATADIR', mutter_tests_datadir)
|
||||
dbusrunnerconf.set('SRCDIR', meson.current_source_dir())
|
||||
|
||||
dbus_runner = configure_file(
|
||||
input: 'gnome-shell-dbus-runner.py.in',
|
||||
output: 'gnome-shell-dbus-runner.py',
|
||||
configuration: dbusrunnerconf,
|
||||
)
|
||||
|
||||
testenv = environment()
|
||||
testenv.set('GSETTINGS_SCHEMA_DIR', join_paths(meson.project_build_root(), 'data'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user