summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-07-31 11:51:55 +0200
committerBenjamin Berg <bberg@redhat.com>2021-07-31 11:53:33 +0200
commit6bc19c8892bd9dc4e23fb4e2463640181949f239 (patch)
tree7fa8a0316325acd63881f3391fded11bc9b5d9a0
parentc690542e7c41a53bf4d2e66a5428a1e7944f016e (diff)
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.
-rw-r--r--tests/fprintd.py12
1 files 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