[gnome-settings-daemon] power: Add test_unindle_on_ac_plug()
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Add test_unindle_on_ac_plug()
- Date: Fri, 25 Jan 2013 21:02:00 +0000 (UTC)
commit 7760c8ed6b70fdeeae7f1b72abfd94bd065541d3
Author: Bastien Nocera <hadess hadess net>
Date: Fri Jan 25 21:43:19 2013 +0100
power: Add test_unindle_on_ac_plug()
plugins/power/gsdpowerconstants.py | 1 +
plugins/power/test.py | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/plugins/power/gsdpowerconstants.py b/plugins/power/gsdpowerconstants.py
index 1e23b16..b2fb63c 100644
--- a/plugins/power/gsdpowerconstants.py
+++ b/plugins/power/gsdpowerconstants.py
@@ -10,3 +10,4 @@ SCREENSAVER_TIMEOUT_BLANK = 20;
IDLE_DIM_BLANK_DISABLED_MIN = 60;
IDLE_DELAY_TO_IDLE_DIM_MULTIPLIER = 4.0/5.0;
MINIMUM_IDLE_DIM_DELAY = 10;
+POWER_UP_TIME_ON_AC = 10;
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 21c7ae0..0f0605b 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -256,6 +256,21 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
else:
self.fail('timed out waiting for dim')
+ def check_undim(self, timeout):
+ '''Check that mode is set to normal in the given time'''
+
+ # wait for specified time to ensure it didn't do anything
+ while timeout > 0:
+ time.sleep(1)
+ timeout -= 1
+ # check that it requested normal
+ log = self.plugin_log.read()
+
+ if 'Doing a state transition: normal' in log:
+ break
+ else:
+ self.fail('timed out waiting for normal mode')
+
def check_blank(self, timeout):
'''Check that blank is requested.
@@ -620,5 +635,22 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
# Drop inhibitor
self.obj_session_mgr.Uninhibit(dbus.UInt32(inhibit_id))
+ def test_unindle_on_ac_plug(self):
+ idle_delay = round(gsdpowerconstants.MINIMUM_IDLE_DIM_DELAY / gsdpowerconstants.IDLE_DELAY_TO_IDLE_DIM_MULTIPLIER)
+ self.settings_session['idle-delay'] = idle_delay
+
+ # Wait for idle
+ self.check_dim(idle_delay + 2)
+
+ # Plug in the AC
+ self.obj_upower.Set('org.freedesktop.UPower', 'OnBattery', False)
+ self.obj_upower.EmitSignal('', 'Changed', '', [], dbus_interface='org.freedesktop.DBus.Mock')
+
+ # Check that we undim
+ self.check_undim(gsdpowerconstants.POWER_UP_TIME_ON_AC / 2)
+
+ # And wait a little more to see us dim again
+ self.check_dim(idle_delay + 2)
+
# avoid writing to stderr
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]