test-fpi-device: Add tests for verify/identify warnings
This commit is contained in:
parent
cdcc476325
commit
58a9214610
1 changed files with 174 additions and 1 deletions
|
@ -813,6 +813,46 @@ fake_device_verify_complete_error (FpDevice *device)
|
||||||
fpi_device_verify_complete (device, complete_error);
|
fpi_device_verify_complete (device, complete_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_driver_verify_report_no_callback (void)
|
||||||
|
{
|
||||||
|
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||||
|
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
|
||||||
|
g_autoptr(FpAutoCloseDevice) device = NULL;
|
||||||
|
g_autoptr(FpPrint) enrolled_print = NULL;
|
||||||
|
g_autoptr(FpPrint) print = NULL;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
FpiDeviceFake *fake_dev;
|
||||||
|
gboolean match;
|
||||||
|
|
||||||
|
dev_class->verify = fake_device_verify_complete_error;
|
||||||
|
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
|
fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
|
enrolled_print = g_object_ref_sink (fp_print_new (device));
|
||||||
|
|
||||||
|
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*Driver reported a verify error that was not in the retry domain*");
|
||||||
|
|
||||||
|
fake_dev->ret_result = FPI_MATCH_ERROR;
|
||||||
|
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED);
|
||||||
|
fp_device_verify_sync (device, enrolled_print, NULL,
|
||||||
|
test_driver_match_cb, match_data,
|
||||||
|
&match, &print, &error);
|
||||||
|
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_assert_false (match_data->called);
|
||||||
|
g_assert_null (match_data->match);
|
||||||
|
g_assert_no_error (match_data->error);
|
||||||
|
|
||||||
|
g_assert (fake_dev->last_called_function == dev_class->verify);
|
||||||
|
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED);
|
||||||
|
g_assert (error == g_steal_pointer (&fake_dev->ret_error));
|
||||||
|
g_assert_false (match);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_driver_verify_complete_retry (void)
|
test_driver_verify_complete_retry (void)
|
||||||
{
|
{
|
||||||
|
@ -893,6 +933,50 @@ test_driver_verify_complete_retry (void)
|
||||||
g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT);
|
g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT);
|
||||||
g_assert_false (match);
|
g_assert_false (match);
|
||||||
g_assert_null (print);
|
g_assert_null (print);
|
||||||
|
g_clear_error (&error);
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*Driver reported an error without specifying a retry "
|
||||||
|
"code, assuming general retry error*");
|
||||||
|
|
||||||
|
test_driver_match_data_clear (match_data);
|
||||||
|
fake_dev->ret_result = FPI_MATCH_ERROR;
|
||||||
|
|
||||||
|
fp_device_verify_sync (device, enrolled_print, NULL, test_driver_match_cb,
|
||||||
|
match_data, &match, &print, &error);
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_assert_true (error != g_steal_pointer (&fake_dev->ret_error));
|
||||||
|
g_assert_true (error != g_steal_pointer (&fake_dev->user_data));
|
||||||
|
g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL);
|
||||||
|
g_assert_true (match_data->called);
|
||||||
|
g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL);
|
||||||
|
g_assert_false (match);
|
||||||
|
g_assert_null (print);
|
||||||
|
g_clear_error (&error);
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*Driver reported a print together with an error*");
|
||||||
|
|
||||||
|
test_driver_match_data_clear (match_data);
|
||||||
|
fake_dev->ret_result = FPI_MATCH_ERROR;
|
||||||
|
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT);
|
||||||
|
fake_dev->ret_print = fp_print_new (device);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
|
||||||
|
(gpointer) (&fake_dev->ret_print));
|
||||||
|
|
||||||
|
fp_device_verify_sync (device, enrolled_print, NULL, test_driver_match_cb,
|
||||||
|
match_data, &match, &print, &error);
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT);
|
||||||
|
g_assert_true (error == g_steal_pointer (&fake_dev->ret_error));
|
||||||
|
g_assert_true (match_data->called);
|
||||||
|
g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT);
|
||||||
|
g_assert_null (fake_dev->ret_print);
|
||||||
|
g_assert_false (match);
|
||||||
|
g_assert_null (print);
|
||||||
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1088,7 +1172,6 @@ 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 = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
g_autoptr(FpPrint) out_print = NULL;
|
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -1118,6 +1201,8 @@ fake_device_identify_complete_error (FpDevice *device)
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
GError *complete_error = fake_dev->user_data;
|
GError *complete_error = fake_dev->user_data;
|
||||||
|
|
||||||
|
fake_dev->last_called_function = fake_device_identify_complete_error;
|
||||||
|
|
||||||
fpi_device_identify_report (device, fake_dev->ret_match, fake_dev->ret_print, fake_dev->ret_error);
|
fpi_device_identify_report (device, fake_dev->ret_match, fake_dev->ret_print, fake_dev->ret_error);
|
||||||
fpi_device_identify_complete (device, complete_error);
|
fpi_device_identify_complete (device, complete_error);
|
||||||
}
|
}
|
||||||
|
@ -1163,6 +1248,92 @@ test_driver_identify_complete_retry (void)
|
||||||
g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT);
|
g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT);
|
||||||
g_assert_null (match);
|
g_assert_null (match);
|
||||||
g_assert_null (print);
|
g_assert_null (print);
|
||||||
|
g_clear_error (&error);
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*Driver reported a match to a print that was not in the gallery*");
|
||||||
|
|
||||||
|
test_driver_match_data_clear (match_data);
|
||||||
|
fake_dev->ret_match = fp_print_new (device);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_match),
|
||||||
|
(gpointer) (&fake_dev->ret_match));
|
||||||
|
fp_device_identify_sync (device, prints, NULL, test_driver_match_cb, match_data,
|
||||||
|
&match, &print, &error);
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_object_unref (fake_dev->ret_match);
|
||||||
|
g_assert_null (fake_dev->ret_match);
|
||||||
|
g_assert_true (match_data->called);
|
||||||
|
g_assert_no_error (match_data->error);
|
||||||
|
g_assert_no_error (error);
|
||||||
|
g_assert_false (match);
|
||||||
|
g_assert_null (print);
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*Driver reported an error code but also provided a match*");
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*Driver reported a print together with an error*");
|
||||||
|
|
||||||
|
test_driver_match_data_clear (match_data);
|
||||||
|
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_REMOVE_FINGER);
|
||||||
|
fake_dev->ret_match = prints->pdata[0];
|
||||||
|
fake_dev->ret_print = fp_print_new (device);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
|
||||||
|
(gpointer) (&fake_dev->ret_print));
|
||||||
|
fp_device_identify_sync (device, prints, NULL, test_driver_match_cb, match_data,
|
||||||
|
&match, &print, &error);
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_REMOVE_FINGER);
|
||||||
|
g_assert_true (error == g_steal_pointer (&fake_dev->ret_error));
|
||||||
|
g_assert_null (fake_dev->ret_print);
|
||||||
|
g_assert_true (match_data->called);
|
||||||
|
g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_REMOVE_FINGER);
|
||||||
|
g_assert_false (match);
|
||||||
|
g_assert_null (print);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_driver_identify_report_no_callback (void)
|
||||||
|
{
|
||||||
|
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
|
||||||
|
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(FpAutoCloseDevice) device = NULL;
|
||||||
|
g_autoptr(FpPrint) enrolled_print = NULL;
|
||||||
|
g_autoptr(FpPrint) print = NULL;
|
||||||
|
g_autoptr(FpPrint) match = NULL;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
FpiDeviceFake *fake_dev;
|
||||||
|
|
||||||
|
dev_class->identify = fake_device_identify_complete_error;
|
||||||
|
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||||
|
fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
|
enrolled_print = g_object_ref_sink (fp_print_new (device));
|
||||||
|
|
||||||
|
g_assert_true (fp_device_open_sync (device, NULL, NULL));
|
||||||
|
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
|
||||||
|
"*Driver reported a verify error that was not in the retry domain*");
|
||||||
|
|
||||||
|
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED);
|
||||||
|
fp_device_identify_sync (device, prints, NULL,
|
||||||
|
test_driver_match_cb, match_data,
|
||||||
|
&match, &print, &error);
|
||||||
|
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_assert_null (match);
|
||||||
|
g_assert_null (print);
|
||||||
|
g_assert_false (match_data->called);
|
||||||
|
g_assert_null (match_data->match);
|
||||||
|
g_assert_no_error (match_data->error);
|
||||||
|
|
||||||
|
g_assert (fake_dev->last_called_function == dev_class->identify);
|
||||||
|
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED);
|
||||||
|
g_assert (error == g_steal_pointer (&fake_dev->ret_error));
|
||||||
|
g_assert_false (match);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1970,6 +2141,7 @@ main (int argc, char *argv[])
|
||||||
g_test_add_func ("/driver/verify/fail", test_driver_verify_fail);
|
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/retry", test_driver_verify_retry);
|
||||||
g_test_add_func ("/driver/verify/error", test_driver_verify_error);
|
g_test_add_func ("/driver/verify/error", test_driver_verify_error);
|
||||||
|
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/not_reported", test_driver_verify_not_reported);
|
||||||
g_test_add_func ("/driver/verify/complete_retry", test_driver_verify_complete_retry);
|
g_test_add_func ("/driver/verify/complete_retry", test_driver_verify_complete_retry);
|
||||||
g_test_add_func ("/driver/identify", test_driver_identify);
|
g_test_add_func ("/driver/identify", test_driver_identify);
|
||||||
|
@ -1978,6 +2150,7 @@ main (int argc, char *argv[])
|
||||||
g_test_add_func ("/driver/identify/error", test_driver_identify_error);
|
g_test_add_func ("/driver/identify/error", test_driver_identify_error);
|
||||||
g_test_add_func ("/driver/identify/not_reported", test_driver_identify_not_reported);
|
g_test_add_func ("/driver/identify/not_reported", test_driver_identify_not_reported);
|
||||||
g_test_add_func ("/driver/identify/complete_retry", test_driver_identify_complete_retry);
|
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", test_driver_capture);
|
||||||
g_test_add_func ("/driver/capture/error", test_driver_capture_error);
|
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", test_driver_list);
|
||||||
|
|
Loading…
Reference in a new issue