tests: Run a localed mock implementation on tests

As per this we can just warn if its proxy initialization fails.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
This commit is contained in:
Marco Trevisan (Treviño) 2021-08-26 15:07:47 +02:00 committed by Jonas Ådahl
parent b3c5ca12a5
commit a4223007e2
3 changed files with 55 additions and 2 deletions

View File

@ -396,8 +396,7 @@ init_keymap (MetaDefaultPlugin *self)
&error);
if (!proxy)
{
g_message ("Failed to acquire org.freedesktop.locale1 proxy: %s, "
"probably running in CI",
g_warning ("Failed to acquire org.freedesktop.locale1 proxy: %s",
error->message);
return;
}

View File

@ -0,0 +1,53 @@
# 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__ = 'Marco Trevisan'
__copyright__ = '(c) 2021 Canonical Ltd.'
import dbus
import time
BUS_NAME = 'org.freedesktop.locale1'
MAIN_OBJ = '/org/freedesktop/locale1'
MAIN_IFACE = 'org.freedesktop.locale1'
SYSTEM_BUS = True
def load(mock, parameters):
mock.AddProperty(MAIN_IFACE, 'Locale', dbus.Array(['LANG=C'], signature='s'))
mock.AddProperty(MAIN_IFACE, 'X11Layout', dbus.String())
mock.AddProperty(MAIN_IFACE, 'X11Model', dbus.String())
mock.AddProperty(MAIN_IFACE, 'X11Variant', dbus.String())
mock.AddProperty(MAIN_IFACE, 'X11Options', dbus.String())
mock.AddProperty(MAIN_IFACE, 'VConsoleKeymap', dbus.String())
mock.AddProperty(MAIN_IFACE, 'VConsoleKeymapToggle', dbus.String())
def simulate_interaction():
time.sleep(1)
@dbus.service.method(MAIN_IFACE, in_signature='asb')
def SetLocale(self, locale, interactive):
if interactive:
simulate_interaction()
self.Set(MAIN_IFACE, 'Locale', locale)
@dbus.service.method(MAIN_IFACE, in_signature='ssbb')
def SetVConsoleKeyboard(self, keymap, keymap_toggle, convert, interactive):
if interactive:
simulate_interaction()
self.Set(MAIN_IFACE, 'VConsoleKeymap', keymap)
self.Set(MAIN_IFACE, 'VConsoleKeymapToggle', keymap_toggle)
@dbus.service.method(MAIN_IFACE, in_signature='ssssbb')
def SetVConsoleKeyboard(self, layout, model, variant, options, convert, interactive):
if interactive:
simulate_interaction()
self.Set(MAIN_IFACE, 'X11Layout', layout)
self.Set(MAIN_IFACE, 'X11Model', model)
self.Set(MAIN_IFACE, 'X11Variant', variant)
self.Set(MAIN_IFACE, 'X11Options', options)

View File

@ -39,6 +39,7 @@ class MutterDBusTestCase(DBusTestCase):
'meta-mocks-manager', {'templates-dir': get_templates_dir()})
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)