summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2022-06-22 18:38:49 +0200
committerBenjamin Berg <bberg@redhat.com>2022-06-22 18:38:49 +0200
commit3c4f902fbdf6382366b515186aca28e0a868ed8b (patch)
treef55a6c77c061907d618c91252a1c6b5a6ff488f3
parent46b5eb5fe7e8e904f3c1d3ee762105a8f123925e (diff)
downloadupower-3c4f902fbdf6382366b515186aca28e0a868ed8b.tar.gz
test: Add battery ID changing test for history loading/saving
-rwxr-xr-xsrc/linux/integration-test.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/linux/integration-test.py b/src/linux/integration-test.py
index d935d09..8cd7142 100755
--- a/src/linux/integration-test.py
+++ b/src/linux/integration-test.py
@@ -1265,6 +1265,48 @@ class Tests(dbusmock.DBusTestCase):
self.stop_daemon()
+ def test_battery_id_change(self):
+ '''check that we save/load the history correctly when the ID changes'''
+
+ bat0 = self.testbed.add_device('power_supply', 'BAT0', None,
+ ['type', 'Battery',
+ 'manufacturer', 'FDO',
+ 'model_name', 'Fake Battery',
+ 'serial_number', '001',
+ 'present', '1',
+ 'status', 'Discharging',
+ 'energy_full', '60000000',
+ 'energy_full_design', '80000000',
+ 'energy_now', '50000000',
+ 'voltage_now', '12000000'], [])
+
+ self.start_daemon()
+
+ self.daemon_log.check_line(f"using id: Fake_Battery-80-001", timeout=1)
+
+ # Change the serial of the battery
+ self.testbed.set_attribute(bat0, 'energy_full_design', '90000000')
+ self.testbed.set_attribute(bat0, 'serial_number', '002')
+ self.testbed.uevent(bat0, 'change')
+
+ # This saves the old history, and then opens a new one
+ self.daemon_log.check_line_re(f"saved .*/history-time-empty-Fake_Battery-80-001.dat", timeout=1)
+ self.daemon_log.check_line(f"using id: Fake_Battery-90-002", timeout=1)
+
+ # Only happens once
+ self.daemon_log.check_no_line(f"using id:", wait=1.0)
+
+ # Remove the battery
+ self.testbed.set_attribute(bat0, 'present', '0')
+ self.testbed.uevent(bat0, 'change')
+
+ # This saves the old history, and does *not* open a new one
+ self.daemon_log.check_line_re(f"saved .*/history-time-empty-Fake_Battery-90-002.dat", timeout=1)
+ self.daemon_log.check_no_line(f"using id:", wait=1.0)
+
+ self.stop_daemon()
+
+
def test_percentage_low_icon_set(self):
'''Without battery level, PercentageLow is limit for icon change'''