device: Gracefully handle identify on devices with no support

We were crashing as trying to still call the identify vfunc, so check if
identification is supported and if not return a relative error.

Added test as well
This commit is contained in:
Marco Trevisan (Treviño)
2021-04-01 17:43:07 +02:00
parent 59767af552
commit 4031bb62d7
2 changed files with 17 additions and 0 deletions

View File

@@ -849,6 +849,15 @@ class VirtualDevice(VirtualDeviceBase):
self.assertEqual(close_res.code, int(FPrint.DeviceError.BUSY))
def test_identify_unsupported(self):
if self.dev.supports_identify():
self.skipTest('Device supports identification')
with self.assertRaises(GLib.Error) as error:
self.dev.identify_sync([FPrint.Print.new(self.dev)])
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
FPrint.DeviceError.NOT_SUPPORTED))
class VirtualDeviceClosed(VirtualDeviceBase):