[gnome-settings-daemon] power: Add brightness levels check to the tests
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Add brightness levels check to the tests
- Date: Tue, 29 Jan 2013 13:57:48 +0000 (UTC)
commit 1a896aa0e39d79e6ade064a3248e3de5c273cb02
Author: Bastien Nocera <hadess hadess net>
Date: Tue Jan 29 14:40:53 2013 +0100
power: Add brightness levels check to the tests
plugins/power/gsdpowerconstants.py | 2 ++
plugins/power/test.py | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/plugins/power/gsdpowerconstants.py b/plugins/power/gsdpowerconstants.py
index b2fb63c..e85af95 100644
--- a/plugins/power/gsdpowerconstants.py
+++ b/plugins/power/gsdpowerconstants.py
@@ -11,3 +11,5 @@ 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;
+GSD_MOCK_DEFAULT_BRIGHTNESS = 50;
+GSD_MOCK_MAX_BRIGHTNESS = 100;
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 3fe3b81..0ce7de6 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -142,6 +142,11 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
except OSError:
pass
+ try:
+ os.unlink('GSD_MOCK_brightness')
+ except OSError:
+ pass
+
# we check this at the end so that the other cleanup always happens
self.assertTrue(daemon_running or self.daemon_death_expected, 'daemon died during the test')
@@ -159,6 +164,12 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
def get_status(self):
return self.obj_session_presence_props.Get('org.gnome.SessionManager.Presence', 'status')
+ def get_brightness(self):
+ f = open('GSD_MOCK_brightness', 'r')
+ ret = f.read()
+ f.close()
+ return int(ret)
+
def set_has_external_monitor(self, external):
f = open('GSD_MOCK_EXTERNAL_MONITOR', 'w')
if external:
@@ -326,11 +337,14 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
# blank is supposed to happen straight away
self.check_blank(2)
+ # check that the brightness is at the minimum
+ self.assertTrue(self.get_brightness() == 0, 'incorrect blank brightness')
# wiggle the mouse now and check for unblank; this is expected to pop up
# the locked screen saver
self.reset_idle_timer()
self.check_unblank(2)
+ self.assertTrue(self.get_brightness() == gsdpowerconstants.GSD_MOCK_DEFAULT_BRIGHTNESS , 'incorrect unblanked brightness')
# Check for no blank before the normal blank timeout
self.check_no_blank(gsdpowerconstants.SCREENSAVER_TIMEOUT_BLANK - 4)
@@ -338,6 +352,7 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
# and check for blank after the blank timeout
self.check_blank(10)
+ self.assertTrue(self.get_brightness() == 0, 'incorrect blank brightness')
# Drop inhibitor
self.obj_session_mgr.Uninhibit(dbus.UInt32(inhibit_id))
@@ -500,12 +515,15 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
self.settings_session['idle-delay'] = idle_delay
self.settings_gsd_power['sleep-inactive-battery-timeout'] = idle_delay + 1
self.settings_gsd_power['sleep-inactive-battery-type'] = 'suspend'
+ # This is an absolute percentage, and our brightness is 0..100
+ dim_level = self.settings_gsd_power['idle-brightness'];
# Check that we're not idle
self.assertEqual(self.get_status(), gsdpowerenums.GSM_PRESENCE_STATUS_AVAILABLE)
# Wait and check we're not idle, but dimmed
self.check_dim(gsdpowerconstants.MINIMUM_IDLE_DIM_DELAY)
+ self.assertTrue(self.get_brightness() == dim_level, 'incorrect dim brightness')
self.assertEqual(self.get_status(), gsdpowerenums.GSM_PRESENCE_STATUS_AVAILABLE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]