linux: integration-test: determining a low power charger based on battery percenatge change

If the line power is attached and the battery percentage drops 3% within
300 seconds, upower determines the attached line power is a low-power
charger.
This commit is contained in:
Kate Hsuan 2025-04-07 12:21:24 +08:00
parent c0750c5dd9
commit 30449acecc

View file

@ -676,9 +676,12 @@ class Tests(dbusmock.DBusTestCase):
# a low power charger causes the battery is discharging and the AC is online # a low power charger causes the battery is discharging and the AC is online
self.testbed.set_attribute(ac, "online", "1") self.testbed.set_attribute(ac, "online", "1")
self.testbed.set_attribute(bat0, "energy_now", "3600000")
self.testbed.set_attribute(bat0, "status", "Discharging") self.testbed.set_attribute(bat0, "status", "Discharging")
self.testbed.set_attribute(bat0, "energy_now", "1500000")
self.start_daemon() self.start_daemon()
time.sleep(5)
self.testbed.set_attribute(bat0, "energy_now", "1500000")
time.sleep(30)
devs = self.proxy.EnumerateDevices() devs = self.proxy.EnumerateDevices()
self.assertEqual(len(devs), 2) self.assertEqual(len(devs), 2)
self.assertEqual(self.get_dbus_property("OnBattery"), True) self.assertEqual(self.get_dbus_property("OnBattery"), True)