diff options
author | Bastien Nocera <hadess@hadess.net> | 2023-07-05 12:26:23 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2023-07-05 17:39:19 +0200 |
commit | 53ccc01be9a512f560ac899566a43e6b727ed383 (patch) | |
tree | 9fb4be93406143dc01c2fea96b55c2217f74fdfc | |
parent | 4d3d8759dbbdcdc7c839e50981be071f789c95e1 (diff) |
linux: Add test for device signals with wireless_status
-rwxr-xr-x | src/linux/integration-test.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/linux/integration-test.py b/src/linux/integration-test.py index 511f6fb..b1714db 100755 --- a/src/linux/integration-test.py +++ b/src/linux/integration-test.py @@ -2494,24 +2494,40 @@ class Tests(dbusmock.DBusTestCase): intf = '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5:1.3' self.testbed.set_attribute(intf, 'wireless_status', 'connected') + num_devices = 0 + self.start_daemon() devs = self.proxy.EnumerateDevices() - self.assertEqual(len(devs), 1) + num_devices = len(devs) + self.assertEqual(num_devices, 1) headset_up = devs[0] self.assertEqual(self.get_dbus_dev_property(headset_up, 'Percentage'), 69.0) + client = UPowerGlib.Client.new() + + def device_added_cb(client, device): + nonlocal num_devices + num_devices += 1 + def device_removed_cb(client, path): + nonlocal num_devices + num_devices -= 1 + + client.connect('device-added', device_added_cb) + client.connect('device-removed', device_removed_cb) + self.testbed.set_attribute(intf, 'wireless_status', 'disconnected') self.testbed.uevent(intf, 'change') + self.wait_for_mainloop() - devs = self.proxy.EnumerateDevices() - self.assertEqual(len(devs), 0) + self.assertEqual(num_devices, 0) self.testbed.set_attribute(intf, 'wireless_status', 'connected') self.testbed.uevent(intf, 'change') + self.wait_for_mainloop() + self.assertEqual(num_devices, 1) devs = self.proxy.EnumerateDevices() - self.assertEqual(len(devs), 1) headset_up = devs[0] self.assertEqual(self.get_dbus_dev_property(headset_up, 'Percentage'), 69.0) |