tests: Speed up tests by only using parts of the image

We just need large enough samples to tell them apart correctly. For this
a 128x128 area from the center of each image is sufficient.

This speeds up the test run considerably. Other ways of achieving this
could be to also lower the number of enroll steps for the image device.
This commit is contained in:
Benjamin Berg
2021-07-31 11:51:55 +02:00
parent c690542e7c
commit 6bc19c8892

View File

@ -121,6 +121,8 @@ class Connection:
self.con.close()
del self.con
# Speed up tests by only loading a 128x128px area from the center
MAX_IMG_SIZE = 128
def load_image(img):
png = cairo.ImageSurface.create_from_png(img)
@ -129,7 +131,13 @@ def load_image(img):
h = png.get_height()
w = (w + 3) // 4 * 4
h = (h + 3) // 4 * 4
img = cairo.ImageSurface(cairo.Format.A8, w, h)
w_out = min(MAX_IMG_SIZE, w)
h_out = min(MAX_IMG_SIZE, h)
x = (w - w_out) // 2
y = (h - h_out) // 2
img = cairo.ImageSurface(cairo.Format.A8, w_out, h_out)
cr = cairo.Context(img)
cr.set_source_rgba(1, 1, 1, 1)
@ -138,7 +146,7 @@ def load_image(img):
cr.set_source_rgba(0, 0, 0, 0)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.set_source_surface(png)
cr.set_source_surface(png, -x, -y)
cr.paint()
return img