mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-06-11 02:28:05 +00:00
Merge remote-tracking branch 'origin/master' into tod
This commit is contained in:
+30
-1
@@ -21,4 +21,33 @@ To create a new umockdev test, you should:
|
||||
Please note, there is no need to use a real finger print in this case. If
|
||||
you would like to avoid submitting your own fingerprint then please just
|
||||
use e.g. the side of your finger, arm, or anything else that will produce
|
||||
an image with the device.
|
||||
an image with the device.
|
||||
|
||||
|
||||
Note that umockdev-record groups URBs aggressively. In most cases, manual
|
||||
intervention is unfortunately required. In most cases, drivers do a chain
|
||||
of commands like e.g. A then B each with a different reply. Umockdev will
|
||||
create a file like:
|
||||
|
||||
A
|
||||
reply 1
|
||||
reply 2
|
||||
B
|
||||
reply 1
|
||||
reply 2
|
||||
|
||||
which then needs to be re-ordered to be:
|
||||
|
||||
A
|
||||
reply 1
|
||||
B
|
||||
reply 1
|
||||
A
|
||||
reply 2
|
||||
B
|
||||
reply 2
|
||||
|
||||
Other changes may be needed to get everything working. For example the elan
|
||||
driver relies on a timeout that is not reported correctly. In this case the
|
||||
driver works around it by interpreting the protocol error differently in
|
||||
the virtual environment.
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
@@ -0,0 +1,284 @@
|
||||
P: /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.4
|
||||
N: bus/usb/001/094=1201000200000008F304260C40010102000109023E0001010080320904000005FF0000000921100100012215000705810240000107050102400001070582024000010705830240000107050302400001
|
||||
E: DEVNAME=/dev/bus/usb/001/094
|
||||
E: DEVTYPE=usb_device
|
||||
E: DRIVER=usb
|
||||
E: PRODUCT=4f3/c26/140
|
||||
E: TYPE=0/0/0
|
||||
E: BUSNUM=001
|
||||
E: DEVNUM=094
|
||||
E: MAJOR=189
|
||||
E: MINOR=93
|
||||
E: SUBSYSTEM=usb
|
||||
E: ID_VENDOR=ELAN
|
||||
E: ID_VENDOR_ENC=ELAN
|
||||
E: ID_VENDOR_ID=04f3
|
||||
E: ID_MODEL=ELAN:Fingerprint
|
||||
E: ID_MODEL_ENC=ELAN:Fingerprint
|
||||
E: ID_MODEL_ID=0c26
|
||||
E: ID_REVISION=0140
|
||||
E: ID_SERIAL=ELAN_ELAN:Fingerprint
|
||||
E: ID_BUS=usb
|
||||
E: ID_USB_INTERFACES=:ff0000:
|
||||
E: ID_VENDOR_FROM_DATABASE=Elan Microelectronics Corp.
|
||||
E: ID_PATH=pci-0000:00:14.0-usb-0:4.4
|
||||
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_4_4
|
||||
E: LIBFPRINT_DRIVER=ElanTech Fingerprint Sensor
|
||||
A: authorized=1
|
||||
A: avoid_reset_quirk=0
|
||||
A: bConfigurationValue=1
|
||||
A: bDeviceClass=00
|
||||
A: bDeviceProtocol=00
|
||||
A: bDeviceSubClass=00
|
||||
A: bMaxPacketSize0=8
|
||||
A: bMaxPower=100mA
|
||||
A: bNumConfigurations=1
|
||||
A: bNumInterfaces= 1
|
||||
A: bcdDevice=0140
|
||||
A: bmAttributes=80
|
||||
A: busnum=1
|
||||
A: configuration=
|
||||
H: descriptors=1201000200000008F304260C40010102000109023E0001010080320904000005FF0000000921100100012215000705810240000107050102400001070582024000010705830240000107050302400001
|
||||
A: dev=189:93
|
||||
A: devnum=94
|
||||
A: devpath=4.4
|
||||
L: driver=../../../../../../bus/usb/drivers/usb
|
||||
A: idProduct=0c26
|
||||
A: idVendor=04f3
|
||||
A: ltm_capable=no
|
||||
A: manufacturer=ELAN
|
||||
A: maxchild=0
|
||||
L: port=../1-4:1.0/1-4-port4
|
||||
A: power/active_duration=4747
|
||||
A: power/autosuspend=2
|
||||
A: power/autosuspend_delay_ms=2000
|
||||
A: power/connected_duration=54012
|
||||
A: power/control=auto
|
||||
A: power/level=auto
|
||||
A: power/persist=1
|
||||
A: power/runtime_active_time=4721
|
||||
A: power/runtime_status=active
|
||||
A: power/runtime_suspended_time=49114
|
||||
A: product=ELAN:Fingerprint
|
||||
A: quirks=0x0
|
||||
A: removable=removable
|
||||
A: rx_lanes=1
|
||||
A: speed=12
|
||||
A: tx_lanes=1
|
||||
A: urbnum=13
|
||||
A: version= 2.00
|
||||
|
||||
P: /devices/pci0000:00/0000:00:14.0/usb1/1-4
|
||||
N: bus/usb/001/083=1201100209000140EF17181084520102000109021900010100E0000904000001090000000705810301000C
|
||||
E: DEVNAME=/dev/bus/usb/001/083
|
||||
E: DEVTYPE=usb_device
|
||||
E: DRIVER=usb
|
||||
E: PRODUCT=17ef/1018/5284
|
||||
E: TYPE=9/0/1
|
||||
E: BUSNUM=001
|
||||
E: DEVNUM=083
|
||||
E: MAJOR=189
|
||||
E: MINOR=82
|
||||
E: SUBSYSTEM=usb
|
||||
E: ID_VENDOR=VIA_Labs__Inc.
|
||||
E: ID_VENDOR_ENC=VIA\x20Labs\x2c\x20Inc.\x20\x20\x20\x20\x20\x20\x20\x20\x20
|
||||
E: ID_VENDOR_ID=17ef
|
||||
E: ID_MODEL=USB2.0_Hub
|
||||
E: ID_MODEL_ENC=USB2.0\x20Hub\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
|
||||
E: ID_MODEL_ID=1018
|
||||
E: ID_REVISION=5284
|
||||
E: ID_SERIAL=VIA_Labs__Inc._USB2.0_Hub
|
||||
E: ID_BUS=usb
|
||||
E: ID_USB_INTERFACES=:090000:
|
||||
E: ID_VENDOR_FROM_DATABASE=Lenovo
|
||||
E: ID_PATH=pci-0000:00:14.0-usb-0:4
|
||||
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_4
|
||||
E: ID_FOR_SEAT=usb-pci-0000_00_14_0-usb-0_4
|
||||
E: TAGS=:seat:
|
||||
A: authorized=1
|
||||
A: avoid_reset_quirk=0
|
||||
A: bConfigurationValue=1
|
||||
A: bDeviceClass=09
|
||||
A: bDeviceProtocol=01
|
||||
A: bDeviceSubClass=00
|
||||
A: bMaxPacketSize0=64
|
||||
A: bMaxPower=0mA
|
||||
A: bNumConfigurations=1
|
||||
A: bNumInterfaces= 1
|
||||
A: bcdDevice=5284
|
||||
A: bmAttributes=e0
|
||||
A: busnum=1
|
||||
A: configuration=
|
||||
H: descriptors=1201100209000140EF17181084520102000109021900010100E0000904000001090000000705810301000C
|
||||
A: dev=189:82
|
||||
A: devnum=83
|
||||
A: devpath=4
|
||||
L: driver=../../../../../bus/usb/drivers/usb
|
||||
A: idProduct=1018
|
||||
A: idVendor=17ef
|
||||
A: ltm_capable=no
|
||||
A: manufacturer=VIA Labs, Inc.
|
||||
A: maxchild=4
|
||||
L: port=../1-0:1.0/usb1-port4
|
||||
A: power/active_duration=11223581
|
||||
A: power/autosuspend=0
|
||||
A: power/autosuspend_delay_ms=0
|
||||
A: power/connected_duration=11223581
|
||||
A: power/control=auto
|
||||
A: power/level=auto
|
||||
A: power/runtime_active_time=11223333
|
||||
A: power/runtime_status=active
|
||||
A: power/runtime_suspended_time=0
|
||||
A: power/wakeup=disabled
|
||||
A: power/wakeup_abort_count=
|
||||
A: power/wakeup_active=
|
||||
A: power/wakeup_active_count=
|
||||
A: power/wakeup_count=
|
||||
A: power/wakeup_expire_count=
|
||||
A: power/wakeup_last_time_ms=
|
||||
A: power/wakeup_max_time_ms=
|
||||
A: power/wakeup_total_time_ms=
|
||||
A: product=USB2.0 Hub
|
||||
A: quirks=0x0
|
||||
A: removable=removable
|
||||
A: rx_lanes=1
|
||||
A: speed=480
|
||||
A: tx_lanes=1
|
||||
A: urbnum=106
|
||||
A: version= 2.10
|
||||
|
||||
P: /devices/pci0000:00/0000:00:14.0/usb1
|
||||
N: bus/usb/001/001=12010002090001406B1D020003050302010109021900010100E0000904000001090000000705810304000C
|
||||
E: DEVNAME=/dev/bus/usb/001/001
|
||||
E: DEVTYPE=usb_device
|
||||
E: DRIVER=usb
|
||||
E: PRODUCT=1d6b/2/503
|
||||
E: TYPE=9/0/1
|
||||
E: BUSNUM=001
|
||||
E: DEVNUM=001
|
||||
E: MAJOR=189
|
||||
E: MINOR=0
|
||||
E: SUBSYSTEM=usb
|
||||
E: ID_VENDOR=Linux_5.3.8-300.fc31.x86_64_xhci-hcd
|
||||
E: ID_VENDOR_ENC=Linux\x205.3.8-300.fc31.x86_64\x20xhci-hcd
|
||||
E: ID_VENDOR_ID=1d6b
|
||||
E: ID_MODEL=xHCI_Host_Controller
|
||||
E: ID_MODEL_ENC=xHCI\x20Host\x20Controller
|
||||
E: ID_MODEL_ID=0002
|
||||
E: ID_REVISION=0503
|
||||
E: ID_SERIAL=Linux_5.3.8-300.fc31.x86_64_xhci-hcd_xHCI_Host_Controller_0000:00:14.0
|
||||
E: ID_SERIAL_SHORT=0000:00:14.0
|
||||
E: ID_BUS=usb
|
||||
E: ID_USB_INTERFACES=:090000:
|
||||
E: ID_VENDOR_FROM_DATABASE=Linux Foundation
|
||||
E: ID_MODEL_FROM_DATABASE=2.0 root hub
|
||||
E: ID_PATH=pci-0000:00:14.0
|
||||
E: ID_PATH_TAG=pci-0000_00_14_0
|
||||
E: ID_FOR_SEAT=usb-pci-0000_00_14_0
|
||||
E: TAGS=:seat:
|
||||
A: authorized=1
|
||||
A: authorized_default=1
|
||||
A: avoid_reset_quirk=0
|
||||
A: bConfigurationValue=1
|
||||
A: bDeviceClass=09
|
||||
A: bDeviceProtocol=01
|
||||
A: bDeviceSubClass=00
|
||||
A: bMaxPacketSize0=64
|
||||
A: bMaxPower=0mA
|
||||
A: bNumConfigurations=1
|
||||
A: bNumInterfaces= 1
|
||||
A: bcdDevice=0503
|
||||
A: bmAttributes=e0
|
||||
A: busnum=1
|
||||
A: configuration=
|
||||
H: descriptors=12010002090001406B1D020003050302010109021900010100E0000904000001090000000705810304000C
|
||||
A: dev=189:0
|
||||
A: devnum=1
|
||||
A: devpath=0
|
||||
L: driver=../../../../bus/usb/drivers/usb
|
||||
A: idProduct=0002
|
||||
A: idVendor=1d6b
|
||||
A: interface_authorized_default=1
|
||||
A: ltm_capable=no
|
||||
A: manufacturer=Linux 5.3.8-300.fc31.x86_64 xhci-hcd
|
||||
A: maxchild=12
|
||||
A: power/active_duration=2372569822
|
||||
A: power/autosuspend=0
|
||||
A: power/autosuspend_delay_ms=0
|
||||
A: power/connected_duration=2405642105
|
||||
A: power/control=auto
|
||||
A: power/level=auto
|
||||
A: power/runtime_active_time=2372599414
|
||||
A: power/runtime_status=active
|
||||
A: power/runtime_suspended_time=33016992
|
||||
A: power/wakeup=disabled
|
||||
A: power/wakeup_abort_count=
|
||||
A: power/wakeup_active=
|
||||
A: power/wakeup_active_count=
|
||||
A: power/wakeup_count=
|
||||
A: power/wakeup_expire_count=
|
||||
A: power/wakeup_last_time_ms=
|
||||
A: power/wakeup_max_time_ms=
|
||||
A: power/wakeup_total_time_ms=
|
||||
A: product=xHCI Host Controller
|
||||
A: quirks=0x0
|
||||
A: removable=unknown
|
||||
A: rx_lanes=1
|
||||
A: serial=0000:00:14.0
|
||||
A: speed=480
|
||||
A: tx_lanes=1
|
||||
A: urbnum=19225
|
||||
A: version= 2.00
|
||||
|
||||
P: /devices/pci0000:00/0000:00:14.0
|
||||
E: DRIVER=xhci_hcd
|
||||
E: PCI_CLASS=C0330
|
||||
E: PCI_ID=8086:9D2F
|
||||
E: PCI_SUBSYS_ID=17AA:2238
|
||||
E: PCI_SLOT_NAME=0000:00:14.0
|
||||
E: MODALIAS=pci:v00008086d00009D2Fsv000017AAsd00002238bc0Csc03i30
|
||||
E: SUBSYSTEM=pci
|
||||
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
|
||||
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
|
||||
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
|
||||
E: ID_VENDOR_FROM_DATABASE=Intel Corporation
|
||||
E: ID_MODEL_FROM_DATABASE=Sunrise Point-LP USB 3.0 xHCI Controller
|
||||
A: ari_enabled=0
|
||||
A: broken_parity_status=0
|
||||
A: class=0x0c0330
|
||||
H: config=86802F9D060490022130030C00008000040022E1000000000000000000000000000000000000000000000000AA1738220000000070000000000000000B010000
|
||||
A: consistent_dma_mask_bits=64
|
||||
A: d3cold_allowed=1
|
||||
A: dbc=disabled
|
||||
A: device=0x9d2f
|
||||
A: dma_mask_bits=64
|
||||
L: driver=../../../bus/pci/drivers/xhci_hcd
|
||||
A: driver_override=(null)
|
||||
A: enable=1
|
||||
A: irq=125
|
||||
A: local_cpulist=0-3
|
||||
A: local_cpus=f
|
||||
A: modalias=pci:v00008086d00009D2Fsv000017AAsd00002238bc0Csc03i30
|
||||
A: msi_bus=1
|
||||
A: msi_irqs/125=msi
|
||||
A: numa_node=-1
|
||||
A: pools=poolinfo - 0.1\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\nxHCI 1KB stream ctx arrays 0 0 1024 0\nxHCI 256 byte stream ctx arrays 0 0 256 0\nxHCI input/output contexts 37 38 2112 38\nxHCI ring segments 116 120 4096 120\nbuffer-2048 3 6 2048 3\nbuffer-512 0 0 512 0\nbuffer-128 30 32 128 1\nbuffer-32 0 0 32 0
|
||||
A: power/control=on
|
||||
A: power/runtime_active_time=2405617003
|
||||
A: power/runtime_status=active
|
||||
A: power/runtime_suspended_time=0
|
||||
A: power/wakeup=enabled
|
||||
A: power/wakeup_abort_count=0
|
||||
A: power/wakeup_active=0
|
||||
A: power/wakeup_active_count=0
|
||||
A: power/wakeup_count=0
|
||||
A: power/wakeup_expire_count=0
|
||||
A: power/wakeup_last_time_ms=0
|
||||
A: power/wakeup_max_time_ms=0
|
||||
A: power/wakeup_total_time_ms=0
|
||||
A: resource=0x00000000e1220000 0x00000000e122ffff 0x0000000000140204\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000
|
||||
A: revision=0x21
|
||||
A: subsystem_device=0x2238
|
||||
A: subsystem_vendor=0x17aa
|
||||
A: vendor=0x8086
|
||||
|
||||
+71
-14
@@ -4,7 +4,7 @@ envs.set('G_DEBUG', 'fatal-warnings')
|
||||
envs.set('G_MESSAGES_DEBUG', 'all')
|
||||
|
||||
# Setup paths
|
||||
envs.set('MESON_SOURCE_ROOT', meson.build_root())
|
||||
envs.set('MESON_SOURCE_ROOT', meson.source_root())
|
||||
envs.prepend('LD_LIBRARY_PATH', join_paths(meson.build_root(), 'libfprint'))
|
||||
|
||||
# Set FP_DEVICE_EMULATION so that drivers can adapt (e.g. to use fixed
|
||||
@@ -16,6 +16,12 @@ envs.set('FP_DRIVERS_WHITELIST', 'virtual_image')
|
||||
|
||||
envs.set('NO_AT_BRIDGE', '1')
|
||||
|
||||
drivers_tests = [
|
||||
'elan',
|
||||
'vfs5011',
|
||||
'synaptics',
|
||||
]
|
||||
|
||||
if get_option('introspection')
|
||||
envs.prepend('GI_TYPELIB_PATH', join_paths(meson.build_root(), 'libfprint'))
|
||||
|
||||
@@ -26,24 +32,44 @@ if get_option('introspection')
|
||||
env: envs,
|
||||
depends: libfprint_typelib,
|
||||
)
|
||||
else
|
||||
test('virtual-image',
|
||||
find_program('sh'),
|
||||
args: ['-c', 'exit 77']
|
||||
)
|
||||
endif
|
||||
|
||||
drivers_tests = [
|
||||
'vfs5011',
|
||||
'synaptics',
|
||||
]
|
||||
|
||||
foreach driver_test: drivers_tests
|
||||
driver_envs = envs
|
||||
driver_envs.set('FP_DRIVERS_WHITELIST', driver_test)
|
||||
|
||||
if driver_test in drivers
|
||||
test(driver_test,
|
||||
find_program('umockdev-test.py'),
|
||||
args: join_paths(meson.current_source_dir(), driver_test),
|
||||
env: driver_envs,
|
||||
suite: ['drivers'],
|
||||
timeout: 10,
|
||||
depends: libfprint_typelib,
|
||||
)
|
||||
else
|
||||
test(driver_test,
|
||||
find_program('sh'),
|
||||
args: ['-c', 'exit 77']
|
||||
)
|
||||
endif
|
||||
endforeach
|
||||
else
|
||||
warning('Skipping all driver tests as introspection bindings are missing')
|
||||
test('virtual-image',
|
||||
find_program('sh'),
|
||||
args: ['-c', 'exit 77']
|
||||
)
|
||||
|
||||
foreach driver_test: drivers_tests
|
||||
test(driver_test,
|
||||
find_program('umockdev-test.py'),
|
||||
args: join_paths(meson.current_source_dir(), driver_test),
|
||||
env: driver_envs,
|
||||
suite: ['drivers'],
|
||||
timeout: 10,
|
||||
depends: libfprint_typelib,
|
||||
find_program('sh'),
|
||||
args: ['-c', 'exit 77']
|
||||
)
|
||||
endforeach
|
||||
endif
|
||||
@@ -59,6 +85,7 @@ test_utils = static_library('fprint-test-utils',
|
||||
unit_tests = [
|
||||
'fpi-device',
|
||||
'fpi-ssm',
|
||||
'fpi-assembling',
|
||||
]
|
||||
|
||||
if 'virtual_image' in drivers
|
||||
@@ -68,11 +95,41 @@ if 'virtual_image' in drivers
|
||||
]
|
||||
endif
|
||||
|
||||
unit_tests_deps = { 'fpi-assembling' : [cairo_dep] }
|
||||
|
||||
test_config = configuration_data()
|
||||
test_config.set_quoted('SOURCE_ROOT', meson.source_root())
|
||||
test_config_h = configure_file(output: 'test-config.h', configuration: test_config)
|
||||
|
||||
foreach test_name: unit_tests
|
||||
if unit_tests_deps.has_key(test_name)
|
||||
missing_deps = false
|
||||
foreach dep: unit_tests_deps[test_name]
|
||||
if not dep.found()
|
||||
missing_deps = true
|
||||
break
|
||||
endif
|
||||
endforeach
|
||||
|
||||
if missing_deps
|
||||
# Create a dummy test that always skips instead
|
||||
warning('Test @0@ cannot be compiled due to missing dependencies'.format(test_name))
|
||||
test(test_name,
|
||||
find_program('sh'),
|
||||
suite: ['unit-tests'],
|
||||
args: ['-c', 'exit 77'],
|
||||
)
|
||||
continue
|
||||
endif
|
||||
extra_deps = unit_tests_deps[test_name]
|
||||
else
|
||||
extra_deps = []
|
||||
endif
|
||||
|
||||
basename = 'test-' + test_name
|
||||
test_exe = executable(basename,
|
||||
sources: basename + '.c',
|
||||
dependencies: libfprint_private_dep,
|
||||
sources: [basename + '.c', test_config_h],
|
||||
dependencies: [ libfprint_private_dep ] + extra_deps,
|
||||
c_args: common_cflags,
|
||||
link_with: test_utils,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Example fingerprint device prints listing and deletion
|
||||
* Enrolls your right index finger and saves the print to disk
|
||||
* Copyright (C) 2019 Benjamin Berg <bberg@redhat.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 <cairo.h>
|
||||
#include "fpi-assembling.h"
|
||||
#include "fpi-image.h"
|
||||
#include "test-config.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct fpi_frame frame;
|
||||
cairo_surface_t *surf;
|
||||
guchar *data;
|
||||
guint stride;
|
||||
guint width;
|
||||
guint height;
|
||||
guint x;
|
||||
guint y;
|
||||
} cairo_frame;
|
||||
|
||||
static unsigned char
|
||||
cairo_get_pixel (struct fpi_frame_asmbl_ctx *ctx,
|
||||
struct fpi_frame *frame,
|
||||
unsigned int x,
|
||||
unsigned int y)
|
||||
{
|
||||
cairo_frame *c_frame = (void *) frame; /* Indirect cast to avoid alignment warning. */
|
||||
|
||||
x = x + c_frame->x;
|
||||
y = y + c_frame->y;
|
||||
|
||||
g_assert (x < c_frame->width);
|
||||
g_assert (y < c_frame->height);
|
||||
|
||||
return c_frame->data[x * 4 + y * c_frame->stride + 1];
|
||||
}
|
||||
|
||||
static void
|
||||
test_frame_assembling (void)
|
||||
{
|
||||
g_autofree char *path = NULL;
|
||||
cairo_surface_t *img = NULL;
|
||||
int width, height, stride, offset;
|
||||
int test_height;
|
||||
guchar *data;
|
||||
struct fpi_frame_asmbl_ctx ctx = { 0, };
|
||||
|
||||
g_autoptr(FpImage) fp_img = NULL;
|
||||
GSList *frames = NULL;
|
||||
|
||||
g_assert_false (SOURCE_ROOT == NULL);
|
||||
path = g_build_path (G_DIR_SEPARATOR_S, SOURCE_ROOT, "tests", "vfs5011", "capture.png", NULL);
|
||||
|
||||
img = cairo_image_surface_create_from_png (path);
|
||||
data = cairo_image_surface_get_data (img);
|
||||
width = cairo_image_surface_get_width (img);
|
||||
height = cairo_image_surface_get_height (img);
|
||||
stride = cairo_image_surface_get_stride (img);
|
||||
g_assert_cmpint (cairo_image_surface_get_format (img), ==, CAIRO_FORMAT_RGB24);
|
||||
|
||||
ctx.get_pixel = cairo_get_pixel;
|
||||
ctx.frame_width = width;
|
||||
ctx.frame_height = 20;
|
||||
ctx.image_width = width;
|
||||
|
||||
offset = 10;
|
||||
test_height = height - (height - ctx.frame_height) % offset;
|
||||
|
||||
/* for now, fixed offset */
|
||||
for (int y = 0; y + ctx.frame_height < height; y += offset)
|
||||
{
|
||||
cairo_frame *frame = g_new0 (cairo_frame, 1);
|
||||
|
||||
frame->surf = img;
|
||||
frame->width = width;
|
||||
frame->height = height;
|
||||
frame->stride = stride;
|
||||
frame->data = data;
|
||||
frame->x = 0;
|
||||
frame->y = y;
|
||||
//frame->y = test_height - ctx.frame_height - y;
|
||||
|
||||
frames = g_slist_append (frames, frame);
|
||||
}
|
||||
//offset = -offset;
|
||||
|
||||
fpi_do_movement_estimation (&ctx, frames);
|
||||
for (GSList *l = frames->next; l != NULL; l = l->next)
|
||||
{
|
||||
cairo_frame * frame = l->data;
|
||||
|
||||
g_assert_cmpint (frame->frame.delta_x, ==, 0);
|
||||
g_assert_cmpint (frame->frame.delta_y, ==, offset);
|
||||
}
|
||||
|
||||
fp_img = fpi_assemble_frames (&ctx, frames);
|
||||
g_assert_cmpint (fp_img->height, ==, test_height);
|
||||
|
||||
/* The FpImage and cairo surface need to be identical in the test area */
|
||||
for (int y = 0; y < test_height; y++)
|
||||
for (int x = 0; x < width; x++)
|
||||
g_assert_cmpint (data[x * 4 + y * stride + 1], ==, fp_img->data[x + y * width]);
|
||||
|
||||
g_slist_free_full (frames, g_free);
|
||||
cairo_surface_destroy (img);
|
||||
g_assert (1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/assembling/frames", test_frame_assembling);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
Reference in New Issue
Block a user