[gnome-settings-daemon/wip/benzea/backlight: 15/15] power: Add test to check backlight brightness is updated after uevent



commit 2edd95fe8c5fffeb0f33e47a0189632dd484cfad
Author: Benjamin Berg <bberg redhat com>
Date:   Fri Apr 20 19:16:29 2018 +0200

    power: Add test to check backlight brightness is updated after uevent
    
    A simple test to check that gsd-power will notice an update to the
    brightness.

 plugins/power/gsd-backlight.c |  2 ++
 plugins/power/test.py         | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)
---
diff --git a/plugins/power/gsd-backlight.c b/plugins/power/gsd-backlight.c
index 93cfe28a..d2c758d2 100644
--- a/plugins/power/gsd-backlight.c
+++ b/plugins/power/gsd-backlight.c
@@ -197,6 +197,8 @@ gsd_backlight_udev_uevent (GUdevClient *client, gchar *action, GUdevDevice *devi
                        g_udev_device_get_sysfs_path (backlight->udev_device)) != 0)
                 return;
 
+        g_debug ("GsdBacklight: Got uevent");
+
         gsd_backlight_udev_idle_update (backlight);
 }
 
diff --git a/plugins/power/test.py b/plugins/power/test.py
index afb94687..53958836 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -1121,6 +1121,26 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
         time.sleep(1.0)
         self.assertEqual(self.get_brightness(), 90)
 
+    def test_brightness_uevent(self):
+        obj_gsd_power = self.session_bus_con.get_object(
+            'org.gnome.SettingsDaemon.Power', '/org/gnome/SettingsDaemon/Power')
+        obj_gsd_power_prop_iface = dbus.Interface(obj_gsd_power, dbus.PROPERTIES_IFACE)
+
+        brightness = obj_gsd_power_prop_iface.Get('org.gnome.SettingsDaemon.Power.Screen', 'Brightness')
+        self.assertEqual(50, brightness)
+
+        # Check that the brightness is updated if it was changed through some
+        # other mechanism (e.g. firmware).
+        # Set to 80+1 because of the GSD offset (see add_backlight).
+        self.testbed.set_attribute(self.backlight, 'brightness', '81')
+        self.testbed.uevent(self.backlight, 'change')
+
+        self.check_plugin_log('GsdBacklight: Got uevent', 1, 'gsd-power did not process uevent')
+        time.sleep(0.1)
+
+        brightness = obj_gsd_power_prop_iface.Get('org.gnome.SettingsDaemon.Power.Screen', 'Brightness')
+        self.assertEqual(80, brightness)
+
     def test_brightness_step(self):
         # We cannot use check_plugin_log here because the startup check already
         # read the relevant message.


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