[mutter] tests: Run a localed mock implementation on tests



commit a4223007e24683f301cdcf80014377f7e74c0126
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Aug 26 15:07:47 2021 +0200

    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>

 src/compositor/plugins/default.c        |  3 +-
 src/tests/dbusmock-templates/localed.py | 53 +++++++++++++++++++++++++++++++++
 src/tests/meta-dbus-runner.py           |  1 +
 3 files changed, 55 insertions(+), 2 deletions(-)
---
diff --git a/src/compositor/plugins/default.c b/src/compositor/plugins/default.c
index 2a622f6f16..4a23d1457e 100644
--- a/src/compositor/plugins/default.c
+++ b/src/compositor/plugins/default.c
@@ -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;
     }
diff --git a/src/tests/dbusmock-templates/localed.py b/src/tests/dbusmock-templates/localed.py
new file mode 100644
index 0000000000..db205d17e7
--- /dev/null
+++ b/src/tests/dbusmock-templates/localed.py
@@ -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)
diff --git a/src/tests/meta-dbus-runner.py b/src/tests/meta-dbus-runner.py
index 3b2e57e04c..254d4d5125 100755
--- a/src/tests/meta-dbus-runner.py
+++ b/src/tests/meta-dbus-runner.py
@@ -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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]