GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 99.5% 2689 / 0 / 2703
Functions: 99.4% 156 / 0 / 157
Branches: 51.9% 1311 / 0 / 2528

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