parent
098ff97edd
commit
7ff95dc39a
2 changed files with 76 additions and 3 deletions
|
@ -2177,6 +2177,39 @@ test_driver_delete_error (void)
|
||||||
g_assert_false (ret);
|
g_assert_false (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_driver_clear_storage (void)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
ret = fp_device_clear_storage_sync (device, NULL, &error);
|
||||||
|
g_assert (fake_dev->last_called_function == dev_class->clear_storage);
|
||||||
|
g_assert_no_error (error);
|
||||||
|
g_assert_true (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_driver_clear_storage_error (void)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL);
|
||||||
|
ret = fp_device_clear_storage_sync (device, NULL, &error);
|
||||||
|
g_assert (fake_dev->last_called_function == dev_class->clear_storage);
|
||||||
|
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL);
|
||||||
|
g_assert (error == g_steal_pointer (&fake_dev->ret_error));
|
||||||
|
|
||||||
|
g_assert_false (ret);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fake_device_delete_wait_for_cancel_timeout (gpointer data)
|
fake_device_delete_wait_for_cancel_timeout (gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -2543,6 +2576,12 @@ test_driver_action_error_all (void)
|
||||||
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID);
|
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
|
|
||||||
|
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID);
|
||||||
|
g_assert_false (fp_device_clear_storage_sync (device, NULL, &error));
|
||||||
|
g_assert_true (fake_dev->last_called_function == dev_class->clear_storage);
|
||||||
|
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID);
|
||||||
|
g_clear_error (&error);
|
||||||
|
|
||||||
/* Test close last, as we can't operate on a closed device. */
|
/* Test close last, as we can't operate on a closed device. */
|
||||||
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID);
|
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID);
|
||||||
g_assert_false (fp_device_close_sync (device, NULL, &error));
|
g_assert_false (fp_device_close_sync (device, NULL, &error));
|
||||||
|
@ -2642,6 +2681,16 @@ test_driver_action_error_fallback_all (void)
|
||||||
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL);
|
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*Device failed to pass an error to generic action "
|
||||||
|
"error function*");
|
||||||
|
|
||||||
|
g_assert_false (fp_device_clear_storage_sync (device, NULL, &error));
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
g_assert_true (fake_dev->last_called_function == dev_class->clear_storage);
|
||||||
|
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL);
|
||||||
|
g_clear_error (&error);
|
||||||
|
|
||||||
/* Test close last, as we can't operate on a closed device. */
|
/* Test close last, as we can't operate on a closed device. */
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
"*Device failed to pass an error to generic action "
|
"*Device failed to pass an error to generic action "
|
||||||
|
@ -2846,6 +2895,8 @@ main (int argc, char *argv[])
|
||||||
g_test_add_func ("/driver/list/no_storage", test_driver_list_no_storage);
|
g_test_add_func ("/driver/list/no_storage", test_driver_list_no_storage);
|
||||||
g_test_add_func ("/driver/delete", test_driver_delete);
|
g_test_add_func ("/driver/delete", test_driver_delete);
|
||||||
g_test_add_func ("/driver/delete/error", test_driver_delete_error);
|
g_test_add_func ("/driver/delete/error", test_driver_delete_error);
|
||||||
|
g_test_add_func ("/driver/clear_storage", test_driver_clear_storage);
|
||||||
|
g_test_add_func ("/driver/clear_storage/error", test_driver_clear_storage_error);
|
||||||
g_test_add_func ("/driver/cancel", test_driver_cancel);
|
g_test_add_func ("/driver/cancel", test_driver_cancel);
|
||||||
g_test_add_func ("/driver/cancel/fail", test_driver_cancel_fail);
|
g_test_add_func ("/driver/cancel/fail", test_driver_cancel_fail);
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,8 @@ class VirtualDeviceBase(unittest.TestCase):
|
||||||
def send_command(self, command, *args):
|
def send_command(self, command, *args):
|
||||||
self.assertIn(command, ['INSERT', 'REMOVE', 'SCAN', 'ERROR', 'RETRY',
|
self.assertIn(command, ['INSERT', 'REMOVE', 'SCAN', 'ERROR', 'RETRY',
|
||||||
'FINGER', 'UNPLUG', 'SLEEP', 'SET_ENROLL_STAGES', 'SET_SCAN_TYPE',
|
'FINGER', 'UNPLUG', 'SLEEP', 'SET_ENROLL_STAGES', 'SET_SCAN_TYPE',
|
||||||
'SET_CANCELLATION_ENABLED', 'SET_KEEP_ALIVE', 'IGNORED_COMMAND'])
|
'SET_CANCELLATION_ENABLED', 'SET_KEEP_ALIVE', 'IGNORED_COMMAND',
|
||||||
|
'CONT'])
|
||||||
|
|
||||||
with Connection(self.sockaddr) as con:
|
with Connection(self.sockaddr) as con:
|
||||||
params = ' '.join(str(p) for p in args)
|
params = ' '.join(str(p) for p in args)
|
||||||
|
@ -1006,8 +1007,8 @@ class VirtualDeviceStorage(VirtualDevice):
|
||||||
|
|
||||||
def cleanup_device_storage(self):
|
def cleanup_device_storage(self):
|
||||||
if self.dev.is_open() and not self.dev.props.removed:
|
if self.dev.is_open() and not self.dev.props.removed:
|
||||||
for print in self.dev.list_prints_sync():
|
self.send_command('CONT')
|
||||||
self.dev.delete_print_sync(print, None)
|
self.dev.clear_storage_sync()
|
||||||
|
|
||||||
def test_device_properties(self):
|
def test_device_properties(self):
|
||||||
self.assertEqual(self.dev.get_driver(), 'virtual_device_storage')
|
self.assertEqual(self.dev.get_driver(), 'virtual_device_storage')
|
||||||
|
@ -1106,6 +1107,27 @@ class VirtualDeviceStorage(VirtualDevice):
|
||||||
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
|
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
|
||||||
FPrint.DeviceError.DATA_NOT_FOUND))
|
FPrint.DeviceError.DATA_NOT_FOUND))
|
||||||
|
|
||||||
|
def test_clear_storage(self):
|
||||||
|
self.send_command('INSERT', 'p1')
|
||||||
|
l = self.dev.list_prints_sync()
|
||||||
|
print(l[0])
|
||||||
|
self.assertEqual(len(l), 1)
|
||||||
|
self.send_command('CONT')
|
||||||
|
self.dev.clear_storage_sync()
|
||||||
|
self.assertFalse(self.dev.list_prints_sync())
|
||||||
|
|
||||||
|
def test_clear_storage_error(self):
|
||||||
|
self.send_command('INSERT', 'p1')
|
||||||
|
l = self.dev.list_prints_sync()
|
||||||
|
print(l[0])
|
||||||
|
self.assertEqual(len(l), 1)
|
||||||
|
|
||||||
|
self.send_error(FPrint.DeviceError.PROTO)
|
||||||
|
with self.assertRaises(GLib.Error) as error:
|
||||||
|
self.dev.clear_storage_sync()
|
||||||
|
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
|
||||||
|
FPrint.DeviceError.PROTO))
|
||||||
|
|
||||||
def test_identify_match(self):
|
def test_identify_match(self):
|
||||||
rt = self.enroll_print('right-thumb', FPrint.Finger.RIGHT_THUMB)
|
rt = self.enroll_print('right-thumb', FPrint.Finger.RIGHT_THUMB)
|
||||||
lt = self.enroll_print('left-thumb', FPrint.Finger.LEFT_THUMB)
|
lt = self.enroll_print('left-thumb', FPrint.Finger.LEFT_THUMB)
|
||||||
|
|
Loading…
Reference in a new issue