[gnome-settings-daemon] power: Add test case for falling back on critical



commit ef4ae20315de08a41e9c06402d3fad9bdb5983e6
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Aug 6 11:48:09 2013 +0200

    power: Add test case for falling back on critical
    
    When hibernate isn't available, make sure that we end up
    suspending instead. This also tests the removal of deprecated
    UPower functions, replaced by logind ones.

 plugins/power/test.py |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 486d115..b267e7a 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -266,6 +266,17 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
             self.assertFalse(b' Suspend' in log, 'unexpected Suspend request')
             self.assertFalse(b' Hibernate' in log, 'unexpected Hibernate request')
 
+    def check_suspend_no_hibernate(self, seconds):
+        '''Check that Suspend was requested and not Hibernate, in the given time'''
+
+        # wait for specified time to ensure it didn't do anything
+        time.sleep(seconds)
+        # check that it did suspend and didn't hibernate
+        log = self.logind.stdout.read()
+        if log:
+            self.assertTrue(b' Suspend' in log, 'missing Suspend request')
+            self.assertFalse(b' Hibernate' in log, 'unexpected Hibernate request')
+
     def check_no_dim(self, seconds):
         '''Check that mode is not set to dim in the given time'''
 
@@ -475,6 +486,21 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
         # delay + 1 s error margin
         self.check_for_suspend(7)
 
+    def test_suspend_no_hibernate(self):
+        '''suspend-no-hibernate'''
+
+        self.settings_session['idle-delay'] = 2
+        self.settings_gsd_power['sleep-inactive-battery-timeout'] = 5
+        # Hibernate isn't possible, so it should end up suspending
+        self.settings_gsd_power['critical-battery-action'] = 'hibernate'
+
+        # wait for idle delay; should not yet hibernate
+        self.check_no_suspend(2)
+
+        # suspend should happen after inactive sleep timeout + 1 s notification
+        # delay + 1 s error margin
+        self.check_suspend_no_hibernate(7)
+
     def test_sleep_inhibition(self):
         '''Does not sleep under idle inhibition'''
 


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