summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-07-20 18:22:05 +0200
committerBenjamin Berg <bberg@redhat.com>2021-07-22 14:24:36 +0200
commitcc675cafa1d8e8397f8f269ec82d2a362c72a100 (patch)
treea6654ed5972f8cbc72ffce471c61b5b16106aa35 /plugins
parentdc22db203808bb1298b19ee2ac44998a4a7a4011 (diff)
downloadgnome-settings-daemon-cc675cafa1d8e8397f8f269ec82d2a362c72a100.tar.gz
xsettings: Use OutputChecker for tests and wait for daemon startup
The power and xsettings tests have diverged a lot, this lowers the difference. The nice thing about this is that we now wait for the plugin to be initialized based on its output.
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xsettings/test.py37
1 files changed, 8 insertions, 29 deletions
diff --git a/plugins/xsettings/test.py b/plugins/xsettings/test.py
index 3657b588..367f5212 100755
--- a/plugins/xsettings/test.py
+++ b/plugins/xsettings/test.py
@@ -22,6 +22,7 @@ sys.path.insert(0, builddir)
import gsdtestcase
import dbus
import dbusmock
+from output_checker import OutputChecker
from gi.repository import Gio
from gi.repository import GLib
@@ -59,7 +60,6 @@ class XsettingsPluginTest(gsdtestcase.GSDTestCase):
self.start_mutter()
Gio.Settings.sync()
- self.plugin_log_write = open(os.path.join(self.workdir, 'plugin_xsettings.log'), 'wb', buffering=0)
os.environ['GSD_ignore_llvmpipe'] = '1'
# Setup fontconfig config path before starting the daemon
@@ -87,20 +87,20 @@ class XsettingsPluginTest(gsdtestcase.GSDTestCase):
self.settings_sound = Gio.Settings.new('org.gnome.desktop.sound')
env = os.environ.copy()
+ self.plugin_log = OutputChecker()
self.daemon = subprocess.Popen(
[os.path.join(builddir, 'gsd-xsettings'), '--verbose'],
# comment out this line if you want to see the logs in real time
- stdout=self.plugin_log_write,
+ stdout=self.plugin_log.fd,
stderr=subprocess.STDOUT,
env=env)
-
- # you can use this for reading the current daemon log in tests
- self.plugin_log = open(self.plugin_log_write.name, 'rb', buffering=0)
+ self.plugin_log.writer_attached()
# flush notification log
self.p_notify_log.clear()
- time.sleep(3)
+ self.plugin_log.check_line(b'GsdXSettingsGtk initializing', timeout=10)
+
obj_xsettings = self.session_bus_con.get_object(
'org.gtk.Settings', '/org/gtk/Settings')
self.obj_xsettings_props = dbus.Interface(obj_xsettings, dbus.PROPERTIES_IFACE)
@@ -110,9 +110,7 @@ class XsettingsPluginTest(gsdtestcase.GSDTestCase):
daemon_running = self.daemon.poll() == None
if daemon_running:
self.stop_process(self.daemon)
- self.plugin_log.close()
- self.plugin_log_write.flush()
- self.plugin_log_write.close()
+ self.plugin_log.assert_closed()
self.stop_session()
self.stop_mutter()
@@ -144,26 +142,7 @@ class XsettingsPluginTest(gsdtestcase.GSDTestCase):
Fail after the given timeout.
'''
- if type(needle) == str:
- needle = needle.encode('ascii')
- # Fast path if the message was already logged
- log = self.plugin_log.read()
- if needle in log:
- return
-
- while timeout > 0:
- time.sleep(0.5)
- timeout -= 0.5
-
- # read new data (lines) from the log
- log = self.plugin_log.read()
- if needle in log:
- break
- else:
- if failmsg is not None:
- self.fail(failmsg)
- else:
- self.fail('timed out waiting for needle "%s"' % needle)
+ self.plugin_log.check_line(needle, timeout=timeout, failmsg=failmsg)
def test_gtk_modules(self):
# Turn off event sounds