Commit db1865eb authored by Marco Trevisan's avatar Marco Trevisan Committed by Bastien Nocera
Browse files

tests/fprintd: Deduplicate result wait code

parent 10a3e759
...@@ -340,6 +340,17 @@ class FPrintdVirtualDeviceTest(FPrintdTest): ...@@ -340,6 +340,17 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
return self.assertRaisesRegex(GLib.Error, return self.assertRaisesRegex(GLib.Error,
'.*net\.reactivated\.Fprint\.Error\.{}.*'.format(fprint_error)) '.*net\.reactivated\.Fprint\.Error\.{}.*'.format(fprint_error))
def wait_for_result(self, expected=None):
self._abort = False
while not self._abort:
ctx.iteration(True)
self.assertTrue(self._abort)
self._abort = False
if expected is not None:
self.assertEqual(self._last_result, expected)
def test_allowed_claim(self): def test_allowed_claim(self):
self._polkitd_obj.SetAllowed(['net.reactivated.fprint.device.setusername', self._polkitd_obj.SetAllowed(['net.reactivated.fprint.device.setusername',
'net.reactivated.fprint.device.enroll']) 'net.reactivated.fprint.device.enroll'])
...@@ -439,9 +450,7 @@ class FPrintdVirtualDeviceTest(FPrintdTest): ...@@ -439,9 +450,7 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
self.send_image('whorl') self.send_image('whorl')
self._abort = False self.wait_for_result()
while not self._abort:
ctx.iteration(True)
self.assertEqual(self._last_result, 'enroll-completed') self.assertEqual(self._last_result, 'enroll-completed')
...@@ -459,9 +468,7 @@ class FPrintdVirtualDeviceTest(FPrintdTest): ...@@ -459,9 +468,7 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
# Try a wrong print; will stop verification # Try a wrong print; will stop verification
self.send_image('tented_arch') self.send_image('tented_arch')
self._abort = False self.wait_for_result()
while not self._abort:
ctx.iteration(True)
self.assertTrue(self._verify_stopped) self.assertTrue(self._verify_stopped)
self.assertEqual(self._last_result, 'verify-no-match') self.assertEqual(self._last_result, 'verify-no-match')
...@@ -470,17 +477,13 @@ class FPrintdVirtualDeviceTest(FPrintdTest): ...@@ -470,17 +477,13 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
# Send a retry error (swipe too short); will not stop verification # Send a retry error (swipe too short); will not stop verification
self.send_retry() self.send_retry()
self._abort = False self.wait_for_result()
while not self._abort:
ctx.iteration(True)
self.assertFalse(self._verify_stopped) self.assertFalse(self._verify_stopped)
self.assertEqual(self._last_result, 'verify-swipe-too-short') self.assertEqual(self._last_result, 'verify-swipe-too-short')
# Try the correct print; will stop verification # Try the correct print; will stop verification
self.send_image('whorl') self.send_image('whorl')
self._abort = False self.wait_for_result()
while not self._abort:
ctx.iteration(True)
self.assertTrue(self._verify_stopped) self.assertTrue(self._verify_stopped)
self.assertEqual(self._last_result, 'verify-match') self.assertEqual(self._last_result, 'verify-match')
...@@ -504,9 +507,7 @@ class FPrintdVirtualDeviceTest(FPrintdTest): ...@@ -504,9 +507,7 @@ class FPrintdVirtualDeviceTest(FPrintdTest):
self.send_image('whorl') self.send_image('whorl')
self._abort = False self.wait_for_result()
while not self._abort:
ctx.iteration(True)
self.assertEqual(self._last_result, 'enroll-completed') self.assertEqual(self._last_result, 'enroll-completed')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment