virtual-device: Test unplug operation while we're verifying

This commit is contained in:
Marco Trevisan (Treviño) 2021-01-25 15:14:30 +01:00
parent 153b24a95a
commit 89b4c4ee75

View file

@ -406,6 +406,39 @@ class VirtualDevice(unittest.TestCase):
with self.assertRaisesRegex(GLib.GError, 'device has been removed from the system'): with self.assertRaisesRegex(GLib.GError, 'device has been removed from the system'):
self.dev.close_sync() self.dev.close_sync()
def test_device_unplug_during_verify(self):
self._close_on_teardown = False
notified_spec = None
def on_removed_notify(dev, spec):
nonlocal notified_spec
notified_spec = spec
removed = False
def on_removed(dev):
nonlocal removed
removed = True
self.assertFalse(self.dev.props.removed)
self.dev.connect('notify::removed', on_removed_notify)
self.dev.connect('removed', on_removed)
self.start_verify(FPrint.Print.new(self.dev),
identify=self.dev.supports_identify())
self.send_command('UNPLUG')
self.assertEqual(notified_spec.name, 'removed')
self.assertTrue(self.dev.props.removed)
self.assertFalse(removed)
with self.assertRaisesRegex(GLib.GError, 'device has been removed from the system'):
self.complete_verify()
self.assertTrue(removed)
with self.assertRaisesRegex(GLib.GError, 'device has been removed from the system'):
self.dev.close_sync()
class VirtualDeviceStorage(VirtualDevice): class VirtualDeviceStorage(VirtualDevice):
def tearDown(self): def tearDown(self):