| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Unit tests for the internal fingerprint drivers API | ||
| 3 | * Copyright (C) 2019 Marco Trevisan <marco.trevisan@canonical.com> | ||
| 4 | * | ||
| 5 | * This library is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Lesser General Public | ||
| 7 | * License as published by the Free Software Foundation; either | ||
| 8 | * version 2.1 of the License, or (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This library is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | * Lesser General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU Lesser General Public | ||
| 16 | * License along with this library; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include "fp-device.h" | ||
| 21 | #include "fp-enums.h" | ||
| 22 | #include <libfprint/fprint.h> | ||
| 23 | |||
| 24 | #define FP_COMPONENT "device" | ||
| 25 | |||
| 26 | #include "fpi-device.h" | ||
| 27 | #include "fpi-compat.h" | ||
| 28 | #include "fpi-log.h" | ||
| 29 | #include "test-device-fake.h" | ||
| 30 | #include "fp-print-private.h" | ||
| 31 | |||
| 32 | /* gcc 12.0.1 is complaining about dangling pointers in the auto_close* functions */ | ||
| 33 | #if G_GNUC_CHECK_VERSION (12, 0) | ||
| 34 | #pragma GCC diagnostic push | ||
| 35 | #pragma GCC diagnostic ignored "-Wdangling-pointer" | ||
| 36 | #endif | ||
| 37 | |||
| 38 | /* Utility functions */ | ||
| 39 | |||
| 40 | typedef FpDevice FpAutoCloseDevice; | ||
| 41 | |||
| 42 | static FpAutoCloseDevice * | ||
| 43 | 33 | auto_close_fake_device_new (void) | |
| 44 | { | ||
| 45 | 66 | g_autoptr(GError) error = NULL; | |
| 46 | 33 | FpAutoCloseDevice *device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 47 | |||
| 48 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→9) taken 33 times.
|
33 | if (!fp_device_open_sync (device, NULL, &error)) |
| 49 | ✗ | g_error ("Could not open device: %s", error->message); | |
| 50 | |||
| 51 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 33 times.
|
33 | return device; |
| 52 | } | ||
| 53 | |||
| 54 | static void | ||
| 55 | 50 | auto_close_fake_device_free (FpAutoCloseDevice *device) | |
| 56 | { | ||
| 57 | 100 | g_autoptr(GError) error = NULL; | |
| 58 | 50 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 59 | |||
| 60 |
2/2✓ Branch 0 (2→3) taken 2 times.
✓ Branch 1 (2→4) taken 48 times.
|
50 | if (fake_dev->return_action_error) |
| 61 | { | ||
| 62 | 2 | fake_dev->return_action_error = FALSE; | |
| 63 | 2 | fake_dev->ret_error = NULL; | |
| 64 | } | ||
| 65 | |||
| 66 |
2/2✓ Branch 0 (5→6) taken 46 times.
✓ Branch 1 (5→11) taken 4 times.
|
50 | if (fp_device_is_open (device)) |
| 67 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→11) taken 46 times.
|
46 | if (!fp_device_close_sync (device, NULL, &error)) |
| 68 | ✗ | g_error ("Could not close device: %s", error->message); | |
| 69 | |||
| 70 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 50 times.
|
50 | g_object_unref (device); |
| 71 | 50 | } | |
| 72 | 3 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpAutoCloseDevice, auto_close_fake_device_free) | |
| 73 | |||
| 74 | #if G_GNUC_CHECK_VERSION (12, 0) | ||
| 75 | #pragma GCC diagnostic pop | ||
| 76 | #endif | ||
| 77 | |||
| 78 | typedef FpDeviceClass FpAutoResetClass; | ||
| 79 | static FpAutoResetClass default_fake_dev_class = {0}; | ||
| 80 | |||
| 81 | static FpAutoResetClass * | ||
| 82 | 51 | auto_reset_device_class (void) | |
| 83 | { | ||
| 84 | 102 | g_autoptr(FpDeviceClass) type_class = NULL; | |
| 85 | 51 | FpDeviceClass *dev_class = g_type_class_peek_static (FPI_TYPE_DEVICE_FAKE); | |
| 86 | |||
| 87 |
2/2✓ Branch 0 (4→5) taken 1 times.
✓ Branch 1 (4→9) taken 50 times.
|
51 | if (!dev_class) |
| 88 | { | ||
| 89 | 1 | type_class = g_type_class_ref (FPI_TYPE_DEVICE_FAKE); | |
| 90 | 1 | dev_class = type_class; | |
| 91 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_nonnull (dev_class); |
| 92 | } | ||
| 93 | |||
| 94 | 51 | default_fake_dev_class = *dev_class; | |
| 95 | |||
| 96 |
2/2✓ Branch 0 (9→10) taken 1 times.
✓ Branch 1 (9→11) taken 50 times.
|
51 | return dev_class; |
| 97 | } | ||
| 98 | |||
| 99 | static void | ||
| 100 | 51 | auto_reset_device_class_cleanup (FpAutoResetClass *dev_class) | |
| 101 | { | ||
| 102 | 51 | *dev_class = default_fake_dev_class; | |
| 103 | |||
| 104 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 51 times.
|
51 | g_assert_cmpint (memcmp (dev_class, &default_fake_dev_class, |
| 105 | sizeof (FpAutoResetClass)), ==, 0); | ||
| 106 | 51 | } | |
| 107 | 3 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpAutoResetClass, auto_reset_device_class_cleanup) | |
| 108 | |||
| 109 | |||
| 110 | static void | ||
| 111 | 3 | assert_equal_galleries (GPtrArray *g1, | |
| 112 | GPtrArray *g2) | ||
| 113 | { | ||
| 114 | 3 | unsigned i; | |
| 115 | |||
| 116 |
1/4✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→5) taken 3 times.
✗ Branch 2 (3→4) not taken.
✗ Branch 3 (3→5) not taken.
|
3 | g_assert ((g1 && g2) || (!g1 || !g1)); |
| 117 | |||
| 118 |
1/2✓ Branch 0 (5→6) taken 3 times.
✗ Branch 1 (5→14) not taken.
|
3 | if (g1 == g2) |
| 119 | return; | ||
| 120 | |||
| 121 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 3 times.
|
3 | g_assert_cmpuint (g1->len, ==, g2->len); |
| 122 | |||
| 123 |
2/2✓ Branch 0 (13→9) taken 1500 times.
✓ Branch 1 (13→14) taken 3 times.
|
1503 | for (i = 0; i < g1->len; i++) |
| 124 | { | ||
| 125 | 1500 | FpPrint *print = g_ptr_array_index (g1, i); | |
| 126 | |||
| 127 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1500 times.
|
1500 | g_assert_true (g_ptr_array_find_with_equal_func (g2, print, (GEqualFunc) |
| 128 | fp_print_equal, NULL)); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | static void | ||
| 133 | 9 | on_device_notify (FpDevice *device, GParamSpec *spec, gpointer user_data) | |
| 134 | { | ||
| 135 | 9 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 136 | |||
| 137 | 9 | fake_dev->last_called_function = on_device_notify; | |
| 138 | 9 | fake_dev->user_data = g_param_spec_ref (spec); | |
| 139 | 9 | } | |
| 140 | |||
| 141 | static FpPrint * | ||
| 142 | 5526 | make_fake_print (FpDevice *device, | |
| 143 | GVariant *print_data) | ||
| 144 | { | ||
| 145 | 5526 | FpPrint *enrolled_print = fp_print_new (device); | |
| 146 | |||
| 147 | 5526 | fpi_print_set_type (enrolled_print, FPI_PRINT_RAW); | |
| 148 | |||
| 149 |
2/2✓ Branch 0 (4→5) taken 23 times.
✓ Branch 1 (4→6) taken 5503 times.
|
5526 | if (!print_data) |
| 150 | 23 | print_data = g_variant_new_string ("Test print private data"); | |
| 151 | 5526 | g_object_set (G_OBJECT (enrolled_print), "fpi-data", print_data, NULL); | |
| 152 | |||
| 153 | 5526 | return enrolled_print; | |
| 154 | } | ||
| 155 | |||
| 156 | static FpPrint * | ||
| 157 | 4 | make_fake_nbis_print (FpDevice *device) | |
| 158 | { | ||
| 159 | 4 | FpPrint *enrolled_print = fp_print_new (device); | |
| 160 | |||
| 161 | 4 | fpi_print_set_type (enrolled_print, FPI_PRINT_NBIS); | |
| 162 | |||
| 163 | 4 | return enrolled_print; | |
| 164 | } | ||
| 165 | |||
| 166 | static FpPrint * | ||
| 167 | 5519 | make_fake_print_reffed (FpDevice *device, | |
| 168 | GVariant *print_data) | ||
| 169 | { | ||
| 170 | 5519 | return g_object_ref_sink (make_fake_print (device, print_data)); | |
| 171 | } | ||
| 172 | |||
| 173 | static GPtrArray * | ||
| 174 | 14 | make_fake_prints_gallery (FpDevice *device, | |
| 175 | size_t size) | ||
| 176 | { | ||
| 177 | 14 | GPtrArray *array; | |
| 178 | 14 | size_t i; | |
| 179 | |||
| 180 | 14 | array = g_ptr_array_new_full (size, g_object_unref); | |
| 181 | |||
| 182 |
2/2✓ Branch 0 (8→4) taken 5500 times.
✓ Branch 1 (8→9) taken 14 times.
|
5528 | for (i = 0; i < size; i++) |
| 183 | 5500 | g_ptr_array_add (array, make_fake_print_reffed (device, g_variant_new_uint64 (i))); | |
| 184 | |||
| 185 | 14 | return array; | |
| 186 | } | ||
| 187 | |||
| 188 | /* Tests */ | ||
| 189 | |||
| 190 | static void | ||
| 191 | 1 | test_driver_get_driver (void) | |
| 192 | { | ||
| 193 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 194 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 195 | |||
| 196 | 1 | dev_class->id = "test-fpi-device-driver"; | |
| 197 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 198 | |||
| 199 |
2/4✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
✓ Branch 2 (9→10) taken 1 times.
✗ Branch 3 (9→11) not taken.
|
1 | g_assert_cmpstr (fp_device_get_driver (device), ==, "test-fpi-device-driver"); |
| 200 | 1 | } | |
| 201 | |||
| 202 | static void | ||
| 203 | 1 | test_driver_get_device_id (void) | |
| 204 | { | ||
| 205 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 206 | |||
| 207 |
2/4✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✗ Branch 3 (8→10) not taken.
|
1 | g_assert_cmpstr (fp_device_get_device_id (device), ==, "0"); |
| 208 | 1 | } | |
| 209 | |||
| 210 | static void | ||
| 211 | 1 | test_driver_get_name (void) | |
| 212 | { | ||
| 213 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 214 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 215 | |||
| 216 | 1 | dev_class->full_name = "Test Device Full Name!"; | |
| 217 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 218 | |||
| 219 |
2/4✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
✓ Branch 2 (9→10) taken 1 times.
✗ Branch 3 (9→11) not taken.
|
1 | g_assert_cmpstr (fp_device_get_name (device), ==, "Test Device Full Name!"); |
| 220 | 1 | } | |
| 221 | |||
| 222 | static void | ||
| 223 | 1 | test_driver_is_open (void) | |
| 224 | { | ||
| 225 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 226 | |||
| 227 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert_false (fp_device_is_open (device)); |
| 228 | 1 | fp_device_open_sync (device, NULL, NULL); | |
| 229 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_true (fp_device_is_open (device)); |
| 230 | 1 | fp_device_close_sync (FP_DEVICE (device), NULL, NULL); | |
| 231 |
2/4✗ Branch 0 (13→14) not taken.
✓ Branch 1 (13→15) taken 1 times.
✓ Branch 2 (15→16) taken 1 times.
✗ Branch 3 (15→17) not taken.
|
1 | g_assert_false (fp_device_is_open (device)); |
| 232 | 1 | } | |
| 233 | |||
| 234 | static void | ||
| 235 | 1 | test_driver_get_scan_type_press (void) | |
| 236 | { | ||
| 237 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 238 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 239 | |||
| 240 | 1 | dev_class->scan_type = FP_SCAN_TYPE_PRESS; | |
| 241 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 242 |
2/4✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✗ Branch 3 (8→10) not taken.
|
1 | g_assert_cmpuint (fp_device_get_scan_type (device), ==, FP_SCAN_TYPE_PRESS); |
| 243 | 1 | } | |
| 244 | |||
| 245 | static void | ||
| 246 | 1 | test_driver_get_scan_type_swipe (void) | |
| 247 | { | ||
| 248 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 249 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 250 | |||
| 251 | 1 | dev_class->scan_type = FP_SCAN_TYPE_SWIPE; | |
| 252 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 253 |
2/4✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✗ Branch 3 (8→10) not taken.
|
1 | g_assert_cmpuint (fp_device_get_scan_type (device), ==, FP_SCAN_TYPE_SWIPE); |
| 254 | 1 | } | |
| 255 | |||
| 256 | static void | ||
| 257 | 1 | test_driver_set_scan_type_press (void) | |
| 258 | { | ||
| 259 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 260 | 1 | g_autoptr(GParamSpec) pspec = NULL; | |
| 261 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 262 | |||
| 263 | 1 | g_signal_connect (device, "notify::scan-type", G_CALLBACK (on_device_notify), NULL); | |
| 264 | |||
| 265 | 1 | fpi_device_set_scan_type (device, FP_SCAN_TYPE_PRESS); | |
| 266 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_scan_type (device), ==, FP_SCAN_TYPE_PRESS); |
| 267 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == on_device_notify); |
| 268 | |||
| 269 | 1 | pspec = g_steal_pointer (&fake_dev->user_data); | |
| 270 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_cmpstr (pspec->name, ==, "scan-type"); |
| 271 | 1 | } | |
| 272 | |||
| 273 | static void | ||
| 274 | 1 | test_driver_set_scan_type_swipe (void) | |
| 275 | { | ||
| 276 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 277 | 1 | g_autoptr(GParamSpec) pspec = NULL; | |
| 278 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 279 | |||
| 280 | 1 | g_signal_connect (device, "notify::scan-type", G_CALLBACK (on_device_notify), NULL); | |
| 281 | |||
| 282 | 1 | fpi_device_set_scan_type (device, FP_SCAN_TYPE_SWIPE); | |
| 283 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_scan_type (device), ==, FP_SCAN_TYPE_SWIPE); |
| 284 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == on_device_notify); |
| 285 | |||
| 286 | 1 | pspec = g_steal_pointer (&fake_dev->user_data); | |
| 287 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_cmpstr (pspec->name, ==, "scan-type"); |
| 288 | 1 | } | |
| 289 | |||
| 290 | static void | ||
| 291 | 1 | test_driver_finger_status_inactive (void) | |
| 292 | { | ||
| 293 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 294 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 295 | 1 | FpFingerStatusFlags finger_status; | |
| 296 | |||
| 297 | 1 | g_signal_connect (device, "notify::finger-status", G_CALLBACK (on_device_notify), NULL); | |
| 298 | |||
| 299 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_false (fpi_device_report_finger_status (device, FP_FINGER_STATUS_NONE)); |
| 300 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_finger_status (device), ==, FP_FINGER_STATUS_NONE); |
| 301 | |||
| 302 | 1 | g_object_get (fake_dev, "finger-status", &finger_status, NULL); | |
| 303 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_cmpuint (finger_status, ==, FP_FINGER_STATUS_NONE); |
| 304 | |||
| 305 |
1/2✓ Branch 0 (14→15) taken 1 times.
✗ Branch 1 (14→16) not taken.
|
1 | g_assert (fake_dev->last_called_function != on_device_notify); |
| 306 |
1/2✗ Branch 0 (15→17) not taken.
✓ Branch 1 (15→18) taken 1 times.
|
1 | g_assert_null (g_steal_pointer (&fake_dev->user_data)); |
| 307 | 1 | } | |
| 308 | |||
| 309 | static void | ||
| 310 | 1 | test_driver_finger_status_needed (void) | |
| 311 | { | ||
| 312 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 313 | 1 | g_autoptr(GParamSpec) pspec = NULL; | |
| 314 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 315 | 1 | FpFingerStatusFlags finger_status; | |
| 316 | |||
| 317 | 1 | g_signal_connect (device, "notify::finger-status", G_CALLBACK (on_device_notify), NULL); | |
| 318 | |||
| 319 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fpi_device_report_finger_status (device, FP_FINGER_STATUS_NEEDED)); |
| 320 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_finger_status (device), ==, FP_FINGER_STATUS_NEEDED); |
| 321 | |||
| 322 | 1 | g_object_get (fake_dev, "finger-status", &finger_status, NULL); | |
| 323 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_cmpuint (finger_status, ==, FP_FINGER_STATUS_NEEDED); |
| 324 | |||
| 325 |
1/2✓ Branch 0 (14→15) taken 1 times.
✗ Branch 1 (14→17) not taken.
|
1 | g_assert (fake_dev->last_called_function == on_device_notify); |
| 326 | 1 | pspec = g_steal_pointer (&fake_dev->user_data); | |
| 327 |
1/2✗ Branch 0 (16→18) not taken.
✓ Branch 1 (16→19) taken 1 times.
|
1 | g_assert_cmpstr (pspec->name, ==, "finger-status"); |
| 328 | |||
| 329 | 1 | fake_dev->last_called_function = NULL; | |
| 330 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_false (fpi_device_report_finger_status (device, FP_FINGER_STATUS_NEEDED)); |
| 331 |
1/2✗ Branch 0 (22→23) not taken.
✓ Branch 1 (22→24) taken 1 times.
|
1 | g_assert_null (fake_dev->last_called_function); |
| 332 |
1/2✗ Branch 0 (24→25) not taken.
✓ Branch 1 (24→26) taken 1 times.
|
1 | g_assert_null (g_steal_pointer (&fake_dev->user_data)); |
| 333 | 1 | } | |
| 334 | |||
| 335 | static void | ||
| 336 | 1 | test_driver_finger_status_present (void) | |
| 337 | { | ||
| 338 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 339 | 1 | g_autoptr(GParamSpec) pspec = NULL; | |
| 340 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 341 | 1 | FpFingerStatusFlags finger_status; | |
| 342 | |||
| 343 | 1 | g_signal_connect (device, "notify::finger-status", G_CALLBACK (on_device_notify), NULL); | |
| 344 | |||
| 345 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fpi_device_report_finger_status (device, FP_FINGER_STATUS_PRESENT)); |
| 346 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_finger_status (device), ==, FP_FINGER_STATUS_PRESENT); |
| 347 | |||
| 348 | 1 | g_object_get (fake_dev, "finger-status", &finger_status, NULL); | |
| 349 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_cmpuint (finger_status, ==, FP_FINGER_STATUS_PRESENT); |
| 350 | |||
| 351 |
1/2✓ Branch 0 (14→15) taken 1 times.
✗ Branch 1 (14→17) not taken.
|
1 | g_assert (fake_dev->last_called_function == on_device_notify); |
| 352 | 1 | pspec = g_steal_pointer (&fake_dev->user_data); | |
| 353 |
1/2✗ Branch 0 (16→18) not taken.
✓ Branch 1 (16→19) taken 1 times.
|
1 | g_assert_cmpstr (pspec->name, ==, "finger-status"); |
| 354 | |||
| 355 | 1 | fake_dev->last_called_function = NULL; | |
| 356 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_false (fpi_device_report_finger_status (device, FP_FINGER_STATUS_PRESENT)); |
| 357 |
1/2✗ Branch 0 (22→23) not taken.
✓ Branch 1 (22→24) taken 1 times.
|
1 | g_assert_null (fake_dev->last_called_function); |
| 358 |
1/2✗ Branch 0 (24→25) not taken.
✓ Branch 1 (24→26) taken 1 times.
|
1 | g_assert_null (g_steal_pointer (&fake_dev->user_data)); |
| 359 | 1 | } | |
| 360 | |||
| 361 | static void | ||
| 362 | 2 | driver_finger_status_changes_check (FpDevice *device, gboolean add) | |
| 363 | { | ||
| 364 | 2 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 365 | |||
| 366 | 2 | g_autoptr(GFlagsClass) status_class = g_type_class_ref (FP_TYPE_FINGER_STATUS_FLAGS); | |
| 367 | 2 | guint expected_status; | |
| 368 | 2 | guint initial_value; | |
| 369 | 2 | guint i; | |
| 370 | 2 | gulong signal_id; | |
| 371 | |||
| 372 |
2/2✓ Branch 0 (4→5) taken 1 times.
✓ Branch 1 (4→6) taken 1 times.
|
2 | if (add) |
| 373 | initial_value = FP_FINGER_STATUS_NONE; | ||
| 374 | else | ||
| 375 | 1 | initial_value = status_class->mask; | |
| 376 | |||
| 377 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 2 times.
|
2 | g_assert_cmpuint (fp_device_get_finger_status (device), ==, initial_value); |
| 378 | |||
| 379 | 2 | signal_id = g_signal_connect (device, "notify::finger-status", | |
| 380 | G_CALLBACK (on_device_notify), NULL); | ||
| 381 | |||
| 382 |
2/2✓ Branch 0 (39→11) taken 6 times.
✓ Branch 1 (39→40) taken 2 times.
|
10 | for (i = 0, expected_status = initial_value; i < status_class->n_values; ++i) |
| 383 | { | ||
| 384 | 6 | g_autoptr(GParamSpec) pspec = NULL; | |
| 385 | 6 | FpFingerStatusFlags finger_status = status_class->values[i].value; | |
| 386 |
2/2✓ Branch 0 (11→12) taken 3 times.
✓ Branch 1 (11→13) taken 3 times.
|
6 | FpFingerStatusFlags added_status = add ? finger_status : FP_FINGER_STATUS_NONE; |
| 387 | 3 | FpFingerStatusFlags removed_status = add ? FP_FINGER_STATUS_NONE : finger_status; | |
| 388 | 6 | gboolean ret; | |
| 389 | |||
| 390 | 6 | fake_dev->last_called_function = NULL; | |
| 391 | 6 | ret = fpi_device_report_finger_status_changes (device, | |
| 392 | added_status, | ||
| 393 | removed_status); | ||
| 394 |
2/2✓ Branch 0 (14→15) taken 4 times.
✓ Branch 1 (14→17) taken 2 times.
|
6 | if (finger_status != FP_FINGER_STATUS_NONE) |
| 395 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→19) taken 4 times.
|
4 | g_assert_true (ret); |
| 396 | else | ||
| 397 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 2 times.
|
2 | g_assert_false (ret); |
| 398 | |||
| 399 | 6 | expected_status |= added_status; | |
| 400 | 6 | expected_status &= ~removed_status; | |
| 401 | |||
| 402 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 6 times.
|
6 | g_assert_cmpuint (fp_device_get_finger_status (device), ==, expected_status); |
| 403 | |||
| 404 |
2/2✓ Branch 0 (22→23) taken 4 times.
✓ Branch 1 (22→29) taken 2 times.
|
6 | if (finger_status != FP_FINGER_STATUS_NONE) |
| 405 | { | ||
| 406 |
1/2✓ Branch 0 (23→24) taken 4 times.
✗ Branch 1 (23→27) not taken.
|
4 | g_assert (fake_dev->last_called_function == on_device_notify); |
| 407 | 4 | pspec = g_steal_pointer (&fake_dev->user_data); | |
| 408 |
1/2✓ Branch 0 (25→26) taken 4 times.
✗ Branch 1 (25→28) not taken.
|
4 | g_assert_cmpstr (pspec->name, ==, "finger-status"); |
| 409 | } | ||
| 410 | |||
| 411 | 6 | fake_dev->last_called_function = NULL; | |
| 412 |
1/2✗ Branch 0 (30→31) not taken.
✓ Branch 1 (30→32) taken 6 times.
|
6 | g_assert_false (fpi_device_report_finger_status_changes (device, |
| 413 | added_status, | ||
| 414 | removed_status)); | ||
| 415 |
1/2✗ Branch 0 (32→33) not taken.
✓ Branch 1 (32→34) taken 6 times.
|
6 | g_assert_null (fake_dev->last_called_function); |
| 416 |
3/4✗ Branch 0 (34→35) not taken.
✓ Branch 1 (34→36) taken 6 times.
✓ Branch 2 (36→37) taken 4 times.
✓ Branch 3 (36→38) taken 2 times.
|
6 | g_assert_null (g_steal_pointer (&fake_dev->user_data)); |
| 417 | } | ||
| 418 | |||
| 419 |
2/2✓ Branch 0 (40→41) taken 1 times.
✓ Branch 1 (40→44) taken 1 times.
|
2 | if (add) |
| 420 |
1/2✗ Branch 0 (42→43) not taken.
✓ Branch 1 (42→47) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_finger_status (device), ==, status_class->mask); |
| 421 | else | ||
| 422 |
1/2✗ Branch 0 (45→46) not taken.
✓ Branch 1 (45→47) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_finger_status (device), ==, FP_FINGER_STATUS_NONE); |
| 423 | |||
| 424 | 2 | fake_dev->last_called_function = NULL; | |
| 425 |
1/2✗ Branch 0 (48→49) not taken.
✓ Branch 1 (48→50) taken 2 times.
|
2 | g_assert_false (fpi_device_report_finger_status_changes (device, |
| 426 | FP_FINGER_STATUS_NONE, | ||
| 427 | FP_FINGER_STATUS_NONE)); | ||
| 428 | |||
| 429 |
1/2✗ Branch 0 (50→51) not taken.
✓ Branch 1 (50→52) taken 2 times.
|
2 | g_assert_null (fake_dev->last_called_function); |
| 430 |
1/2✗ Branch 0 (52→53) not taken.
✓ Branch 1 (52→54) taken 2 times.
|
2 | g_assert_null (g_steal_pointer (&fake_dev->user_data)); |
| 431 | |||
| 432 | 2 | g_signal_handler_disconnect (device, signal_id); | |
| 433 | 2 | } | |
| 434 | |||
| 435 | static void | ||
| 436 | 1 | test_driver_finger_status_changes (void) | |
| 437 | { | ||
| 438 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 439 | |||
| 440 | 1 | driver_finger_status_changes_check (device, TRUE); | |
| 441 |
1/2✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→8) not taken.
|
1 | driver_finger_status_changes_check (device, FALSE); |
| 442 | 1 | } | |
| 443 | |||
| 444 | static void | ||
| 445 | 1 | test_driver_get_nr_enroll_stages (void) | |
| 446 | { | ||
| 447 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 448 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 449 | 1 | int expected_stages = g_random_int_range (G_MININT32, G_MAXINT32); | |
| 450 | |||
| 451 | 1 | dev_class->nr_enroll_stages = expected_stages; | |
| 452 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 453 | |||
| 454 |
2/4✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
✓ Branch 2 (9→10) taken 1 times.
✗ Branch 3 (9→11) not taken.
|
1 | g_assert_cmpint (fp_device_get_nr_enroll_stages (device), ==, expected_stages); |
| 455 | 1 | } | |
| 456 | |||
| 457 | static void | ||
| 458 | 1 | test_driver_set_nr_enroll_stages (void) | |
| 459 | { | ||
| 460 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 461 | 1 | g_autoptr(GParamSpec) pspec = NULL; | |
| 462 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 463 | 1 | int expected_stages = g_random_int_range (1, G_MAXINT32); | |
| 464 | |||
| 465 | 1 | g_signal_connect (device, "notify::nr-enroll-stages", G_CALLBACK (on_device_notify), NULL); | |
| 466 | 1 | fpi_device_set_nr_enroll_stages (device, expected_stages); | |
| 467 | |||
| 468 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_cmpint (fp_device_get_nr_enroll_stages (device), ==, expected_stages); |
| 469 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == on_device_notify); |
| 470 | |||
| 471 | 1 | pspec = g_steal_pointer (&fake_dev->user_data); | |
| 472 |
1/2✗ Branch 0 (13→14) not taken.
✓ Branch 1 (13→15) taken 1 times.
|
1 | g_assert_cmpstr (pspec->name, ==, "nr-enroll-stages"); |
| 473 | |||
| 474 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 475 | "*enroll_stages > 0*"); | ||
| 476 | 1 | fpi_device_set_nr_enroll_stages (device, 0); | |
| 477 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_cmpint (fp_device_get_nr_enroll_stages (device), ==, expected_stages); |
| 478 | 1 | g_test_assert_expected_messages (); | |
| 479 | |||
| 480 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 481 | "*enroll_stages > 0*"); | ||
| 482 | 1 | fpi_device_set_nr_enroll_stages (device, -2); | |
| 483 |
1/2✗ Branch 0 (24→25) not taken.
✓ Branch 1 (24→26) taken 1 times.
|
1 | g_assert_cmpint (fp_device_get_nr_enroll_stages (device), ==, expected_stages); |
| 484 | 1 | g_test_assert_expected_messages (); | |
| 485 | 1 | } | |
| 486 | |||
| 487 | static void | ||
| 488 | 1 | test_driver_get_usb_device (void) | |
| 489 | { | ||
| 490 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 491 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 492 | |||
| 493 | 1 | dev_class->type = FP_DEVICE_TYPE_USB; | |
| 494 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, "fpi-usb-device", NULL, NULL); | |
| 495 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_null (fpi_device_get_usb_device (device)); |
| 496 | |||
| 497 |
1/2✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→10) not taken.
|
1 | g_clear_object (&device); |
| 498 | 1 | dev_class->type = FP_DEVICE_TYPE_VIRTUAL; | |
| 499 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 500 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 501 | "*assertion*type*FP_DEVICE_TYPE_USB*failed*"); | ||
| 502 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_null (fpi_device_get_usb_device (device)); |
| 503 |
1/2✓ Branch 0 (17→18) taken 1 times.
✗ Branch 1 (17→19) not taken.
|
1 | g_test_assert_expected_messages (); |
| 504 | 1 | } | |
| 505 | |||
| 506 | static void | ||
| 507 | 1 | test_driver_get_virtual_env (void) | |
| 508 | { | ||
| 509 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 510 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 511 | |||
| 512 | 1 | dev_class->type = FP_DEVICE_TYPE_VIRTUAL; | |
| 513 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, "fpi-environ", "TEST_VIRTUAL_ENV_GETTER", NULL); | |
| 514 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_cmpstr (fpi_device_get_virtual_env (device), ==, "TEST_VIRTUAL_ENV_GETTER"); |
| 515 | |||
| 516 |
1/2✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→11) not taken.
|
1 | g_clear_object (&device); |
| 517 | 1 | dev_class->type = FP_DEVICE_TYPE_USB; | |
| 518 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 519 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 520 | "*assertion*type*FP_DEVICE_TYPE_VIRTUAL*failed*"); | ||
| 521 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert_null (fpi_device_get_virtual_env (device)); |
| 522 |
1/2✓ Branch 0 (18→19) taken 1 times.
✗ Branch 1 (18→20) not taken.
|
1 | g_test_assert_expected_messages (); |
| 523 | 1 | } | |
| 524 | |||
| 525 | static void | ||
| 526 | 1 | test_driver_get_driver_data (void) | |
| 527 | { | ||
| 528 | 2 | g_autoptr(FpDevice) device = NULL; | |
| 529 | 1 | guint64 driver_data; | |
| 530 | |||
| 531 | 1 | driver_data = g_random_int (); | |
| 532 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, "fpi-driver-data", driver_data, NULL); | |
| 533 |
2/4✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✗ Branch 3 (8→10) not taken.
|
1 | g_assert_cmpuint (fpi_device_get_driver_data (device), ==, driver_data); |
| 534 | 1 | } | |
| 535 | |||
| 536 | static void | ||
| 537 | 1 | test_driver_features_probe_updates (void) | |
| 538 | { | ||
| 539 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 540 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); |
| 541 | 1 | FpiDeviceFake *fake_dev; | |
| 542 | |||
| 543 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 544 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 545 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 546 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 547 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 548 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 549 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 550 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 551 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 552 | |||
| 553 | /* Effectively clears FP_DEVICE_FEATURE_STORAGE_DELETE */ | ||
| 554 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 555 | 1 | fake_dev->probe_features_update = FP_DEVICE_FEATURE_STORAGE_LIST | FP_DEVICE_FEATURE_STORAGE_DELETE; | |
| 556 | 1 | fake_dev->probe_features_value = FP_DEVICE_FEATURE_STORAGE_LIST; | |
| 557 | |||
| 558 | 1 | g_async_initable_init_async (G_ASYNC_INITABLE (device), | |
| 559 | G_PRIORITY_DEFAULT, NULL, NULL, NULL); | ||
| 560 |
2/2✓ Branch 0 (26→24) taken 2 times.
✓ Branch 1 (26→27) taken 1 times.
|
3 | while (g_main_context_iteration (NULL, FALSE)) |
| 561 | 2 | continue; | |
| 562 | |||
| 563 |
1/2✗ Branch 0 (28→29) not taken.
✓ Branch 1 (28→30) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE)); |
| 564 |
1/2✗ Branch 0 (31→32) not taken.
✓ Branch 1 (31→33) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); |
| 565 |
1/2✗ Branch 0 (34→35) not taken.
✓ Branch 1 (34→36) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_VERIFY)); |
| 566 |
1/2✗ Branch 0 (37→38) not taken.
✓ Branch 1 (37→39) taken 1 times.
|
1 | g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_DUPLICATES_CHECK)); |
| 567 |
1/2✗ Branch 0 (40→41) not taken.
✓ Branch 1 (40→42) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE)); |
| 568 |
1/2✗ Branch 0 (43→44) not taken.
✓ Branch 1 (43→45) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_LIST)); |
| 569 |
1/2✗ Branch 0 (46→47) not taken.
✓ Branch 1 (46→48) taken 1 times.
|
1 | g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_DELETE)); |
| 570 |
1/2✗ Branch 0 (49→50) not taken.
✓ Branch 1 (49→51) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_CLEAR)); |
| 571 | |||
| 572 |
1/2✗ Branch 0 (52→53) not taken.
✓ Branch 1 (52→54) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_features (device), |
| 573 | ==, | ||
| 574 | FP_DEVICE_FEATURE_CAPTURE | | ||
| 575 | FP_DEVICE_FEATURE_IDENTIFY | | ||
| 576 | FP_DEVICE_FEATURE_VERIFY | | ||
| 577 | FP_DEVICE_FEATURE_STORAGE | | ||
| 578 | FP_DEVICE_FEATURE_STORAGE_LIST | | ||
| 579 | FP_DEVICE_FEATURE_STORAGE_CLEAR); | ||
| 580 | 1 | } | |
| 581 | |||
| 582 | static void | ||
| 583 | 1 | test_driver_initial_features (void) | |
| 584 | { | ||
| 585 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 586 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); |
| 587 | |||
| 588 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 589 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 590 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 591 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 592 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 593 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 594 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 595 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 596 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 597 | |||
| 598 | 1 | g_async_initable_init_async (G_ASYNC_INITABLE (device), | |
| 599 | G_PRIORITY_DEFAULT, NULL, NULL, NULL); | ||
| 600 |
2/2✓ Branch 0 (26→24) taken 2 times.
✓ Branch 1 (26→27) taken 1 times.
|
3 | while (g_main_context_iteration (NULL, FALSE)) |
| 601 | 2 | continue; | |
| 602 | |||
| 603 |
1/2✗ Branch 0 (28→29) not taken.
✓ Branch 1 (28→30) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE)); |
| 604 |
1/2✗ Branch 0 (31→32) not taken.
✓ Branch 1 (31→33) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); |
| 605 |
1/2✗ Branch 0 (34→35) not taken.
✓ Branch 1 (34→36) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_VERIFY)); |
| 606 |
1/2✗ Branch 0 (37→38) not taken.
✓ Branch 1 (37→39) taken 1 times.
|
1 | g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_DUPLICATES_CHECK)); |
| 607 |
1/2✗ Branch 0 (40→41) not taken.
✓ Branch 1 (40→42) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE)); |
| 608 |
1/2✗ Branch 0 (43→44) not taken.
✓ Branch 1 (43→45) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_LIST)); |
| 609 |
1/2✗ Branch 0 (46→47) not taken.
✓ Branch 1 (46→48) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_DELETE)); |
| 610 |
1/2✗ Branch 0 (49→50) not taken.
✓ Branch 1 (49→51) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE_CLEAR)); |
| 611 | |||
| 612 |
1/2✗ Branch 0 (52→53) not taken.
✓ Branch 1 (52→54) taken 1 times.
|
1 | g_assert_cmpuint (fp_device_get_features (device), |
| 613 | ==, | ||
| 614 | FP_DEVICE_FEATURE_CAPTURE | | ||
| 615 | FP_DEVICE_FEATURE_IDENTIFY | | ||
| 616 | FP_DEVICE_FEATURE_VERIFY | | ||
| 617 | FP_DEVICE_FEATURE_STORAGE | | ||
| 618 | FP_DEVICE_FEATURE_STORAGE_LIST | | ||
| 619 | FP_DEVICE_FEATURE_STORAGE_DELETE | | ||
| 620 | FP_DEVICE_FEATURE_STORAGE_CLEAR); | ||
| 621 | 1 | } | |
| 622 | |||
| 623 | static void | ||
| 624 | 1 | test_driver_initial_features_none (void) | |
| 625 | { | ||
| 626 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 627 | |||
| 628 | 1 | dev_class->list = NULL; | |
| 629 | 1 | dev_class->capture = NULL; | |
| 630 | 1 | dev_class->verify = NULL; | |
| 631 | 1 | dev_class->identify = NULL; | |
| 632 | 1 | dev_class->delete = NULL; | |
| 633 | 1 | dev_class->clear_storage = NULL; | |
| 634 | 1 | dev_class->features = FP_DEVICE_FEATURE_NONE; | |
| 635 | |||
| 636 | 1 | fpi_device_class_auto_initialize_features (dev_class); | |
| 637 | |||
| 638 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, ==, FP_DEVICE_FEATURE_NONE); |
| 639 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 640 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 641 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 642 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 643 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 644 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 645 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 646 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 647 | 1 | } | |
| 648 | |||
| 649 | static void | ||
| 650 | 1 | test_driver_initial_features_no_capture (void) | |
| 651 | { | ||
| 652 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 653 | |||
| 654 | 1 | dev_class->capture = NULL; | |
| 655 | 1 | dev_class->features = FP_DEVICE_FEATURE_NONE; | |
| 656 | |||
| 657 | 1 | fpi_device_class_auto_initialize_features (dev_class); | |
| 658 | |||
| 659 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 660 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 661 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 662 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 663 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 664 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 665 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 666 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 667 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 668 | 1 | } | |
| 669 | |||
| 670 | static void | ||
| 671 | 1 | test_driver_initial_features_no_verify (void) | |
| 672 | { | ||
| 673 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 674 | |||
| 675 | 1 | dev_class->verify = NULL; | |
| 676 | 1 | dev_class->features = FP_DEVICE_FEATURE_NONE; | |
| 677 | |||
| 678 | 1 | fpi_device_class_auto_initialize_features (dev_class); | |
| 679 | |||
| 680 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 681 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 682 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 683 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 684 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 685 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 686 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 687 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 688 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 689 | 1 | } | |
| 690 | |||
| 691 | static void | ||
| 692 | 1 | test_driver_initial_features_no_identify (void) | |
| 693 | { | ||
| 694 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 695 | |||
| 696 | 1 | dev_class->identify = NULL; | |
| 697 | 1 | dev_class->features = FP_DEVICE_FEATURE_NONE; | |
| 698 | |||
| 699 | 1 | fpi_device_class_auto_initialize_features (dev_class); | |
| 700 | |||
| 701 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 702 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 703 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 704 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 705 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 706 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 707 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 708 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 709 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 710 | 1 | } | |
| 711 | |||
| 712 | static void | ||
| 713 | 1 | test_driver_initial_features_no_storage (void) | |
| 714 | { | ||
| 715 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 716 | |||
| 717 | 1 | dev_class->delete = NULL; | |
| 718 | 1 | dev_class->features = FP_DEVICE_FEATURE_NONE; | |
| 719 | |||
| 720 | 1 | fpi_device_class_auto_initialize_features (dev_class); | |
| 721 | |||
| 722 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 723 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 724 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 725 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 726 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 727 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 728 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 729 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 730 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 731 | 1 | } | |
| 732 | |||
| 733 | static void | ||
| 734 | 1 | test_driver_initial_features_no_list (void) | |
| 735 | { | ||
| 736 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 737 | |||
| 738 | 1 | dev_class->list = NULL; | |
| 739 | 1 | dev_class->features = FP_DEVICE_FEATURE_NONE; | |
| 740 | |||
| 741 | 1 | fpi_device_class_auto_initialize_features (dev_class); | |
| 742 | |||
| 743 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 744 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 745 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 746 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 747 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 748 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 749 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 750 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 751 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 752 | 1 | } | |
| 753 | |||
| 754 | static void | ||
| 755 | 1 | test_driver_initial_features_no_delete (void) | |
| 756 | { | ||
| 757 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 758 | |||
| 759 | 1 | dev_class->delete = NULL; | |
| 760 | 1 | dev_class->features = FP_DEVICE_FEATURE_NONE; | |
| 761 | |||
| 762 | 1 | fpi_device_class_auto_initialize_features (dev_class); | |
| 763 | |||
| 764 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 765 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 766 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 767 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 768 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 769 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 770 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 771 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 772 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 773 | 1 | } | |
| 774 | |||
| 775 | static void | ||
| 776 | 1 | test_driver_initial_features_no_clear (void) | |
| 777 | { | ||
| 778 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 779 | |||
| 780 | 1 | dev_class->clear_storage = NULL; | |
| 781 | 1 | dev_class->features = FP_DEVICE_FEATURE_NONE; | |
| 782 | |||
| 783 | 1 | fpi_device_class_auto_initialize_features (dev_class); | |
| 784 | |||
| 785 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_cmpuint (dev_class->features, !=, FP_DEVICE_FEATURE_NONE); |
| 786 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_CAPTURE); |
| 787 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_IDENTIFY); |
| 788 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_VERIFY); |
| 789 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_DUPLICATES_CHECK); |
| 790 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE); |
| 791 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_LIST); |
| 792 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (dev_class->features & FP_DEVICE_FEATURE_STORAGE_DELETE); |
| 793 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_false (dev_class->features & FP_DEVICE_FEATURE_STORAGE_CLEAR); |
| 794 | 1 | } | |
| 795 | |||
| 796 | static void | ||
| 797 | 1 | on_driver_probe_async (GObject *initable, GAsyncResult *res, gpointer user_data) | |
| 798 | { | ||
| 799 | 2 | g_autoptr(GError) error = NULL; | |
| 800 | 1 | FpDevice **out_device = user_data; | |
| 801 | 1 | FpDevice *device; | |
| 802 | 1 | FpDeviceClass *dev_class; | |
| 803 | 1 | FpiDeviceFake *fake_dev; | |
| 804 | |||
| 805 | 1 | device = FP_DEVICE (g_async_initable_new_finish (G_ASYNC_INITABLE (initable), res, &error)); | |
| 806 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | dev_class = FP_DEVICE_GET_CLASS (device); |
| 807 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 808 | |||
| 809 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->probe); |
| 810 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert_no_error (error); |
| 811 | |||
| 812 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_false (fp_device_is_open (device)); |
| 813 | |||
| 814 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | *out_device = device; |
| 815 | 1 | } | |
| 816 | |||
| 817 | static void | ||
| 818 | 1 | test_driver_probe (void) | |
| 819 | { | ||
| 820 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 821 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 822 | |||
| 823 | 1 | dev_class->id = "Probed device ID"; | |
| 824 | 1 | dev_class->full_name = "Probed device name"; | |
| 825 | 1 | g_async_initable_new_async (FPI_TYPE_DEVICE_FAKE, G_PRIORITY_DEFAULT, NULL, | |
| 826 | on_driver_probe_async, &device, NULL); | ||
| 827 | |||
| 828 |
2/2✓ Branch 0 (8→6) taken 2 times.
✓ Branch 1 (8→9) taken 1 times.
|
3 | while (!FP_IS_DEVICE (device)) |
| 829 | 2 | g_main_context_iteration (NULL, TRUE); | |
| 830 | |||
| 831 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_false (fp_device_is_open (device)); |
| 832 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_cmpstr (fp_device_get_device_id (device), ==, "Probed device ID"); |
| 833 |
2/4✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
✓ Branch 2 (20→21) taken 1 times.
✗ Branch 3 (20→22) not taken.
|
1 | g_assert_cmpstr (fp_device_get_name (device), ==, "Probed device name"); |
| 834 | 1 | } | |
| 835 | |||
| 836 | static void | ||
| 837 | 1 | fake_device_probe_error (FpDevice *device) | |
| 838 | { | ||
| 839 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 840 | |||
| 841 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_PROBE); |
| 842 | |||
| 843 | 1 | fpi_device_probe_complete (device, dev_class->id, dev_class->full_name, | |
| 844 | fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED)); | ||
| 845 | 1 | } | |
| 846 | |||
| 847 | static void | ||
| 848 | 1 | fake_device_probe_action_error (FpDevice *device) | |
| 849 | { | ||
| 850 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_PROBE); |
| 851 | |||
| 852 | 1 | fpi_device_action_error (device, fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED)); | |
| 853 | 1 | } | |
| 854 | |||
| 855 | static void | ||
| 856 | 2 | on_driver_probe_error_async (GObject *initable, GAsyncResult *res, gpointer user_data) | |
| 857 | { | ||
| 858 | 4 | g_autoptr(GError) error = NULL; | |
| 859 | 2 | gboolean *out_done = user_data; | |
| 860 | 2 | FpDevice *device; | |
| 861 | |||
| 862 | 2 | device = FP_DEVICE (g_async_initable_new_finish (G_ASYNC_INITABLE (initable), res, &error)); | |
| 863 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 2 times.
|
2 | g_assert_null (device); |
| 864 | |||
| 865 |
3/6✓ Branch 0 (5→6) taken 2 times.
✗ Branch 1 (5→9) not taken.
✓ Branch 2 (7→8) taken 2 times.
✗ Branch 3 (7→9) not taken.
✗ Branch 4 (8→9) not taken.
✓ Branch 5 (8→11) taken 2 times.
|
2 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED); |
| 866 |
1/2✓ Branch 0 (11→12) taken 2 times.
✗ Branch 1 (11→13) not taken.
|
2 | *out_done = TRUE; |
| 867 | 2 | } | |
| 868 | |||
| 869 | static void | ||
| 870 | 1 | test_driver_probe_error (void) | |
| 871 | { | ||
| 872 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 873 | 1 | gboolean done = FALSE; | |
| 874 | |||
| 875 | 1 | dev_class->id = "Error device ID"; | |
| 876 | 1 | dev_class->probe = fake_device_probe_error; | |
| 877 | 1 | g_async_initable_new_async (FPI_TYPE_DEVICE_FAKE, G_PRIORITY_DEFAULT, NULL, | |
| 878 | on_driver_probe_error_async, &done, NULL); | ||
| 879 | |||
| 880 |
2/2✓ Branch 0 (7→6) taken 2 times.
✓ Branch 1 (7→8) taken 1 times.
|
3 | while (!done) |
| 881 | 2 | g_main_context_iteration (NULL, TRUE); | |
| 882 | 1 | } | |
| 883 | |||
| 884 | static void | ||
| 885 | 1 | test_driver_probe_action_error (void) | |
| 886 | { | ||
| 887 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 888 | 1 | gboolean done = FALSE; | |
| 889 | |||
| 890 | 1 | dev_class->id = "Error device ID"; | |
| 891 | 1 | dev_class->probe = fake_device_probe_action_error; | |
| 892 | 1 | g_async_initable_new_async (FPI_TYPE_DEVICE_FAKE, G_PRIORITY_DEFAULT, NULL, | |
| 893 | on_driver_probe_error_async, &done, NULL); | ||
| 894 | |||
| 895 |
2/2✓ Branch 0 (7→6) taken 2 times.
✓ Branch 1 (7→8) taken 1 times.
|
3 | while (!done) |
| 896 | 2 | g_main_context_iteration (NULL, TRUE); | |
| 897 | 1 | } | |
| 898 | |||
| 899 | static void | ||
| 900 | 1 | test_driver_open (void) | |
| 901 | { | ||
| 902 | 2 | g_autoptr(GError) error = NULL; | |
| 903 |
1/2✗ Branch 0 (22→23) not taken.
✓ Branch 1 (22→24) taken 1 times.
|
2 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); |
| 904 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); |
| 905 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 906 | |||
| 907 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function != dev_class->probe); |
| 908 | |||
| 909 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, &error)); |
| 910 |
1/2✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→11) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->open); |
| 911 |
1/2✗ Branch 0 (10→12) not taken.
✓ Branch 1 (10→13) taken 1 times.
|
1 | g_assert_no_error (error); |
| 912 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (fp_device_is_open (device)); |
| 913 | |||
| 914 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_true (fp_device_close_sync (FP_DEVICE (device), NULL, &error)); |
| 915 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 1 times.
|
1 | g_assert_no_error (error); |
| 916 | 1 | } | |
| 917 | |||
| 918 | static void | ||
| 919 | 1 | test_driver_open_error (void) | |
| 920 | { | ||
| 921 | 2 | g_autoptr(GError) error = NULL; | |
| 922 |
1/2✓ Branch 0 (22→23) taken 1 times.
✗ Branch 1 (22→24) not taken.
|
2 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); |
| 923 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 924 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 925 | |||
| 926 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 927 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_false (fp_device_open_sync (device, NULL, &error)); |
| 928 |
1/2✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→10) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->open); |
| 929 |
3/6✓ Branch 0 (9→11) taken 1 times.
✗ Branch 1 (9→14) not taken.
✓ Branch 2 (12→13) taken 1 times.
✗ Branch 3 (12→14) not taken.
✗ Branch 4 (13→14) not taken.
✓ Branch 5 (13→16) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 930 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_false (fp_device_is_open (device)); |
| 931 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 1 times.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 932 | 1 | } | |
| 933 | |||
| 934 | static void | ||
| 935 | 1 | test_driver_close (void) | |
| 936 | { | ||
| 937 | 2 | g_autoptr(GError) error = NULL; | |
| 938 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 939 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 940 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 941 | |||
| 942 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert_true (fp_device_close_sync (device, NULL, &error)); |
| 943 |
1/2✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→8) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->close); |
| 944 | |||
| 945 |
1/2✗ Branch 0 (7→9) not taken.
✓ Branch 1 (7→10) taken 1 times.
|
1 | g_assert_no_error (error); |
| 946 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_false (fp_device_is_open (device)); |
| 947 | 1 | } | |
| 948 | |||
| 949 | static void | ||
| 950 | 1 | test_driver_close_error (void) | |
| 951 | { | ||
| 952 | 2 | g_autoptr(GError) error = NULL; | |
| 953 |
1/2✓ Branch 0 (21→22) taken 1 times.
✗ Branch 1 (21→23) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 954 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 955 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 956 | |||
| 957 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 958 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert_false (fp_device_close_sync (device, NULL, &error)); |
| 959 | |||
| 960 |
1/2✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→9) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->close); |
| 961 |
3/6✓ Branch 0 (8→10) taken 1 times.
✗ Branch 1 (8→13) not taken.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
✗ Branch 4 (12→13) not taken.
✓ Branch 5 (12→15) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 962 |
1/2✓ Branch 0 (15→16) taken 1 times.
✗ Branch 1 (15→18) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 963 |
1/2✗ Branch 0 (17→19) not taken.
✓ Branch 1 (17→20) taken 1 times.
|
1 | g_assert_false (fp_device_is_open (device)); |
| 964 | 1 | } | |
| 965 | |||
| 966 | static void | ||
| 967 | 1 | test_driver_enroll (void) | |
| 968 | { | ||
| 969 | 2 | g_autoptr(GError) error = NULL; | |
| 970 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 971 | 2 | g_autoptr(FpPrint) template_print = fp_print_new (device); | |
| 972 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 973 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 974 | 1 | FpPrint *out_print = NULL; | |
| 975 | |||
| 976 | 1 | out_print = | |
| 977 | 1 | fp_device_enroll_sync (device, template_print, NULL, NULL, NULL, &error); | |
| 978 | |||
| 979 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->enroll); |
| 980 |
1/2✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→9) not taken.
|
1 | g_assert (fake_dev->action_data == template_print); |
| 981 | |||
| 982 |
1/2✗ Branch 0 (8→10) not taken.
✓ Branch 1 (8→11) taken 1 times.
|
1 | g_assert_no_error (error); |
| 983 |
2/4✓ Branch 0 (11→12) taken 1 times.
✗ Branch 1 (11→13) not taken.
✓ Branch 2 (12→14) taken 1 times.
✗ Branch 3 (12→15) not taken.
|
1 | g_assert (out_print == template_print); |
| 984 | 1 | } | |
| 985 | |||
| 986 | static void | ||
| 987 | 1 | test_driver_enroll_error (void) | |
| 988 | { | ||
| 989 | 2 | g_autoptr(GError) error = NULL; | |
| 990 |
1/2✓ Branch 0 (19→20) taken 1 times.
✗ Branch 1 (19→21) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 991 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 992 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 993 | 1 | FpPrint *template_print = fp_print_new (device); | |
| 994 | 1 | FpPrint *out_print = NULL; | |
| 995 | |||
| 996 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 997 | 1 | out_print = | |
| 998 | 1 | fp_device_enroll_sync (device, template_print, NULL, NULL, NULL, &error); | |
| 999 | |||
| 1000 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->enroll); |
| 1001 |
3/6✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→12) not taken.
✓ Branch 2 (10→11) taken 1 times.
✗ Branch 3 (10→12) not taken.
✗ Branch 4 (11→12) not taken.
✓ Branch 5 (11→14) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1002 |
1/2✓ Branch 0 (14→15) taken 1 times.
✗ Branch 1 (14→16) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1003 |
1/2✗ Branch 0 (15→17) not taken.
✓ Branch 1 (15→18) taken 1 times.
|
1 | g_assert_null (out_print); |
| 1004 | 1 | } | |
| 1005 | |||
| 1006 | static void | ||
| 1007 | 3 | test_driver_enroll_complete_simple (FpDevice *device) | |
| 1008 | { | ||
| 1009 | 3 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1010 | |||
| 1011 | 3 | fake_dev->last_called_function = test_driver_enroll_complete_simple; | |
| 1012 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 3 times.
|
3 | g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_ENROLL); |
| 1013 | |||
| 1014 | 3 | fpi_device_enroll_complete (device, fake_dev->ret_print, fake_dev->ret_error); | |
| 1015 | 3 | } | |
| 1016 | |||
| 1017 | static void | ||
| 1018 | 1 | test_driver_enroll_error_no_print (void) | |
| 1019 | { | ||
| 1020 | 2 | g_autoptr(GError) error = NULL; | |
| 1021 |
1/2✗ Branch 0 (63→64) not taken.
✓ Branch 1 (63→65) taken 1 times.
|
2 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); |
| 1022 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1023 | 1 | g_autoptr(FpPrint) out_print = NULL; | |
| 1024 | 1 | FpiDeviceFake *fake_dev; | |
| 1025 | |||
| 1026 | 1 | dev_class->enroll = test_driver_enroll_complete_simple; | |
| 1027 | 1 | device = auto_close_fake_device_new (); | |
| 1028 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1029 | |||
| 1030 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1031 | "*Driver did not provide a valid print and failed to provide an error*"); | ||
| 1032 | 2 | out_print = | |
| 1033 | 1 | fp_device_enroll_sync (device, fp_print_new (device), NULL, NULL, NULL, &error); | |
| 1034 | |||
| 1035 | 1 | g_test_assert_expected_messages (); | |
| 1036 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->enroll); |
| 1037 |
3/6✓ Branch 0 (10→11) taken 1 times.
✗ Branch 1 (10→14) not taken.
✓ Branch 2 (12→13) taken 1 times.
✗ Branch 3 (12→14) not taken.
✗ Branch 4 (13→14) not taken.
✓ Branch 5 (13→16) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1038 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_null (out_print); |
| 1039 | 1 | g_clear_error (&error); | |
| 1040 | |||
| 1041 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1042 | "*Driver passed an error but also provided a print, returning error*"); | ||
| 1043 | |||
| 1044 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 1045 | 1 | fake_dev->ret_print = make_fake_print_reffed (device, NULL); | |
| 1046 | 1 | g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print), | |
| 1047 | 1 | (gpointer) (&fake_dev->ret_print)); | |
| 1048 | 2 | out_print = | |
| 1049 | 1 | fp_device_enroll_sync (device, fp_print_new (device), NULL, NULL, NULL, &error); | |
| 1050 | |||
| 1051 | 1 | g_test_assert_expected_messages (); | |
| 1052 |
1/2✓ Branch 0 (26→27) taken 1 times.
✗ Branch 1 (26→28) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->enroll); |
| 1053 |
3/6✓ Branch 0 (27→29) taken 1 times.
✗ Branch 1 (27→32) not taken.
✓ Branch 2 (30→31) taken 1 times.
✗ Branch 3 (30→32) not taken.
✗ Branch 4 (31→32) not taken.
✓ Branch 5 (31→34) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1054 |
1/2✗ Branch 0 (34→35) not taken.
✓ Branch 1 (34→36) taken 1 times.
|
1 | g_assert_true (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1055 |
1/2✗ Branch 0 (36→37) not taken.
✓ Branch 1 (36→38) taken 1 times.
|
1 | g_assert_null (out_print); |
| 1056 |
1/2✗ Branch 0 (38→39) not taken.
✓ Branch 1 (38→40) taken 1 times.
|
1 | g_assert_null (fake_dev->ret_print); |
| 1057 | 1 | g_clear_error (&error); | |
| 1058 | |||
| 1059 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1060 | "*Driver did not set the type on the returned print*"); | ||
| 1061 | |||
| 1062 | 1 | fake_dev->ret_error = NULL; | |
| 1063 | 1 | fake_dev->ret_print = fp_print_new (device); /* Type not set. */ | |
| 1064 | 1 | g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print), | |
| 1065 | (gpointer) (&fake_dev->ret_print)); | ||
| 1066 | 2 | out_print = | |
| 1067 | 1 | fp_device_enroll_sync (device, fp_print_new (device), NULL, NULL, NULL, &error); | |
| 1068 | |||
| 1069 |
1/2✓ Branch 0 (46→47) taken 1 times.
✗ Branch 1 (46→48) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->enroll); |
| 1070 |
3/6✓ Branch 0 (47→49) taken 1 times.
✗ Branch 1 (47→52) not taken.
✓ Branch 2 (50→51) taken 1 times.
✗ Branch 3 (50→52) not taken.
✗ Branch 4 (51→52) not taken.
✓ Branch 5 (51→54) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1071 |
1/2✗ Branch 0 (54→55) not taken.
✓ Branch 1 (54→56) taken 1 times.
|
1 | g_assert_null (out_print); |
| 1072 |
1/2✗ Branch 0 (56→57) not taken.
✓ Branch 1 (56→58) taken 1 times.
|
1 | g_assert_null (fake_dev->ret_print); |
| 1073 |
1/2✗ Branch 0 (59→60) not taken.
✓ Branch 1 (59→61) taken 1 times.
|
1 | g_clear_error (&error); |
| 1074 | 1 | } | |
| 1075 | |||
| 1076 | static void | ||
| 1077 | 1 | test_driver_enroll_update_nbis (void) | |
| 1078 | { | ||
| 1079 | 2 | g_autoptr(GError) error = NULL; | |
| 1080 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
2 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); |
| 1081 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1082 | 1 | g_autoptr(FpPrint) template_print = NULL; | |
| 1083 | 1 | FpiDeviceFake *fake_dev = NULL; | |
| 1084 | 1 | FpPrint *out_print = NULL; | |
| 1085 | |||
| 1086 | 1 | dev_class->features |= FP_DEVICE_FEATURE_UPDATE_PRINT; | |
| 1087 | 1 | device = auto_close_fake_device_new (); | |
| 1088 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1089 | |||
| 1090 | 1 | template_print = make_fake_nbis_print (device); | |
| 1091 | 1 | fake_dev->ret_print = template_print; | |
| 1092 | |||
| 1093 | 1 | out_print = | |
| 1094 | 1 | fp_device_enroll_sync (device, template_print, NULL, NULL, NULL, &error); | |
| 1095 | |||
| 1096 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->enroll); |
| 1097 |
1/2✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→10) not taken.
|
1 | g_assert (fake_dev->action_data == template_print); |
| 1098 | |||
| 1099 |
1/2✗ Branch 0 (9→11) not taken.
✓ Branch 1 (9→12) taken 1 times.
|
1 | g_assert_no_error (error); |
| 1100 |
2/4✓ Branch 0 (12→13) taken 1 times.
✗ Branch 1 (12→14) not taken.
✓ Branch 2 (13→15) taken 1 times.
✗ Branch 3 (13→16) not taken.
|
1 | g_assert (out_print == template_print); |
| 1101 | 1 | } | |
| 1102 | |||
| 1103 | static void | ||
| 1104 | 1 | test_driver_enroll_update_nbis_wrong_device (void) | |
| 1105 | { | ||
| 1106 | 2 | g_autoptr(GError) error = NULL; | |
| 1107 |
1/2✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→22) not taken.
|
2 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); |
| 1108 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1109 | 1 | g_autoptr(FpPrint) template_print = NULL; | |
| 1110 | 1 | FpiDeviceFake *fake_dev = NULL; | |
| 1111 | 1 | FpPrint *out_print = NULL; | |
| 1112 | |||
| 1113 | 1 | dev_class->features |= FP_DEVICE_FEATURE_UPDATE_PRINT; | |
| 1114 | |||
| 1115 | 1 | device = auto_close_fake_device_new (); | |
| 1116 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1117 | |||
| 1118 | 1 | template_print = make_fake_nbis_print (device); | |
| 1119 |
1/2✓ Branch 0 (5→6) taken 1 times.
✗ Branch 1 (5→7) not taken.
|
1 | g_clear_pointer (&template_print->device_id, g_free); |
| 1120 | 1 | template_print->device_id = g_strdup ("wrong_device"); | |
| 1121 | 1 | fake_dev->ret_print = template_print; | |
| 1122 | |||
| 1123 | 1 | out_print = | |
| 1124 | 1 | fp_device_enroll_sync (device, template_print, NULL, NULL, NULL, &error); | |
| 1125 | |||
| 1126 |
3/6✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→13) not taken.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
✗ Branch 4 (12→13) not taken.
✓ Branch 5 (12→15) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 1127 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert (out_print == NULL); |
| 1128 | 1 | } | |
| 1129 | |||
| 1130 | static void | ||
| 1131 | 1 | test_driver_enroll_update_nbis_wrong_driver (void) | |
| 1132 | { | ||
| 1133 | 2 | g_autoptr(GError) error = NULL; | |
| 1134 |
1/2✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→22) not taken.
|
2 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); |
| 1135 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1136 | 1 | g_autoptr(FpPrint) template_print = NULL; | |
| 1137 | 1 | FpiDeviceFake *fake_dev = NULL; | |
| 1138 | 1 | FpPrint *out_print = NULL; | |
| 1139 | |||
| 1140 | 1 | dev_class->features |= FP_DEVICE_FEATURE_UPDATE_PRINT; | |
| 1141 | |||
| 1142 | 1 | device = auto_close_fake_device_new (); | |
| 1143 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1144 | |||
| 1145 | 1 | template_print = make_fake_nbis_print (device); | |
| 1146 |
1/2✓ Branch 0 (5→6) taken 1 times.
✗ Branch 1 (5→7) not taken.
|
1 | g_clear_pointer (&template_print->driver, g_free); |
| 1147 | 1 | template_print->driver = g_strdup ("wrong_driver"); | |
| 1148 | 1 | fake_dev->ret_print = template_print; | |
| 1149 | |||
| 1150 | 1 | out_print = | |
| 1151 | 1 | fp_device_enroll_sync (device, template_print, NULL, NULL, NULL, &error); | |
| 1152 | |||
| 1153 |
3/6✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→13) not taken.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
✗ Branch 4 (12→13) not taken.
✓ Branch 5 (12→15) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 1154 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert (out_print == NULL); |
| 1155 | 1 | } | |
| 1156 | |||
| 1157 | static void | ||
| 1158 | 1 | test_driver_enroll_update_nbis_missing_feature (void) | |
| 1159 | { | ||
| 1160 | 2 | g_autoptr(GError) error = NULL; | |
| 1161 |
1/2✓ Branch 0 (22→23) taken 1 times.
✗ Branch 1 (22→24) not taken.
|
2 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); |
| 1162 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1163 | 1 | g_autoptr(FpPrint) template_print = NULL; | |
| 1164 | 1 | FpiDeviceFake *fake_dev = NULL; | |
| 1165 | 1 | FpPrint *out_print = NULL; | |
| 1166 | |||
| 1167 | 1 | device = auto_close_fake_device_new (); | |
| 1168 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1169 | |||
| 1170 | 1 | template_print = make_fake_nbis_print (device); | |
| 1171 | 1 | fake_dev->ret_print = template_print; | |
| 1172 | |||
| 1173 | 1 | out_print = | |
| 1174 | 1 | fp_device_enroll_sync (device, template_print, NULL, NULL, NULL, &error); | |
| 1175 | |||
| 1176 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->open); |
| 1177 |
1/2✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→10) not taken.
|
1 | g_assert (fake_dev->action_data == NULL); |
| 1178 | |||
| 1179 |
3/6✓ Branch 0 (9→11) taken 1 times.
✗ Branch 1 (9→14) not taken.
✓ Branch 2 (12→13) taken 1 times.
✗ Branch 3 (12→14) not taken.
✗ Branch 4 (13→14) not taken.
✓ Branch 5 (13→16) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 1180 |
2/4✓ Branch 0 (16→17) taken 1 times.
✗ Branch 1 (16→18) not taken.
✓ Branch 2 (17→19) taken 1 times.
✗ Branch 3 (17→20) not taken.
|
1 | g_assert (out_print == NULL); |
| 1181 | 1 | } | |
| 1182 | |||
| 1183 | typedef struct | ||
| 1184 | { | ||
| 1185 | gint completed_stages; | ||
| 1186 | FpPrint *print; | ||
| 1187 | GError *error; | ||
| 1188 | } ExpectedEnrollData; | ||
| 1189 | |||
| 1190 | static void | ||
| 1191 | 3 | test_driver_enroll_progress_callback (FpDevice *device, | |
| 1192 | gint completed_stages, | ||
| 1193 | FpPrint *print, | ||
| 1194 | gpointer user_data, | ||
| 1195 | GError *error) | ||
| 1196 | { | ||
| 1197 | 3 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1198 | 3 | ExpectedEnrollData *expected_data = user_data; | |
| 1199 | |||
| 1200 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 3 times.
|
3 | g_assert_cmpint (expected_data->completed_stages, ==, completed_stages); |
| 1201 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 3 times.
|
3 | g_assert (expected_data->print == print); |
| 1202 |
3/4✓ Branch 0 (6→7) taken 1 times.
✓ Branch 1 (6→10) taken 2 times.
✗ Branch 2 (8→9) not taken.
✓ Branch 3 (8→10) taken 1 times.
|
3 | g_assert_true (print == NULL || FP_IS_PRINT (print)); |
| 1203 |
1/2✓ Branch 0 (10→11) taken 3 times.
✗ Branch 1 (10→12) not taken.
|
3 | g_assert (expected_data->error == error); |
| 1204 | |||
| 1205 | 3 | fake_dev->last_called_function = test_driver_enroll_progress_callback; | |
| 1206 | 3 | } | |
| 1207 | |||
| 1208 | static void | ||
| 1209 | 1 | test_driver_enroll_progress_vfunc (FpDevice *device) | |
| 1210 | { | ||
| 1211 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1212 | 1 | ExpectedEnrollData *expected_data = fake_dev->user_data; | |
| 1213 | |||
| 1214 | 2 | g_autoptr(GError) error = NULL; | |
| 1215 | |||
| 1216 | 2 | expected_data->completed_stages = | |
| 1217 | 1 | g_random_int_range (fp_device_get_nr_enroll_stages (device), G_MAXINT32); | |
| 1218 | 1 | expected_data->print = fp_print_new (device); | |
| 1219 | 1 | expected_data->error = NULL; | |
| 1220 | |||
| 1221 | 1 | g_object_add_weak_pointer (G_OBJECT (expected_data->print), | |
| 1222 | 1 | (gpointer) & expected_data->print); | |
| 1223 | |||
| 1224 | 1 | fpi_device_enroll_progress (device, expected_data->completed_stages, | |
| 1225 | expected_data->print, expected_data->error); | ||
| 1226 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == test_driver_enroll_progress_callback); |
| 1227 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_null (expected_data->print); |
| 1228 | |||
| 1229 | |||
| 1230 | 2 | expected_data->completed_stages = | |
| 1231 | 1 | g_random_int_range (fp_device_get_nr_enroll_stages (device), G_MAXINT32); | |
| 1232 | 1 | expected_data->print = NULL; | |
| 1233 | 1 | expected_data->error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT); | |
| 1234 | |||
| 1235 | 1 | fpi_device_enroll_progress (device, expected_data->completed_stages, | |
| 1236 | expected_data->print, expected_data->error); | ||
| 1237 |
1/2✓ Branch 0 (15→16) taken 1 times.
✗ Branch 1 (15→24) not taken.
|
1 | g_assert (fake_dev->last_called_function == test_driver_enroll_progress_callback); |
| 1238 | |||
| 1239 | |||
| 1240 | 2 | expected_data->completed_stages = | |
| 1241 | 1 | g_random_int_range (fp_device_get_nr_enroll_stages (device), G_MAXINT32); | |
| 1242 | 1 | expected_data->print = make_fake_print_reffed (device, | |
| 1243 | g_variant_new_int32 (expected_data->completed_stages)); | ||
| 1244 | 1 | expected_data->error = NULL; | |
| 1245 | |||
| 1246 | 1 | error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 1247 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 1248 | "*assertion*error*FP_DEVICE_RETRY*failed"); | ||
| 1249 | 1 | fpi_device_enroll_progress (device, expected_data->completed_stages, | |
| 1250 | expected_data->print, error); | ||
| 1251 |
1/2✓ Branch 0 (23→25) taken 1 times.
✗ Branch 1 (23→26) not taken.
|
1 | g_assert (fake_dev->last_called_function == test_driver_enroll_progress_callback); |
| 1252 |
1/2✓ Branch 0 (25→27) taken 1 times.
✗ Branch 1 (25→28) not taken.
|
1 | g_clear_object (&expected_data->print); |
| 1253 | 1 | g_test_assert_expected_messages (); | |
| 1254 | |||
| 1255 | 2 | expected_data->completed_stages = | |
| 1256 | 1 | g_random_int_range (fp_device_get_nr_enroll_stages (device), G_MAXINT32); | |
| 1257 | 1 | expected_data->print = NULL; | |
| 1258 | 1 | expected_data->error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT); | |
| 1259 | |||
| 1260 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1261 | "*Driver passed an error and also provided a print*"); | ||
| 1262 | 1 | fpi_device_enroll_progress (device, expected_data->completed_stages, | |
| 1263 | fp_print_new (device), expected_data->error); | ||
| 1264 |
1/2✓ Branch 0 (35→36) taken 1 times.
✗ Branch 1 (35→39) not taken.
|
1 | g_assert (fake_dev->last_called_function == test_driver_enroll_progress_callback); |
| 1265 | 1 | g_test_assert_expected_messages (); | |
| 1266 | |||
| 1267 | 1 | default_fake_dev_class.enroll (device); | |
| 1268 |
1/2✓ Branch 0 (38→40) taken 1 times.
✗ Branch 1 (38→41) not taken.
|
1 | fake_dev->last_called_function = test_driver_enroll_progress_vfunc; |
| 1269 | 1 | } | |
| 1270 | |||
| 1271 | static void | ||
| 1272 | 1 | test_driver_enroll_progress (void) | |
| 1273 | { | ||
| 1274 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1275 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1276 | 1 | G_GNUC_UNUSED g_autoptr(FpPrint) enrolled_print = NULL; | |
| 1277 | 1 | ExpectedEnrollData expected_enroll_data = {0}; | |
| 1278 | 1 | FpiDeviceFake *fake_dev; | |
| 1279 | |||
| 1280 | 1 | dev_class->nr_enroll_stages = g_random_int_range (10, G_MAXINT32); | |
| 1281 | 1 | dev_class->enroll = test_driver_enroll_progress_vfunc; | |
| 1282 | 1 | device = auto_close_fake_device_new (); | |
| 1283 | |||
| 1284 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 1285 | "*assertion*current_action*FPI_DEVICE_ACTION_ENROLL*failed"); | ||
| 1286 | 1 | fpi_device_enroll_progress (device, 0, NULL, NULL); | |
| 1287 | 1 | g_test_assert_expected_messages (); | |
| 1288 | |||
| 1289 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1290 | 1 | fake_dev->user_data = &expected_enroll_data; | |
| 1291 | |||
| 1292 | 1 | enrolled_print = fp_device_enroll_sync (device, fp_print_new (device), NULL, | |
| 1293 | test_driver_enroll_progress_callback, | ||
| 1294 | &expected_enroll_data, NULL); | ||
| 1295 | |||
| 1296 |
2/4✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
✓ Branch 2 (12→13) taken 1 times.
✗ Branch 3 (12→14) not taken.
|
1 | g_assert (fake_dev->last_called_function == test_driver_enroll_progress_vfunc); |
| 1297 | 1 | } | |
| 1298 | |||
| 1299 | typedef struct | ||
| 1300 | { | ||
| 1301 | gboolean called; | ||
| 1302 | FpPrint *match; | ||
| 1303 | FpPrint *print; | ||
| 1304 | GPtrArray *gallery; | ||
| 1305 | GError *error; | ||
| 1306 | } MatchCbData; | ||
| 1307 | |||
| 1308 | static void | ||
| 1309 | 28 | test_driver_match_data_clear (MatchCbData *data) | |
| 1310 | { | ||
| 1311 | 28 | data->called = FALSE; | |
| 1312 |
2/2✓ Branch 0 (2→3) taken 6 times.
✓ Branch 1 (2→4) taken 22 times.
|
28 | g_clear_object (&data->match); |
| 1313 |
2/2✓ Branch 0 (4→5) taken 8 times.
✓ Branch 1 (4→6) taken 20 times.
|
28 | g_clear_object (&data->print); |
| 1314 | 28 | g_clear_error (&data->error); | |
| 1315 | 28 | } | |
| 1316 | |||
| 1317 | static void | ||
| 1318 | 20 | test_driver_match_data_free (MatchCbData *data) | |
| 1319 | { | ||
| 1320 | 20 | test_driver_match_data_clear (data); | |
| 1321 | 20 | g_free (data); | |
| 1322 | 20 | } | |
| 1323 |
1/2✓ Branch 0 (2→3) taken 20 times.
✗ Branch 1 (2→6) not taken.
|
20 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (MatchCbData, test_driver_match_data_free); |
| 1324 | |||
| 1325 | static void | ||
| 1326 | 16 | test_driver_match_cb (FpDevice *device, | |
| 1327 | FpPrint *match, | ||
| 1328 | FpPrint *print, | ||
| 1329 | gpointer user_data, | ||
| 1330 | GError *error) | ||
| 1331 | { | ||
| 1332 | 16 | MatchCbData *data = user_data; | |
| 1333 | |||
| 1334 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 16 times.
|
16 | g_assert (data->called == FALSE); |
| 1335 | 16 | data->called = TRUE; | |
| 1336 |
2/2✓ Branch 0 (4→5) taken 4 times.
✓ Branch 1 (4→7) taken 12 times.
|
16 | if (match) |
| 1337 | 4 | data->match = g_object_ref (match); | |
| 1338 |
2/2✓ Branch 0 (7→8) taken 6 times.
✓ Branch 1 (7→10) taken 10 times.
|
16 | if (print) |
| 1339 | 6 | data->print = g_object_ref (print); | |
| 1340 |
2/2✓ Branch 0 (10→11) taken 9 times.
✓ Branch 1 (10→14) taken 7 times.
|
16 | if (error) |
| 1341 | { | ||
| 1342 | 9 | data->error = g_error_copy (error); | |
| 1343 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 9 times.
|
9 | g_assert_null (match); |
| 1344 | } | ||
| 1345 | |||
| 1346 |
2/2✓ Branch 0 (14→15) taken 4 times.
✓ Branch 1 (14→17) taken 12 times.
|
16 | if (match) |
| 1347 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 4 times.
|
4 | g_assert_no_error (error); |
| 1348 | |||
| 1349 | /* Compar gallery if this is an identify operation */ | ||
| 1350 |
2/2✓ Branch 0 (17→18) taken 3 times.
✓ Branch 1 (17→21) taken 13 times.
|
16 | if (data->gallery) |
| 1351 | { | ||
| 1352 | 3 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1353 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 3 times.
|
3 | g_assert_false (fake_dev->action_data == data->gallery); |
| 1354 | 3 | assert_equal_galleries (fake_dev->action_data, data->gallery); | |
| 1355 | } | ||
| 1356 | 16 | } | |
| 1357 | |||
| 1358 | static void | ||
| 1359 | 1 | fake_device_stub_verify (FpDevice *device) | |
| 1360 | { | ||
| 1361 | 1 | } | |
| 1362 | |||
| 1363 | static void | ||
| 1364 | 1 | test_driver_verify (void) | |
| 1365 | { | ||
| 1366 | 2 | g_autoptr(GError) error = NULL; | |
| 1367 |
1/2✗ Branch 0 (32→33) not taken.
✓ Branch 1 (32→34) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 1368 | 2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); | |
| 1369 |
1/2✓ Branch 0 (29→30) taken 1 times.
✗ Branch 1 (29→31) not taken.
|
1 | g_autoptr(FpPrint) out_print = NULL; |
| 1370 |
1/2✓ Branch 0 (27→28) taken 1 times.
✗ Branch 1 (27→29) not taken.
|
2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); |
| 1371 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 1372 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1373 | 1 | gboolean match; | |
| 1374 | |||
| 1375 | 1 | fake_dev->ret_result = FPI_MATCH_SUCCESS; | |
| 1376 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fp_device_verify_sync (device, enrolled_print, NULL, |
| 1377 | test_driver_match_cb, match_data, | ||
| 1378 | &match, &out_print, &error)); | ||
| 1379 | |||
| 1380 |
1/2✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→10) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->verify); |
| 1381 |
1/2✓ Branch 0 (9→11) taken 1 times.
✗ Branch 1 (9→12) not taken.
|
1 | g_assert (fake_dev->action_data == enrolled_print); |
| 1382 |
1/2✗ Branch 0 (11→13) not taken.
✓ Branch 1 (11→14) taken 1 times.
|
1 | g_assert_no_error (error); |
| 1383 | |||
| 1384 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1385 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_nonnull (match_data->match); |
| 1386 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (match_data->print == out_print); |
| 1387 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (match_data->match == enrolled_print); |
| 1388 | |||
| 1389 |
1/2✓ Branch 0 (22→23) taken 1 times.
✗ Branch 1 (22→24) not taken.
|
1 | g_assert (out_print == enrolled_print); |
| 1390 |
1/2✗ Branch 0 (23→25) not taken.
✓ Branch 1 (23→26) taken 1 times.
|
1 | g_assert_true (match); |
| 1391 | 1 | } | |
| 1392 | |||
| 1393 | static void | ||
| 1394 | 1 | test_driver_verify_not_supported (void) | |
| 1395 | { | ||
| 1396 | 2 | g_autoptr(GError) error = NULL; | |
| 1397 |
1/2✓ Branch 0 (33→34) taken 1 times.
✗ Branch 1 (33→35) not taken.
|
1 | g_autoptr(FpPrint) enrolled_print = NULL; |
| 1398 |
1/2✓ Branch 0 (31→32) taken 1 times.
✗ Branch 1 (31→33) not taken.
|
1 | g_autoptr(FpPrint) out_print = NULL; |
| 1399 |
1/2✗ Branch 0 (29→30) not taken.
✓ Branch 1 (29→31) taken 1 times.
|
2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); |
| 1400 | 2 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1401 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1402 | 1 | FpiDeviceFake *fake_dev; | |
| 1403 | 1 | gboolean match; | |
| 1404 | |||
| 1405 | 1 | dev_class->features &= ~FP_DEVICE_FEATURE_VERIFY; | |
| 1406 | |||
| 1407 | 1 | device = auto_close_fake_device_new (); | |
| 1408 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1409 | 1 | fake_dev->last_called_function = NULL; | |
| 1410 | |||
| 1411 | 1 | enrolled_print = make_fake_print_reffed (device, g_variant_new_uint64 (3)); | |
| 1412 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, |
| 1413 | test_driver_match_cb, match_data, | ||
| 1414 | &match, &out_print, &error)); | ||
| 1415 | |||
| 1416 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_null (fake_dev->last_called_function); |
| 1417 |
3/6✓ Branch 0 (12→13) taken 1 times.
✗ Branch 1 (12→16) not taken.
✓ Branch 2 (14→15) taken 1 times.
✗ Branch 3 (14→16) not taken.
✗ Branch 4 (15→16) not taken.
✓ Branch 5 (15→18) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED); |
| 1418 | |||
| 1419 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_false (match_data->called); |
| 1420 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_no_error (match_data->error); |
| 1421 | |||
| 1422 |
1/2✗ Branch 0 (22→23) not taken.
✓ Branch 1 (22→24) taken 1 times.
|
1 | g_assert_null (out_print); |
| 1423 |
1/2✗ Branch 0 (24→25) not taken.
✓ Branch 1 (24→26) taken 1 times.
|
1 | g_assert_false (match); |
| 1424 | 1 | } | |
| 1425 | |||
| 1426 | static void | ||
| 1427 | 1 | test_driver_verify_fail (void) | |
| 1428 | { | ||
| 1429 | 2 | g_autoptr(GError) error = NULL; | |
| 1430 |
1/2✗ Branch 0 (31→32) not taken.
✓ Branch 1 (31→33) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 1431 | 1 | g_autoptr(FpPrint) enrolled_print = NULL; | |
| 1432 |
1/2✓ Branch 0 (28→29) taken 1 times.
✗ Branch 1 (28→30) not taken.
|
1 | g_autoptr(FpPrint) out_print = NULL; |
| 1433 |
1/2✓ Branch 0 (26→27) taken 1 times.
✗ Branch 1 (26→28) not taken.
|
2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); |
| 1434 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 1435 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1436 | 1 | gboolean match; | |
| 1437 | |||
| 1438 | 1 | enrolled_print = make_fake_print_reffed (device, g_variant_new_uint64 (3)); | |
| 1439 | 1 | fake_dev->ret_result = FPI_MATCH_FAIL; | |
| 1440 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_true (fp_device_verify_sync (device, enrolled_print, NULL, |
| 1441 | test_driver_match_cb, match_data, | ||
| 1442 | &match, &out_print, &error)); | ||
| 1443 | |||
| 1444 |
1/2✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→11) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->verify); |
| 1445 |
1/2✗ Branch 0 (10→12) not taken.
✓ Branch 1 (10→13) taken 1 times.
|
1 | g_assert_no_error (error); |
| 1446 | |||
| 1447 |
1/2✗ Branch 0 (13→14) not taken.
✓ Branch 1 (13→15) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1448 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert_no_error (match_data->error); |
| 1449 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_true (match_data->print == out_print); |
| 1450 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 1 times.
|
1 | g_assert_null (match_data->match); |
| 1451 | |||
| 1452 |
1/2✓ Branch 0 (21→22) taken 1 times.
✗ Branch 1 (21→23) not taken.
|
1 | g_assert (out_print == enrolled_print); |
| 1453 |
1/2✗ Branch 0 (22→24) not taken.
✓ Branch 1 (22→25) taken 1 times.
|
1 | g_assert_false (match); |
| 1454 | 1 | } | |
| 1455 | |||
| 1456 | static void | ||
| 1457 | 1 | test_driver_verify_retry (void) | |
| 1458 | { | ||
| 1459 | 2 | g_autoptr(GError) error = NULL; | |
| 1460 |
1/2✓ Branch 0 (37→38) taken 1 times.
✗ Branch 1 (37→39) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 1461 | 2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); | |
| 1462 |
1/2✓ Branch 0 (34→35) taken 1 times.
✗ Branch 1 (34→36) not taken.
|
1 | g_autoptr(FpPrint) out_print = NULL; |
| 1463 |
1/2✗ Branch 0 (32→33) not taken.
✓ Branch 1 (32→34) taken 1 times.
|
2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); |
| 1464 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 1465 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1466 | 1 | gboolean match; | |
| 1467 | |||
| 1468 | 1 | fake_dev->ret_result = FPI_MATCH_ERROR; | |
| 1469 | 1 | fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_GENERAL); | |
| 1470 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, |
| 1471 | test_driver_match_cb, match_data, | ||
| 1472 | &match, &out_print, &error)); | ||
| 1473 | |||
| 1474 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1475 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_null (match_data->match); |
| 1476 |
3/6✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→17) not taken.
✓ Branch 2 (15→16) taken 1 times.
✗ Branch 3 (15→17) not taken.
✗ Branch 4 (16→17) not taken.
✓ Branch 5 (16→19) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL); |
| 1477 | |||
| 1478 |
1/2✓ Branch 0 (19→20) taken 1 times.
✗ Branch 1 (19→21) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->verify); |
| 1479 |
3/6✓ Branch 0 (20→22) taken 1 times.
✗ Branch 1 (20→25) not taken.
✓ Branch 2 (23→24) taken 1 times.
✗ Branch 3 (23→25) not taken.
✗ Branch 4 (24→25) not taken.
✓ Branch 5 (24→27) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL); |
| 1480 |
1/2✓ Branch 0 (27→28) taken 1 times.
✗ Branch 1 (27→29) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1481 |
1/2✗ Branch 0 (28→30) not taken.
✓ Branch 1 (28→31) taken 1 times.
|
1 | g_assert_false (match); |
| 1482 | 1 | } | |
| 1483 | |||
| 1484 | static void | ||
| 1485 | 1 | test_driver_verify_error (void) | |
| 1486 | { | ||
| 1487 | 2 | g_autoptr(GError) error = NULL; | |
| 1488 |
1/2✓ Branch 0 (33→34) taken 1 times.
✗ Branch 1 (33→35) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 1489 | 2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); | |
| 1490 |
1/2✓ Branch 0 (30→31) taken 1 times.
✗ Branch 1 (30→32) not taken.
|
1 | g_autoptr(FpPrint) out_print = NULL; |
| 1491 |
1/2✗ Branch 0 (28→29) not taken.
✓ Branch 1 (28→30) taken 1 times.
|
2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); |
| 1492 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 1493 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1494 | 1 | gboolean match; | |
| 1495 | |||
| 1496 | 1 | fake_dev->ret_result = FPI_MATCH_ERROR; | |
| 1497 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 1498 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, |
| 1499 | test_driver_match_cb, match_data, | ||
| 1500 | &match, &out_print, &error)); | ||
| 1501 | |||
| 1502 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_false (match_data->called); |
| 1503 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_null (match_data->match); |
| 1504 |
1/2✗ Branch 0 (13→14) not taken.
✓ Branch 1 (13→15) taken 1 times.
|
1 | g_assert_no_error (match_data->error); |
| 1505 | |||
| 1506 |
1/2✓ Branch 0 (15→16) taken 1 times.
✗ Branch 1 (15→17) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->verify); |
| 1507 |
3/6✓ Branch 0 (16→18) taken 1 times.
✗ Branch 1 (16→21) not taken.
✓ Branch 2 (19→20) taken 1 times.
✗ Branch 3 (19→21) not taken.
✗ Branch 4 (20→21) not taken.
✓ Branch 5 (20→23) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1508 |
1/2✓ Branch 0 (23→24) taken 1 times.
✗ Branch 1 (23→25) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1509 |
1/2✗ Branch 0 (24→26) not taken.
✓ Branch 1 (24→27) taken 1 times.
|
1 | g_assert_false (match); |
| 1510 | 1 | } | |
| 1511 | |||
| 1512 | static void | ||
| 1513 | 1 | fake_device_verify_immediate_complete (FpDevice *device) | |
| 1514 | { | ||
| 1515 | 1 | fpi_device_verify_complete (device, NULL); | |
| 1516 | 1 | } | |
| 1517 | |||
| 1518 | static void | ||
| 1519 | 1 | test_driver_verify_not_reported (void) | |
| 1520 | { | ||
| 1521 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1522 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1523 |
1/2✓ Branch 0 (24→25) taken 1 times.
✗ Branch 1 (24→26) not taken.
|
1 | g_autoptr(FpPrint) enrolled_print = NULL; |
| 1524 |
1/2✓ Branch 0 (22→23) taken 1 times.
✗ Branch 1 (22→24) not taken.
|
1 | g_autoptr(GError) error = NULL; |
| 1525 | |||
| 1526 | 1 | dev_class->verify = fake_device_verify_immediate_complete; | |
| 1527 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 1528 | 1 | enrolled_print = make_fake_print_reffed (device, NULL); | |
| 1529 | |||
| 1530 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 1531 | |||
| 1532 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1533 | "*reported successful verify complete*not report*result*"); | ||
| 1534 | |||
| 1535 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, |
| 1536 | NULL, NULL, | ||
| 1537 | NULL, NULL, &error)); | ||
| 1538 | |||
| 1539 |
3/6✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→17) not taken.
✓ Branch 2 (15→16) taken 1 times.
✗ Branch 3 (15→17) not taken.
✗ Branch 4 (16→17) not taken.
✓ Branch 5 (16→19) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1540 | |||
| 1541 |
1/2✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→22) not taken.
|
1 | g_test_assert_expected_messages (); |
| 1542 | 1 | } | |
| 1543 | |||
| 1544 | static void | ||
| 1545 | 6 | fake_device_verify_complete_error (FpDevice *device) | |
| 1546 | { | ||
| 1547 | 6 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1548 | 6 | GError *complete_error = fake_dev->user_data; | |
| 1549 | |||
| 1550 | 6 | fake_dev->last_called_function = fake_device_verify_complete_error; | |
| 1551 | |||
| 1552 | 6 | fpi_device_verify_report (device, fake_dev->ret_result, fake_dev->ret_print, fake_dev->ret_error); | |
| 1553 | 6 | fpi_device_verify_complete (device, complete_error); | |
| 1554 | 6 | } | |
| 1555 | |||
| 1556 | static void | ||
| 1557 | 1 | test_driver_verify_report_no_callback (void) | |
| 1558 | { | ||
| 1559 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1560 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 1561 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1562 | 1 | g_autoptr(FpPrint) enrolled_print = NULL; | |
| 1563 |
1/2✓ Branch 0 (38→39) taken 1 times.
✗ Branch 1 (38→40) not taken.
|
1 | g_autoptr(FpPrint) print = NULL; |
| 1564 |
1/2✗ Branch 0 (36→37) not taken.
✓ Branch 1 (36→38) taken 1 times.
|
1 | g_autoptr(GError) error = NULL; |
| 1565 | 1 | FpiDeviceFake *fake_dev; | |
| 1566 | 1 | gboolean match; | |
| 1567 | |||
| 1568 | 1 | dev_class->verify = fake_device_verify_complete_error; | |
| 1569 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 1570 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1571 | 1 | enrolled_print = make_fake_print_reffed (device, NULL); | |
| 1572 | |||
| 1573 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 1574 | |||
| 1575 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1576 | "*Driver reported a verify error that was not in the retry domain*"); | ||
| 1577 | |||
| 1578 | 1 | fake_dev->ret_result = FPI_MATCH_ERROR; | |
| 1579 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED); | |
| 1580 |
1/2✗ Branch 0 (13→14) not taken.
✓ Branch 1 (13→15) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, |
| 1581 | test_driver_match_cb, match_data, | ||
| 1582 | &match, &print, &error)); | ||
| 1583 | |||
| 1584 | 1 | g_test_assert_expected_messages (); | |
| 1585 | |||
| 1586 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert_false (match_data->called); |
| 1587 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_null (match_data->match); |
| 1588 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_no_error (match_data->error); |
| 1589 | |||
| 1590 |
1/2✓ Branch 0 (22→23) taken 1 times.
✗ Branch 1 (22→24) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->verify); |
| 1591 |
3/6✓ Branch 0 (23→25) taken 1 times.
✗ Branch 1 (23→28) not taken.
✓ Branch 2 (26→27) taken 1 times.
✗ Branch 3 (26→28) not taken.
✗ Branch 4 (27→28) not taken.
✓ Branch 5 (27→30) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED); |
| 1592 |
1/2✓ Branch 0 (30→31) taken 1 times.
✗ Branch 1 (30→32) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1593 |
2/4✗ Branch 0 (31→33) not taken.
✓ Branch 1 (31→34) taken 1 times.
✓ Branch 2 (34→35) taken 1 times.
✗ Branch 3 (34→36) not taken.
|
1 | g_assert_false (match); |
| 1594 | 1 | } | |
| 1595 | |||
| 1596 | static void | ||
| 1597 | 1 | test_driver_verify_complete_retry (void) | |
| 1598 | { | ||
| 1599 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1600 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 1601 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1602 | 1 | g_autoptr(FpPrint) enrolled_print = NULL; | |
| 1603 |
1/2✓ Branch 0 (160→161) taken 1 times.
✗ Branch 1 (160→162) not taken.
|
1 | g_autoptr(FpPrint) print = NULL; |
| 1604 |
1/2✗ Branch 0 (158→159) not taken.
✓ Branch 1 (158→160) taken 1 times.
|
1 | g_autoptr(GError) error = NULL; |
| 1605 | 1 | FpiDeviceFake *fake_dev; | |
| 1606 | 1 | gboolean match; | |
| 1607 | |||
| 1608 | 1 | dev_class->verify = fake_device_verify_complete_error; | |
| 1609 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 1610 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1611 | 1 | enrolled_print = make_fake_print_reffed (device, NULL); | |
| 1612 | |||
| 1613 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 1614 | |||
| 1615 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1616 | "*Driver reported an error code without setting match result to error*"); | ||
| 1617 | |||
| 1618 | 1 | test_driver_match_data_clear (match_data); | |
| 1619 | 1 | fake_dev->ret_result = FPI_MATCH_FAIL; | |
| 1620 | 1 | fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT); | |
| 1621 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, test_driver_match_cb, |
| 1622 | match_data, &match, &print, &error)); | ||
| 1623 | 1 | g_test_assert_expected_messages (); | |
| 1624 | |||
| 1625 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_true (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1626 |
3/6✓ Branch 0 (19→20) taken 1 times.
✗ Branch 1 (19→23) not taken.
✓ Branch 2 (21→22) taken 1 times.
✗ Branch 3 (21→23) not taken.
✗ Branch 4 (22→23) not taken.
✓ Branch 5 (22→25) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT); |
| 1627 |
1/2✗ Branch 0 (25→26) not taken.
✓ Branch 1 (25→27) taken 1 times.
|
1 | g_assert_false (match); |
| 1628 |
1/2✗ Branch 0 (27→28) not taken.
✓ Branch 1 (27→29) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1629 |
3/6✓ Branch 0 (29→30) taken 1 times.
✗ Branch 1 (29→33) not taken.
✓ Branch 2 (31→32) taken 1 times.
✗ Branch 3 (31→33) not taken.
✗ Branch 4 (32→33) not taken.
✓ Branch 5 (32→35) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT); |
| 1630 |
1/2✗ Branch 0 (35→36) not taken.
✓ Branch 1 (35→37) taken 1 times.
|
1 | g_assert_null (print); |
| 1631 | 1 | g_clear_error (&error); | |
| 1632 | |||
| 1633 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1634 | "*Driver reported an error code without setting match result to error*"); | ||
| 1635 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1636 | "*Driver reported a retry error to fpi_device_verify_complete" | ||
| 1637 | "*reporting general verification failure*"); | ||
| 1638 | |||
| 1639 | 1 | test_driver_match_data_clear (match_data); | |
| 1640 | 1 | fake_dev->ret_result = FPI_MATCH_FAIL; | |
| 1641 | 1 | fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT); | |
| 1642 | 1 | fake_dev->user_data = g_error_copy (fake_dev->ret_error); | |
| 1643 |
1/2✗ Branch 0 (44→45) not taken.
✓ Branch 1 (44→46) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, test_driver_match_cb, |
| 1644 | match_data, &match, &print, &error)); | ||
| 1645 | |||
| 1646 | 1 | g_test_assert_expected_messages (); | |
| 1647 |
1/2✗ Branch 0 (47→48) not taken.
✓ Branch 1 (47→49) taken 1 times.
|
1 | g_assert_true (error != g_steal_pointer (&fake_dev->ret_error)); |
| 1648 |
1/2✓ Branch 0 (49→50) taken 1 times.
✗ Branch 1 (49→53) not taken.
|
1 | g_steal_pointer (&fake_dev->user_data); |
| 1649 |
3/6✓ Branch 0 (49→50) taken 1 times.
✗ Branch 1 (49→53) not taken.
✓ Branch 2 (51→52) taken 1 times.
✗ Branch 3 (51→53) not taken.
✗ Branch 4 (52→53) not taken.
✓ Branch 5 (52→55) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1650 |
1/2✗ Branch 0 (55→56) not taken.
✓ Branch 1 (55→57) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1651 |
3/6✓ Branch 0 (57→58) taken 1 times.
✗ Branch 1 (57→61) not taken.
✓ Branch 2 (59→60) taken 1 times.
✗ Branch 3 (59→61) not taken.
✗ Branch 4 (60→61) not taken.
✓ Branch 5 (60→63) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT); |
| 1652 |
1/2✗ Branch 0 (63→64) not taken.
✓ Branch 1 (63→65) taken 1 times.
|
1 | g_assert_false (match); |
| 1653 |
1/2✗ Branch 0 (65→66) not taken.
✓ Branch 1 (65→67) taken 1 times.
|
1 | g_assert_null (print); |
| 1654 | 1 | g_clear_error (&error); | |
| 1655 | |||
| 1656 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1657 | "*Driver reported a retry error to fpi_device_verify_complete" | ||
| 1658 | "*reporting general verification failure*"); | ||
| 1659 | |||
| 1660 | 1 | test_driver_match_data_clear (match_data); | |
| 1661 | 1 | fake_dev->ret_result = FPI_MATCH_ERROR; | |
| 1662 | 1 | fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT); | |
| 1663 | 1 | fake_dev->user_data = g_error_copy (fake_dev->ret_error); | |
| 1664 | |||
| 1665 |
1/2✗ Branch 0 (73→74) not taken.
✓ Branch 1 (73→75) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, test_driver_match_cb, |
| 1666 | match_data, &match, &print, &error)); | ||
| 1667 | 1 | g_test_assert_expected_messages (); | |
| 1668 | |||
| 1669 |
1/2✗ Branch 0 (76→77) not taken.
✓ Branch 1 (76→78) taken 1 times.
|
1 | g_assert_true (error != g_steal_pointer (&fake_dev->ret_error)); |
| 1670 |
1/2✓ Branch 0 (78→79) taken 1 times.
✗ Branch 1 (78→82) not taken.
|
1 | g_steal_pointer (&fake_dev->user_data); |
| 1671 |
3/6✓ Branch 0 (78→79) taken 1 times.
✗ Branch 1 (78→82) not taken.
✓ Branch 2 (80→81) taken 1 times.
✗ Branch 3 (80→82) not taken.
✗ Branch 4 (81→82) not taken.
✓ Branch 5 (81→84) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1672 |
1/2✗ Branch 0 (84→85) not taken.
✓ Branch 1 (84→86) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1673 |
3/6✓ Branch 0 (86→87) taken 1 times.
✗ Branch 1 (86→90) not taken.
✓ Branch 2 (88→89) taken 1 times.
✗ Branch 3 (88→90) not taken.
✗ Branch 4 (89→90) not taken.
✓ Branch 5 (89→92) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT); |
| 1674 |
1/2✗ Branch 0 (92→93) not taken.
✓ Branch 1 (92→94) taken 1 times.
|
1 | g_assert_false (match); |
| 1675 |
1/2✗ Branch 0 (94→95) not taken.
✓ Branch 1 (94→96) taken 1 times.
|
1 | g_assert_null (print); |
| 1676 | 1 | g_clear_error (&error); | |
| 1677 | |||
| 1678 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1679 | "*Driver reported an error without specifying a retry " | ||
| 1680 | "code, assuming general retry error*"); | ||
| 1681 | |||
| 1682 | 1 | test_driver_match_data_clear (match_data); | |
| 1683 | 1 | fake_dev->ret_result = FPI_MATCH_ERROR; | |
| 1684 | |||
| 1685 |
1/2✗ Branch 0 (100→101) not taken.
✓ Branch 1 (100→102) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, test_driver_match_cb, |
| 1686 | match_data, &match, &print, &error)); | ||
| 1687 | 1 | g_test_assert_expected_messages (); | |
| 1688 | |||
| 1689 |
1/2✗ Branch 0 (103→104) not taken.
✓ Branch 1 (103→105) taken 1 times.
|
1 | g_assert_true (error != g_steal_pointer (&fake_dev->ret_error)); |
| 1690 |
1/2✓ Branch 0 (105→106) taken 1 times.
✗ Branch 1 (105→109) not taken.
|
1 | g_steal_pointer (&fake_dev->user_data); |
| 1691 |
3/6✓ Branch 0 (105→106) taken 1 times.
✗ Branch 1 (105→109) not taken.
✓ Branch 2 (107→108) taken 1 times.
✗ Branch 3 (107→109) not taken.
✗ Branch 4 (108→109) not taken.
✓ Branch 5 (108→111) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL); |
| 1692 |
1/2✗ Branch 0 (111→112) not taken.
✓ Branch 1 (111→113) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1693 |
3/6✓ Branch 0 (113→114) taken 1 times.
✗ Branch 1 (113→117) not taken.
✓ Branch 2 (115→116) taken 1 times.
✗ Branch 3 (115→117) not taken.
✗ Branch 4 (116→117) not taken.
✓ Branch 5 (116→119) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL); |
| 1694 |
1/2✗ Branch 0 (119→120) not taken.
✓ Branch 1 (119→121) taken 1 times.
|
1 | g_assert_false (match); |
| 1695 |
1/2✗ Branch 0 (121→122) not taken.
✓ Branch 1 (121→123) taken 1 times.
|
1 | g_assert_null (print); |
| 1696 | 1 | g_clear_error (&error); | |
| 1697 | |||
| 1698 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1699 | "*Driver reported a print together with an error*"); | ||
| 1700 | |||
| 1701 | 1 | test_driver_match_data_clear (match_data); | |
| 1702 | 1 | fake_dev->ret_result = FPI_MATCH_ERROR; | |
| 1703 | 1 | fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT); | |
| 1704 | 1 | fake_dev->ret_print = make_fake_print (device, NULL); | |
| 1705 | 1 | g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print), | |
| 1706 | 1 | (gpointer) (&fake_dev->ret_print)); | |
| 1707 | |||
| 1708 |
1/2✗ Branch 0 (130→131) not taken.
✓ Branch 1 (130→132) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, test_driver_match_cb, |
| 1709 | match_data, &match, &print, &error)); | ||
| 1710 | 1 | g_test_assert_expected_messages (); | |
| 1711 | |||
| 1712 |
3/6✓ Branch 0 (133→134) taken 1 times.
✗ Branch 1 (133→137) not taken.
✓ Branch 2 (135→136) taken 1 times.
✗ Branch 3 (135→137) not taken.
✗ Branch 4 (136→137) not taken.
✓ Branch 5 (136→139) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT); |
| 1713 |
1/2✗ Branch 0 (139→140) not taken.
✓ Branch 1 (139→141) taken 1 times.
|
1 | g_assert_true (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1714 |
1/2✗ Branch 0 (141→142) not taken.
✓ Branch 1 (141→143) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1715 |
3/6✓ Branch 0 (143→144) taken 1 times.
✗ Branch 1 (143→147) not taken.
✓ Branch 2 (145→146) taken 1 times.
✗ Branch 3 (145→147) not taken.
✗ Branch 4 (146→147) not taken.
✓ Branch 5 (146→149) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT); |
| 1716 |
1/2✗ Branch 0 (149→150) not taken.
✓ Branch 1 (149→151) taken 1 times.
|
1 | g_assert_null (fake_dev->ret_print); |
| 1717 |
1/2✗ Branch 0 (151→152) not taken.
✓ Branch 1 (151→153) taken 1 times.
|
1 | g_assert_false (match); |
| 1718 |
1/2✗ Branch 0 (153→154) not taken.
✓ Branch 1 (153→155) taken 1 times.
|
1 | g_assert_null (print); |
| 1719 |
1/2✗ Branch 0 (156→157) not taken.
✓ Branch 1 (156→158) taken 1 times.
|
1 | g_clear_error (&error); |
| 1720 | 1 | } | |
| 1721 | |||
| 1722 | static void | ||
| 1723 | 4 | fake_device_stub_identify (FpDevice *device) | |
| 1724 | { | ||
| 1725 | 4 | } | |
| 1726 | |||
| 1727 | static void | ||
| 1728 | 4 | test_driver_identify_cb (FpDevice *device, | |
| 1729 | GAsyncResult *res, | ||
| 1730 | gpointer user_data) | ||
| 1731 | { | ||
| 1732 | 4 | MatchCbData *data = user_data; | |
| 1733 | 4 | gboolean r; | |
| 1734 | |||
| 1735 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 4 times.
|
4 | g_assert (data->called == FALSE); |
| 1736 | 4 | data->called = TRUE; | |
| 1737 | |||
| 1738 | 4 | r = fp_device_identify_finish (device, res, &data->match, &data->print, &data->error); | |
| 1739 | |||
| 1740 |
2/2✓ Branch 0 (5→6) taken 2 times.
✓ Branch 1 (5→8) taken 2 times.
|
4 | if (r) |
| 1741 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→10) taken 2 times.
|
2 | g_assert_no_error (data->error); |
| 1742 | else | ||
| 1743 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 2 times.
|
2 | g_assert_nonnull (data->error); |
| 1744 | |||
| 1745 |
2/2✓ Branch 0 (10→11) taken 2 times.
✓ Branch 1 (10→13) taken 2 times.
|
4 | if (data->match) |
| 1746 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 2 times.
|
2 | g_assert_no_error (data->error); |
| 1747 | 4 | } | |
| 1748 | |||
| 1749 | static void | ||
| 1750 | 1 | test_driver_supports_identify (void) | |
| 1751 | { | ||
| 1752 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1753 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 1754 | |||
| 1755 | 1 | dev_class->identify = fake_device_stub_identify; | |
| 1756 | |||
| 1757 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 1758 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 1759 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fp_device_supports_identify (device)); |
| 1760 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 1761 |
2/4✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); |
| 1762 | 1 | } | |
| 1763 | |||
| 1764 | static void | ||
| 1765 | 1 | test_driver_do_not_support_identify (void) | |
| 1766 | { | ||
| 1767 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1768 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 1769 | |||
| 1770 | 1 | dev_class->features &= ~FP_DEVICE_FEATURE_IDENTIFY; | |
| 1771 | |||
| 1772 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 1773 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 1774 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_false (fp_device_supports_identify (device)); |
| 1775 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 1776 |
2/4✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
|
1 | g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); |
| 1777 | 1 | } | |
| 1778 | |||
| 1779 | static void | ||
| 1780 | 1 | test_driver_identify (void) | |
| 1781 | { | ||
| 1782 | 2 | g_autoptr(GError) error = NULL; | |
| 1783 |
1/2✗ Branch 0 (41→42) not taken.
✓ Branch 1 (41→43) taken 1 times.
|
1 | g_autoptr(FpPrint) print = NULL; |
| 1784 |
1/2✓ Branch 0 (39→40) taken 1 times.
✗ Branch 1 (39→41) not taken.
|
1 | g_autoptr(FpPrint) matched_print = NULL; |
| 1785 |
1/2✓ Branch 0 (36→38) taken 1 times.
✗ Branch 1 (36→39) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 1786 | 2 | g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500); | |
| 1787 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 1788 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 1789 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1790 | 1 | FpPrint *expected_matched; | |
| 1791 | |||
| 1792 | 1 | expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); | |
| 1793 | 1 | fp_print_set_description (expected_matched, "fake-verified"); | |
| 1794 | |||
| 1795 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 1796 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (fp_device_supports_identify (device)); |
| 1797 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 1798 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); |
| 1799 | |||
| 1800 | 1 | match_data->gallery = prints; | |
| 1801 | |||
| 1802 | 1 | fake_dev->ret_print = make_fake_print (device, NULL); | |
| 1803 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert_true (fp_device_identify_sync (device, prints, NULL, |
| 1804 | test_driver_match_cb, match_data, | ||
| 1805 | &matched_print, &print, &error)); | ||
| 1806 | |||
| 1807 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1808 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 1 times.
|
1 | g_assert_nonnull (match_data->match); |
| 1809 |
1/2✗ Branch 0 (21→22) not taken.
✓ Branch 1 (21→23) taken 1 times.
|
1 | g_assert_true (match_data->match == matched_print); |
| 1810 |
1/2✗ Branch 0 (23→24) not taken.
✓ Branch 1 (23→25) taken 1 times.
|
1 | g_assert_true (match_data->print == print); |
| 1811 | |||
| 1812 |
1/2✓ Branch 0 (25→26) taken 1 times.
✗ Branch 1 (25→27) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->identify); |
| 1813 |
1/2✗ Branch 0 (26→28) not taken.
✓ Branch 1 (26→29) taken 1 times.
|
1 | g_assert_no_error (error); |
| 1814 | |||
| 1815 |
2/4✓ Branch 0 (29→30) taken 1 times.
✗ Branch 1 (29→32) not taken.
✓ Branch 2 (30→31) taken 1 times.
✗ Branch 3 (30→32) not taken.
|
1 | g_assert (print != NULL && print == fake_dev->ret_print); |
| 1816 |
1/2✓ Branch 0 (31→33) taken 1 times.
✗ Branch 1 (31→37) not taken.
|
1 | g_assert (expected_matched == matched_print); |
| 1817 | 1 | } | |
| 1818 | |||
| 1819 | static void | ||
| 1820 | 1 | test_driver_identify_fail (void) | |
| 1821 | { | ||
| 1822 | 2 | g_autoptr(GError) error = NULL; | |
| 1823 |
1/2✗ Branch 0 (42→43) not taken.
✓ Branch 1 (42→44) taken 1 times.
|
1 | g_autoptr(FpPrint) print = NULL; |
| 1824 |
1/2✓ Branch 0 (40→41) taken 1 times.
✗ Branch 1 (40→42) not taken.
|
1 | g_autoptr(FpPrint) matched_print = NULL; |
| 1825 |
1/2✗ Branch 0 (38→39) not taken.
✓ Branch 1 (38→40) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 1826 | 2 | g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500); | |
| 1827 |
1/2✓ Branch 0 (35→36) taken 1 times.
✗ Branch 1 (35→37) not taken.
|
2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); |
| 1828 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 1829 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1830 | |||
| 1831 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 1832 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fp_device_supports_identify (device)); |
| 1833 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 1834 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); |
| 1835 | |||
| 1836 | 1 | fake_dev->ret_print = make_fake_print (device, NULL); | |
| 1837 |
1/2✗ Branch 0 (13→14) not taken.
✓ Branch 1 (13→15) taken 1 times.
|
1 | g_assert_true (fp_device_identify_sync (device, prints, NULL, |
| 1838 | test_driver_match_cb, match_data, | ||
| 1839 | &matched_print, &print, &error)); | ||
| 1840 | |||
| 1841 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1842 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_null (match_data->match); |
| 1843 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 1 times.
|
1 | g_assert_no_error (match_data->error); |
| 1844 |
1/2✗ Branch 0 (21→22) not taken.
✓ Branch 1 (21→23) taken 1 times.
|
1 | g_assert_true (match_data->match == matched_print); |
| 1845 |
1/2✗ Branch 0 (23→24) not taken.
✓ Branch 1 (23→25) taken 1 times.
|
1 | g_assert_true (match_data->print == print); |
| 1846 | |||
| 1847 |
1/2✓ Branch 0 (25→26) taken 1 times.
✗ Branch 1 (25→27) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->identify); |
| 1848 |
1/2✗ Branch 0 (26→28) not taken.
✓ Branch 1 (26→29) taken 1 times.
|
1 | g_assert_no_error (error); |
| 1849 | |||
| 1850 |
2/4✓ Branch 0 (29→30) taken 1 times.
✗ Branch 1 (29→32) not taken.
✓ Branch 2 (30→31) taken 1 times.
✗ Branch 3 (30→32) not taken.
|
1 | g_assert (print != NULL && print == fake_dev->ret_print); |
| 1851 |
1/2✗ Branch 0 (31→33) not taken.
✓ Branch 1 (31→34) taken 1 times.
|
1 | g_assert_null (matched_print); |
| 1852 | 1 | } | |
| 1853 | |||
| 1854 | static void | ||
| 1855 | 1 | test_driver_identify_retry (void) | |
| 1856 | { | ||
| 1857 | 2 | g_autoptr(GError) error = NULL; | |
| 1858 |
1/2✓ Branch 0 (48→49) taken 1 times.
✗ Branch 1 (48→50) not taken.
|
1 | g_autoptr(FpPrint) print = NULL; |
| 1859 |
1/2✗ Branch 0 (46→47) not taken.
✓ Branch 1 (46→48) taken 1 times.
|
1 | g_autoptr(FpPrint) matched_print = NULL; |
| 1860 |
1/2✗ Branch 0 (44→45) not taken.
✓ Branch 1 (44→46) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 1861 | 2 | g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500); | |
| 1862 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 1863 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 1864 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1865 | 1 | FpPrint *expected_matched; | |
| 1866 | |||
| 1867 | 1 | expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); | |
| 1868 | 1 | fp_print_set_description (expected_matched, "fake-verified"); | |
| 1869 | |||
| 1870 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 1871 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (fp_device_supports_identify (device)); |
| 1872 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 1873 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); |
| 1874 | |||
| 1875 | 1 | fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_GENERAL); | |
| 1876 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert_false (fp_device_identify_sync (device, prints, NULL, |
| 1877 | test_driver_match_cb, match_data, | ||
| 1878 | &matched_print, &print, &error)); | ||
| 1879 | |||
| 1880 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 1881 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 1 times.
|
1 | g_assert_null (match_data->match); |
| 1882 |
3/6✓ Branch 0 (21→22) taken 1 times.
✗ Branch 1 (21→25) not taken.
✓ Branch 2 (23→24) taken 1 times.
✗ Branch 3 (23→25) not taken.
✗ Branch 4 (24→25) not taken.
✓ Branch 5 (24→27) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL); |
| 1883 | |||
| 1884 |
1/2✓ Branch 0 (27→28) taken 1 times.
✗ Branch 1 (27→29) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->identify); |
| 1885 |
3/6✓ Branch 0 (28→30) taken 1 times.
✗ Branch 1 (28→33) not taken.
✓ Branch 2 (31→32) taken 1 times.
✗ Branch 3 (31→33) not taken.
✗ Branch 4 (32→33) not taken.
✓ Branch 5 (32→35) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL); |
| 1886 |
1/2✓ Branch 0 (35→36) taken 1 times.
✗ Branch 1 (35→37) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1887 |
1/2✗ Branch 0 (36→38) not taken.
✓ Branch 1 (36→39) taken 1 times.
|
1 | g_assert_null (matched_print); |
| 1888 |
1/2✗ Branch 0 (39→40) not taken.
✓ Branch 1 (39→41) taken 1 times.
|
1 | g_assert_null (print); |
| 1889 | 1 | } | |
| 1890 | |||
| 1891 | static void | ||
| 1892 | 1 | test_driver_identify_error (void) | |
| 1893 | { | ||
| 1894 | 2 | g_autoptr(GError) error = NULL; | |
| 1895 |
1/2✓ Branch 0 (44→45) taken 1 times.
✗ Branch 1 (44→46) not taken.
|
1 | g_autoptr(FpPrint) print = NULL; |
| 1896 |
1/2✗ Branch 0 (42→43) not taken.
✓ Branch 1 (42→44) taken 1 times.
|
1 | g_autoptr(FpPrint) matched_print = NULL; |
| 1897 |
1/2✗ Branch 0 (40→41) not taken.
✓ Branch 1 (40→42) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 1898 | 2 | g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500); | |
| 1899 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 1900 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 1901 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1902 | 1 | FpPrint *expected_matched; | |
| 1903 | |||
| 1904 | 1 | expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); | |
| 1905 | 1 | fp_print_set_description (expected_matched, "fake-verified"); | |
| 1906 | |||
| 1907 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 1908 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (fp_device_supports_identify (device)); |
| 1909 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 1910 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); |
| 1911 | |||
| 1912 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 1913 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert_false (fp_device_identify_sync (device, prints, NULL, |
| 1914 | test_driver_match_cb, match_data, | ||
| 1915 | &matched_print, &print, &error)); | ||
| 1916 | |||
| 1917 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_false (match_data->called); |
| 1918 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 1 times.
|
1 | g_assert_null (match_data->match); |
| 1919 |
1/2✗ Branch 0 (21→22) not taken.
✓ Branch 1 (21→23) taken 1 times.
|
1 | g_assert_no_error (match_data->error); |
| 1920 | |||
| 1921 |
1/2✓ Branch 0 (23→24) taken 1 times.
✗ Branch 1 (23→25) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->identify); |
| 1922 |
3/6✓ Branch 0 (24→26) taken 1 times.
✗ Branch 1 (24→29) not taken.
✓ Branch 2 (27→28) taken 1 times.
✗ Branch 3 (27→29) not taken.
✗ Branch 4 (28→29) not taken.
✓ Branch 5 (28→31) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1923 |
1/2✓ Branch 0 (31→32) taken 1 times.
✗ Branch 1 (31→33) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 1924 |
1/2✗ Branch 0 (32→34) not taken.
✓ Branch 1 (32→35) taken 1 times.
|
1 | g_assert_null (matched_print); |
| 1925 |
1/2✗ Branch 0 (35→36) not taken.
✓ Branch 1 (35→37) taken 1 times.
|
1 | g_assert_null (print); |
| 1926 | 1 | } | |
| 1927 | |||
| 1928 | static void | ||
| 1929 | 1 | fake_device_identify_immediate_complete (FpDevice *device) | |
| 1930 | { | ||
| 1931 | 1 | fpi_device_identify_complete (device, NULL); | |
| 1932 | 1 | } | |
| 1933 | |||
| 1934 | static void | ||
| 1935 | 1 | test_driver_identify_not_reported (void) | |
| 1936 | { | ||
| 1937 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1938 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1939 |
1/2✓ Branch 0 (24→25) taken 1 times.
✗ Branch 1 (24→26) not taken.
|
1 | g_autoptr(GPtrArray) prints = NULL; |
| 1940 |
1/2✓ Branch 0 (22→23) taken 1 times.
✗ Branch 1 (22→24) not taken.
|
1 | g_autoptr(GError) error = NULL; |
| 1941 | |||
| 1942 | 1 | dev_class->identify = fake_device_identify_immediate_complete; | |
| 1943 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 1944 | 1 | prints = make_fake_prints_gallery (device, 500); | |
| 1945 | |||
| 1946 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 1947 | |||
| 1948 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1949 | "*reported successful identify complete*not report*result*"); | ||
| 1950 | |||
| 1951 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_false (fp_device_identify_sync (device, prints, NULL, |
| 1952 | NULL, NULL, | ||
| 1953 | NULL, NULL, &error)); | ||
| 1954 | |||
| 1955 |
3/6✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→17) not taken.
✓ Branch 2 (15→16) taken 1 times.
✗ Branch 3 (15→17) not taken.
✗ Branch 4 (16→17) not taken.
✓ Branch 5 (16→19) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 1956 | |||
| 1957 |
1/2✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→22) not taken.
|
1 | g_test_assert_expected_messages (); |
| 1958 | 1 | } | |
| 1959 | |||
| 1960 | static void | ||
| 1961 | 4 | fake_device_identify_complete_error (FpDevice *device) | |
| 1962 | { | ||
| 1963 | 4 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 1964 | 4 | GError *complete_error = fake_dev->user_data; | |
| 1965 | |||
| 1966 | 4 | fake_dev->last_called_function = fake_device_identify_complete_error; | |
| 1967 | |||
| 1968 | 4 | fpi_device_identify_report (device, fake_dev->ret_match, fake_dev->ret_print, fake_dev->ret_error); | |
| 1969 | 4 | fpi_device_identify_complete (device, complete_error); | |
| 1970 | 4 | } | |
| 1971 | |||
| 1972 | static void | ||
| 1973 | 1 | test_driver_identify_complete_retry (void) | |
| 1974 | { | ||
| 1975 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 1976 | 1 | g_autoptr(GPtrArray) prints = NULL; | |
| 1977 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 1978 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 1979 | 1 | g_autoptr(FpPrint) print = NULL; | |
| 1980 |
1/2✗ Branch 0 (97→98) not taken.
✓ Branch 1 (97→99) taken 1 times.
|
1 | g_autoptr(FpPrint) match = NULL; |
| 1981 |
1/2✗ Branch 0 (95→96) not taken.
✓ Branch 1 (95→97) taken 1 times.
|
1 | g_autoptr(GError) error = NULL; |
| 1982 | 1 | FpiDeviceFake *fake_dev; | |
| 1983 | |||
| 1984 | 1 | dev_class->identify = fake_device_identify_complete_error; | |
| 1985 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 1986 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 1987 | 1 | prints = make_fake_prints_gallery (device, 500); | |
| 1988 | |||
| 1989 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 1990 | |||
| 1991 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 1992 | "*Driver reported a retry error to fpi_device_identify_complete" | ||
| 1993 | "*reporting general identification failure*"); | ||
| 1994 | |||
| 1995 | 1 | test_driver_match_data_clear (match_data); | |
| 1996 | 1 | fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT); | |
| 1997 | 1 | fake_dev->user_data = g_error_copy (fake_dev->ret_error); | |
| 1998 | |||
| 1999 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert_false (fp_device_identify_sync (device, prints, NULL, |
| 2000 | test_driver_match_cb, match_data, | ||
| 2001 | &match, &print, &error)); | ||
| 2002 | 1 | g_test_assert_expected_messages (); | |
| 2003 | |||
| 2004 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
1 | g_assert_true (error != g_steal_pointer (&fake_dev->ret_error)); |
| 2005 |
1/2✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→24) not taken.
|
1 | g_steal_pointer (&fake_dev->user_data); |
| 2006 |
3/6✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→24) not taken.
✓ Branch 2 (22→23) taken 1 times.
✗ Branch 3 (22→24) not taken.
✗ Branch 4 (23→24) not taken.
✓ Branch 5 (23→26) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 2007 |
1/2✗ Branch 0 (26→27) not taken.
✓ Branch 1 (26→28) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 2008 |
3/6✓ Branch 0 (28→29) taken 1 times.
✗ Branch 1 (28→32) not taken.
✓ Branch 2 (30→31) taken 1 times.
✗ Branch 3 (30→32) not taken.
✗ Branch 4 (31→32) not taken.
✓ Branch 5 (31→34) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_TOO_SHORT); |
| 2009 |
1/2✗ Branch 0 (34→35) not taken.
✓ Branch 1 (34→36) taken 1 times.
|
1 | g_assert_null (match); |
| 2010 |
1/2✗ Branch 0 (36→37) not taken.
✓ Branch 1 (36→38) taken 1 times.
|
1 | g_assert_null (print); |
| 2011 | 1 | g_clear_error (&error); | |
| 2012 | |||
| 2013 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 2014 | "*Driver reported a match to a print that was not in the gallery*"); | ||
| 2015 | |||
| 2016 | 1 | test_driver_match_data_clear (match_data); | |
| 2017 | 1 | fake_dev->ret_match = make_fake_print_reffed (device, NULL); | |
| 2018 | 1 | g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_match), | |
| 2019 | 1 | (gpointer) (&fake_dev->ret_match)); | |
| 2020 |
1/2✗ Branch 0 (44→45) not taken.
✓ Branch 1 (44→46) taken 1 times.
|
1 | g_assert_true (fp_device_identify_sync (device, prints, NULL, |
| 2021 | test_driver_match_cb, match_data, | ||
| 2022 | &match, &print, &error)); | ||
| 2023 | 1 | g_test_assert_expected_messages (); | |
| 2024 | |||
| 2025 | 1 | g_object_unref (fake_dev->ret_match); | |
| 2026 |
1/2✗ Branch 0 (48→49) not taken.
✓ Branch 1 (48→50) taken 1 times.
|
1 | g_assert_null (fake_dev->ret_match); |
| 2027 |
1/2✗ Branch 0 (50→51) not taken.
✓ Branch 1 (50→52) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 2028 |
1/2✗ Branch 0 (52→53) not taken.
✓ Branch 1 (52→54) taken 1 times.
|
1 | g_assert_no_error (match_data->error); |
| 2029 |
1/2✗ Branch 0 (54→55) not taken.
✓ Branch 1 (54→56) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2030 |
1/2✗ Branch 0 (56→57) not taken.
✓ Branch 1 (56→58) taken 1 times.
|
1 | g_assert_false (match); |
| 2031 |
1/2✗ Branch 0 (58→59) not taken.
✓ Branch 1 (58→60) taken 1 times.
|
1 | g_assert_null (print); |
| 2032 | |||
| 2033 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 2034 | "*Driver reported an error code but also provided a match*"); | ||
| 2035 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 2036 | "*Driver reported a print together with an error*"); | ||
| 2037 | |||
| 2038 | 1 | test_driver_match_data_clear (match_data); | |
| 2039 | 1 | fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_REMOVE_FINGER); | |
| 2040 | 1 | fake_dev->ret_match = prints->pdata[0]; | |
| 2041 | 1 | fake_dev->ret_print = make_fake_print (device, NULL); | |
| 2042 | 1 | g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print), | |
| 2043 | 1 | (gpointer) (&fake_dev->ret_print)); | |
| 2044 |
1/2✗ Branch 0 (67→68) not taken.
✓ Branch 1 (67→69) taken 1 times.
|
1 | g_assert_false (fp_device_identify_sync (device, prints, NULL, |
| 2045 | test_driver_match_cb, match_data, | ||
| 2046 | &match, &print, &error)); | ||
| 2047 | 1 | g_test_assert_expected_messages (); | |
| 2048 | |||
| 2049 |
3/6✓ Branch 0 (70→71) taken 1 times.
✗ Branch 1 (70→74) not taken.
✓ Branch 2 (72→73) taken 1 times.
✗ Branch 3 (72→74) not taken.
✗ Branch 4 (73→74) not taken.
✓ Branch 5 (73→76) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_REMOVE_FINGER); |
| 2050 |
1/2✗ Branch 0 (76→77) not taken.
✓ Branch 1 (76→78) taken 1 times.
|
1 | g_assert_true (error == g_steal_pointer (&fake_dev->ret_error)); |
| 2051 |
1/2✗ Branch 0 (78→79) not taken.
✓ Branch 1 (78→80) taken 1 times.
|
1 | g_assert_null (fake_dev->ret_print); |
| 2052 |
1/2✗ Branch 0 (80→81) not taken.
✓ Branch 1 (80→82) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 2053 |
3/6✓ Branch 0 (82→83) taken 1 times.
✗ Branch 1 (82→86) not taken.
✓ Branch 2 (84→85) taken 1 times.
✗ Branch 3 (84→86) not taken.
✗ Branch 4 (85→86) not taken.
✓ Branch 5 (85→88) taken 1 times.
|
1 | g_assert_error (match_data->error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_REMOVE_FINGER); |
| 2054 |
1/2✗ Branch 0 (88→89) not taken.
✓ Branch 1 (88→90) taken 1 times.
|
1 | g_assert_false (match); |
| 2055 |
1/2✗ Branch 0 (90→91) not taken.
✓ Branch 1 (90→92) taken 1 times.
|
1 | g_assert_null (print); |
| 2056 |
1/2✗ Branch 0 (93→94) not taken.
✓ Branch 1 (93→95) taken 1 times.
|
1 | g_clear_error (&error); |
| 2057 | 1 | } | |
| 2058 | |||
| 2059 | static void | ||
| 2060 | 1 | test_driver_identify_report_no_callback (void) | |
| 2061 | { | ||
| 2062 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2063 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 2064 | 1 | g_autoptr(GPtrArray) prints = NULL; | |
| 2065 |
1/2✓ Branch 0 (48→49) taken 1 times.
✗ Branch 1 (48→50) not taken.
|
1 | g_autoptr(FpAutoCloseDevice) device = NULL; |
| 2066 | 1 | G_GNUC_UNUSED g_autoptr(FpPrint) enrolled_print = NULL; | |
| 2067 |
1/2✓ Branch 0 (45→46) taken 1 times.
✗ Branch 1 (45→47) not taken.
|
1 | g_autoptr(FpPrint) print = NULL; |
| 2068 |
1/2✗ Branch 0 (43→44) not taken.
✓ Branch 1 (43→45) taken 1 times.
|
1 | g_autoptr(FpPrint) match = NULL; |
| 2069 |
1/2✗ Branch 0 (41→42) not taken.
✓ Branch 1 (41→43) taken 1 times.
|
1 | g_autoptr(GError) error = NULL; |
| 2070 | 1 | FpiDeviceFake *fake_dev; | |
| 2071 | |||
| 2072 | 1 | dev_class->identify = fake_device_identify_complete_error; | |
| 2073 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2074 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2075 | 1 | prints = make_fake_prints_gallery (device, 0); | |
| 2076 | 1 | enrolled_print = make_fake_print_reffed (device, NULL); | |
| 2077 | |||
| 2078 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 2079 | |||
| 2080 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 2081 | "*Driver reported a verify error that was not in the retry domain*"); | ||
| 2082 | |||
| 2083 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED); | |
| 2084 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_false (fp_device_identify_sync (device, prints, NULL, |
| 2085 | test_driver_match_cb, match_data, | ||
| 2086 | &match, &print, &error)); | ||
| 2087 | |||
| 2088 | 1 | g_test_assert_expected_messages (); | |
| 2089 | |||
| 2090 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_null (match); |
| 2091 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 1 times.
|
1 | g_assert_null (print); |
| 2092 |
1/2✗ Branch 0 (21→22) not taken.
✓ Branch 1 (21→23) taken 1 times.
|
1 | g_assert_false (match_data->called); |
| 2093 |
1/2✗ Branch 0 (23→24) not taken.
✓ Branch 1 (23→25) taken 1 times.
|
1 | g_assert_null (match_data->match); |
| 2094 |
1/2✗ Branch 0 (25→26) not taken.
✓ Branch 1 (25→27) taken 1 times.
|
1 | g_assert_no_error (match_data->error); |
| 2095 | |||
| 2096 |
1/2✓ Branch 0 (27→28) taken 1 times.
✗ Branch 1 (27→29) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->identify); |
| 2097 |
3/6✓ Branch 0 (28→30) taken 1 times.
✗ Branch 1 (28→33) not taken.
✓ Branch 2 (31→32) taken 1 times.
✗ Branch 3 (31→33) not taken.
✗ Branch 4 (32→33) not taken.
✓ Branch 5 (32→35) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED); |
| 2098 |
1/2✓ Branch 0 (35→36) taken 1 times.
✗ Branch 1 (35→37) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 2099 |
2/4✗ Branch 0 (36→38) not taken.
✓ Branch 1 (36→39) taken 1 times.
✓ Branch 2 (39→40) taken 1 times.
✗ Branch 3 (39→41) not taken.
|
1 | g_assert_false (match); |
| 2100 | 1 | } | |
| 2101 | |||
| 2102 | static void | ||
| 2103 | 1 | test_driver_identify_suspend_continues (void) | |
| 2104 | { | ||
| 2105 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2106 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 2107 | 2 | g_autoptr(MatchCbData) identify_data = g_new0 (MatchCbData, 1); | |
| 2108 | 1 | g_autoptr(GPtrArray) prints = NULL; | |
| 2109 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2110 | 1 | g_autoptr(GError) error = NULL; | |
| 2111 | 1 | void (*orig_identify) (FpDevice *device); | |
| 2112 | 1 | FpiDeviceFake *fake_dev; | |
| 2113 | 1 | FpPrint *expected_matched; | |
| 2114 | |||
| 2115 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2116 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2117 | 1 | orig_identify = dev_class->identify; | |
| 2118 | 1 | dev_class->identify = fake_device_stub_identify; | |
| 2119 | |||
| 2120 | 1 | prints = make_fake_prints_gallery (device, 500); | |
| 2121 | 1 | expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); | |
| 2122 | 1 | fp_print_set_description (expected_matched, "fake-verified"); | |
| 2123 | |||
| 2124 | 1 | match_data->gallery = prints; | |
| 2125 | |||
| 2126 | 1 | fake_dev->ret_print = make_fake_print (device, NULL); | |
| 2127 | |||
| 2128 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 2129 | |||
| 2130 | 1 | fp_device_identify (device, prints, NULL, | |
| 2131 | test_driver_match_cb, match_data, NULL, | ||
| 2132 | (GAsyncReadyCallback) test_driver_identify_cb, identify_data); | ||
| 2133 | |||
| 2134 |
1/2✗ Branch 0 (18→16) not taken.
✓ Branch 1 (18→19) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE)) |
| 2135 | ✗ | continue; | |
| 2136 | |||
| 2137 | 1 | fake_dev->ret_suspend = NULL; | |
| 2138 | 1 | fp_device_suspend_sync (device, NULL, &error); | |
| 2139 |
1/2✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→22) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->suspend); |
| 2140 |
1/2✗ Branch 0 (21→23) not taken.
✓ Branch 1 (21→24) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2141 | |||
| 2142 |
1/2✗ Branch 0 (27→25) not taken.
✓ Branch 1 (27→28) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE)) |
| 2143 | ✗ | continue; | |
| 2144 | |||
| 2145 |
1/2✗ Branch 0 (28→29) not taken.
✓ Branch 1 (28→30) taken 1 times.
|
1 | g_assert_false (match_data->called); |
| 2146 |
1/2✗ Branch 0 (30→31) not taken.
✓ Branch 1 (30→32) taken 1 times.
|
1 | g_assert_false (identify_data->called); |
| 2147 | |||
| 2148 | 1 | fake_dev->ret_resume = NULL; | |
| 2149 | 1 | fp_device_resume_sync (device, NULL, &error); | |
| 2150 |
1/2✓ Branch 0 (33→34) taken 1 times.
✗ Branch 1 (33→35) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->resume); |
| 2151 |
1/2✗ Branch 0 (34→36) not taken.
✓ Branch 1 (34→37) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2152 | |||
| 2153 | 1 | orig_identify (device); | |
| 2154 | |||
| 2155 | /* This currently happens immediately (not ABI though) */ | ||
| 2156 |
1/2✗ Branch 0 (38→39) not taken.
✓ Branch 1 (38→40) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 2157 |
1/2✓ Branch 0 (40→41) taken 1 times.
✗ Branch 1 (40→42) not taken.
|
1 | g_assert (match_data->match == expected_matched); |
| 2158 | |||
| 2159 |
2/2✓ Branch 0 (45→43) taken 1 times.
✓ Branch 1 (45→46) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2160 | 1 | continue; | |
| 2161 | |||
| 2162 |
1/2✗ Branch 0 (46→47) not taken.
✓ Branch 1 (46→48) taken 1 times.
|
1 | g_assert_true (identify_data->called); |
| 2163 |
1/2✓ Branch 0 (48→49) taken 1 times.
✗ Branch 1 (48→50) not taken.
|
1 | g_assert (identify_data->match == expected_matched); |
| 2164 | |||
| 2165 |
2/4✓ Branch 0 (49→51) taken 1 times.
✗ Branch 1 (49→52) not taken.
✗ Branch 2 (51→53) not taken.
✓ Branch 3 (51→54) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == orig_identify); |
| 2166 | 1 | } | |
| 2167 | |||
| 2168 | static void | ||
| 2169 | 1 | test_driver_identify_suspend_succeeds (void) | |
| 2170 | { | ||
| 2171 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2172 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 2173 | 2 | g_autoptr(MatchCbData) identify_data = g_new0 (MatchCbData, 1); | |
| 2174 | 1 | g_autoptr(GPtrArray) prints = NULL; | |
| 2175 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2176 | 1 | g_autoptr(GError) error = NULL; | |
| 2177 | 1 | void (*orig_identify) (FpDevice *device); | |
| 2178 | 1 | FpiDeviceFake *fake_dev; | |
| 2179 | 1 | FpPrint *expected_matched; | |
| 2180 | |||
| 2181 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2182 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2183 | 1 | orig_identify = dev_class->identify; | |
| 2184 | 1 | dev_class->identify = fake_device_stub_identify; | |
| 2185 | |||
| 2186 | 1 | prints = make_fake_prints_gallery (device, 500); | |
| 2187 | 1 | expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); | |
| 2188 | 1 | fp_print_set_description (expected_matched, "fake-verified"); | |
| 2189 | |||
| 2190 | 1 | match_data->gallery = prints; | |
| 2191 | |||
| 2192 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 2193 | |||
| 2194 | 1 | fake_dev->ret_print = make_fake_print (device, NULL); | |
| 2195 | 1 | fp_device_identify (device, prints, NULL, | |
| 2196 | test_driver_match_cb, match_data, NULL, | ||
| 2197 | (GAsyncReadyCallback) test_driver_identify_cb, identify_data); | ||
| 2198 | |||
| 2199 |
1/2✗ Branch 0 (18→16) not taken.
✓ Branch 1 (18→19) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE)) |
| 2200 | ✗ | continue; | |
| 2201 | |||
| 2202 | /* suspend_sync hangs until cancellation, so we need to trigger orig_identify | ||
| 2203 | * from the mainloop after calling suspend_sync. | ||
| 2204 | */ | ||
| 2205 | 1 | fpi_device_add_timeout (device, 0, (FpTimeoutFunc) orig_identify, NULL, NULL); | |
| 2206 | |||
| 2207 | 1 | fake_dev->ret_suspend = fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED); | |
| 2208 | 1 | fp_device_suspend_sync (device, NULL, &error); | |
| 2209 | |||
| 2210 | /* At this point we are done with everything */ | ||
| 2211 |
1/2✓ Branch 0 (22→23) taken 1 times.
✗ Branch 1 (22→24) not taken.
|
1 | g_assert (fake_dev->last_called_function == orig_identify); |
| 2212 |
3/6✓ Branch 0 (23→25) taken 1 times.
✗ Branch 1 (23→28) not taken.
✓ Branch 2 (26→27) taken 1 times.
✗ Branch 3 (26→28) not taken.
✗ Branch 4 (27→28) not taken.
✓ Branch 5 (27→30) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED); |
| 2213 | 1 | g_clear_error (&error); | |
| 2214 | |||
| 2215 | /* We suspended, but device reported success and that will be reported. */ | ||
| 2216 |
1/2✗ Branch 0 (31→32) not taken.
✓ Branch 1 (31→33) taken 1 times.
|
1 | g_assert_true (match_data->called); |
| 2217 |
1/2✓ Branch 0 (33→34) taken 1 times.
✗ Branch 1 (33→35) not taken.
|
1 | g_assert (match_data->match == expected_matched); |
| 2218 |
1/2✗ Branch 0 (34→36) not taken.
✓ Branch 1 (34→37) taken 1 times.
|
1 | g_assert_true (identify_data->called); |
| 2219 |
1/2✓ Branch 0 (37→38) taken 1 times.
✗ Branch 1 (37→40) not taken.
|
1 | g_assert (identify_data->match == expected_matched); |
| 2220 | |||
| 2221 | /* Resuming the device does not call resume handler, as the action was | ||
| 2222 | * cancelled already. | ||
| 2223 | */ | ||
| 2224 | 1 | fake_dev->last_called_function = NULL; | |
| 2225 | 1 | fp_device_resume_sync (device, NULL, &error); | |
| 2226 |
1/2✓ Branch 0 (39→41) taken 1 times.
✗ Branch 1 (39→42) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2227 |
2/4✗ Branch 0 (41→43) not taken.
✓ Branch 1 (41→44) taken 1 times.
✗ Branch 2 (44→45) not taken.
✓ Branch 3 (44→46) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2228 | 1 | } | |
| 2229 | |||
| 2230 | static void | ||
| 2231 | 1 | test_driver_identify_suspend_busy_error (void) | |
| 2232 | { | ||
| 2233 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2234 | 2 | g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); | |
| 2235 | 2 | g_autoptr(MatchCbData) identify_data = g_new0 (MatchCbData, 1); | |
| 2236 | 1 | g_autoptr(GPtrArray) prints = NULL; | |
| 2237 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2238 | 1 | g_autoptr(GError) error = NULL; | |
| 2239 | 1 | void (*orig_identify) (FpDevice *device); | |
| 2240 | 1 | FpiDeviceFake *fake_dev; | |
| 2241 | 1 | FpPrint *expected_matched; | |
| 2242 | |||
| 2243 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2244 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2245 | 1 | orig_identify = dev_class->identify; | |
| 2246 | 1 | dev_class->identify = fake_device_stub_identify; | |
| 2247 | |||
| 2248 | 1 | prints = make_fake_prints_gallery (device, 500); | |
| 2249 | 1 | expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); | |
| 2250 | 1 | fp_print_set_description (expected_matched, "fake-verified"); | |
| 2251 | |||
| 2252 | 1 | match_data->gallery = prints; | |
| 2253 | |||
| 2254 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 2255 | |||
| 2256 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 2257 | 1 | fake_dev->ret_print = make_fake_print (device, NULL); | |
| 2258 | 1 | fp_device_identify (device, prints, NULL, | |
| 2259 | test_driver_match_cb, match_data, NULL, | ||
| 2260 | (GAsyncReadyCallback) test_driver_identify_cb, identify_data); | ||
| 2261 | |||
| 2262 |
1/2✗ Branch 0 (19→17) not taken.
✓ Branch 1 (19→20) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE)) |
| 2263 | ✗ | continue; | |
| 2264 | |||
| 2265 | /* suspend_sync hangs until cancellation, so we need to trigger orig_identify | ||
| 2266 | * from the mainloop after calling suspend_sync. | ||
| 2267 | */ | ||
| 2268 | 1 | fpi_device_add_timeout (device, 0, (FpTimeoutFunc) orig_identify, NULL, NULL); | |
| 2269 | |||
| 2270 | 1 | fake_dev->ret_suspend = fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED); | |
| 2271 | 1 | fp_device_suspend_sync (device, NULL, &error); | |
| 2272 | 1 | fake_dev->ret_error = NULL; | |
| 2273 | |||
| 2274 | /* At this point we are done with everything */ | ||
| 2275 |
1/2✓ Branch 0 (23→24) taken 1 times.
✗ Branch 1 (23→25) not taken.
|
1 | g_assert (fake_dev->last_called_function == orig_identify); |
| 2276 |
3/6✓ Branch 0 (24→26) taken 1 times.
✗ Branch 1 (24→29) not taken.
✓ Branch 2 (27→28) taken 1 times.
✗ Branch 3 (27→29) not taken.
✗ Branch 4 (28→29) not taken.
✓ Branch 5 (28→31) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED); |
| 2277 | 1 | g_clear_error (&error); | |
| 2278 | |||
| 2279 | /* The device reported an error, an this error will be overwritten. | ||
| 2280 | */ | ||
| 2281 |
1/2✗ Branch 0 (32→33) not taken.
✓ Branch 1 (32→34) taken 1 times.
|
1 | g_assert_false (match_data->called); |
| 2282 |
1/2✗ Branch 0 (34→35) not taken.
✓ Branch 1 (34→36) taken 1 times.
|
1 | g_assert_true (identify_data->called); |
| 2283 |
1/2✗ Branch 0 (36→37) not taken.
✓ Branch 1 (36→38) taken 1 times.
|
1 | g_assert_null (identify_data->match); |
| 2284 |
3/6✓ Branch 0 (38→39) taken 1 times.
✗ Branch 1 (38→42) not taken.
✓ Branch 2 (40→41) taken 1 times.
✗ Branch 3 (40→42) not taken.
✗ Branch 4 (41→42) not taken.
✓ Branch 5 (41→44) taken 1 times.
|
1 | g_assert_error (identify_data->error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_BUSY); |
| 2285 | |||
| 2286 | 1 | fake_dev->last_called_function = NULL; | |
| 2287 | 1 | fp_device_resume_sync (device, NULL, &error); | |
| 2288 |
1/2✓ Branch 0 (45→46) taken 1 times.
✗ Branch 1 (45→47) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2289 |
2/4✗ Branch 0 (46→48) not taken.
✓ Branch 1 (46→49) taken 1 times.
✗ Branch 2 (49→50) not taken.
✓ Branch 3 (49→51) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2290 | 1 | } | |
| 2291 | |||
| 2292 | static void | ||
| 2293 | 1 | test_driver_identify_suspend_while_idle (void) | |
| 2294 | { | ||
| 2295 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2296 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2297 | 1 | g_autoptr(GError) error = NULL; | |
| 2298 | 1 | FpiDeviceFake *fake_dev; | |
| 2299 | |||
| 2300 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2301 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2302 | |||
| 2303 | /* Suspending and resuming a closed device works */ | ||
| 2304 | 1 | fp_device_suspend (device, NULL, (GAsyncReadyCallback) fp_device_suspend_finish, &error); | |
| 2305 |
2/2✓ Branch 0 (9→7) taken 1 times.
✓ Branch 1 (9→10) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2306 | 1 | continue; | |
| 2307 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2308 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2309 | |||
| 2310 | 1 | fp_device_resume (device, NULL, (GAsyncReadyCallback) fp_device_resume_finish, NULL); | |
| 2311 |
2/2✓ Branch 0 (18→16) taken 1 times.
✓ Branch 1 (18→19) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2312 | 1 | continue; | |
| 2313 |
1/2✓ Branch 0 (19→20) taken 1 times.
✗ Branch 1 (19→21) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2314 |
1/2✗ Branch 0 (20→22) not taken.
✓ Branch 1 (20→23) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2315 | |||
| 2316 |
1/2✗ Branch 0 (24→25) not taken.
✓ Branch 1 (24→26) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 2317 | |||
| 2318 | 1 | fake_dev->last_called_function = NULL; | |
| 2319 | 1 | fp_device_suspend (device, NULL, (GAsyncReadyCallback) fp_device_suspend_finish, &error); | |
| 2320 |
2/2✓ Branch 0 (30→28) taken 1 times.
✓ Branch 1 (30→31) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2321 | 1 | continue; | |
| 2322 |
1/2✓ Branch 0 (31→32) taken 1 times.
✗ Branch 1 (31→33) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2323 |
1/2✗ Branch 0 (32→34) not taken.
✓ Branch 1 (32→35) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2324 | |||
| 2325 | 1 | fp_device_resume (device, NULL, (GAsyncReadyCallback) fp_device_resume_finish, NULL); | |
| 2326 |
2/2✓ Branch 0 (39→37) taken 1 times.
✓ Branch 1 (39→40) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2327 | 1 | continue; | |
| 2328 |
1/2✓ Branch 0 (40→41) taken 1 times.
✗ Branch 1 (40→42) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2329 |
2/4✗ Branch 0 (41→43) not taken.
✓ Branch 1 (41→44) taken 1 times.
✗ Branch 2 (44→45) not taken.
✓ Branch 3 (44→46) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2330 | 1 | } | |
| 2331 | |||
| 2332 | static void | ||
| 2333 | 1 | test_driver_identify_warmup_cooldown (void) | |
| 2334 | { | ||
| 2335 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2336 | 2 | g_autoptr(MatchCbData) identify_data = g_new0 (MatchCbData, 1); | |
| 2337 | 1 | g_autoptr(GPtrArray) prints = NULL; | |
| 2338 |
1/2✓ Branch 0 (97→98) taken 1 times.
✗ Branch 1 (97→99) not taken.
|
1 | g_autoptr(FpAutoCloseDevice) device = NULL; |
| 2339 | 1 | g_autoptr(GError) error = NULL; | |
| 2340 | 1 | void (*orig_identify) (FpDevice *device); | |
| 2341 | 1 | FpiDeviceFake *fake_dev; | |
| 2342 | 1 | gint64 start_time; | |
| 2343 | |||
| 2344 | 1 | dev_class->temp_hot_seconds = 2; | |
| 2345 | 1 | dev_class->temp_cold_seconds = 5; | |
| 2346 | |||
| 2347 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2348 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2349 | 1 | orig_identify = dev_class->identify; | |
| 2350 | 1 | dev_class->identify = fake_device_stub_identify; | |
| 2351 | |||
| 2352 | 1 | prints = make_fake_prints_gallery (device, 500); | |
| 2353 | |||
| 2354 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 2355 | 1 | fake_dev->last_called_function = NULL; | |
| 2356 | |||
| 2357 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 2358 | |||
| 2359 | /* Undefined: Whether match_cb is called. */ | ||
| 2360 | 1 | fp_device_identify (device, prints, NULL, | |
| 2361 | NULL, NULL, NULL, | ||
| 2362 | (GAsyncReadyCallback) test_driver_identify_cb, identify_data); | ||
| 2363 | |||
| 2364 | /* Identify is running, the temperature will change after only a short time. | ||
| 2365 | * Changes are delayed by 100ms and we give 150ms of slack for the test. | ||
| 2366 | */ | ||
| 2367 | 1 | start_time = g_get_monotonic_time (); | |
| 2368 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_cmpint (fp_device_get_temperature (device), ==, FP_TEMPERATURE_COLD); |
| 2369 |
2/2✓ Branch 0 (19→17) taken 2 times.
✓ Branch 1 (19→20) taken 1 times.
|
3 | while (fp_device_get_temperature (device) == FP_TEMPERATURE_COLD) |
| 2370 | 2 | g_main_context_iteration (NULL, TRUE); | |
| 2371 |
1/2✗ Branch 0 (21→22) not taken.
✓ Branch 1 (21→23) taken 1 times.
|
1 | g_assert_cmpint (fp_device_get_temperature (device), ==, FP_TEMPERATURE_WARM); |
| 2372 |
1/2✗ Branch 0 (25→26) not taken.
✓ Branch 1 (25→27) taken 1 times.
|
1 | g_assert_false (g_cancellable_is_cancelled (fpi_device_get_cancellable (device))); |
| 2373 |
1/2✗ Branch 0 (28→29) not taken.
✓ Branch 1 (28→30) taken 1 times.
|
1 | g_assert_cmpint (g_get_monotonic_time () - start_time, <, 0 + 250000); |
| 2374 | |||
| 2375 | /* we reach hot 2 seconds later */ | ||
| 2376 |
2/2✓ Branch 0 (33→31) taken 2 times.
✓ Branch 1 (33→34) taken 1 times.
|
3 | while (fp_device_get_temperature (device) == FP_TEMPERATURE_WARM) |
| 2377 | 2 | g_main_context_iteration (NULL, TRUE); | |
| 2378 |
1/2✗ Branch 0 (35→36) not taken.
✓ Branch 1 (35→37) taken 1 times.
|
1 | g_assert_cmpint (fp_device_get_temperature (device), ==, FP_TEMPERATURE_HOT); |
| 2379 |
1/2✗ Branch 0 (39→40) not taken.
✓ Branch 1 (39→41) taken 1 times.
|
1 | g_assert_true (g_cancellable_is_cancelled (fpi_device_get_cancellable (device))); |
| 2380 |
1/2✗ Branch 0 (42→43) not taken.
✓ Branch 1 (42→44) taken 1 times.
|
1 | g_assert_cmpint (g_get_monotonic_time () - start_time, <, 2000000 + 250000); |
| 2381 | |||
| 2382 | /* cancel vfunc will be called now */ | ||
| 2383 |
1/2✓ Branch 0 (44→45) taken 1 times.
✗ Branch 1 (44→46) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2384 |
2/2✓ Branch 0 (49→47) taken 1 times.
✓ Branch 1 (49→50) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2385 | 1 | continue; | |
| 2386 |
1/2✓ Branch 0 (50→51) taken 1 times.
✗ Branch 1 (50→53) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->cancel); |
| 2387 | |||
| 2388 | 1 | orig_identify (device); | |
| 2389 | 1 | fake_dev->ret_error = NULL; | |
| 2390 |
2/2✓ Branch 0 (56→54) taken 1 times.
✓ Branch 1 (56→57) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2391 | 1 | continue; | |
| 2392 |
1/2✗ Branch 0 (57→58) not taken.
✓ Branch 1 (57→59) taken 1 times.
|
1 | g_assert_true (identify_data->called); |
| 2393 |
3/6✓ Branch 0 (59→60) taken 1 times.
✗ Branch 1 (59→63) not taken.
✓ Branch 2 (61→62) taken 1 times.
✗ Branch 3 (61→63) not taken.
✗ Branch 4 (62→63) not taken.
✓ Branch 5 (62→65) taken 1 times.
|
1 | g_assert_error (identify_data->error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_TOO_HOT); |
| 2394 | |||
| 2395 | /* Try to identify again, and ensure that we fail early */ | ||
| 2396 | 1 | fp_device_identify_sync (device, prints, NULL, NULL, NULL, NULL, NULL, &error); | |
| 2397 |
3/6✓ Branch 0 (66→67) taken 1 times.
✗ Branch 1 (66→70) not taken.
✓ Branch 2 (68→69) taken 1 times.
✗ Branch 3 (68→70) not taken.
✗ Branch 4 (69→70) not taken.
✓ Branch 5 (69→72) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_TOO_HOT); |
| 2398 | 1 | g_clear_error (&error); | |
| 2399 | |||
| 2400 | /* Now, wait for it to cool down again; | ||
| 2401 | * WARM should be reached after about 2s | ||
| 2402 | * COLD after 5s but give it some more slack. */ | ||
| 2403 | 1 | start_time = g_get_monotonic_time (); | |
| 2404 |
2/2✓ Branch 0 (77→75) taken 1 times.
✓ Branch 1 (77→78) taken 1 times.
|
2 | while (fp_device_get_temperature (device) == FP_TEMPERATURE_HOT) |
| 2405 | 1 | g_main_context_iteration (NULL, TRUE); | |
| 2406 |
1/2✗ Branch 0 (79→80) not taken.
✓ Branch 1 (79→81) taken 1 times.
|
1 | g_assert_cmpint (fp_device_get_temperature (device), ==, FP_TEMPERATURE_WARM); |
| 2407 |
1/2✗ Branch 0 (82→83) not taken.
✓ Branch 1 (82→84) taken 1 times.
|
1 | g_assert_cmpint (g_get_monotonic_time () - start_time, <, 2000000 + 250000); |
| 2408 | |||
| 2409 |
2/2✓ Branch 0 (87→85) taken 2 times.
✓ Branch 1 (87→88) taken 1 times.
|
3 | while (fp_device_get_temperature (device) == FP_TEMPERATURE_WARM) |
| 2410 | 2 | g_main_context_iteration (NULL, TRUE); | |
| 2411 |
1/2✗ Branch 0 (89→90) not taken.
✓ Branch 1 (89→91) taken 1 times.
|
1 | g_assert_cmpint (fp_device_get_temperature (device), ==, FP_TEMPERATURE_COLD); |
| 2412 |
2/4✗ Branch 0 (92→93) not taken.
✓ Branch 1 (92→94) taken 1 times.
✗ Branch 2 (94→95) not taken.
✓ Branch 3 (94→96) taken 1 times.
|
1 | g_assert_cmpint (g_get_monotonic_time () - start_time, <, 5000000 + 500000); |
| 2413 | 1 | } | |
| 2414 | |||
| 2415 | static void | ||
| 2416 | ✗ | fake_device_stub_capture (FpDevice *device) | |
| 2417 | { | ||
| 2418 | ✗ | } | |
| 2419 | |||
| 2420 | static void | ||
| 2421 | 1 | test_driver_supports_capture (void) | |
| 2422 | { | ||
| 2423 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2424 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 2425 | |||
| 2426 | 1 | dev_class->features |= FP_DEVICE_FEATURE_CAPTURE; | |
| 2427 | 1 | dev_class->capture = fake_device_stub_capture; | |
| 2428 | |||
| 2429 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2430 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 2431 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fp_device_supports_capture (device)); |
| 2432 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 2433 |
2/4✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE)); |
| 2434 | 1 | } | |
| 2435 | |||
| 2436 | static void | ||
| 2437 | 1 | test_driver_do_not_support_capture (void) | |
| 2438 | { | ||
| 2439 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2440 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 2441 | |||
| 2442 | 1 | dev_class->features &= ~FP_DEVICE_FEATURE_CAPTURE; | |
| 2443 | 1 | dev_class->capture = NULL; | |
| 2444 | |||
| 2445 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2446 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 2447 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_false (fp_device_supports_capture (device)); |
| 2448 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 2449 |
2/4✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
|
1 | g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE)); |
| 2450 | 1 | } | |
| 2451 | |||
| 2452 | static void | ||
| 2453 | 1 | test_driver_capture (void) | |
| 2454 | { | ||
| 2455 | 2 | g_autoptr(GError) error = NULL; | |
| 2456 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_autoptr(FpImage) image = NULL; |
| 2457 |
1/2✓ Branch 0 (14→15) taken 1 times.
✗ Branch 1 (14→16) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2458 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2459 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2460 | 1 | gboolean wait_for_finger = TRUE; | |
| 2461 | |||
| 2462 | 1 | fake_dev->ret_image = fp_image_new (500, 500); | |
| 2463 | 1 | image = fp_device_capture_sync (device, wait_for_finger, NULL, &error); | |
| 2464 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->capture); |
| 2465 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_true (GPOINTER_TO_UINT (fake_dev->action_data)); |
| 2466 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2467 | |||
| 2468 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert (image == fake_dev->ret_image); |
| 2469 | 1 | } | |
| 2470 | |||
| 2471 | static void | ||
| 2472 | 1 | test_driver_capture_not_supported (void) | |
| 2473 | { | ||
| 2474 | 2 | g_autoptr(GError) error = NULL; | |
| 2475 |
1/2✓ Branch 0 (19→20) taken 1 times.
✗ Branch 1 (19→21) not taken.
|
1 | g_autoptr(FpImage) image = NULL; |
| 2476 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
2 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); |
| 2477 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2478 | 1 | gboolean wait_for_finger = TRUE; | |
| 2479 | 1 | FpiDeviceFake *fake_dev; | |
| 2480 | |||
| 2481 | 1 | dev_class->features &= ~FP_DEVICE_FEATURE_CAPTURE; | |
| 2482 | |||
| 2483 | 1 | device = auto_close_fake_device_new (); | |
| 2484 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2485 | 1 | fake_dev->last_called_function = NULL; | |
| 2486 | |||
| 2487 | 1 | image = fp_device_capture_sync (device, wait_for_finger, NULL, &error); | |
| 2488 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert_null (fake_dev->last_called_function); |
| 2489 |
3/6✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→11) not taken.
✓ Branch 2 (9→10) taken 1 times.
✗ Branch 3 (9→11) not taken.
✗ Branch 4 (10→11) not taken.
✓ Branch 5 (10→13) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED); |
| 2490 | |||
| 2491 |
1/2✗ Branch 0 (13→14) not taken.
✓ Branch 1 (13→15) taken 1 times.
|
1 | g_assert_null (image); |
| 2492 | 1 | } | |
| 2493 | |||
| 2494 | static void | ||
| 2495 | 1 | test_driver_capture_error (void) | |
| 2496 | { | ||
| 2497 | 2 | g_autoptr(GError) error = NULL; | |
| 2498 |
1/2✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→22) not taken.
|
1 | g_autoptr(FpImage) image = NULL; |
| 2499 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→20) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2500 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2501 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2502 | 1 | gboolean wait_for_finger = TRUE; | |
| 2503 | |||
| 2504 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 2505 | 1 | image = fp_device_capture_sync (device, wait_for_finger, NULL, &error); | |
| 2506 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->capture); |
| 2507 |
3/6✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→11) not taken.
✓ Branch 2 (9→10) taken 1 times.
✗ Branch 3 (9→11) not taken.
✗ Branch 4 (10→11) not taken.
✓ Branch 5 (10→13) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 2508 |
1/2✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→15) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 2509 | |||
| 2510 |
1/2✗ Branch 0 (14→16) not taken.
✓ Branch 1 (14→17) taken 1 times.
|
1 | g_assert_null (image); |
| 2511 | 1 | } | |
| 2512 | |||
| 2513 | static void | ||
| 2514 | 1 | test_driver_has_storage (void) | |
| 2515 | { | ||
| 2516 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2517 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 2518 | |||
| 2519 | 1 | dev_class->features |= FP_DEVICE_FEATURE_STORAGE; | |
| 2520 | |||
| 2521 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2522 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 2523 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fp_device_has_storage (device)); |
| 2524 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 2525 |
2/4✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
|
1 | g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE)); |
| 2526 | 1 | } | |
| 2527 | |||
| 2528 | static void | ||
| 2529 | 1 | test_driver_has_not_storage (void) | |
| 2530 | { | ||
| 2531 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2532 | 1 | g_autoptr(FpDevice) device = NULL; | |
| 2533 | |||
| 2534 | 1 | dev_class->features &= ~FP_DEVICE_FEATURE_STORAGE; | |
| 2535 | |||
| 2536 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2537 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 2538 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_false (fp_device_has_storage (device)); |
| 2539 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 2540 |
2/4✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
|
1 | g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE)); |
| 2541 | 1 | } | |
| 2542 | |||
| 2543 | static void | ||
| 2544 | 1 | test_driver_list (void) | |
| 2545 | { | ||
| 2546 | 2 | g_autoptr(GError) error = NULL; | |
| 2547 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2548 | 2 | g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500); | |
| 2549 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2550 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2551 | |||
| 2552 | 1 | fake_dev->ret_list = g_steal_pointer (&prints); | |
| 2553 | 1 | prints = fp_device_list_prints_sync (device, NULL, &error); | |
| 2554 | |||
| 2555 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->list); |
| 2556 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2557 | |||
| 2558 |
2/4✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→11) not taken.
✓ Branch 2 (10→12) taken 1 times.
✗ Branch 3 (10→13) not taken.
|
1 | g_assert (prints == fake_dev->ret_list); |
| 2559 | 1 | } | |
| 2560 | |||
| 2561 | static void | ||
| 2562 | 1 | test_driver_list_error (void) | |
| 2563 | { | ||
| 2564 | 2 | g_autoptr(GError) error = NULL; | |
| 2565 |
1/2✓ Branch 0 (20→21) taken 1 times.
✗ Branch 1 (20→22) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2566 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2567 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2568 | |||
| 2569 | 1 | g_autoptr(GPtrArray) prints = NULL; | |
| 2570 | |||
| 2571 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 2572 | 1 | prints = fp_device_list_prints_sync (device, NULL, &error); | |
| 2573 | |||
| 2574 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->list); |
| 2575 |
3/6✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→11) not taken.
✓ Branch 2 (9→10) taken 1 times.
✗ Branch 3 (9→11) not taken.
✗ Branch 4 (10→11) not taken.
✓ Branch 5 (10→13) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 2576 |
1/2✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→15) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 2577 | |||
| 2578 |
2/4✗ Branch 0 (14→16) not taken.
✓ Branch 1 (14→17) taken 1 times.
✗ Branch 2 (17→18) not taken.
✓ Branch 3 (17→19) taken 1 times.
|
1 | g_assert_null (prints); |
| 2579 | 1 | } | |
| 2580 | |||
| 2581 | static void | ||
| 2582 | 1 | test_driver_list_no_storage (void) | |
| 2583 | { | ||
| 2584 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2585 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2586 |
1/2✓ Branch 0 (23→24) taken 1 times.
✗ Branch 1 (23→25) not taken.
|
1 | g_autoptr(GPtrArray) prints = NULL; |
| 2587 |
1/2✗ Branch 0 (21→22) not taken.
✓ Branch 1 (21→23) taken 1 times.
|
1 | g_autoptr(GError) error = NULL; |
| 2588 | |||
| 2589 | 1 | dev_class->features &= ~FP_DEVICE_FEATURE_STORAGE; | |
| 2590 | |||
| 2591 | 1 | device = auto_close_fake_device_new (); | |
| 2592 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
| 2593 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert_false (fp_device_has_storage (device)); |
| 2594 | G_GNUC_END_IGNORE_DEPRECATIONS | ||
| 2595 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE)); |
| 2596 | |||
| 2597 | 1 | prints = fp_device_list_prints_sync (device, NULL, &error); | |
| 2598 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_null (prints); |
| 2599 |
4/8✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→17) not taken.
✓ Branch 2 (15→16) taken 1 times.
✗ Branch 3 (15→17) not taken.
✗ Branch 4 (16→17) not taken.
✓ Branch 5 (16→19) taken 1 times.
✓ Branch 6 (19→20) taken 1 times.
✗ Branch 7 (19→21) not taken.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_NOT_SUPPORTED); |
| 2600 | 1 | } | |
| 2601 | |||
| 2602 | static void | ||
| 2603 | 1 | test_driver_delete (void) | |
| 2604 | { | ||
| 2605 | 2 | g_autoptr(GError) error = NULL; | |
| 2606 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2607 | 2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); | |
| 2608 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2609 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2610 | 1 | gboolean ret; | |
| 2611 | |||
| 2612 | 1 | ret = fp_device_delete_print_sync (device, enrolled_print, NULL, &error); | |
| 2613 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->delete); |
| 2614 |
1/2✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→9) not taken.
|
1 | g_assert (fake_dev->action_data == enrolled_print); |
| 2615 |
1/2✗ Branch 0 (8→10) not taken.
✓ Branch 1 (8→11) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2616 |
2/4✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
✓ Branch 2 (13→14) taken 1 times.
✗ Branch 3 (13→15) not taken.
|
1 | g_assert_true (ret); |
| 2617 | 1 | } | |
| 2618 | |||
| 2619 | static void | ||
| 2620 | 1 | test_driver_delete_error (void) | |
| 2621 | { | ||
| 2622 | 2 | g_autoptr(GError) error = NULL; | |
| 2623 |
1/2✓ Branch 0 (21→22) taken 1 times.
✗ Branch 1 (21→23) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2624 | 2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); | |
| 2625 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2626 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2627 | 1 | gboolean ret; | |
| 2628 | |||
| 2629 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 2630 | 1 | ret = fp_device_delete_print_sync (device, enrolled_print, NULL, &error); | |
| 2631 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->delete); |
| 2632 |
3/6✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→12) not taken.
✓ Branch 2 (10→11) taken 1 times.
✗ Branch 3 (10→12) not taken.
✗ Branch 4 (11→12) not taken.
✓ Branch 5 (11→14) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 2633 |
1/2✓ Branch 0 (14→15) taken 1 times.
✗ Branch 1 (14→16) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 2634 | |||
| 2635 |
2/4✗ Branch 0 (15→17) not taken.
✓ Branch 1 (15→18) taken 1 times.
✓ Branch 2 (18→19) taken 1 times.
✗ Branch 3 (18→20) not taken.
|
1 | g_assert_false (ret); |
| 2636 | 1 | } | |
| 2637 | |||
| 2638 | static void | ||
| 2639 | 1 | test_driver_clear_storage (void) | |
| 2640 | { | ||
| 2641 | 2 | g_autoptr(GError) error = NULL; | |
| 2642 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2643 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2644 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2645 | 1 | gboolean ret; | |
| 2646 | |||
| 2647 | 1 | ret = fp_device_clear_storage_sync (device, NULL, &error); | |
| 2648 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->clear_storage); |
| 2649 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_no_error (error); |
| 2650 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_true (ret); |
| 2651 | 1 | } | |
| 2652 | |||
| 2653 | static void | ||
| 2654 | 1 | test_driver_clear_storage_error (void) | |
| 2655 | { | ||
| 2656 | 2 | g_autoptr(GError) error = NULL; | |
| 2657 |
1/2✓ Branch 0 (18→19) taken 1 times.
✗ Branch 1 (18→20) not taken.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2658 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2659 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2660 | 1 | gboolean ret; | |
| 2661 | |||
| 2662 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); | |
| 2663 | 1 | ret = fp_device_clear_storage_sync (device, NULL, &error); | |
| 2664 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->clear_storage); |
| 2665 |
3/6✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→11) not taken.
✓ Branch 2 (9→10) taken 1 times.
✗ Branch 3 (9→11) not taken.
✗ Branch 4 (10→11) not taken.
✓ Branch 5 (10→13) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 2666 |
1/2✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→15) not taken.
|
1 | g_assert (error == g_steal_pointer (&fake_dev->ret_error)); |
| 2667 | |||
| 2668 |
1/2✗ Branch 0 (14→16) not taken.
✓ Branch 1 (14→17) taken 1 times.
|
1 | g_assert_false (ret); |
| 2669 | 1 | } | |
| 2670 | |||
| 2671 | static gboolean | ||
| 2672 | 1 | fake_device_delete_wait_for_cancel_timeout (gpointer data) | |
| 2673 | { | ||
| 2674 | 1 | FpDevice *device = data; | |
| 2675 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2676 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 1 times.
|
1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); |
| 2677 | |||
| 2678 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == dev_class->cancel); |
| 2679 | 1 | default_fake_dev_class.delete (device); | |
| 2680 | |||
| 2681 |
1/2✓ Branch 0 (5→6) taken 1 times.
✗ Branch 1 (5→7) not taken.
|
1 | g_assert (fake_dev->last_called_function == default_fake_dev_class.delete); |
| 2682 | 1 | fake_dev->last_called_function = fake_device_delete_wait_for_cancel_timeout; | |
| 2683 | |||
| 2684 | 1 | return G_SOURCE_REMOVE; | |
| 2685 | } | ||
| 2686 | |||
| 2687 | static void | ||
| 2688 | 1 | fake_device_delete_wait_for_cancel (FpDevice *device) | |
| 2689 | { | ||
| 2690 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2691 | |||
| 2692 | 1 | fake_dev->last_called_function = fake_device_delete_wait_for_cancel; | |
| 2693 | |||
| 2694 | 1 | g_timeout_add (100, fake_device_delete_wait_for_cancel_timeout, device); | |
| 2695 | 1 | } | |
| 2696 | |||
| 2697 | static void | ||
| 2698 | 1 | on_driver_cancel_delete (GObject *obj, GAsyncResult *res, gpointer user_data) | |
| 2699 | { | ||
| 2700 | 2 | g_autoptr(GError) error = NULL; | |
| 2701 | 1 | FpDevice *device = FP_DEVICE (obj); | |
| 2702 | 1 | gboolean *completed = user_data; | |
| 2703 | |||
| 2704 | 1 | fp_device_delete_print_finish (device, res, &error); | |
| 2705 |
3/6✓ Branch 0 (3→4) taken 1 times.
✗ Branch 1 (3→7) not taken.
✓ Branch 2 (5→6) taken 1 times.
✗ Branch 3 (5→7) not taken.
✗ Branch 4 (6→7) not taken.
✓ Branch 5 (6→9) taken 1 times.
|
1 | g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED); |
| 2706 | |||
| 2707 |
1/2✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→11) not taken.
|
1 | *completed = TRUE; |
| 2708 | 1 | } | |
| 2709 | |||
| 2710 | static void | ||
| 2711 | 1 | test_driver_cancel (void) | |
| 2712 | { | ||
| 2713 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2714 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2715 | 1 | g_autoptr(GCancellable) cancellable = NULL; | |
| 2716 |
1/2✓ Branch 0 (15→16) taken 1 times.
✗ Branch 1 (15→17) not taken.
|
1 | g_autoptr(FpPrint) enrolled_print = NULL; |
| 2717 | 1 | gboolean completed = FALSE; | |
| 2718 | 1 | FpiDeviceFake *fake_dev; | |
| 2719 | |||
| 2720 | 1 | dev_class->delete = fake_device_delete_wait_for_cancel; | |
| 2721 | |||
| 2722 | 1 | device = auto_close_fake_device_new (); | |
| 2723 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2724 | 1 | cancellable = g_cancellable_new (); | |
| 2725 | 1 | enrolled_print = make_fake_print_reffed (device, NULL); | |
| 2726 | |||
| 2727 | 1 | fp_device_delete_print (device, enrolled_print, cancellable, | |
| 2728 | on_driver_cancel_delete, &completed); | ||
| 2729 | 1 | g_cancellable_cancel (cancellable); | |
| 2730 | |||
| 2731 |
2/2✓ Branch 0 (10→9) taken 4 times.
✓ Branch 1 (10→11) taken 1 times.
|
5 | while (!completed) |
| 2732 | 4 | g_main_context_iteration (NULL, TRUE); | |
| 2733 | |||
| 2734 |
2/4✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
✓ Branch 2 (13→14) taken 1 times.
✗ Branch 3 (13→15) not taken.
|
1 | g_assert (fake_dev->last_called_function == fake_device_delete_wait_for_cancel_timeout); |
| 2735 | 1 | } | |
| 2736 | |||
| 2737 | static void | ||
| 2738 | 1 | test_driver_cancel_fail (void) | |
| 2739 | { | ||
| 2740 | 2 | g_autoptr(GError) error = NULL; | |
| 2741 |
1/2✗ Branch 0 (24→25) not taken.
✓ Branch 1 (24→26) taken 1 times.
|
2 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); |
| 2742 | 2 | g_autoptr(GCancellable) cancellable = g_cancellable_new (); | |
| 2743 |
1/2✓ Branch 0 (21→22) taken 1 times.
✗ Branch 1 (21→23) not taken.
|
2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); |
| 2744 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 2745 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2746 | |||
| 2747 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fp_device_delete_print_sync (device, enrolled_print, cancellable, &error)); |
| 2748 |
1/2✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→11) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->delete); |
| 2749 | 1 | g_cancellable_cancel (cancellable); | |
| 2750 | |||
| 2751 |
1/2✗ Branch 0 (14→12) not taken.
✓ Branch 1 (14→15) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE)) |
| 2752 | ✗ | continue; | |
| 2753 | |||
| 2754 |
1/2✓ Branch 0 (15→16) taken 1 times.
✗ Branch 1 (15→17) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->delete); |
| 2755 |
2/4✗ Branch 0 (16→18) not taken.
✓ Branch 1 (16→19) taken 1 times.
✓ Branch 2 (19→20) taken 1 times.
✗ Branch 3 (19→21) not taken.
|
1 | g_assert_no_error (error); |
| 2756 | 1 | } | |
| 2757 | |||
| 2758 | static void | ||
| 2759 | 1 | test_driver_critical (void) | |
| 2760 | { | ||
| 2761 | 1 | g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); | |
| 2762 | 2 | g_autoptr(GCancellable) cancellable = g_cancellable_new (); | |
| 2763 |
1/2✓ Branch 0 (79→80) taken 1 times.
✗ Branch 1 (79→81) not taken.
|
2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); |
| 2764 |
1/2✓ Branch 0 (77→78) taken 1 times.
✗ Branch 1 (77→79) not taken.
|
2 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); |
| 2765 | 1 | void (*orig_verify) (FpDevice *device) = dev_class->verify; | |
| 2766 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2767 | |||
| 2768 | 1 | fake_dev->last_called_function = NULL; | |
| 2769 | |||
| 2770 | 1 | dev_class->verify = fake_device_stub_verify; | |
| 2771 | 1 | fp_device_verify (device, enrolled_print, cancellable, | |
| 2772 | NULL, NULL, NULL, | ||
| 2773 | NULL, NULL); | ||
| 2774 | |||
| 2775 | /* We started a verify operation, now emulate a "critical" section */ | ||
| 2776 | 1 | fpi_device_critical_enter (device); | |
| 2777 | |||
| 2778 | /* Throw a suspend and external cancellation against it. */ | ||
| 2779 | 1 | fp_device_suspend (device, NULL, NULL, NULL); | |
| 2780 | 1 | g_cancellable_cancel (cancellable); | |
| 2781 | |||
| 2782 | /* The only thing that happens is that the cancellable is cancelled */ | ||
| 2783 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_true (fpi_device_action_is_cancelled (device)); |
| 2784 |
1/2✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→15) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2785 |
2/2✓ Branch 0 (18→16) taken 1 times.
✓ Branch 1 (18→19) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2786 | 1 | continue; | |
| 2787 |
1/2✓ Branch 0 (19→20) taken 1 times.
✗ Branch 1 (19→23) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2788 | |||
| 2789 | /* Leaving and entering the critical section in the same mainloop iteration | ||
| 2790 | * does not do anything. */ | ||
| 2791 | 1 | fpi_device_critical_leave (device); | |
| 2792 | 1 | fpi_device_critical_enter (device); | |
| 2793 |
1/2✗ Branch 0 (26→24) not taken.
✓ Branch 1 (26→27) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE)) |
| 2794 | ✗ | continue; | |
| 2795 |
1/2✓ Branch 0 (27→28) taken 1 times.
✗ Branch 1 (27→30) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2796 | |||
| 2797 | /* Leaving it and running the mainloop will first run the cancel handler */ | ||
| 2798 | 1 | fpi_device_critical_leave (device); | |
| 2799 |
2/4✓ Branch 0 (33→34) taken 1 times.
✗ Branch 1 (33→35) not taken.
✗ Branch 2 (34→31) not taken.
✓ Branch 3 (34→35) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE) && !fake_dev->last_called_function) |
| 2800 | ✗ | continue; | |
| 2801 |
1/2✓ Branch 0 (35→36) taken 1 times.
✗ Branch 1 (35→38) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->cancel); |
| 2802 |
1/2✗ Branch 0 (37→39) not taken.
✓ Branch 1 (37→40) taken 1 times.
|
1 | g_assert_true (fpi_device_action_is_cancelled (device)); |
| 2803 | 1 | fake_dev->last_called_function = NULL; | |
| 2804 | |||
| 2805 | /* Then the suspend handler */ | ||
| 2806 |
2/4✓ Branch 0 (43→44) taken 1 times.
✗ Branch 1 (43→45) not taken.
✗ Branch 2 (44→41) not taken.
✓ Branch 3 (44→45) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE) && !fake_dev->last_called_function) |
| 2807 | ✗ | continue; | |
| 2808 |
1/2✓ Branch 0 (45→46) taken 1 times.
✗ Branch 1 (45→47) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->suspend); |
| 2809 | 1 | fake_dev->last_called_function = NULL; | |
| 2810 | |||
| 2811 | /* Nothing happens afterwards */ | ||
| 2812 |
2/2✓ Branch 0 (50→48) taken 1 times.
✓ Branch 1 (50→51) taken 1 times.
|
2 | while (g_main_context_iteration (NULL, FALSE)) |
| 2813 | 1 | continue; | |
| 2814 |
1/2✓ Branch 0 (51→52) taken 1 times.
✗ Branch 1 (51→55) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2815 | |||
| 2816 | |||
| 2817 | /* Throw a resume at the system */ | ||
| 2818 | 1 | fpi_device_critical_enter (device); | |
| 2819 | 1 | fp_device_resume (device, NULL, NULL, NULL); | |
| 2820 | |||
| 2821 | /* Nothing will happen, as the resume is delayed */ | ||
| 2822 |
1/2✗ Branch 0 (58→56) not taken.
✓ Branch 1 (58→59) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE)) |
| 2823 | ✗ | continue; | |
| 2824 |
1/2✓ Branch 0 (59→60) taken 1 times.
✗ Branch 1 (59→63) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2825 | |||
| 2826 | /* Finally the resume is called from the mainloop after leaving the critical section */ | ||
| 2827 | 1 | fpi_device_critical_leave (device); | |
| 2828 |
1/2✓ Branch 0 (61→62) taken 1 times.
✗ Branch 1 (61→64) not taken.
|
1 | g_assert (fake_dev->last_called_function == NULL); |
| 2829 |
2/4✓ Branch 0 (67→68) taken 1 times.
✗ Branch 1 (67→69) not taken.
✗ Branch 2 (68→65) not taken.
✓ Branch 3 (68→69) taken 1 times.
|
1 | while (g_main_context_iteration (NULL, FALSE) && !fake_dev->last_called_function) |
| 2830 | ✗ | continue; | |
| 2831 |
1/2✓ Branch 0 (69→70) taken 1 times.
✗ Branch 1 (69→72) not taken.
|
1 | g_assert (fake_dev->last_called_function == dev_class->resume); |
| 2832 | 1 | fake_dev->last_called_function = NULL; | |
| 2833 | |||
| 2834 | |||
| 2835 | /* The "verify" operation is still ongoing, finish it. */ | ||
| 2836 | 1 | orig_verify (device); | |
| 2837 |
2/2✓ Branch 0 (75→73) taken 3 times.
✓ Branch 1 (75→76) taken 1 times.
|
4 | while (g_main_context_iteration (NULL, FALSE)) |
| 2838 | 3 | continue; | |
| 2839 | 1 | } | |
| 2840 | |||
| 2841 | static void | ||
| 2842 | 1 | test_driver_current_action (void) | |
| 2843 | { | ||
| 2844 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2845 | |||
| 2846 |
2/4✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 1 times.
✓ Branch 2 (7→8) taken 1 times.
✗ Branch 3 (7→9) not taken.
|
1 | g_assert_cmpint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_NONE); |
| 2847 | 1 | } | |
| 2848 | |||
| 2849 | static void | ||
| 2850 | 1 | test_driver_current_action_open_vfunc (FpDevice *device) | |
| 2851 | { | ||
| 2852 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2853 | |||
| 2854 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_OPEN); |
| 2855 | 1 | fake_dev->last_called_function = test_driver_current_action_open_vfunc; | |
| 2856 | |||
| 2857 | 1 | fpi_device_open_complete (device, NULL); | |
| 2858 | 1 | } | |
| 2859 | |||
| 2860 | static void | ||
| 2861 | 1 | test_driver_current_action_open (void) | |
| 2862 | { | ||
| 2863 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2864 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2865 | 1 | FpiDeviceFake *fake_dev; | |
| 2866 | |||
| 2867 | 1 | dev_class->open = test_driver_current_action_open_vfunc; | |
| 2868 | 1 | device = auto_close_fake_device_new (); | |
| 2869 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2870 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == test_driver_current_action_open_vfunc); |
| 2871 | |||
| 2872 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_cmpint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_NONE); |
| 2873 | 1 | } | |
| 2874 | |||
| 2875 | static void | ||
| 2876 | 1 | test_driver_action_get_cancellable_open_vfunc (FpDevice *device) | |
| 2877 | { | ||
| 2878 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2879 | |||
| 2880 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_OPEN); |
| 2881 | 1 | fake_dev->last_called_function = test_driver_action_get_cancellable_open_vfunc; | |
| 2882 | |||
| 2883 |
3/8✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→10) not taken.
✓ Branch 2 (7→8) taken 1 times.
✗ Branch 3 (7→9) not taken.
✗ Branch 4 (8→9) not taken.
✓ Branch 5 (8→11) taken 1 times.
✗ Branch 6 (9→10) not taken.
✗ Branch 7 (9→11) not taken.
|
1 | g_assert_true (G_IS_CANCELLABLE (fpi_device_get_cancellable (device))); |
| 2884 | |||
| 2885 | 1 | fpi_device_open_complete (device, NULL); | |
| 2886 | 1 | } | |
| 2887 | |||
| 2888 | static void | ||
| 2889 | 1 | test_driver_action_get_cancellable_open (void) | |
| 2890 | { | ||
| 2891 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2892 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2893 | 1 | g_autoptr(GCancellable) cancellable = NULL; | |
| 2894 | 1 | FpiDeviceFake *fake_dev; | |
| 2895 | |||
| 2896 | 1 | dev_class->open = test_driver_action_get_cancellable_open_vfunc; | |
| 2897 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2898 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2899 | |||
| 2900 | 1 | cancellable = g_cancellable_new (); | |
| 2901 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, cancellable, NULL)); |
| 2902 | |||
| 2903 |
2/4✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→11) not taken.
✓ Branch 2 (10→12) taken 1 times.
✗ Branch 3 (10→13) not taken.
|
1 | g_assert (fake_dev->last_called_function == test_driver_action_get_cancellable_open_vfunc); |
| 2904 | 1 | } | |
| 2905 | |||
| 2906 | static void | ||
| 2907 | 1 | test_driver_action_get_cancellable_open_internal_vfunc (FpDevice *device) | |
| 2908 | { | ||
| 2909 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2910 | |||
| 2911 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 1 times.
|
1 | g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_OPEN); |
| 2912 | 1 | fake_dev->last_called_function = test_driver_action_get_cancellable_open_internal_vfunc; | |
| 2913 | |||
| 2914 |
3/8✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→10) not taken.
✓ Branch 2 (7→8) taken 1 times.
✗ Branch 3 (7→9) not taken.
✗ Branch 4 (8→9) not taken.
✓ Branch 5 (8→11) taken 1 times.
✗ Branch 6 (9→10) not taken.
✗ Branch 7 (9→11) not taken.
|
1 | g_assert_true (G_IS_CANCELLABLE (fpi_device_get_cancellable (device))); |
| 2915 | |||
| 2916 | 1 | fpi_device_open_complete (device, NULL); | |
| 2917 | 1 | } | |
| 2918 | |||
| 2919 | static void | ||
| 2920 | 1 | test_driver_action_get_cancellable_open_internal (void) | |
| 2921 | { | ||
| 2922 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2923 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2924 | 1 | FpiDeviceFake *fake_dev; | |
| 2925 | |||
| 2926 | 1 | dev_class->open = test_driver_action_get_cancellable_open_internal_vfunc; | |
| 2927 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2928 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2929 | |||
| 2930 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 2931 | |||
| 2932 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == test_driver_action_get_cancellable_open_internal_vfunc); |
| 2933 | 1 | } | |
| 2934 | |||
| 2935 | static void | ||
| 2936 | 1 | test_driver_action_get_cancellable_error (void) | |
| 2937 | { | ||
| 2938 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2939 | |||
| 2940 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 2941 | "*assertion*current_action*FPI_DEVICE_ACTION_NONE*failed"); | ||
| 2942 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_null (fpi_device_get_cancellable (device)); |
| 2943 |
1/2✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→11) not taken.
|
1 | g_test_assert_expected_messages (); |
| 2944 | 1 | } | |
| 2945 | |||
| 2946 | static void | ||
| 2947 | 2 | test_driver_action_is_cancelled_open_vfunc (FpDevice *device) | |
| 2948 | { | ||
| 2949 | 2 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 2950 | |||
| 2951 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 2 times.
|
2 | g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_OPEN); |
| 2952 | 2 | fake_dev->last_called_function = test_driver_action_is_cancelled_open_vfunc; | |
| 2953 | |||
| 2954 |
3/8✓ Branch 0 (6→7) taken 2 times.
✗ Branch 1 (6→10) not taken.
✓ Branch 2 (7→8) taken 2 times.
✗ Branch 3 (7→9) not taken.
✗ Branch 4 (8→9) not taken.
✓ Branch 5 (8→11) taken 2 times.
✗ Branch 6 (9→10) not taken.
✗ Branch 7 (9→11) not taken.
|
2 | g_assert_true (G_IS_CANCELLABLE (fpi_device_get_cancellable (device))); |
| 2955 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 2 times.
|
2 | g_assert_false (fpi_device_action_is_cancelled (device)); |
| 2956 | |||
| 2957 |
2/2✓ Branch 0 (14→15) taken 1 times.
✓ Branch 1 (14→16) taken 1 times.
|
2 | if (fake_dev->ext_cancellable) |
| 2958 | 1 | g_cancellable_cancel (fake_dev->ext_cancellable); | |
| 2959 | else | ||
| 2960 | 1 | g_cancellable_cancel (fpi_device_get_cancellable (device)); | |
| 2961 | |||
| 2962 |
1/2✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→21) taken 2 times.
|
2 | g_assert_true (fpi_device_action_is_cancelled (device)); |
| 2963 | |||
| 2964 | 2 | fpi_device_open_complete (device, NULL); | |
| 2965 | 2 | } | |
| 2966 | |||
| 2967 | static void | ||
| 2968 | 1 | test_driver_action_is_cancelled_open (void) | |
| 2969 | { | ||
| 2970 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2971 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2972 | 1 | g_autoptr(GCancellable) cancellable = NULL; | |
| 2973 |
1/2✓ Branch 0 (19→20) taken 1 times.
✗ Branch 1 (19→21) not taken.
|
1 | g_autoptr(GError) error = NULL; |
| 2974 | 1 | FpiDeviceFake *fake_dev; | |
| 2975 | |||
| 2976 | 1 | dev_class->open = test_driver_action_is_cancelled_open_vfunc; | |
| 2977 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2978 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2979 | |||
| 2980 | 1 | cancellable = fake_dev->ext_cancellable = g_cancellable_new (); | |
| 2981 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_false (fp_device_open_sync (device, cancellable, &error)); |
| 2982 |
3/6✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→13) not taken.
✓ Branch 2 (11→12) taken 1 times.
✗ Branch 3 (11→13) not taken.
✗ Branch 4 (12→13) not taken.
✓ Branch 5 (12→15) taken 1 times.
|
1 | g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED); |
| 2983 | |||
| 2984 |
2/4✓ Branch 0 (15→16) taken 1 times.
✗ Branch 1 (15→17) not taken.
✓ Branch 2 (16→18) taken 1 times.
✗ Branch 3 (16→19) not taken.
|
1 | g_assert (fake_dev->last_called_function == test_driver_action_is_cancelled_open_vfunc); |
| 2985 | 1 | } | |
| 2986 | |||
| 2987 | static void | ||
| 2988 | 1 | test_driver_action_internally_cancelled_open (void) | |
| 2989 | { | ||
| 2990 | 1 | g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); | |
| 2991 | 1 | g_autoptr(FpAutoCloseDevice) device = NULL; | |
| 2992 | 1 | g_autoptr(GCancellable) cancellable = NULL; | |
| 2993 |
1/2✓ Branch 0 (15→16) taken 1 times.
✗ Branch 1 (15→17) not taken.
|
1 | g_autoptr(GError) error = NULL; |
| 2994 | 1 | FpiDeviceFake *fake_dev; | |
| 2995 | |||
| 2996 | 1 | dev_class->open = test_driver_action_is_cancelled_open_vfunc; | |
| 2997 | 1 | device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 2998 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 2999 | |||
| 3000 | /* No error, just some internal cancellation but we let nothing happen externally. */ | ||
| 3001 | 1 | cancellable = g_cancellable_new (); | |
| 3002 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, cancellable, &error)); |
| 3003 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_null (error); |
| 3004 | |||
| 3005 |
2/4✓ Branch 0 (11→12) taken 1 times.
✗ Branch 1 (11→13) not taken.
✗ Branch 2 (12→14) not taken.
✓ Branch 3 (12→15) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == test_driver_action_is_cancelled_open_vfunc); |
| 3006 | 1 | } | |
| 3007 | |||
| 3008 | static void | ||
| 3009 | 1 | test_driver_action_is_cancelled_error (void) | |
| 3010 | { | ||
| 3011 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3012 | |||
| 3013 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3014 | "*assertion*current_action*FPI_DEVICE_ACTION_NONE*failed"); | ||
| 3015 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 1 times.
|
1 | g_assert_true (fpi_device_action_is_cancelled (device)); |
| 3016 |
1/2✓ Branch 0 (9→10) taken 1 times.
✗ Branch 1 (9→11) not taken.
|
1 | g_test_assert_expected_messages (); |
| 3017 | 1 | } | |
| 3018 | |||
| 3019 | static void | ||
| 3020 | 1 | test_driver_complete_actions_errors (void) | |
| 3021 | { | ||
| 3022 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3023 | |||
| 3024 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3025 | "*assertion*current_action*failed"); | ||
| 3026 | 1 | fpi_device_probe_complete (device, NULL, NULL, NULL); | |
| 3027 | 1 | g_test_assert_expected_messages (); | |
| 3028 | |||
| 3029 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3030 | "*assertion*current_action*failed"); | ||
| 3031 | 1 | fpi_device_open_complete (device, NULL); | |
| 3032 | 1 | g_test_assert_expected_messages (); | |
| 3033 | |||
| 3034 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3035 | "*assertion*current_action*failed"); | ||
| 3036 | 1 | fpi_device_close_complete (device, NULL); | |
| 3037 | 1 | g_test_assert_expected_messages (); | |
| 3038 | |||
| 3039 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3040 | "*assertion*current_action*failed"); | ||
| 3041 | 1 | fpi_device_enroll_complete (device, NULL, NULL); | |
| 3042 | 1 | g_test_assert_expected_messages (); | |
| 3043 | |||
| 3044 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3045 | "*assertion*current_action*failed"); | ||
| 3046 | 1 | fpi_device_verify_complete (device, NULL); | |
| 3047 | 1 | g_test_assert_expected_messages (); | |
| 3048 | |||
| 3049 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3050 | "*assertion*current_action*failed"); | ||
| 3051 | 1 | fpi_device_identify_complete (device, NULL); | |
| 3052 | 1 | g_test_assert_expected_messages (); | |
| 3053 | |||
| 3054 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3055 | "*assertion*current_action*failed"); | ||
| 3056 | 1 | fpi_device_capture_complete (device, NULL, NULL); | |
| 3057 | 1 | g_test_assert_expected_messages (); | |
| 3058 | |||
| 3059 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3060 | "*assertion*current_action*failed"); | ||
| 3061 | 1 | fpi_device_delete_complete (device, NULL); | |
| 3062 | 1 | g_test_assert_expected_messages (); | |
| 3063 | |||
| 3064 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3065 | "*assertion*current_action*failed"); | ||
| 3066 | 1 | fpi_device_list_complete (device, NULL, NULL); | |
| 3067 |
1/2✓ Branch 0 (31→32) taken 1 times.
✗ Branch 1 (31→33) not taken.
|
1 | g_test_assert_expected_messages (); |
| 3068 | 1 | } | |
| 3069 | |||
| 3070 | static void | ||
| 3071 | 1 | test_driver_action_error_error (void) | |
| 3072 | { | ||
| 3073 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3074 | |||
| 3075 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, | |
| 3076 | "*assertion*current_action*FPI_DEVICE_ACTION_NONE*failed"); | ||
| 3077 | 1 | fpi_device_action_error (device, NULL); | |
| 3078 |
1/2✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→9) not taken.
|
1 | g_test_assert_expected_messages (); |
| 3079 | 1 | } | |
| 3080 | |||
| 3081 | static void | ||
| 3082 | 1 | test_driver_action_error_all (void) | |
| 3083 | { | ||
| 3084 | 1 | g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3085 | 2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); | |
| 3086 |
1/2✓ Branch 0 (131→132) taken 1 times.
✗ Branch 1 (131→133) not taken.
|
2 | g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 0); |
| 3087 |
1/2✓ Branch 0 (129→130) taken 1 times.
✗ Branch 1 (129→131) not taken.
|
1 | g_autoptr(GError) error = NULL; |
| 3088 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 3089 | 1 | FpiDeviceFake *fake_dev; | |
| 3090 | |||
| 3091 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 3092 | 1 | fake_dev->return_action_error = TRUE; | |
| 3093 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3094 | |||
| 3095 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_false (fp_device_open_sync (device, NULL, &error)); |
| 3096 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->open); |
| 3097 |
3/6✓ Branch 0 (12→13) taken 1 times.
✗ Branch 1 (12→16) not taken.
✓ Branch 2 (14→15) taken 1 times.
✗ Branch 3 (14→16) not taken.
✗ Branch 4 (15→16) not taken.
✓ Branch 5 (15→18) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3098 | 1 | g_clear_error (&error); | |
| 3099 | |||
| 3100 | 1 | fake_dev->return_action_error = FALSE; | |
| 3101 | 1 | fake_dev->ret_error = NULL; | |
| 3102 |
1/2✗ Branch 0 (20→21) not taken.
✓ Branch 1 (20→22) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 3103 | |||
| 3104 | 1 | fake_dev->return_action_error = TRUE; | |
| 3105 | |||
| 3106 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3107 |
1/2✗ Branch 0 (25→26) not taken.
✓ Branch 1 (25→27) taken 1 times.
|
1 | g_assert_null (fp_device_enroll_sync (device, fp_print_new (device), NULL, |
| 3108 | NULL, NULL, &error)); | ||
| 3109 |
1/2✗ Branch 0 (27→28) not taken.
✓ Branch 1 (27→29) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->enroll); |
| 3110 |
3/6✓ Branch 0 (29→30) taken 1 times.
✗ Branch 1 (29→33) not taken.
✓ Branch 2 (31→32) taken 1 times.
✗ Branch 3 (31→33) not taken.
✗ Branch 4 (32→33) not taken.
✓ Branch 5 (32→35) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3111 | 1 | g_clear_error (&error); | |
| 3112 | |||
| 3113 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3114 |
1/2✗ Branch 0 (38→39) not taken.
✓ Branch 1 (38→40) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, |
| 3115 | NULL, NULL, NULL, NULL, &error)); | ||
| 3116 |
1/2✗ Branch 0 (40→41) not taken.
✓ Branch 1 (40→42) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->verify); |
| 3117 |
3/6✓ Branch 0 (42→43) taken 1 times.
✗ Branch 1 (42→46) not taken.
✓ Branch 2 (44→45) taken 1 times.
✗ Branch 3 (44→46) not taken.
✗ Branch 4 (45→46) not taken.
✓ Branch 5 (45→48) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3118 | 1 | g_clear_error (&error); | |
| 3119 | |||
| 3120 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3121 |
1/2✗ Branch 0 (51→52) not taken.
✓ Branch 1 (51→53) taken 1 times.
|
1 | g_assert_false (fp_device_identify_sync (device, prints, NULL, |
| 3122 | NULL, NULL, NULL, NULL, &error)); | ||
| 3123 |
1/2✗ Branch 0 (53→54) not taken.
✓ Branch 1 (53→55) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->identify); |
| 3124 |
3/6✓ Branch 0 (55→56) taken 1 times.
✗ Branch 1 (55→59) not taken.
✓ Branch 2 (57→58) taken 1 times.
✗ Branch 3 (57→59) not taken.
✗ Branch 4 (58→59) not taken.
✓ Branch 5 (58→61) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3125 | 1 | g_clear_error (&error); | |
| 3126 | |||
| 3127 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3128 |
1/2✗ Branch 0 (64→65) not taken.
✓ Branch 1 (64→66) taken 1 times.
|
1 | g_assert_null (fp_device_capture_sync (device, TRUE, NULL, &error)); |
| 3129 |
1/2✗ Branch 0 (66→67) not taken.
✓ Branch 1 (66→68) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->capture); |
| 3130 |
3/6✓ Branch 0 (68→69) taken 1 times.
✗ Branch 1 (68→72) not taken.
✓ Branch 2 (70→71) taken 1 times.
✗ Branch 3 (70→72) not taken.
✗ Branch 4 (71→72) not taken.
✓ Branch 5 (71→74) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3131 | 1 | g_clear_error (&error); | |
| 3132 | |||
| 3133 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3134 |
1/2✗ Branch 0 (77→78) not taken.
✓ Branch 1 (77→79) taken 1 times.
|
1 | g_assert_null (fp_device_list_prints_sync (device, NULL, &error)); |
| 3135 |
1/2✗ Branch 0 (79→80) not taken.
✓ Branch 1 (79→81) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->list); |
| 3136 |
3/6✓ Branch 0 (81→82) taken 1 times.
✗ Branch 1 (81→85) not taken.
✓ Branch 2 (83→84) taken 1 times.
✗ Branch 3 (83→85) not taken.
✗ Branch 4 (84→85) not taken.
✓ Branch 5 (84→87) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3137 | 1 | g_clear_error (&error); | |
| 3138 | |||
| 3139 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3140 |
1/2✗ Branch 0 (90→91) not taken.
✓ Branch 1 (90→92) taken 1 times.
|
1 | g_assert_false (fp_device_delete_print_sync (device, enrolled_print, NULL, &error)); |
| 3141 |
1/2✗ Branch 0 (92→93) not taken.
✓ Branch 1 (92→94) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->delete); |
| 3142 |
3/6✓ Branch 0 (94→95) taken 1 times.
✗ Branch 1 (94→98) not taken.
✓ Branch 2 (96→97) taken 1 times.
✗ Branch 3 (96→98) not taken.
✗ Branch 4 (97→98) not taken.
✓ Branch 5 (97→100) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3143 | 1 | g_clear_error (&error); | |
| 3144 | |||
| 3145 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3146 |
1/2✗ Branch 0 (103→104) not taken.
✓ Branch 1 (103→105) taken 1 times.
|
1 | g_assert_false (fp_device_clear_storage_sync (device, NULL, &error)); |
| 3147 |
1/2✗ Branch 0 (105→106) not taken.
✓ Branch 1 (105→107) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->clear_storage); |
| 3148 |
3/6✓ Branch 0 (107→108) taken 1 times.
✗ Branch 1 (107→111) not taken.
✓ Branch 2 (109→110) taken 1 times.
✗ Branch 3 (109→111) not taken.
✗ Branch 4 (110→111) not taken.
✓ Branch 5 (110→113) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3149 | 1 | g_clear_error (&error); | |
| 3150 | |||
| 3151 | /* Test close last, as we can't operate on a closed device. */ | ||
| 3152 | 1 | fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID); | |
| 3153 |
1/2✗ Branch 0 (116→117) not taken.
✓ Branch 1 (116→118) taken 1 times.
|
1 | g_assert_false (fp_device_close_sync (device, NULL, &error)); |
| 3154 |
1/2✗ Branch 0 (118→119) not taken.
✓ Branch 1 (118→120) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->close); |
| 3155 |
3/6✓ Branch 0 (120→121) taken 1 times.
✗ Branch 1 (120→124) not taken.
✓ Branch 2 (122→123) taken 1 times.
✗ Branch 3 (122→124) not taken.
✗ Branch 4 (123→124) not taken.
✓ Branch 5 (123→126) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID); |
| 3156 |
1/2✗ Branch 0 (127→128) not taken.
✓ Branch 1 (127→129) taken 1 times.
|
1 | g_clear_error (&error); |
| 3157 | 1 | } | |
| 3158 | |||
| 3159 | static void | ||
| 3160 | 1 | test_driver_action_error_fallback_all (void) | |
| 3161 | { | ||
| 3162 | 1 | g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3163 | 2 | g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL); | |
| 3164 |
1/2✓ Branch 0 (141→142) taken 1 times.
✗ Branch 1 (141→143) not taken.
|
2 | g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 0); |
| 3165 |
1/2✓ Branch 0 (139→140) taken 1 times.
✗ Branch 1 (139→141) not taken.
|
1 | g_autoptr(GError) error = NULL; |
| 3166 | 1 | FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); | |
| 3167 | 1 | FpiDeviceFake *fake_dev; | |
| 3168 | |||
| 3169 | 1 | fake_dev = FPI_DEVICE_FAKE (device); | |
| 3170 | 1 | fake_dev->return_action_error = TRUE; | |
| 3171 | |||
| 3172 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3173 | "*Device failed to pass an error to generic action " | ||
| 3174 | "error function*"); | ||
| 3175 | |||
| 3176 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_false (fp_device_open_sync (device, NULL, &error)); |
| 3177 | 1 | g_test_assert_expected_messages (); | |
| 3178 |
1/2✗ Branch 0 (11→12) not taken.
✓ Branch 1 (11→13) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->open); |
| 3179 |
3/6✓ Branch 0 (13→14) taken 1 times.
✗ Branch 1 (13→17) not taken.
✓ Branch 2 (15→16) taken 1 times.
✗ Branch 3 (15→17) not taken.
✗ Branch 4 (16→17) not taken.
✓ Branch 5 (16→19) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3180 | 1 | g_clear_error (&error); | |
| 3181 | |||
| 3182 | 1 | fake_dev->return_action_error = FALSE; | |
| 3183 |
1/2✗ Branch 0 (21→22) not taken.
✓ Branch 1 (21→23) taken 1 times.
|
1 | g_assert_true (fp_device_open_sync (device, NULL, NULL)); |
| 3184 | |||
| 3185 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3186 | "*Device failed to pass an error to generic action " | ||
| 3187 | "error function*"); | ||
| 3188 | |||
| 3189 | 1 | fake_dev->return_action_error = TRUE; | |
| 3190 |
1/2✗ Branch 0 (26→27) not taken.
✓ Branch 1 (26→28) taken 1 times.
|
1 | g_assert_null (fp_device_enroll_sync (device, fp_print_new (device), NULL, |
| 3191 | NULL, NULL, &error)); | ||
| 3192 | 1 | g_test_assert_expected_messages (); | |
| 3193 | 1 | g_test_assert_expected_messages (); | |
| 3194 |
1/2✗ Branch 0 (30→31) not taken.
✓ Branch 1 (30→32) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->enroll); |
| 3195 |
3/6✓ Branch 0 (32→33) taken 1 times.
✗ Branch 1 (32→36) not taken.
✓ Branch 2 (34→35) taken 1 times.
✗ Branch 3 (34→36) not taken.
✗ Branch 4 (35→36) not taken.
✓ Branch 5 (35→38) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3196 | 1 | g_clear_error (&error); | |
| 3197 | |||
| 3198 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3199 | "*Device failed to pass an error to generic action " | ||
| 3200 | "error function*"); | ||
| 3201 | |||
| 3202 |
1/2✗ Branch 0 (41→42) not taken.
✓ Branch 1 (41→43) taken 1 times.
|
1 | g_assert_false (fp_device_verify_sync (device, enrolled_print, NULL, |
| 3203 | NULL, NULL, NULL, NULL, &error)); | ||
| 3204 | 1 | g_test_assert_expected_messages (); | |
| 3205 |
1/2✗ Branch 0 (44→45) not taken.
✓ Branch 1 (44→46) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->verify); |
| 3206 |
3/6✓ Branch 0 (46→47) taken 1 times.
✗ Branch 1 (46→50) not taken.
✓ Branch 2 (48→49) taken 1 times.
✗ Branch 3 (48→50) not taken.
✗ Branch 4 (49→50) not taken.
✓ Branch 5 (49→52) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3207 | 1 | g_clear_error (&error); | |
| 3208 | |||
| 3209 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3210 | "*Device failed to pass an error to generic action " | ||
| 3211 | "error function*"); | ||
| 3212 | |||
| 3213 |
1/2✗ Branch 0 (55→56) not taken.
✓ Branch 1 (55→57) taken 1 times.
|
1 | g_assert_false (fp_device_identify_sync (device, prints, NULL, |
| 3214 | NULL, NULL, NULL, NULL, &error)); | ||
| 3215 | 1 | g_test_assert_expected_messages (); | |
| 3216 |
1/2✗ Branch 0 (58→59) not taken.
✓ Branch 1 (58→60) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->identify); |
| 3217 |
3/6✓ Branch 0 (60→61) taken 1 times.
✗ Branch 1 (60→64) not taken.
✓ Branch 2 (62→63) taken 1 times.
✗ Branch 3 (62→64) not taken.
✗ Branch 4 (63→64) not taken.
✓ Branch 5 (63→66) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3218 | 1 | g_clear_error (&error); | |
| 3219 | |||
| 3220 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3221 | "*Device failed to pass an error to generic action " | ||
| 3222 | "error function*"); | ||
| 3223 | |||
| 3224 |
1/2✗ Branch 0 (69→70) not taken.
✓ Branch 1 (69→71) taken 1 times.
|
1 | g_assert_null (fp_device_capture_sync (device, TRUE, NULL, &error)); |
| 3225 | 1 | g_test_assert_expected_messages (); | |
| 3226 |
1/2✗ Branch 0 (72→73) not taken.
✓ Branch 1 (72→74) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->capture); |
| 3227 |
3/6✓ Branch 0 (74→75) taken 1 times.
✗ Branch 1 (74→78) not taken.
✓ Branch 2 (76→77) taken 1 times.
✗ Branch 3 (76→78) not taken.
✗ Branch 4 (77→78) not taken.
✓ Branch 5 (77→80) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3228 | 1 | g_clear_error (&error); | |
| 3229 | |||
| 3230 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3231 | "*Device failed to pass an error to generic action " | ||
| 3232 | "error function*"); | ||
| 3233 | |||
| 3234 |
1/2✗ Branch 0 (83→84) not taken.
✓ Branch 1 (83→85) taken 1 times.
|
1 | g_assert_null (fp_device_list_prints_sync (device, NULL, &error)); |
| 3235 | 1 | g_test_assert_expected_messages (); | |
| 3236 |
1/2✗ Branch 0 (86→87) not taken.
✓ Branch 1 (86→88) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->list); |
| 3237 |
3/6✓ Branch 0 (88→89) taken 1 times.
✗ Branch 1 (88→92) not taken.
✓ Branch 2 (90→91) taken 1 times.
✗ Branch 3 (90→92) not taken.
✗ Branch 4 (91→92) not taken.
✓ Branch 5 (91→94) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3238 | 1 | g_clear_error (&error); | |
| 3239 | |||
| 3240 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3241 | "*Device failed to pass an error to generic action " | ||
| 3242 | "error function*"); | ||
| 3243 | |||
| 3244 |
1/2✗ Branch 0 (97→98) not taken.
✓ Branch 1 (97→99) taken 1 times.
|
1 | g_assert_false (fp_device_delete_print_sync (device, enrolled_print, NULL, &error)); |
| 3245 | 1 | g_test_assert_expected_messages (); | |
| 3246 |
1/2✗ Branch 0 (100→101) not taken.
✓ Branch 1 (100→102) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->delete); |
| 3247 |
3/6✓ Branch 0 (102→103) taken 1 times.
✗ Branch 1 (102→106) not taken.
✓ Branch 2 (104→105) taken 1 times.
✗ Branch 3 (104→106) not taken.
✗ Branch 4 (105→106) not taken.
✓ Branch 5 (105→108) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3248 | 1 | g_clear_error (&error); | |
| 3249 | |||
| 3250 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3251 | "*Device failed to pass an error to generic action " | ||
| 3252 | "error function*"); | ||
| 3253 | |||
| 3254 |
1/2✗ Branch 0 (111→112) not taken.
✓ Branch 1 (111→113) taken 1 times.
|
1 | g_assert_false (fp_device_clear_storage_sync (device, NULL, &error)); |
| 3255 | 1 | g_test_assert_expected_messages (); | |
| 3256 |
1/2✗ Branch 0 (114→115) not taken.
✓ Branch 1 (114→116) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->clear_storage); |
| 3257 |
3/6✓ Branch 0 (116→117) taken 1 times.
✗ Branch 1 (116→120) not taken.
✓ Branch 2 (118→119) taken 1 times.
✗ Branch 3 (118→120) not taken.
✗ Branch 4 (119→120) not taken.
✓ Branch 5 (119→122) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3258 | 1 | g_clear_error (&error); | |
| 3259 | |||
| 3260 | /* Test close last, as we can't operate on a closed device. */ | ||
| 3261 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, | |
| 3262 | "*Device failed to pass an error to generic action " | ||
| 3263 | "error function*"); | ||
| 3264 | |||
| 3265 |
1/2✗ Branch 0 (125→126) not taken.
✓ Branch 1 (125→127) taken 1 times.
|
1 | g_assert_false (fp_device_close_sync (device, NULL, &error)); |
| 3266 | 1 | g_test_assert_expected_messages (); | |
| 3267 |
1/2✗ Branch 0 (128→129) not taken.
✓ Branch 1 (128→130) taken 1 times.
|
1 | g_assert_true (fake_dev->last_called_function == dev_class->close); |
| 3268 |
3/6✓ Branch 0 (130→131) taken 1 times.
✗ Branch 1 (130→134) not taken.
✓ Branch 2 (132→133) taken 1 times.
✗ Branch 3 (132→134) not taken.
✗ Branch 4 (133→134) not taken.
✓ Branch 5 (133→136) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3269 |
1/2✗ Branch 0 (137→138) not taken.
✓ Branch 1 (137→139) taken 1 times.
|
1 | g_clear_error (&error); |
| 3270 | 1 | } | |
| 3271 | |||
| 3272 | static void | ||
| 3273 | 1 | test_driver_add_timeout_func (FpDevice *device, gpointer user_data) | |
| 3274 | { | ||
| 3275 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 3276 | |||
| 3277 | 1 | fake_dev->last_called_function = test_driver_add_timeout_func; | |
| 3278 | 1 | } | |
| 3279 | |||
| 3280 | static void | ||
| 3281 | 1 | test_driver_add_timeout (void) | |
| 3282 | { | ||
| 3283 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3284 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 3285 | 1 | FpDevice *data_check = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3286 | |||
| 3287 | 1 | g_object_add_weak_pointer (G_OBJECT (data_check), (gpointer) & data_check); | |
| 3288 | 1 | fpi_device_add_timeout (device, 50, test_driver_add_timeout_func, | |
| 3289 | data_check, g_object_unref); | ||
| 3290 | |||
| 3291 |
1/2✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→10) taken 1 times.
|
1 | g_assert_nonnull (data_check); |
| 3292 | |||
| 3293 |
2/2✓ Branch 0 (13→11) taken 2 times.
✓ Branch 1 (13→14) taken 1 times.
|
3 | while (FP_IS_DEVICE (data_check)) |
| 3294 | 2 | g_main_context_iteration (NULL, TRUE); | |
| 3295 | |||
| 3296 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 1 times.
|
1 | g_assert_null (data_check); |
| 3297 |
1/2✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→18) taken 1 times.
|
1 | g_assert (fake_dev->last_called_function == test_driver_add_timeout_func); |
| 3298 | 1 | } | |
| 3299 | |||
| 3300 | static gboolean | ||
| 3301 | 1 | test_driver_add_timeout_cancelled_timeout (gpointer data) | |
| 3302 | { | ||
| 3303 | 1 | GSource *source = data; | |
| 3304 | |||
| 3305 | 1 | g_source_destroy (source); | |
| 3306 | |||
| 3307 | 1 | return G_SOURCE_REMOVE; | |
| 3308 | } | ||
| 3309 | |||
| 3310 | static void | ||
| 3311 | 1 | test_driver_add_timeout_cancelled (void) | |
| 3312 | { | ||
| 3313 | 1 | g_autoptr(FpDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3314 | 1 | FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); | |
| 3315 | 1 | FpDevice *data_check = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); | |
| 3316 | 1 | GSource *source; | |
| 3317 | |||
| 3318 | 1 | g_object_add_weak_pointer (G_OBJECT (data_check), (gpointer) & data_check); | |
| 3319 | 1 | source = fpi_device_add_timeout (device, 2000, test_driver_add_timeout_func, | |
| 3320 | data_check, g_object_unref); | ||
| 3321 | |||
| 3322 | 1 | g_timeout_add (20, test_driver_add_timeout_cancelled_timeout, source); | |
| 3323 |
1/2✗ Branch 0 (9→10) not taken.
✓ Branch 1 (9→11) taken 1 times.
|
1 | g_assert_nonnull (data_check); |
| 3324 | |||
| 3325 |
2/2✓ Branch 0 (14→12) taken 2 times.
✓ Branch 1 (14→15) taken 1 times.
|
3 | while (FP_IS_DEVICE (data_check)) |
| 3326 | 2 | g_main_context_iteration (NULL, TRUE); | |
| 3327 | |||
| 3328 |
1/2✗ Branch 0 (15→16) not taken.
✓ Branch 1 (15→17) taken 1 times.
|
1 | g_assert_null (data_check); |
| 3329 |
1/2✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→19) taken 1 times.
|
1 | g_assert_null (fake_dev->last_called_function); |
| 3330 | 1 | } | |
| 3331 | |||
| 3332 | static void | ||
| 3333 | 1 | test_driver_error_types (void) | |
| 3334 | { | ||
| 3335 | 2 | g_autoptr(GError) error = NULL; | |
| 3336 |
1/2✓ Branch 0 (44→45) taken 1 times.
✗ Branch 1 (44→46) not taken.
|
2 | g_autoptr(GEnumClass) errors_enum = g_type_class_ref (FP_TYPE_DEVICE_ERROR); |
| 3337 | 1 | int i; | |
| 3338 | |||
| 3339 |
2/2✓ Branch 0 (32→5) taken 10 times.
✓ Branch 1 (32→33) taken 1 times.
|
12 | for (i = 0; g_enum_get_value (errors_enum, i); ++i) |
| 3340 | { | ||
| 3341 | 10 | g_autoptr(GError) e = NULL; | |
| 3342 |
1/2✓ Branch 0 (28→29) taken 10 times.
✗ Branch 1 (28→30) not taken.
|
10 | g_autoptr(GError) msg_e = NULL; |
| 3343 | 10 | g_autofree char *expected_msg = NULL; | |
| 3344 | 20 | g_autofree char *enum_string = g_enum_to_string (FP_TYPE_DEVICE_ERROR, i); | |
| 3345 | |||
| 3346 | 10 | e = fpi_device_error_new (i); | |
| 3347 |
3/6✓ Branch 0 (8→9) taken 10 times.
✗ Branch 1 (8→12) not taken.
✓ Branch 2 (10→11) taken 10 times.
✗ Branch 3 (10→12) not taken.
✗ Branch 4 (11→12) not taken.
✓ Branch 5 (11→14) taken 10 times.
|
10 | g_assert_error (e, FP_DEVICE_ERROR, i); |
| 3348 | |||
| 3349 | 10 | expected_msg = g_strdup_printf ("Error message %s", enum_string); | |
| 3350 | 10 | msg_e = fpi_device_error_new_msg (i, "Error message %s", enum_string); | |
| 3351 |
3/6✓ Branch 0 (16→17) taken 10 times.
✗ Branch 1 (16→20) not taken.
✓ Branch 2 (18→19) taken 10 times.
✗ Branch 3 (18→20) not taken.
✗ Branch 4 (19→20) not taken.
✓ Branch 5 (19→22) taken 10 times.
|
10 | g_assert_error (msg_e, FP_DEVICE_ERROR, i); |
| 3352 |
1/2✗ Branch 0 (23→24) not taken.
✓ Branch 1 (23→25) taken 10 times.
|
10 | g_assert_cmpstr (msg_e->message, ==, expected_msg); |
| 3353 | } | ||
| 3354 | |||
| 3355 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "*Unsupported error*"); | |
| 3356 | 1 | error = fpi_device_error_new (i + 1); | |
| 3357 |
3/6✓ Branch 0 (35→36) taken 1 times.
✗ Branch 1 (35→39) not taken.
✓ Branch 2 (37→38) taken 1 times.
✗ Branch 3 (37→39) not taken.
✗ Branch 4 (38→39) not taken.
✓ Branch 5 (38→41) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_GENERAL); |
| 3358 |
1/2✓ Branch 0 (42→43) taken 1 times.
✗ Branch 1 (42→44) not taken.
|
1 | g_test_assert_expected_messages (); |
| 3359 | 1 | } | |
| 3360 | |||
| 3361 | static void | ||
| 3362 | 1 | test_driver_retry_error_types (void) | |
| 3363 | { | ||
| 3364 | 2 | g_autoptr(GError) error = NULL; | |
| 3365 |
1/2✓ Branch 0 (44→45) taken 1 times.
✗ Branch 1 (44→46) not taken.
|
2 | g_autoptr(GEnumClass) errors_enum = g_type_class_ref (FP_TYPE_DEVICE_RETRY); |
| 3366 | 1 | int i; | |
| 3367 | |||
| 3368 |
2/2✓ Branch 0 (32→5) taken 5 times.
✓ Branch 1 (32→33) taken 1 times.
|
7 | for (i = 0; g_enum_get_value (errors_enum, i); ++i) |
| 3369 | { | ||
| 3370 | 5 | g_autoptr(GError) e = NULL; | |
| 3371 |
1/2✓ Branch 0 (28→29) taken 5 times.
✗ Branch 1 (28→30) not taken.
|
5 | g_autoptr(GError) msg_e = NULL; |
| 3372 | 5 | g_autofree char *expected_msg = NULL; | |
| 3373 | 10 | g_autofree char *enum_string = g_enum_to_string (FP_TYPE_DEVICE_RETRY, i); | |
| 3374 | |||
| 3375 | 5 | e = fpi_device_retry_new (i); | |
| 3376 |
3/6✓ Branch 0 (8→9) taken 5 times.
✗ Branch 1 (8→12) not taken.
✓ Branch 2 (10→11) taken 5 times.
✗ Branch 3 (10→12) not taken.
✗ Branch 4 (11→12) not taken.
✓ Branch 5 (11→14) taken 5 times.
|
5 | g_assert_error (e, FP_DEVICE_RETRY, i); |
| 3377 | |||
| 3378 | 5 | expected_msg = g_strdup_printf ("Retry error message %s", enum_string); | |
| 3379 | 5 | msg_e = fpi_device_retry_new_msg (i, "Retry error message %s", enum_string); | |
| 3380 |
3/6✓ Branch 0 (16→17) taken 5 times.
✗ Branch 1 (16→20) not taken.
✓ Branch 2 (18→19) taken 5 times.
✗ Branch 3 (18→20) not taken.
✗ Branch 4 (19→20) not taken.
✓ Branch 5 (19→22) taken 5 times.
|
5 | g_assert_error (msg_e, FP_DEVICE_RETRY, i); |
| 3381 |
1/2✗ Branch 0 (23→24) not taken.
✓ Branch 1 (23→25) taken 5 times.
|
5 | g_assert_cmpstr (msg_e->message, ==, expected_msg); |
| 3382 | } | ||
| 3383 | |||
| 3384 | 1 | g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "*Unsupported error*"); | |
| 3385 | 1 | error = fpi_device_retry_new (i + 1); | |
| 3386 |
3/6✓ Branch 0 (35→36) taken 1 times.
✗ Branch 1 (35→39) not taken.
✓ Branch 2 (37→38) taken 1 times.
✗ Branch 3 (37→39) not taken.
✗ Branch 4 (38→39) not taken.
✓ Branch 5 (38→41) taken 1 times.
|
1 | g_assert_error (error, FP_DEVICE_RETRY, FP_DEVICE_RETRY_GENERAL); |
| 3387 |
1/2✓ Branch 0 (42→43) taken 1 times.
✗ Branch 1 (42→44) not taken.
|
1 | g_test_assert_expected_messages (); |
| 3388 | 1 | } | |
| 3389 | |||
| 3390 | int | ||
| 3391 | 1 | main (int argc, char *argv[]) | |
| 3392 | { | ||
| 3393 | 1 | g_test_init (&argc, &argv, NULL); | |
| 3394 | |||
| 3395 | 1 | g_test_add_func ("/driver/get_driver", test_driver_get_driver); | |
| 3396 | 1 | g_test_add_func ("/driver/get_device_id", test_driver_get_device_id); | |
| 3397 | 1 | g_test_add_func ("/driver/get_name", test_driver_get_name); | |
| 3398 | 1 | g_test_add_func ("/driver/is_open", test_driver_is_open); | |
| 3399 | 1 | g_test_add_func ("/driver/get_scan_type/press", test_driver_get_scan_type_press); | |
| 3400 | 1 | g_test_add_func ("/driver/get_scan_type/swipe", test_driver_get_scan_type_swipe); | |
| 3401 | 1 | g_test_add_func ("/driver/set_scan_type/press", test_driver_set_scan_type_press); | |
| 3402 | 1 | g_test_add_func ("/driver/set_scan_type/swipe", test_driver_set_scan_type_swipe); | |
| 3403 | 1 | g_test_add_func ("/driver/finger_status/inactive", test_driver_finger_status_inactive); | |
| 3404 | 1 | g_test_add_func ("/driver/finger_status/waiting", test_driver_finger_status_needed); | |
| 3405 | 1 | g_test_add_func ("/driver/finger_status/present", test_driver_finger_status_present); | |
| 3406 | 1 | g_test_add_func ("/driver/finger_status/changes", test_driver_finger_status_changes); | |
| 3407 | 1 | g_test_add_func ("/driver/get_nr_enroll_stages", test_driver_get_nr_enroll_stages); | |
| 3408 | 1 | g_test_add_func ("/driver/set_nr_enroll_stages", test_driver_set_nr_enroll_stages); | |
| 3409 | 1 | g_test_add_func ("/driver/supports_identify", test_driver_supports_identify); | |
| 3410 | 1 | g_test_add_func ("/driver/supports_capture", test_driver_supports_capture); | |
| 3411 | 1 | g_test_add_func ("/driver/has_storage", test_driver_has_storage); | |
| 3412 | 1 | g_test_add_func ("/driver/do_not_support_identify", test_driver_do_not_support_identify); | |
| 3413 | 1 | g_test_add_func ("/driver/do_not_support_capture", test_driver_do_not_support_capture); | |
| 3414 | 1 | g_test_add_func ("/driver/has_not_storage", test_driver_has_not_storage); | |
| 3415 | 1 | g_test_add_func ("/driver/get_usb_device", test_driver_get_usb_device); | |
| 3416 | 1 | g_test_add_func ("/driver/get_virtual_env", test_driver_get_virtual_env); | |
| 3417 | 1 | g_test_add_func ("/driver/get_driver_data", test_driver_get_driver_data); | |
| 3418 | 1 | g_test_add_func ("/driver/features/probe_updates", test_driver_features_probe_updates); | |
| 3419 | 1 | g_test_add_func ("/driver/initial_features", test_driver_initial_features); | |
| 3420 | 1 | g_test_add_func ("/driver/initial_features/none", test_driver_initial_features_none); | |
| 3421 | 1 | g_test_add_func ("/driver/initial_features/no_capture", test_driver_initial_features_no_capture); | |
| 3422 | 1 | g_test_add_func ("/driver/initial_features/no_verify", test_driver_initial_features_no_verify); | |
| 3423 | 1 | g_test_add_func ("/driver/initial_features/no_identify", test_driver_initial_features_no_identify); | |
| 3424 | 1 | g_test_add_func ("/driver/initial_features/no_storage", test_driver_initial_features_no_storage); | |
| 3425 | 1 | g_test_add_func ("/driver/initial_features/no_list", test_driver_initial_features_no_list); | |
| 3426 | 1 | g_test_add_func ("/driver/initial_features/no_delete", test_driver_initial_features_no_delete); | |
| 3427 | 1 | g_test_add_func ("/driver/initial_features/no_clear", test_driver_initial_features_no_clear); | |
| 3428 | |||
| 3429 | |||
| 3430 | 1 | g_test_add_func ("/driver/probe", test_driver_probe); | |
| 3431 | 1 | g_test_add_func ("/driver/probe/error", test_driver_probe_error); | |
| 3432 | 1 | g_test_add_func ("/driver/probe/action_error", test_driver_probe_action_error); | |
| 3433 | 1 | g_test_add_func ("/driver/open", test_driver_open); | |
| 3434 | 1 | g_test_add_func ("/driver/open/error", test_driver_open_error); | |
| 3435 | 1 | g_test_add_func ("/driver/close", test_driver_close); | |
| 3436 | 1 | g_test_add_func ("/driver/close/error", test_driver_close_error); | |
| 3437 | 1 | g_test_add_func ("/driver/enroll", test_driver_enroll); | |
| 3438 | 1 | g_test_add_func ("/driver/enroll/error", test_driver_enroll_error); | |
| 3439 | 1 | g_test_add_func ("/driver/enroll/error/no_print", test_driver_enroll_error_no_print); | |
| 3440 | 1 | g_test_add_func ("/driver/enroll/progress", test_driver_enroll_progress); | |
| 3441 | 1 | g_test_add_func ("/driver/enroll/update_nbis", test_driver_enroll_update_nbis); | |
| 3442 | 1 | g_test_add_func ("/driver/enroll/update_nbis_wrong_device", | |
| 3443 | test_driver_enroll_update_nbis_wrong_device); | ||
| 3444 | 1 | g_test_add_func ("/driver/enroll/update_nbis_wrong_driver", | |
| 3445 | test_driver_enroll_update_nbis_wrong_driver); | ||
| 3446 | 1 | g_test_add_func ("/driver/enroll/update_nbis_missing_feature", | |
| 3447 | test_driver_enroll_update_nbis_missing_feature); | ||
| 3448 | 1 | g_test_add_func ("/driver/verify", test_driver_verify); | |
| 3449 | 1 | g_test_add_func ("/driver/verify/fail", test_driver_verify_fail); | |
| 3450 | 1 | g_test_add_func ("/driver/verify/retry", test_driver_verify_retry); | |
| 3451 | 1 | g_test_add_func ("/driver/verify/error", test_driver_verify_error); | |
| 3452 | 1 | g_test_add_func ("/driver/verify/not_supported", test_driver_verify_not_supported); | |
| 3453 | 1 | g_test_add_func ("/driver/verify/report_no_cb", test_driver_verify_report_no_callback); | |
| 3454 | 1 | g_test_add_func ("/driver/verify/not_reported", test_driver_verify_not_reported); | |
| 3455 | 1 | g_test_add_func ("/driver/verify/complete_retry", test_driver_verify_complete_retry); | |
| 3456 | 1 | g_test_add_func ("/driver/identify", test_driver_identify); | |
| 3457 | 1 | g_test_add_func ("/driver/identify/fail", test_driver_identify_fail); | |
| 3458 | 1 | g_test_add_func ("/driver/identify/retry", test_driver_identify_retry); | |
| 3459 | 1 | g_test_add_func ("/driver/identify/error", test_driver_identify_error); | |
| 3460 | 1 | g_test_add_func ("/driver/identify/not_reported", test_driver_identify_not_reported); | |
| 3461 | 1 | g_test_add_func ("/driver/identify/complete_retry", test_driver_identify_complete_retry); | |
| 3462 | 1 | g_test_add_func ("/driver/identify/report_no_cb", test_driver_identify_report_no_callback); | |
| 3463 | |||
| 3464 | 1 | g_test_add_func ("/driver/identify/suspend_continues", test_driver_identify_suspend_continues); | |
| 3465 | 1 | g_test_add_func ("/driver/identify/suspend_succeeds", test_driver_identify_suspend_succeeds); | |
| 3466 | 1 | g_test_add_func ("/driver/identify/suspend_busy_error", test_driver_identify_suspend_busy_error); | |
| 3467 | 1 | g_test_add_func ("/driver/identify/suspend_while_idle", test_driver_identify_suspend_while_idle); | |
| 3468 | |||
| 3469 | 1 | g_test_add_func ("/driver/identify/warmup_cooldown", test_driver_identify_warmup_cooldown); | |
| 3470 | |||
| 3471 | 1 | g_test_add_func ("/driver/capture", test_driver_capture); | |
| 3472 | 1 | g_test_add_func ("/driver/capture/not_supported", test_driver_capture_not_supported); | |
| 3473 | 1 | g_test_add_func ("/driver/capture/error", test_driver_capture_error); | |
| 3474 | 1 | g_test_add_func ("/driver/list", test_driver_list); | |
| 3475 | 1 | g_test_add_func ("/driver/list/error", test_driver_list_error); | |
| 3476 | 1 | g_test_add_func ("/driver/list/no_storage", test_driver_list_no_storage); | |
| 3477 | 1 | g_test_add_func ("/driver/delete", test_driver_delete); | |
| 3478 | 1 | g_test_add_func ("/driver/delete/error", test_driver_delete_error); | |
| 3479 | 1 | g_test_add_func ("/driver/clear_storage", test_driver_clear_storage); | |
| 3480 | 1 | g_test_add_func ("/driver/clear_storage/error", test_driver_clear_storage_error); | |
| 3481 | 1 | g_test_add_func ("/driver/cancel", test_driver_cancel); | |
| 3482 | 1 | g_test_add_func ("/driver/cancel/fail", test_driver_cancel_fail); | |
| 3483 | |||
| 3484 | 1 | g_test_add_func ("/driver/critical", test_driver_critical); | |
| 3485 | |||
| 3486 | 1 | g_test_add_func ("/driver/get_current_action", test_driver_current_action); | |
| 3487 | 1 | g_test_add_func ("/driver/get_current_action/open", test_driver_current_action_open); | |
| 3488 | 1 | g_test_add_func ("/driver/get_cancellable/error", test_driver_action_get_cancellable_error); | |
| 3489 | 1 | g_test_add_func ("/driver/get_cancellable/open", test_driver_action_get_cancellable_open); | |
| 3490 | 1 | g_test_add_func ("/driver/get_cancellable/open/internal", test_driver_action_get_cancellable_open_internal); | |
| 3491 | 1 | g_test_add_func ("/driver/action_is_cancelled/open", test_driver_action_is_cancelled_open); | |
| 3492 | 1 | g_test_add_func ("/driver/action_is_cancelled/open/internal", test_driver_action_internally_cancelled_open); | |
| 3493 | 1 | g_test_add_func ("/driver/action_is_cancelled/error", test_driver_action_is_cancelled_error); | |
| 3494 | 1 | g_test_add_func ("/driver/complete_action/all/error", test_driver_complete_actions_errors); | |
| 3495 | 1 | g_test_add_func ("/driver/action_error/error", test_driver_action_error_error); | |
| 3496 | 1 | g_test_add_func ("/driver/action_error/all", test_driver_action_error_all); | |
| 3497 | 1 | g_test_add_func ("/driver/action_error/fail", test_driver_action_error_fallback_all); | |
| 3498 | |||
| 3499 | 1 | g_test_add_func ("/driver/timeout", test_driver_add_timeout); | |
| 3500 | 1 | g_test_add_func ("/driver/timeout/cancelled", test_driver_add_timeout_cancelled); | |
| 3501 | |||
| 3502 | 1 | g_test_add_func ("/driver/error_types", test_driver_error_types); | |
| 3503 | 1 | g_test_add_func ("/driver/retry_error_types", test_driver_retry_error_types); | |
| 3504 | |||
| 3505 | 1 | return g_test_run (); | |
| 3506 | } | ||
| 3507 |