mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-06-11 02:28:05 +00:00
Merge branch 'origin/master' into tod
This commit is contained in:
+370
-20
@@ -17,6 +17,8 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "fp-device.h"
|
||||
#include "fp-enums.h"
|
||||
#include <libfprint/fprint.h>
|
||||
|
||||
#define FP_COMPONENT "device"
|
||||
@@ -526,6 +528,257 @@ test_driver_get_driver_data (void)
|
||||
g_assert_cmpuint (fpi_device_get_driver_data (device), ==, driver_data);
|
||||
}
|
||||
|
||||
static void
|
||||
driver_feature_changes_check (FpDevice *device, gboolean add)
|
||||
{
|
||||
g_autoptr(GFlagsClass) features_class = g_type_class_ref (FP_TYPE_DEVICE_FEATURE);
|
||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||
guint expected_features;
|
||||
guint initial_value;
|
||||
guint i;
|
||||
|
||||
if (add)
|
||||
initial_value = FP_DEVICE_FEATURE_NONE;
|
||||
else
|
||||
initial_value = features_class->mask;
|
||||
|
||||
g_assert_cmpuint (fp_device_get_features (device), ==, initial_value);
|
||||
|
||||
for (i = 0, expected_features = initial_value; i < features_class->n_values; ++i)
|
||||
{
|
||||
FpDeviceFeature feature = features_class->values[i].value;
|
||||
FpDeviceFeature added_feature = add ? feature : FP_DEVICE_FEATURE_NONE;
|
||||
FpDeviceFeature removed_feature = add ? FP_DEVICE_FEATURE_NONE : feature;
|
||||
|
||||
dev_class->features |= added_feature;
|
||||
dev_class->features &= ~removed_feature;
|
||||
|
||||
expected_features |= added_feature;
|
||||
expected_features &= ~removed_feature;
|
||||
|
||||
g_assert_cmpuint (fp_device_get_features (device), ==, expected_features);
|
||||
|
||||
if (added_feature != FP_DEVICE_FEATURE_NONE)
|
||||
g_assert_true (fp_device_has_feature (device, added_feature));
|
||||
else if (dev_class->features != FP_DEVICE_FEATURE_NONE)
|
||||
g_assert_false (fp_device_has_feature (device, added_feature));
|
||||
else
|
||||
g_assert_true (fp_device_has_feature (device, added_feature));
|
||||
|
||||
if (removed_feature != FP_DEVICE_FEATURE_NONE)
|
||||
g_assert_false (fp_device_has_feature (device, removed_feature));
|
||||
else if (dev_class->features != FP_DEVICE_FEATURE_NONE)
|
||||
g_assert_false (fp_device_has_feature (device, removed_feature));
|
||||
else
|
||||
g_assert_true (fp_device_has_feature (device, removed_feature));
|
||||
|
||||
g_assert_true (fp_device_has_feature (device, expected_features));
|
||||
}
|
||||
|
||||
if (add)
|
||||
g_assert_cmpuint (fp_device_get_features (device), ==, features_class->mask);
|
||||
else
|
||||
g_assert_cmpuint (fp_device_get_features (device), ==, FP_DEVICE_FEATURE_NONE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_features (void)
|
||||
{
|
||||
g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
|
||||
dev_class->features = FP_DEVICE_FEATURE_NONE;
|
||||
driver_feature_changes_check (device, TRUE);
|
||||
driver_feature_changes_check (device, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_initial_features (void)
|
||||
{
|
||||
g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||
|
||||
g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR);
|
||||
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE));
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY));
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_VERIFY));
|
||||
g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_DUPLICATES_CHECK));
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE));
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_LIST));
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_DELETE));
|
||||
g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_CLEAR));
|
||||
|
||||
g_assert_cmpuint (fp_device_get_features (device),
|
||||
==,
|
||||
FP_DEVICE_FEATURE_CAPTURE |
|
||||
FP_DEVICE_FEATURE_IDENTIFY |
|
||||
FP_DEVICE_FEATURE_VERIFY |
|
||||
FP_DEVICE_FEATURE_STORAGE |
|
||||
FP_DEVICE_FEATURE_STORAGE_LIST |
|
||||
FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_initial_features_none (void)
|
||||
{
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
|
||||
dev_class->list = NULL;
|
||||
dev_class->capture = NULL;
|
||||
dev_class->verify = NULL;
|
||||
dev_class->identify = NULL;
|
||||
dev_class->delete = NULL;
|
||||
dev_class->features = FP_DEVICE_FEATURE_NONE;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
|
||||
g_assert_cmpuint (dev_class->features, ==, FP_DEVICE_FEATURE_NONE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_VERIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_initial_features_no_capture (void)
|
||||
{
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
|
||||
dev_class->capture = NULL;
|
||||
dev_class->features = FP_DEVICE_FEATURE_NONE;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
|
||||
g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_initial_features_no_verify (void)
|
||||
{
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
|
||||
dev_class->verify = NULL;
|
||||
dev_class->features = FP_DEVICE_FEATURE_NONE;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
|
||||
g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_VERIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_initial_features_no_identify (void)
|
||||
{
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
|
||||
dev_class->identify = NULL;
|
||||
dev_class->features = FP_DEVICE_FEATURE_NONE;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
|
||||
g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_initial_features_no_storage (void)
|
||||
{
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
|
||||
dev_class->list = NULL;
|
||||
dev_class->delete = NULL;
|
||||
dev_class->features = FP_DEVICE_FEATURE_NONE;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
|
||||
g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_initial_features_no_list (void)
|
||||
{
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
|
||||
dev_class->list = NULL;
|
||||
dev_class->features = FP_DEVICE_FEATURE_NONE;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
|
||||
g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_initial_features_no_delete (void)
|
||||
{
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
|
||||
dev_class->list = NULL;
|
||||
dev_class->features = FP_DEVICE_FEATURE_NONE;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
|
||||
g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST);
|
||||
g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE);
|
||||
g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR);
|
||||
}
|
||||
|
||||
static void
|
||||
on_driver_probe_async (GObject *initable, GAsyncResult *res, gpointer user_data)
|
||||
{
|
||||
@@ -1012,6 +1265,39 @@ test_driver_verify (void)
|
||||
g_assert_true (match);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_verify_not_supported (void)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(FpPrint) enrolled_print = NULL;
|
||||
g_autoptr(FpPrint) out_print = NULL;
|
||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
g_autoptr(FpAutoCloseDevice) device = NULL;
|
||||
FpiDeviceFake *fake_dev;
|
||||
gboolean match;
|
||||
|
||||
dev_class->features &= ~FP_DEVICE_FEATURE_VERIFY;
|
||||
|
||||
device = auto_close_fake_device_new ();
|
||||
fake_dev = FPI_DEVICE_FAKE (device);
|
||||
fake_dev->last_called_function = NULL;
|
||||
|
||||
enrolled_print = make_fake_print_reffed (device, g_variant_new_uint64 (3));
|
||||
g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL,
|
||||
test_driver_match_cb, match_data,
|
||||
&match, &out_print, &error));
|
||||
|
||||
g_assert_null (fake_dev->last_called_function);
|
||||
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED);
|
||||
|
||||
g_assert_false (match_data->called);
|
||||
g_assert_no_error (match_data->error);
|
||||
|
||||
g_assert_null (out_print);
|
||||
g_assert_false (match);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_verify_fail (void)
|
||||
{
|
||||
@@ -1322,7 +1608,10 @@ test_driver_supports_identify (void)
|
||||
dev_class->identify = fake_device_stub_identify;
|
||||
|
||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1331,10 +1620,13 @@ test_driver_do_not_support_identify (void)
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
g_autoptr(FpDevice) device = NULL;
|
||||
|
||||
dev_class->identify = NULL;
|
||||
dev_class->features &= ~FP_DEVICE_FEATURE_IDENTIFY;
|
||||
|
||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_assert_false (fp_device_supports_identify (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_false (fp_device_supports_identify (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1353,7 +1645,10 @@ test_driver_identify (void)
|
||||
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
||||
fp_print_set_description (expected_matched, "fake-verified");
|
||||
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY));
|
||||
|
||||
match_data->gallery = prints;
|
||||
|
||||
@@ -1386,7 +1681,10 @@ test_driver_identify_fail (void)
|
||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY));
|
||||
|
||||
fake_dev->ret_print = make_fake_print (device, NULL);
|
||||
g_assert_true (fp_device_identify_sync (device, prints, NULL,
|
||||
@@ -1422,7 +1720,10 @@ test_driver_identify_retry (void)
|
||||
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
||||
fp_print_set_description (expected_matched, "fake-verified");
|
||||
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY));
|
||||
|
||||
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_GENERAL);
|
||||
g_assert_false (fp_device_identify_sync (device, prints, NULL,
|
||||
@@ -1456,7 +1757,10 @@ test_driver_identify_error (void)
|
||||
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
||||
fp_print_set_description (expected_matched, "fake-verified");
|
||||
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_supports_identify (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY));
|
||||
|
||||
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL);
|
||||
g_assert_false (fp_device_identify_sync (device, prints, NULL,
|
||||
@@ -1659,10 +1963,14 @@ test_driver_supports_capture (void)
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
g_autoptr(FpDevice) device = NULL;
|
||||
|
||||
dev_class->features |= FP_DEVICE_FEATURE_CAPTURE;
|
||||
dev_class->capture = fake_device_stub_capture;
|
||||
|
||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_assert_true (fp_device_supports_capture (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_supports_capture (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1671,10 +1979,14 @@ test_driver_do_not_support_capture (void)
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
g_autoptr(FpDevice) device = NULL;
|
||||
|
||||
dev_class->features &= ~FP_DEVICE_FEATURE_CAPTURE;
|
||||
dev_class->capture = NULL;
|
||||
|
||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_assert_false (fp_device_supports_capture (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_false (fp_device_supports_capture (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1696,6 +2008,29 @@ test_driver_capture (void)
|
||||
g_assert (image == fake_dev->ret_image);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_capture_not_supported (void)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(FpImage) image = NULL;
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
g_autoptr(FpAutoCloseDevice) device = NULL;
|
||||
gboolean wait_for_finger = TRUE;
|
||||
FpiDeviceFake *fake_dev;
|
||||
|
||||
dev_class->features &= ~FP_DEVICE_FEATURE_CAPTURE;
|
||||
|
||||
device = auto_close_fake_device_new ();
|
||||
fake_dev = FPI_DEVICE_FAKE (device);
|
||||
fake_dev->last_called_function = NULL;
|
||||
|
||||
image = fp_device_capture_sync (device, wait_for_finger, NULL, &error);
|
||||
g_assert_null (fake_dev->last_called_function);
|
||||
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED);
|
||||
|
||||
g_assert_null (image);
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_capture_error (void)
|
||||
{
|
||||
@@ -1715,21 +2050,19 @@ test_driver_capture_error (void)
|
||||
g_assert_null (image);
|
||||
}
|
||||
|
||||
static void
|
||||
fake_device_stub_list (FpDevice *device)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_driver_has_storage (void)
|
||||
{
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
g_autoptr(FpDevice) device = NULL;
|
||||
|
||||
dev_class->list = fake_device_stub_list;
|
||||
dev_class->features |= FP_DEVICE_FEATURE_STORAGE;
|
||||
|
||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_assert_true (fp_device_has_storage (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_has_storage (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1738,10 +2071,13 @@ test_driver_has_not_storage (void)
|
||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||
g_autoptr(FpDevice) device = NULL;
|
||||
|
||||
dev_class->list = NULL;
|
||||
dev_class->features &= ~FP_DEVICE_FEATURE_STORAGE;
|
||||
|
||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_assert_false (fp_device_has_storage (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_false (fp_device_has_storage (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1790,10 +2126,13 @@ test_driver_list_no_storage (void)
|
||||
g_autoptr(GPtrArray) prints = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
dev_class->list = NULL;
|
||||
dev_class->features &= ~FP_DEVICE_FEATURE_STORAGE;
|
||||
|
||||
device = auto_close_fake_device_new ();
|
||||
g_assert_false (fp_device_has_storage (device));
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_assert_false (fp_device_has_storage (device));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE));
|
||||
|
||||
prints = fp_device_list_prints_sync (device, NULL, &error);
|
||||
g_assert_null (prints);
|
||||
@@ -2463,6 +2802,15 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/driver/get_usb_device", test_driver_get_usb_device);
|
||||
g_test_add_func ("/driver/get_virtual_env", test_driver_get_virtual_env);
|
||||
g_test_add_func ("/driver/get_driver_data", test_driver_get_driver_data);
|
||||
g_test_add_func ("/driver/features", test_driver_features);
|
||||
g_test_add_func ("/driver/initial_features", test_driver_initial_features);
|
||||
g_test_add_func ("/driver/initial_features/none", test_driver_initial_features_none);
|
||||
g_test_add_func ("/driver/initial_features/no_capture", test_driver_initial_features_no_capture);
|
||||
g_test_add_func ("/driver/initial_features/no_verify", test_driver_initial_features_no_verify);
|
||||
g_test_add_func ("/driver/initial_features/no_identify", test_driver_initial_features_no_identify);
|
||||
g_test_add_func ("/driver/initial_features/no_storage", test_driver_initial_features_no_storage);
|
||||
g_test_add_func ("/driver/initial_features/no_list", test_driver_initial_features_no_list);
|
||||
g_test_add_func ("/driver/initial_features/no_delete", test_driver_initial_features_no_delete);
|
||||
|
||||
g_test_add_func ("/driver/probe", test_driver_probe);
|
||||
g_test_add_func ("/driver/probe/error", test_driver_probe_error);
|
||||
@@ -2479,6 +2827,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/driver/verify/fail", test_driver_verify_fail);
|
||||
g_test_add_func ("/driver/verify/retry", test_driver_verify_retry);
|
||||
g_test_add_func ("/driver/verify/error", test_driver_verify_error);
|
||||
g_test_add_func ("/driver/verify/not_supported", test_driver_verify_not_supported);
|
||||
g_test_add_func ("/driver/verify/report_no_cb", test_driver_verify_report_no_callback);
|
||||
g_test_add_func ("/driver/verify/not_reported", test_driver_verify_not_reported);
|
||||
g_test_add_func ("/driver/verify/complete_retry", test_driver_verify_complete_retry);
|
||||
@@ -2490,6 +2839,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/driver/identify/complete_retry", test_driver_identify_complete_retry);
|
||||
g_test_add_func ("/driver/identify/report_no_cb", test_driver_identify_report_no_callback);
|
||||
g_test_add_func ("/driver/capture", test_driver_capture);
|
||||
g_test_add_func ("/driver/capture/not_supported", test_driver_capture_not_supported);
|
||||
g_test_add_func ("/driver/capture/error", test_driver_capture_error);
|
||||
g_test_add_func ("/driver/list", test_driver_list);
|
||||
g_test_add_func ("/driver/list/error", test_driver_list_error);
|
||||
|
||||
Reference in New Issue
Block a user