From 2382506491d86293781bcfbc2b3f616ecf046364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 25 Jan 2021 21:16:36 +0100 Subject: [PATCH] virtual-device: Add checks for verify reports --- tests/virtual-device.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/virtual-device.py b/tests/virtual-device.py index 41e5728..30d9705 100644 --- a/tests/virtual-device.py +++ b/tests/virtual-device.py @@ -208,12 +208,21 @@ class VirtualDevice(unittest.TestCase): self._verify_match = None self._verify_fp = None self._verify_error = None + self._verify_report_match = None + self._verify_report_print = None self._verify_completed = False + self._verify_reported = False self._cancellable = Gio.Cancellable() if 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): try: self._verify_match, self._verify_fp = ( @@ -225,9 +234,10 @@ class VirtualDevice(unittest.TestCase): if identify: 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: - 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): self._cancellable.cancel() @@ -254,14 +264,21 @@ class VirtualDevice(unittest.TestCase): self.start_verify(p, identify) self.complete_verify() + self.assertTrue(self._verify_reported) + + if not match: + self.assertIsNone(self._verify_report_match) + if identify: if match: + self.assertIsNotNone(self._verify_report_match) self.assertIsNotNone(self._verify_match) - else: - self.assertIsNone(self._verify_match) else: if self._verify_fp: self.assertEqual(self._verify_fp.equal(p), match) + if match: + self.assertTrue( + self._verify_fp.equal(self._verify_report_match)) else: self.assertFalse(match)