mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
tests/fprintd: Reduce the enroll stages when possible to avoid operations
This commit is contained in:
@ -345,6 +345,10 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
|||||||
def finger_present(self):
|
def finger_present(self):
|
||||||
return self.device.get_cached_property('finger-present').unpack()
|
return self.device.get_cached_property('finger-present').unpack()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def num_enroll_stages(self):
|
||||||
|
return self.device.get_cached_property('num-enroll-stages').unpack()
|
||||||
|
|
||||||
# From libfprint tests
|
# From libfprint tests
|
||||||
def send_retry(self, retry_error=FPrint.DeviceRetry.TOO_SHORT, con=None):
|
def send_retry(self, retry_error=FPrint.DeviceRetry.TOO_SHORT, con=None):
|
||||||
if con:
|
if con:
|
||||||
@ -413,6 +417,9 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
|||||||
while iterate and self.finger_present != has_finger:
|
while iterate and self.finger_present != has_finger:
|
||||||
ctx.iteration(False)
|
ctx.iteration(False)
|
||||||
|
|
||||||
|
def _maybe_reduce_enroll_stages(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def call_proxy_method_async(self, proxy, method, *args):
|
def call_proxy_method_async(self, proxy, method, *args):
|
||||||
def call_handler(proxy, res):
|
def call_handler(proxy, res):
|
||||||
nonlocal method
|
nonlocal method
|
||||||
@ -586,6 +593,8 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
|||||||
self.assertEqual(self._last_result, expected)
|
self.assertEqual(self._last_result, expected)
|
||||||
|
|
||||||
def enroll_image(self, img, device=None, finger='right-index-finger', expected_result='enroll-completed'):
|
def enroll_image(self, img, device=None, finger='right-index-finger', expected_result='enroll-completed'):
|
||||||
|
self._maybe_reduce_enroll_stages()
|
||||||
|
|
||||||
if device is None:
|
if device is None:
|
||||||
device = self.device
|
device = self.device
|
||||||
device.EnrollStart('(s)', finger)
|
device.EnrollStart('(s)', finger)
|
||||||
@ -594,7 +603,7 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
|
|||||||
ctx.iteration(False)
|
ctx.iteration(False)
|
||||||
self.assertTrue(self.finger_needed)
|
self.assertTrue(self.finger_needed)
|
||||||
|
|
||||||
stages = device.get_cached_property('num-enroll-stages').unpack()
|
stages = self.num_enroll_stages
|
||||||
for stage in range(stages):
|
for stage in range(stages):
|
||||||
self.send_image(img)
|
self.send_image(img)
|
||||||
if stage < stages - 1:
|
if stage < stages - 1:
|
||||||
@ -655,6 +664,7 @@ class FPrintdVirtualStorageDeviceBaseTest(FPrintdVirtualDeviceBaseTest):
|
|||||||
socket_env = 'FP_VIRTUAL_DEVICE_STORAGE'
|
socket_env = 'FP_VIRTUAL_DEVICE_STORAGE'
|
||||||
device_driver = 'virtual_device_storage'
|
device_driver = 'virtual_device_storage'
|
||||||
driver_name = 'Virtual device with storage and identification for debugging'
|
driver_name = 'Virtual device with storage and identification for debugging'
|
||||||
|
enroll_stages = 2
|
||||||
|
|
||||||
def _send_command(self, con, command, *args):
|
def _send_command(self, con, command, *args):
|
||||||
params = ' '.join(str(p) for p in args)
|
params = ' '.join(str(p) for p in args)
|
||||||
@ -706,6 +716,18 @@ class FPrintdVirtualStorageDeviceBaseTest(FPrintdVirtualDeviceBaseTest):
|
|||||||
# Using the name of the image as the print id
|
# Using the name of the image as the print id
|
||||||
super().enroll_image(img=nick, finger=finger, expected_result=expected_result)
|
super().enroll_image(img=nick, finger=finger, expected_result=expected_result)
|
||||||
|
|
||||||
|
def _maybe_reduce_enroll_stages(self, stages=-1):
|
||||||
|
# Reduce the number of default enroll stages, we can go a bit faster
|
||||||
|
stages = stages if stages > 0 else self.enroll_stages
|
||||||
|
if self.num_enroll_stages == stages:
|
||||||
|
return
|
||||||
|
self.send_command('SET_ENROLL_STAGES', stages)
|
||||||
|
while self.num_enroll_stages != stages:
|
||||||
|
ctx.iteration(True)
|
||||||
|
self.assertIn({'num-enroll-stages': stages}, self._changed_properties)
|
||||||
|
self._changed_properties.remove({'num-enroll-stages': stages})
|
||||||
|
self.assertEqual(self.num_enroll_stages, stages)
|
||||||
|
|
||||||
|
|
||||||
class FPrintdVirtualStorageDeviceTests(FPrintdVirtualStorageDeviceBaseTest):
|
class FPrintdVirtualStorageDeviceTests(FPrintdVirtualStorageDeviceBaseTest):
|
||||||
def test_garbage_collect(self):
|
def test_garbage_collect(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user