[gnome-settings-daemon/benzea/test-fixes: 4/5] power: Make startup of lid tests more reliable




commit 560fe80e70f94a780c1220943cb089969ec4b4a2
Author: Benjamin Berg <bberg redhat com>
Date:   Thu Feb 10 17:49:52 2022 +0100

    power: Make startup of lid tests more reliable
    
    The lid-switch is inhibited at startup, and a number of tests rely on
    this inhibition to have been released again. Unfortunately, it seems
    that sometimes we were not clearing all messages properly. Either way,
    explicitly waiting for the uninhibit that happens at startup is sane.

 plugins/power/test.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/plugins/power/test.py b/plugins/power/test.py
index daef0e1a..c35c1541 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -594,7 +594,8 @@ class PowerPluginTest4(PowerPluginBase):
             dbus.UInt32(gsdpowerenums.GSM_INHIBITOR_FLAG_SUSPEND),
             dbus_interface='org.gnome.SessionManager')
 
-        time.sleep (gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT)
+        # Wait for startup inhibition to be gone
+        self.check_for_lid_uninhibited(gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT + 2)
 
         # Close the lid
         self.obj_upower.Set('org.freedesktop.UPower', 'LidIsClosed', True)
@@ -621,7 +622,8 @@ class PowerPluginTest4(PowerPluginBase):
             dbus.UInt32(gsdpowerenums.GSM_INHIBITOR_FLAG_SUSPEND),
             dbus_interface='org.gnome.SessionManager')
 
-        time.sleep (gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT)
+        # Wait for startup inhibition to be gone
+        self.check_for_lid_uninhibited(gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT + 2)
 
         # Close the lid
         self.obj_upower.Set('org.freedesktop.UPower', 'LidIsClosed', True)
@@ -645,7 +647,8 @@ class PowerPluginTest4(PowerPluginBase):
             dbus.UInt32(gsdpowerenums.GSM_INHIBITOR_FLAG_SUSPEND),
             dbus_interface='org.gnome.SessionManager')
 
-        time.sleep (gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT)
+        # Wait for startup inhibition to be gone
+        self.check_for_lid_uninhibited(gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT + 2)
 
         # Close the lid
         self.obj_upower.Set('org.freedesktop.UPower', 'LidIsClosed', True)
@@ -669,9 +672,8 @@ class PowerPluginTest5(PowerPluginBase):
     def test_dim(self):
         '''Check that we do go to dim'''
 
-        # Wait and flush log
-        time.sleep (gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT + 1)
-        self.plugin_log.clear()
+        # Wait for startup inhibition to be gone
+        self.check_for_lid_uninhibited(gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT + 2)
 
         idle_delay = math.ceil(gsdpowerconstants.MINIMUM_IDLE_DIM_DELAY / 
gsdpowerconstants.IDLE_DELAY_TO_IDLE_DIM_MULTIPLIER)
         self.reset_idle_timer()
@@ -718,9 +720,8 @@ class PowerPluginTest5(PowerPluginBase):
     def test_lid_close_inhibition(self):
         '''Check that we correctly inhibit suspend with an external monitor'''
 
-        # Wait and flush log
-        time.sleep (gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT + 1)
-        self.plugin_log.clear()
+        # Wait for startup inhibition to be gone
+        self.check_for_lid_uninhibited(gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT + 2)
 
         # Add an external monitor
         self.set_has_external_monitor(True)


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