virtual-device: Add checks for verify reports

This commit is contained in:
Marco Trevisan (Treviño) 2021-01-25 21:16:36 +01:00
parent 08f4be707c
commit 2382506491

View file

@ -208,12 +208,21 @@ class VirtualDevice(unittest.TestCase):
self._verify_match = None self._verify_match = None
self._verify_fp = None self._verify_fp = None
self._verify_error = None self._verify_error = None
self._verify_report_match = None
self._verify_report_print = None
self._verify_completed = False self._verify_completed = False
self._verify_reported = False
self._cancellable = Gio.Cancellable() self._cancellable = Gio.Cancellable()
if identify: if identify:
self.assertTrue(self.dev.supports_identify()) self.assertTrue(self.dev.supports_identify())
def match_cb(dev, match, pnt, data, error):
self._verify_reported = True
self._verify_report_match = match
self._verify_report_print = pnt
self._verify_report_error = error
def verify_cb(dev, res): def verify_cb(dev, res):
try: try:
self._verify_match, self._verify_fp = ( self._verify_match, self._verify_fp = (
@ -225,9 +234,10 @@ class VirtualDevice(unittest.TestCase):
if identify: if identify:
self.dev.identify(p if isinstance(p, list) else [p], self.dev.identify(p if isinstance(p, list) else [p],
cancellable=self._cancellable, callback=verify_cb) cancellable=self._cancellable, match_cb=match_cb, callback=verify_cb)
else: else:
self.dev.verify(p, cancellable=self._cancellable, callback=verify_cb) self.dev.verify(p, cancellable=self._cancellable, match_cb=match_cb,
callback=verify_cb)
def cancel_verify(self): def cancel_verify(self):
self._cancellable.cancel() self._cancellable.cancel()
@ -254,14 +264,21 @@ class VirtualDevice(unittest.TestCase):
self.start_verify(p, identify) self.start_verify(p, identify)
self.complete_verify() self.complete_verify()
self.assertTrue(self._verify_reported)
if not match:
self.assertIsNone(self._verify_report_match)
if identify: if identify:
if match: if match:
self.assertIsNotNone(self._verify_report_match)
self.assertIsNotNone(self._verify_match) self.assertIsNotNone(self._verify_match)
else:
self.assertIsNone(self._verify_match)
else: else:
if self._verify_fp: if self._verify_fp:
self.assertEqual(self._verify_fp.equal(p), match) self.assertEqual(self._verify_fp.equal(p), match)
if match:
self.assertTrue(
self._verify_fp.equal(self._verify_report_match))
else: else:
self.assertFalse(match) self.assertFalse(match)