From e8a7ff1033026b5f20aea0f8180e5a53e52e7507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 3 Mar 2021 19:41:04 +0100 Subject: [PATCH] tests/virtual-device: Add test checking close while we're still opening --- tests/virtual-device.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/virtual-device.py b/tests/virtual-device.py index b9889e0..6c9e32c 100644 --- a/tests/virtual-device.py +++ b/tests/virtual-device.py @@ -424,6 +424,30 @@ class VirtualDevice(VirtualDeviceBase): while not opened: ctx.iteration(True) + def test_close_while_opening(self): + self.set_keep_alive(True) + self.dev.close_sync() + + opened = False + def on_opened(dev, res): + nonlocal opened + dev.open_finish(res) + opened = True + + self.send_sleep(500) + self.dev.open(callback=on_opened) + + self.wait_timeout(10) + self.assertFalse(self.dev.is_open()) + + with self.assertRaises(GLib.Error) as error: + self.dev.close_sync() + self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(), + FPrint.DeviceError.NOT_OPEN)) + + while not opened: + ctx.iteration(True) + def test_enroll(self): matching = self.enroll_print('testprint', FPrint.Finger.LEFT_LITTLE) self.assertEqual(matching.get_username(), 'testuser')