mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-07 08:28:01 +02:00
tests: Add test for non-default low level
This commit is contained in:
parent
665a3b2757
commit
d8482bc767
1 changed files with 36 additions and 0 deletions
|
|
@ -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'''
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue