From 6bc19c8892bd9dc4e23fb4e2463640181949f239 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Sat, 31 Jul 2021 11:51:55 +0200 Subject: [PATCH] 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. --- tests/fprintd.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/fprintd.py b/tests/fprintd.py index 8719e53..c54e6a7 100644 --- a/tests/fprintd.py +++ b/tests/fprintd.py @@ -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