mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-06-11 18:38:07 +00:00
tests: Move tod context creation into test-utils-tod library
This commit is contained in:
+9
-1
@@ -214,6 +214,14 @@ if get_option('tod')
|
|||||||
install: false
|
install: false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
test_utils_tod = static_library('fprint-test-utils-tod',
|
||||||
|
sources: [
|
||||||
|
'test-utils-tod.c',
|
||||||
|
],
|
||||||
|
dependencies: libfprint_private_dep,
|
||||||
|
link_with: test_utils,
|
||||||
|
install: false)
|
||||||
|
|
||||||
tod_unit_tests = [
|
tod_unit_tests = [
|
||||||
'fp-context-tod',
|
'fp-context-tod',
|
||||||
'fp-device-tod',
|
'fp-device-tod',
|
||||||
@@ -225,7 +233,7 @@ if get_option('tod')
|
|||||||
sources: basename + '.c',
|
sources: basename + '.c',
|
||||||
dependencies: libfprint_private_dep,
|
dependencies: libfprint_private_dep,
|
||||||
c_args: common_cflags,
|
c_args: common_cflags,
|
||||||
link_with: test_utils,
|
link_with: test_utils_tod,
|
||||||
)
|
)
|
||||||
test(test_name,
|
test(test_name,
|
||||||
find_program('test-runner.sh'),
|
find_program('test-runner.sh'),
|
||||||
|
|||||||
@@ -19,37 +19,7 @@
|
|||||||
|
|
||||||
#include <libfprint/fprint.h>
|
#include <libfprint/fprint.h>
|
||||||
|
|
||||||
#include "test-utils.h"
|
#include "test-utils-tod.h"
|
||||||
|
|
||||||
static FptContext *
|
|
||||||
fpt_context_new_with_fake_dev (void)
|
|
||||||
{
|
|
||||||
FptContext *tctx;
|
|
||||||
GPtrArray *devices;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
tctx = fpt_context_new ();
|
|
||||||
devices = fp_context_get_devices (tctx->fp_context);
|
|
||||||
|
|
||||||
g_assert_nonnull (devices);
|
|
||||||
g_assert_cmpuint (devices->len, ==, 1);
|
|
||||||
|
|
||||||
for (i = 0; i < devices->len; ++i)
|
|
||||||
{
|
|
||||||
FpDevice *device = devices->pdata[i];
|
|
||||||
|
|
||||||
if (g_strcmp0 (fp_device_get_driver (device), "fake_test_dev") == 0)
|
|
||||||
{
|
|
||||||
tctx->device = device;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_assert_true (FP_IS_DEVICE (tctx->device));
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (tctx->device), (gpointer) & tctx->device);
|
|
||||||
|
|
||||||
return tctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_device_opened (FpDevice *dev, GAsyncResult *res, FptContext *tctx)
|
on_device_opened (FpDevice *dev, GAsyncResult *res, FptContext *tctx)
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Unit tests for libfprint
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libfprint/fprint.h>
|
||||||
|
|
||||||
|
#include "test-utils-tod.h"
|
||||||
|
|
||||||
|
FptContext *
|
||||||
|
fpt_context_new_with_fake_dev (void)
|
||||||
|
{
|
||||||
|
FptContext *tctx;
|
||||||
|
GPtrArray *devices;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
tctx = fpt_context_new ();
|
||||||
|
devices = fp_context_get_devices (tctx->fp_context);
|
||||||
|
|
||||||
|
g_assert_nonnull (devices);
|
||||||
|
g_assert_cmpuint (devices->len, ==, 1);
|
||||||
|
|
||||||
|
for (i = 0; i < devices->len; ++i)
|
||||||
|
{
|
||||||
|
FpDevice *device = devices->pdata[i];
|
||||||
|
|
||||||
|
if (g_strcmp0 (fp_device_get_driver (device), "fake_test_dev") == 0)
|
||||||
|
{
|
||||||
|
tctx->device = device;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert_true (FP_IS_DEVICE (tctx->device));
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (tctx->device), (gpointer) & tctx->device);
|
||||||
|
|
||||||
|
return tctx;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Unit tests for libfprint
|
||||||
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include "test-utils.h"
|
||||||
|
|
||||||
|
FptContext * fpt_context_new_with_fake_dev (void);
|
||||||
Reference in New Issue
Block a user