fp-device: Ensure finger status is set to proper type on property getter
Finger status is a flag not an enum. Add tests.
This commit is contained in:
parent
de271a0e8d
commit
b5496fd257
2 changed files with 14 additions and 1 deletions
|
@ -193,7 +193,7 @@ fp_device_get_property (GObject *object,
|
|||
break;
|
||||
|
||||
case PROP_FINGER_STATUS:
|
||||
g_value_set_enum (value, priv->finger_status);
|
||||
g_value_set_flags (value, priv->finger_status);
|
||||
break;
|
||||
|
||||
case PROP_DRIVER:
|
||||
|
|
|
@ -205,11 +205,16 @@ test_driver_finger_status_inactive (void)
|
|||
{
|
||||
g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||
FpFingerStatusFlags finger_status;
|
||||
|
||||
g_signal_connect (device, "notify::finger-status", G_CALLBACK (on_device_notify), NULL);
|
||||
|
||||
g_assert_false (fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE));
|
||||
g_assert_cmpuint (fp_device_get_finger_status (device), ==, FP_FINGER_STATUS_NONE);
|
||||
|
||||
g_object_get (fake_dev, "finger-status", &finger_status, NULL);
|
||||
g_assert_cmpuint (finger_status, ==, FP_FINGER_STATUS_NONE);
|
||||
|
||||
g_assert (fake_dev->last_called_function != on_device_notify);
|
||||
g_assert_null (g_steal_pointer (&fake_dev->user_data));
|
||||
}
|
||||
|
@ -220,12 +225,16 @@ test_driver_finger_status_needed (void)
|
|||
g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_autoptr(GParamSpec) pspec = NULL;
|
||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||
FpFingerStatusFlags finger_status;
|
||||
|
||||
g_signal_connect (device, "notify::finger-status", G_CALLBACK (on_device_notify), NULL);
|
||||
|
||||
g_assert_true (fpi_device_report_finger_status (device, FP_FINGER_STATUS_NEEDED));
|
||||
g_assert_cmpuint (fp_device_get_finger_status (device), ==, FP_FINGER_STATUS_NEEDED);
|
||||
|
||||
g_object_get (fake_dev, "finger-status", &finger_status, NULL);
|
||||
g_assert_cmpuint (finger_status, ==, FP_FINGER_STATUS_NEEDED);
|
||||
|
||||
g_assert (fake_dev->last_called_function == on_device_notify);
|
||||
pspec = g_steal_pointer (&fake_dev->user_data);
|
||||
g_assert_cmpstr (pspec->name, ==, "finger-status");
|
||||
|
@ -242,12 +251,16 @@ test_driver_finger_status_present (void)
|
|||
g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
|
||||
g_autoptr(GParamSpec) pspec = NULL;
|
||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||
FpFingerStatusFlags finger_status;
|
||||
|
||||
g_signal_connect (device, "notify::finger-status", G_CALLBACK (on_device_notify), NULL);
|
||||
|
||||
g_assert_true (fpi_device_report_finger_status (device, FP_FINGER_STATUS_PRESENT));
|
||||
g_assert_cmpuint (fp_device_get_finger_status (device), ==, FP_FINGER_STATUS_PRESENT);
|
||||
|
||||
g_object_get (fake_dev, "finger-status", &finger_status, NULL);
|
||||
g_assert_cmpuint (finger_status, ==, FP_FINGER_STATUS_PRESENT);
|
||||
|
||||
g_assert (fake_dev->last_called_function == on_device_notify);
|
||||
pspec = g_steal_pointer (&fake_dev->user_data);
|
||||
g_assert_cmpstr (pspec->name, ==, "finger-status");
|
||||
|
|
Loading…
Reference in a new issue