mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
virtual-device: Add support for sleep command
It can be used to delay operations, simulating a busy device.
This commit is contained in:
@@ -96,7 +96,7 @@ class VirtualDevice(unittest.TestCase):
|
||||
|
||||
def send_command(self, command, *args):
|
||||
self.assertIn(command, ['INSERT', 'REMOVE', 'SCAN', 'ERROR', 'RETRY',
|
||||
'FINGER', 'UNPLUG', 'SET_ENROLL_STAGES', 'SET_SCAN_TYPE'])
|
||||
'FINGER', 'UNPLUG', 'SLEEP', 'SET_ENROLL_STAGES', 'SET_SCAN_TYPE'])
|
||||
|
||||
with Connection(self.sockaddr) as con:
|
||||
params = ' '.join(str(p) for p in args)
|
||||
@@ -439,6 +439,24 @@ class VirtualDevice(unittest.TestCase):
|
||||
with self.assertRaisesRegex(GLib.GError, 'device has been removed from the system'):
|
||||
self.dev.close_sync()
|
||||
|
||||
def test_device_sleep(self):
|
||||
enrolled = self.enroll_print('testprint', FPrint.Finger.LEFT_LITTLE)
|
||||
|
||||
timeout_reached = False
|
||||
def on_timeout():
|
||||
nonlocal timeout_reached
|
||||
timeout_reached = True
|
||||
|
||||
self.send_command('SLEEP', 1500)
|
||||
GLib.timeout_add(300, on_timeout)
|
||||
|
||||
self.start_verify(enrolled, identify=self.dev.supports_identify())
|
||||
while not timeout_reached:
|
||||
ctx.iteration(False)
|
||||
|
||||
self.assertFalse(self._verify_completed)
|
||||
self.cancel_verify()
|
||||
|
||||
class VirtualDeviceStorage(VirtualDevice):
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
Reference in New Issue
Block a user