mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-08 03:08:03 +02:00
linux: Add test for Logitech unknown device races
Check that external devices which show up as "battery" types have their capacity_level correctly read, and that the device's type will be correctly read after an input node is attached.
This commit is contained in:
parent
71efbf00ca
commit
8ead05234c
1 changed files with 51 additions and 0 deletions
|
|
@ -1227,6 +1227,57 @@ class Tests(dbusmock.DBusTestCase):
|
|||
self.assertEqual(self.get_dbus_property('OnBattery'), False)
|
||||
self.assertEqual(self.get_dbus_display_property('WarningLevel'), UP_DEVICE_LEVEL_NONE)
|
||||
|
||||
def test_hidpp_touchpad_race(self):
|
||||
'''HID++ touchpad with input node that appears later'''
|
||||
|
||||
dev = self.testbed.add_device('hid',
|
||||
'/devices/pci0000:00/0000:00:14.0/usb3/3-10/3-10:1.2/0003:046D:C52B.0009/0003:046D:4101.000A',
|
||||
None,
|
||||
[], [])
|
||||
|
||||
parent = dev
|
||||
batt_dev = self.testbed.add_device(
|
||||
'power_supply',
|
||||
'/devices/pci0000:00/0000:00:14.0/usb3/3-10/3-10:1.2/0003:046D:C52B.0009/0003:046D:4101.000A/power_supply/hidpp_battery_3',
|
||||
parent,
|
||||
['type', 'Battery',
|
||||
'scope', 'Device',
|
||||
'present', '1',
|
||||
'online', '1',
|
||||
'status', 'Discharging',
|
||||
'capacity_level', 'Full\n',
|
||||
'serial_number', '123456',
|
||||
'model_name', 'Logitech T650'],
|
||||
[])
|
||||
|
||||
self.start_daemon()
|
||||
devs = self.proxy.EnumerateDevices()
|
||||
self.assertEqual(len(devs), 1)
|
||||
mousebat0_up = devs[0]
|
||||
|
||||
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Model'), 'Logitech T650')
|
||||
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'PowerSupply'), False)
|
||||
# 2 == battery
|
||||
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Type'), 2)
|
||||
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Serial'), '123456')
|
||||
self.assertEqual(self.get_dbus_property('OnBattery'), False)
|
||||
self.assertEqual(self.get_dbus_display_property('WarningLevel'), UP_DEVICE_LEVEL_NONE)
|
||||
|
||||
# Now test all the levels
|
||||
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Percentage'), 100)
|
||||
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'BatteryLevel'), UP_DEVICE_LEVEL_FULL)
|
||||
|
||||
self.testbed.add_device(
|
||||
'input',
|
||||
'/devices/pci0000:00/0000:00:14.0/usb3/3-10/3-10:1.2/0003:046D:C52B.0009/0003:046D:4101.000A/input/input22',
|
||||
parent,
|
||||
[], ['DEVNAME', 'input/mouse3', 'ID_INPUT_TOUCHPAD', '1'])
|
||||
self.testbed.uevent(batt_dev, 'change')
|
||||
|
||||
time.sleep(0.5)
|
||||
# 5 == mouse
|
||||
self.assertEqual(self.get_dbus_dev_property(mousebat0_up, 'Type'), 5)
|
||||
|
||||
def test_hidpp_touchpad(self):
|
||||
'''HID++ touchpad battery with 5 capacity levels'''
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue