test-fpi-device: Add function to create fake FpPrint's and galleries
This commit is contained in:
parent
499de3e442
commit
faade91c39
1 changed files with 96 additions and 60 deletions
|
@ -89,6 +89,29 @@ auto_reset_device_class_cleanup (FpAutoResetClass *dev_class)
|
||||||
}
|
}
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpAutoResetClass, auto_reset_device_class_cleanup)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpAutoResetClass, auto_reset_device_class_cleanup)
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
assert_equal_galleries (GPtrArray *g1,
|
||||||
|
GPtrArray *g2)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
g_assert ((g1 && g2) || (!g1 || !g1));
|
||||||
|
|
||||||
|
if (g1 == g2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_assert_cmpuint (g1->len, ==, g2->len);
|
||||||
|
|
||||||
|
for (i = 0; i < g1->len; i++)
|
||||||
|
{
|
||||||
|
FpPrint *print = g_ptr_array_index (g1, i);
|
||||||
|
|
||||||
|
g_assert_true (g_ptr_array_find_with_equal_func (g2, print, (GEqualFunc)
|
||||||
|
fp_print_equal, NULL));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_device_notify (FpDevice *device, GParamSpec *spec, gpointer user_data)
|
on_device_notify (FpDevice *device, GParamSpec *spec, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
@ -98,6 +121,43 @@ on_device_notify (FpDevice *device, GParamSpec *spec, gpointer user_data)
|
||||||
fake_dev->user_data = g_param_spec_ref (spec);
|
fake_dev->user_data = g_param_spec_ref (spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FpPrint *
|
||||||
|
make_fake_print (FpDevice *device,
|
||||||
|
GVariant *print_data)
|
||||||
|
{
|
||||||
|
FpPrint *enrolled_print = fp_print_new (device);
|
||||||
|
|
||||||
|
fpi_print_set_type (enrolled_print, FPI_PRINT_RAW);
|
||||||
|
|
||||||
|
if (!print_data)
|
||||||
|
print_data = g_variant_new_string ("Test print private data");
|
||||||
|
g_object_set (G_OBJECT (enrolled_print), "fpi-data", print_data, NULL);
|
||||||
|
|
||||||
|
return enrolled_print;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FpPrint *
|
||||||
|
make_fake_print_reffed (FpDevice *device,
|
||||||
|
GVariant *print_data)
|
||||||
|
{
|
||||||
|
return g_object_ref_sink (make_fake_print (device, print_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
static GPtrArray *
|
||||||
|
make_fake_prints_gallery (FpDevice *device,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
GPtrArray *array;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
array = g_ptr_array_new_full (size, g_object_unref);
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
g_ptr_array_add (array, make_fake_print_reffed (device, g_variant_new_uint64 (i)));
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tests */
|
/* Tests */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -683,7 +743,7 @@ test_driver_enroll_error_no_print (void)
|
||||||
"*Driver passed an error but also provided a print, returning error*");
|
"*Driver passed an error but also provided a print, returning error*");
|
||||||
|
|
||||||
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL);
|
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL);
|
||||||
fake_dev->ret_print = fp_print_new (device);
|
fake_dev->ret_print = make_fake_print_reffed (device, NULL);
|
||||||
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
|
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
|
||||||
(gpointer) (&fake_dev->ret_print));
|
(gpointer) (&fake_dev->ret_print));
|
||||||
out_print =
|
out_print =
|
||||||
|
@ -774,7 +834,8 @@ test_driver_enroll_progress_vfunc (FpDevice *device)
|
||||||
|
|
||||||
expected_data->completed_stages =
|
expected_data->completed_stages =
|
||||||
g_random_int_range (fp_device_get_nr_enroll_stages (device), G_MAXINT32);
|
g_random_int_range (fp_device_get_nr_enroll_stages (device), G_MAXINT32);
|
||||||
expected_data->print = fp_print_new (device);
|
expected_data->print = make_fake_print_reffed (device,
|
||||||
|
g_variant_new_int32 (expected_data->completed_stages));
|
||||||
expected_data->error = NULL;
|
expected_data->error = NULL;
|
||||||
|
|
||||||
error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL);
|
error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL);
|
||||||
|
@ -885,7 +946,7 @@ test_driver_verify (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
g_autoptr(FpPrint) out_print = NULL;
|
g_autoptr(FpPrint) out_print = NULL;
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
|
@ -915,13 +976,14 @@ test_driver_verify_fail (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
g_autoptr(FpPrint) enrolled_print = NULL;
|
||||||
g_autoptr(FpPrint) out_print = NULL;
|
g_autoptr(FpPrint) out_print = NULL;
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
gboolean match;
|
gboolean match;
|
||||||
|
|
||||||
|
enrolled_print = make_fake_print_reffed (device, g_variant_new_uint64 (3));
|
||||||
fake_dev->ret_result = FPI_MATCH_FAIL;
|
fake_dev->ret_result = FPI_MATCH_FAIL;
|
||||||
g_assert_true (fp_device_verify_sync (device, enrolled_print, NULL,
|
g_assert_true (fp_device_verify_sync (device, enrolled_print, NULL,
|
||||||
test_driver_match_cb, match_data,
|
test_driver_match_cb, match_data,
|
||||||
|
@ -944,7 +1006,7 @@ test_driver_verify_retry (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
g_autoptr(FpPrint) out_print = NULL;
|
g_autoptr(FpPrint) out_print = NULL;
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
|
@ -972,7 +1034,7 @@ test_driver_verify_error (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
g_autoptr(FpPrint) out_print = NULL;
|
g_autoptr(FpPrint) out_print = NULL;
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
|
@ -1011,7 +1073,7 @@ test_driver_verify_not_reported (void)
|
||||||
|
|
||||||
dev_class->verify = fake_device_verify_immediate_complete;
|
dev_class->verify = fake_device_verify_immediate_complete;
|
||||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
enrolled_print = g_object_ref_sink (fp_print_new (device));
|
enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
|
|
||||||
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
||||||
|
|
||||||
|
@ -1054,7 +1116,7 @@ test_driver_verify_report_no_callback (void)
|
||||||
dev_class->verify = fake_device_verify_complete_error;
|
dev_class->verify = fake_device_verify_complete_error;
|
||||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
fake_dev = FPI_DEVICE_FAKE (device);
|
fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
enrolled_print = g_object_ref_sink (fp_print_new (device));
|
enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
|
|
||||||
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
||||||
|
|
||||||
|
@ -1094,7 +1156,7 @@ test_driver_verify_complete_retry (void)
|
||||||
dev_class->verify = fake_device_verify_complete_error;
|
dev_class->verify = fake_device_verify_complete_error;
|
||||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
fake_dev = FPI_DEVICE_FAKE (device);
|
fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
enrolled_print = g_object_ref_sink (fp_print_new (device));
|
enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
|
|
||||||
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
||||||
|
|
||||||
|
@ -1187,7 +1249,7 @@ test_driver_verify_complete_retry (void)
|
||||||
test_driver_match_data_clear (match_data);
|
test_driver_match_data_clear (match_data);
|
||||||
fake_dev->ret_result = FPI_MATCH_ERROR;
|
fake_dev->ret_result = FPI_MATCH_ERROR;
|
||||||
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT);
|
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT);
|
||||||
fake_dev->ret_print = fp_print_new (device);
|
fake_dev->ret_print = make_fake_print (device, NULL);
|
||||||
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
|
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
|
||||||
(gpointer) (&fake_dev->ret_print));
|
(gpointer) (&fake_dev->ret_print));
|
||||||
|
|
||||||
|
@ -1241,22 +1303,18 @@ test_driver_identify (void)
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
g_autoptr(FpPrint) matched_print = NULL;
|
g_autoptr(FpPrint) matched_print = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *expected_matched;
|
FpPrint *expected_matched;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 500; ++i)
|
|
||||||
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
|
||||||
|
|
||||||
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
||||||
fp_print_set_description (expected_matched, "fake-verified");
|
fp_print_set_description (expected_matched, "fake-verified");
|
||||||
|
|
||||||
g_assert_true (fp_device_supports_identify (device));
|
g_assert_true (fp_device_supports_identify (device));
|
||||||
|
|
||||||
fake_dev->ret_print = fp_print_new (device);
|
fake_dev->ret_print = make_fake_print (device, NULL);
|
||||||
g_assert_true (fp_device_identify_sync (device, prints, NULL,
|
g_assert_true (fp_device_identify_sync (device, prints, NULL,
|
||||||
test_driver_match_cb, match_data,
|
test_driver_match_cb, match_data,
|
||||||
&matched_print, &print, &error));
|
&matched_print, &print, &error));
|
||||||
|
@ -1281,18 +1339,14 @@ test_driver_identify_fail (void)
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
g_autoptr(FpPrint) matched_print = NULL;
|
g_autoptr(FpPrint) matched_print = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 500; ++i)
|
|
||||||
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
|
||||||
|
|
||||||
g_assert_true (fp_device_supports_identify (device));
|
g_assert_true (fp_device_supports_identify (device));
|
||||||
|
|
||||||
fake_dev->ret_print = fp_print_new (device);
|
fake_dev->ret_print = make_fake_print (device, NULL);
|
||||||
g_assert_true (fp_device_identify_sync (device, prints, NULL,
|
g_assert_true (fp_device_identify_sync (device, prints, NULL,
|
||||||
test_driver_match_cb, match_data,
|
test_driver_match_cb, match_data,
|
||||||
&matched_print, &print, &error));
|
&matched_print, &print, &error));
|
||||||
|
@ -1317,15 +1371,11 @@ test_driver_identify_retry (void)
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
g_autoptr(FpPrint) matched_print = NULL;
|
g_autoptr(FpPrint) matched_print = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *expected_matched;
|
FpPrint *expected_matched;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 500; ++i)
|
|
||||||
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
|
||||||
|
|
||||||
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
||||||
fp_print_set_description (expected_matched, "fake-verified");
|
fp_print_set_description (expected_matched, "fake-verified");
|
||||||
|
@ -1355,15 +1405,11 @@ test_driver_identify_error (void)
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
g_autoptr(FpPrint) matched_print = NULL;
|
g_autoptr(FpPrint) matched_print = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *expected_matched;
|
FpPrint *expected_matched;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 500; ++i)
|
|
||||||
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
|
||||||
|
|
||||||
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
||||||
fp_print_set_description (expected_matched, "fake-verified");
|
fp_print_set_description (expected_matched, "fake-verified");
|
||||||
|
@ -1397,15 +1443,12 @@ test_driver_identify_not_reported (void)
|
||||||
{
|
{
|
||||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||||
g_autoptr(FpAutoCloseDevice) device = NULL;
|
g_autoptr(FpAutoCloseDevice) device = NULL;
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
dev_class->identify = fake_device_identify_immediate_complete;
|
dev_class->identify = fake_device_identify_immediate_complete;
|
||||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
|
prints = make_fake_prints_gallery (device, 500);
|
||||||
for (i = 0; i < 500; ++i)
|
|
||||||
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
|
||||||
|
|
||||||
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
||||||
|
|
||||||
|
@ -1437,21 +1480,18 @@ static void
|
||||||
test_driver_identify_complete_retry (void)
|
test_driver_identify_complete_retry (void)
|
||||||
{
|
{
|
||||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = NULL;
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
g_autoptr(FpAutoCloseDevice) device = NULL;
|
g_autoptr(FpAutoCloseDevice) device = NULL;
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
g_autoptr(FpPrint) match = NULL;
|
g_autoptr(FpPrint) match = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
FpiDeviceFake *fake_dev;
|
FpiDeviceFake *fake_dev;
|
||||||
int i;
|
|
||||||
|
|
||||||
dev_class->identify = fake_device_identify_complete_error;
|
dev_class->identify = fake_device_identify_complete_error;
|
||||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
fake_dev = FPI_DEVICE_FAKE (device);
|
fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
|
prints = make_fake_prints_gallery (device, 500);
|
||||||
for (i = 0; i < 500; ++i)
|
|
||||||
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
|
||||||
|
|
||||||
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
||||||
|
|
||||||
|
@ -1481,7 +1521,7 @@ test_driver_identify_complete_retry (void)
|
||||||
"*Driver reported a match to a print that was not in the gallery*");
|
"*Driver reported a match to a print that was not in the gallery*");
|
||||||
|
|
||||||
test_driver_match_data_clear (match_data);
|
test_driver_match_data_clear (match_data);
|
||||||
fake_dev->ret_match = fp_print_new (device);
|
fake_dev->ret_match = make_fake_print_reffed (device, NULL);
|
||||||
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_match),
|
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_match),
|
||||||
(gpointer) (&fake_dev->ret_match));
|
(gpointer) (&fake_dev->ret_match));
|
||||||
g_assert_true (fp_device_identify_sync (device, prints, NULL,
|
g_assert_true (fp_device_identify_sync (device, prints, NULL,
|
||||||
|
@ -1505,7 +1545,7 @@ test_driver_identify_complete_retry (void)
|
||||||
test_driver_match_data_clear (match_data);
|
test_driver_match_data_clear (match_data);
|
||||||
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_REMOVE_FINGER);
|
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_REMOVE_FINGER);
|
||||||
fake_dev->ret_match = prints->pdata[0];
|
fake_dev->ret_match = prints->pdata[0];
|
||||||
fake_dev->ret_print = fp_print_new (device);
|
fake_dev->ret_print = make_fake_print (device, NULL);
|
||||||
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
|
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
|
||||||
(gpointer) (&fake_dev->ret_print));
|
(gpointer) (&fake_dev->ret_print));
|
||||||
g_assert_false (fp_device_identify_sync (device, prints, NULL,
|
g_assert_false (fp_device_identify_sync (device, prints, NULL,
|
||||||
|
@ -1528,7 +1568,7 @@ test_driver_identify_report_no_callback (void)
|
||||||
{
|
{
|
||||||
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||||
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = NULL;
|
g_autoptr(FpAutoCloseDevice) device = NULL;
|
||||||
G_GNUC_UNUSED g_autoptr(FpPrint) enrolled_print = NULL;
|
G_GNUC_UNUSED g_autoptr(FpPrint) enrolled_print = NULL;
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
|
@ -1539,7 +1579,8 @@ test_driver_identify_report_no_callback (void)
|
||||||
dev_class->identify = fake_device_identify_complete_error;
|
dev_class->identify = fake_device_identify_complete_error;
|
||||||
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
fake_dev = FPI_DEVICE_FAKE (device);
|
fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
enrolled_print = g_object_ref_sink (fp_print_new (device));
|
prints = make_fake_prints_gallery (device, 0);
|
||||||
|
enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
|
|
||||||
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
||||||
|
|
||||||
|
@ -1666,15 +1707,10 @@ test_driver_list (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
|
g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
|
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 500; ++i)
|
|
||||||
g_ptr_array_add (prints, fp_print_new (device));
|
|
||||||
|
|
||||||
fake_dev->ret_list = g_steal_pointer (&prints);
|
fake_dev->ret_list = g_steal_pointer (&prints);
|
||||||
prints = fp_device_list_prints_sync (device, NULL, &error);
|
prints = fp_device_list_prints_sync (device, NULL, &error);
|
||||||
|
|
||||||
|
@ -1727,7 +1763,7 @@ test_driver_delete (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = fp_print_new (device);
|
g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
@ -1744,7 +1780,7 @@ test_driver_delete_error (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = fp_print_new (device);
|
g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
@ -1812,7 +1848,7 @@ test_driver_cancel (void)
|
||||||
device = auto_close_fake_device_new ();
|
device = auto_close_fake_device_new ();
|
||||||
fake_dev = FPI_DEVICE_FAKE (device);
|
fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
cancellable = g_cancellable_new ();
|
cancellable = g_cancellable_new ();
|
||||||
enrolled_print = fp_print_new (device);
|
enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
|
|
||||||
fp_device_delete_print (device, enrolled_print, cancellable,
|
fp_device_delete_print (device, enrolled_print, cancellable,
|
||||||
on_driver_cancel_delete, &completed);
|
on_driver_cancel_delete, &completed);
|
||||||
|
@ -1830,7 +1866,7 @@ test_driver_cancel_fail (void)
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(GCancellable) cancellable = g_cancellable_new ();
|
g_autoptr(GCancellable) cancellable = g_cancellable_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = fp_print_new (device);
|
g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
|
|
||||||
|
@ -2064,8 +2100,8 @@ static void
|
||||||
test_driver_action_error_all (void)
|
test_driver_action_error_all (void)
|
||||||
{
|
{
|
||||||
g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 0);
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev;
|
FpiDeviceFake *fake_dev;
|
||||||
|
@ -2136,8 +2172,8 @@ static void
|
||||||
test_driver_action_error_fallback_all (void)
|
test_driver_action_error_fallback_all (void)
|
||||||
{
|
{
|
||||||
g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 0);
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev;
|
FpiDeviceFake *fake_dev;
|
||||||
|
|
Loading…
Reference in a new issue