fp-device: Remove confusing success parameter on FpMatchCb

This was added as alias to the error check, but given we're passing to the
callback both the error and the match itself, we can just avoid adding an
extra parameter that could be confusing (as may imply that the matching
happened).

Also clarify the documentation and ensure that the match value is properly
set in tests.
This commit is contained in:
Marco Trevisan (Treviño)
2020-01-16 16:43:56 +01:00
parent 30c783cbeb
commit 0889ec20a8
3 changed files with 40 additions and 29 deletions

View File

@@ -546,7 +546,6 @@ test_driver_enroll_progress (void)
typedef struct
{
gboolean called;
gboolean success;
FpPrint *match;
FpPrint *print;
GError *error;
@@ -556,7 +555,6 @@ static void
test_driver_match_data_clear (MatchCbData *data)
{
data->called = FALSE;
data->success = FALSE;
g_clear_object (&data->match);
g_clear_object (&data->print);
g_clear_error (&data->error);
@@ -564,7 +562,6 @@ test_driver_match_data_clear (MatchCbData *data)
static void
test_driver_match_cb (FpDevice *device,
gboolean success,
FpPrint *match,
FpPrint *print,
gpointer user_data,
@@ -574,24 +571,18 @@ test_driver_match_cb (FpDevice *device,
g_assert (data->called == FALSE);
data->called = TRUE;
data->success = TRUE;
if (match)
data->match = g_object_ref (match);
if (print)
data->print = g_object_ref (print);
if (error)
data->error = g_error_copy (error);
if (success)
{
g_assert_null (error);
}
else
{
g_assert_nonnull (error);
data->error = g_error_copy (error);
g_assert_null (match);
g_assert_null (print);
}
if (match)
g_assert_no_error (error);
}
static void
@@ -616,7 +607,7 @@ test_driver_verify (void)
g_assert_no_error (error);
g_assert_true (match_data.called);
g_assert_true (match_data.success);
g_assert_nonnull (match_data.match);
g_assert_true (match_data.print == out_print);
g_assert_true (match_data.match == enrolled_print);
@@ -647,7 +638,7 @@ test_driver_verify_fail (void)
g_assert_no_error (error);
g_assert_true (match_data.called);
g_assert_true (match_data.success);
g_assert_no_error (match_data.error);
g_assert_true (match_data.print == out_print);
g_assert_null (match_data.match);
@@ -676,6 +667,7 @@ test_driver_verify_retry (void)
&match, &out_print, &error);
g_assert_true (match_data.called);
g_assert_null (match_data.match);
g_assert_error (match_data.error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL);
g_assert (fake_dev->last_called_function == dev_class->verify);
@@ -705,6 +697,8 @@ test_driver_verify_error (void)
&match, &out_print, &error);
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_GENERAL);
@@ -803,7 +797,7 @@ test_driver_identify (void)
&matched_print, &print, &error);
g_assert_true (match_data.called);
g_assert_true (match_data.success);
g_assert_nonnull (match_data.match);
g_assert_true (match_data.match == matched_print);
g_assert_true (match_data.print == print);
@@ -841,7 +835,8 @@ test_driver_identify_fail (void)
&matched_print, &print, &error);
g_assert_true (match_data.called);
g_assert_true (match_data.success);
g_assert_null (match_data.match);
g_assert_no_error (match_data.error);
g_assert_true (match_data.match == matched_print);
g_assert_true (match_data.print == print);
@@ -882,6 +877,7 @@ test_driver_identify_retry (void)
&matched_print, &print, &error);
g_assert_true (match_data.called);
g_assert_null (match_data.match);
g_assert_error (match_data.error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL);
g_assert (fake_dev->last_called_function == dev_class->identify);
@@ -921,6 +917,8 @@ test_driver_identify_error (void)
&matched_print, &print, &error);
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_GENERAL);