Commit 8ead0523 authored by Bastien Nocera's avatar Bastien Nocera

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.
parent 71efbf00
Pipeline #35581 passed with stage
in 5 minutes and 13 seconds
......@@ -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'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment