[gnome-settings-daemon/wip/benzea/backlight: 10/10] power: Add test to verify DBus behaviour without a backlight
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/benzea/backlight: 10/10] power: Add test to verify DBus behaviour without a backlight
- Date: Fri, 21 Sep 2018 18:53:45 +0000 (UTC)
commit 08c6f8a7db0eed52940fade9f2a6f38246b0346e
Author: Benjamin Berg <bberg redhat com>
Date: Fri Sep 21 17:14:03 2018 +0200
power: Add test to verify DBus behaviour without a backlight
In the case that we have no backlight (for the screen) the DBus
interface will partially work. Querying the brightness will result in a
static value of -1. Trying to set the brightness in any way will instead
result in a DBus error.
plugins/power/test.py | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 8ef46433..c789940c 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -54,8 +54,8 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
os.environ['UMOCKDEV_DIR'] = self.testbed.get_root_dir()
# Create a mock backlight device
- # Note that this function creates a different backlight device based on
- # the name of the test.
+ # Note that this function creates a different or even no backlight
+ # device based on the name of the test.
self.add_backlight()
# start mock upowerd
@@ -214,7 +214,9 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
def backlight_defaults(self):
# Hack to modify the brightness defaults before starting gsd-power.
# The alternative would be to create two separate test files.
- if 'legacy_brightness' in self.id():
+ if 'no_backlight' in self.id():
+ return None, None
+ elif 'legacy_brightness' in self.id():
return 15, 15
else:
return 100, 50
@@ -222,6 +224,10 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
def add_backlight(self, _type="raw"):
max_brightness, brightness = self.backlight_defaults()
+ if max_brightness is None:
+ self.backlight = None
+ return
+
# Undo mangling done in GSD
if max_brightness >= 99:
max_brightness += 1
@@ -1186,5 +1192,33 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
time.sleep(0.2)
self.assertEqual(self.get_brightness(), 15)
+ def test_no_backlight(self):
+ '''Check that backlight brightness DBus api without a backlight'''
+
+ obj_gsd_power = self.session_bus_con.get_object(
+ 'org.gnome.SettingsDaemon.Power', '/org/gnome/SettingsDaemon/Power')
+ obj_gsd_power_props = dbus.Interface(obj_gsd_power, dbus.PROPERTIES_IFACE)
+ obj_gsd_power_screen = dbus.Interface(obj_gsd_power, 'org.gnome.SettingsDaemon.Power.Screen')
+
+ # We expect -1 to be returned
+ brightness = obj_gsd_power_props.Get('org.gnome.SettingsDaemon.Power.Screen', 'Brightness')
+ self.assertEqual(brightness, -1)
+
+ # Trying to set the brightness
+ with self.assertRaises(dbus.DBusException) as exc:
+ obj_gsd_power_props.Set('org.gnome.SettingsDaemon.Power.Screen', 'Brightness', 1)
+
+ self.assertEqual(exc.exception.get_dbus_message(), 'No usable backlight could be found!')
+
+ with self.assertRaises(dbus.DBusException) as exc:
+ obj_gsd_power_screen.StepUp()
+
+ self.assertEqual(exc.exception.get_dbus_message(), 'No usable backlight could be found!')
+
+ with self.assertRaises(dbus.DBusException) as exc:
+ obj_gsd_power_screen.StepDown()
+
+ self.assertEqual(exc.exception.get_dbus_message(), 'No usable backlight could be found!')
+
# 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]