diff options
author | Pablo Correa Gómez <ablocorrea@hotmail.com> | 2021-06-30 10:55:33 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-06-30 10:56:25 +0200 |
commit | d8482bc767db44ea1ae5de6057e194628b4bddbf (patch) | |
tree | 89201f0af68bd81a85217a31c04d0d15478c3a6d | |
parent | 665a3b2757737d377039ce00832b741a1ddc9a93 (diff) | |
download | upower-d8482bc767db44ea1ae5de6057e194628b4bddbf.tar.gz |
tests: Add test for non-default low level
-rwxr-xr-x | src/linux/integration-test | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/linux/integration-test b/src/linux/integration-test index 8e1a862..128477c 100755 --- a/src/linux/integration-test +++ b/src/linux/integration-test @@ -1074,6 +1074,42 @@ class Tests(dbusmock.DBusTestCase): os.unlink(config.name) + def test_percentage_low_icon_set(self): + '''Without battery level, PercentageLow is limit for icon change''' + + bat0 = self.testbed.add_device('power_supply', 'BAT0', None, + ['type', 'Battery', + 'present', '1', + 'status', 'Discharging', + 'energy_full', '100000000', + 'energy_full_design', '100000000', + 'energy_now', '15000000', + 'capacity', '15', + 'voltage_now', '12000000'], []) + + config = tempfile.NamedTemporaryFile(delete=False, mode='w') + # Low, Critical and Action are all needed to avoid fallback to defaults + config.write("[UPower]\n") + config.write("PercentageLow=20\n") + config.write("PercentageCritical=3\n") + config.write("PercentageAction=2\n") + config.close() + + self.start_daemon(cfgfile=config.name) + devs = self.proxy.EnumerateDevices() + self.assertEqual(len(devs), 1) + bat0_up = devs[0] + + # capacity_level is unused because a 'capacity' attribute is present and used instead + self.assertEqual(self.get_dbus_dev_property(bat0_up, 'BatteryLevel'), UP_DEVICE_LEVEL_NONE) + self.assertEqual(self.get_dbus_dev_property(bat0_up, 'Percentage'), 15.0) + # Battery below 20% from config, should set 'caution' icon even if over default (10%) + self.assertEqual(self.get_dbus_dev_property(bat0_up, 'IconName'), 'battery-caution-symbolic') + + self.stop_daemon() + + os.unlink(config.name) + def test_vendor_strings(self): '''manufacturer/model_name/serial_number with valid and invalid strings''' |