diff options
author | Bastien Nocera <hadess@hadess.net> | 2013-08-06 11:48:09 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2013-08-06 11:49:06 +0200 |
commit | ef4ae20315de08a41e9c06402d3fad9bdb5983e6 (patch) | |
tree | 95a635af79859fcd5eab4252f3c17b3e2211b2a8 | |
parent | 099b16dfc9b50c06be2751dcfb7dc1dba8249dba (diff) | |
download | gnome-settings-daemon-ef4ae20315de08a41e9c06402d3fad9bdb5983e6.tar.gz |
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.
-rwxr-xr-x | 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 486d1152..b267e7a9 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''' |