[gnome-settings-daemon] power: Add test to avoid idle when inhibited



commit 9e25b69ffeafedeef4dc9ad9a1dd65fdf92a2161
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 22 11:01:31 2013 +0100

    power: Add test to avoid idle when inhibited
    
    As fixed in a9a882c67ac1b81da272d72d0036547dacedccdb and
    29286fe457350a92feeb36493c515118e8f4f34f

 plugins/power/test.py |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 0b7c967..abd82ee 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -138,6 +138,18 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
             self.assertFalse(b' Suspend' in log, 'unexpected Suspend request')
             self.assertFalse(b' Hibernate' in log, 'unexpected Hibernate request')
 
+    def check_no_idle_no_suspend(self, seconds):
+        '''Check that no idle mode is set in the given time'''
+
+        # wait for specified time to ensure it didn't do anything
+        time.sleep(seconds)
+        # check that it did not suspend or hibernate
+        log = self.logind.stdout.read()
+        if log:
+            self.assertFalse(b' Doing a state transition: dim' in log, 'unexpected dim request')
+            self.assertFalse(b' Suspend' in log, 'unexpected Suspend request')
+            self.assertFalse(b' Hibernate' in log, 'unexpected Hibernate request')
+
     def check_blank(self, timeout):
         '''Check that blank is requested.
 
@@ -282,10 +294,15 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
         inhibit_id = self.obj_session_mgr.Inhibit(
             'testsuite', dbus.UInt32(0), 'for testing',
             dbus.UInt32(gsdpowerenums.GSM_INHIBITOR_FLAG_IDLE | gsdpowerenums.GSM_INHIBITOR_FLAG_SUSPEND))
-        try:
-            self.check_no_suspend(7)
-        finally:
-            self.obj_session_mgr.Uninhibit(dbus.UInt32(inhibit_id))
+        self.check_no_idle_no_suspend(7)
+
+        # Check that we didn't go to idle either
+        obj_session_presence = self.session_bus_con.get_object(
+            'org.gnome.SessionManager', '/org/gnome/SessionManager/Presence')
+        dbus_props = dbus.Interface(obj_session_presence, dbus.PROPERTIES_IFACE)
+        self.assertEqual(dbus_props.Get('org.gnome.SessionManager.Presence', 'status'), gsdpowerenums.GSM_PRESENCE_STATUS_AVAILABLE)
+
+        self.obj_session_mgr.Uninhibit(dbus.UInt32(inhibit_id))
 
     def test_action_critical_battery(self):
         '''action on critical battery'''



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