tests/dbus-runner: Add mocked screensaver service

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3234>
This commit is contained in:
Jonas Ådahl 2023-09-01 23:31:32 +02:00 committed by Marge Bot
parent 4a600e1031
commit 10d8c5fa82
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,35 @@
'''org.freedesktop.Screensaver proxy mock template
'''
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
# of the license.
__author__ = 'Jonas Ådahl'
__copyright__ = '(c) 2023 Red Hat Inc.'
import dbus
import os
import random
from dbusmock import MOCK_IFACE
BUS_NAME = 'org.freedesktop.Screensaver'
MAIN_OBJ = '/org/freedesktop/Screensaver'
MAIN_IFACE = BUS_NAME
SYSTEM_BUS = False
def load(mock, parameters=None):
pass
@dbus.service.method(MAIN_IFACE, in_signature='ss', out_signature='u')
def Inhibit(self, application_name, reason):
return random.randint(0, 10000)
@dbus.service.method(MAIN_IFACE, in_signature='u')
def Uninhibit(self, cookie):
pass

View File

@ -49,6 +49,7 @@ class MutterDBusRunner(DBusTestCase):
klass.start_from_local_template('colord')
klass.start_from_local_template('gsd-color')
klass.start_from_local_template('rtkit')
klass.start_from_local_template('screensaver')
klass.system_bus_con = klass.get_dbus(system_bus=True)
klass.session_bus_con = klass.get_dbus(system_bus=False)