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



commit c0c82113b8cd8f9cd25b2500aa9758283776b102
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 d72eb34b..2159f429 100644
--- a/plugins/power/gsd-backlight.c
+++ b/plugins/power/gsd-backlight.c
@@ -204,6 +204,8 @@ gsd_backlight_udev_uevent (GUdevClient *client, const gchar *action, GUdevDevice
                        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 a7fb9fb1..8ef46433 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]