virtual-device: Add test that open fails with a busy error if is still ongoing
The idea of the test was just checking what happens when we're opening a device multiple times while a first request is still going. However, it actually ends up also checking the previous commit change because without it we'd stop the close iteration before the device is actually closed and stop the open iteration before the device is actually opened, leading to an infinite loop.
This commit is contained in:
parent
27c2466bda
commit
acd0a10e76
1 changed files with 22 additions and 0 deletions
|
@ -730,6 +730,28 @@ class VirtualDeviceBusyDeviceOperations(VirtualDeviceBase):
|
||||||
ctx.iteration(True)
|
ctx.iteration(True)
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
|
||||||
|
def test_open(self):
|
||||||
|
self.send_command('IGNORED_COMMAND')
|
||||||
|
self.send_sleep(100)
|
||||||
|
|
||||||
|
with GLibErrorMessage('libfprint-virtual_device',
|
||||||
|
GLib.LogLevelFlags.LEVEL_WARNING, 'Could not process command: *'):
|
||||||
|
while self.dev.is_open():
|
||||||
|
ctx.iteration(True)
|
||||||
|
|
||||||
|
self.assertFalse(self.dev.is_open())
|
||||||
|
self.dev.open()
|
||||||
|
with self.assertRaises(GLib.Error) as error:
|
||||||
|
self.dev.open_sync()
|
||||||
|
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
|
||||||
|
FPrint.DeviceError.BUSY))
|
||||||
|
|
||||||
|
self.assertFalse(self.dev.is_open())
|
||||||
|
while not self.dev.is_open():
|
||||||
|
ctx.iteration(True)
|
||||||
|
|
||||||
|
self.dev.close_sync()
|
||||||
|
|
||||||
def test_close(self):
|
def test_close(self):
|
||||||
with self.assertRaises(GLib.Error) as error:
|
with self.assertRaises(GLib.Error) as error:
|
||||||
self.dev.close_sync()
|
self.dev.close_sync()
|
||||||
|
|
Loading…
Reference in a new issue