summaryrefslogtreecommitdiff
path: root/tests/end2end/fixtures/quteprocess.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-02-11 18:52:42 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-02-11 18:57:22 +0100
commitda5ed6cc29ea35514e58ad0677cf5a3f55367767 (patch)
tree05ef1f17121929ffb64d3006c652d44fcf0b051a /tests/end2end/fixtures/quteprocess.py
parent58220286a91af38d4a83ddd3f02c1075e5375ffe (diff)
downloadqutebrowser-da5ed6cc29ea35514e58ad0677cf5a3f55367767.tar.gz
qutebrowser-da5ed6cc29ea35514e58ad0677cf5a3f55367767.zip
tests: Improve color probing
Probe for the color we actually expect - for some reason, sometimes before rendering is completed we get an old color, rather than black.
Diffstat (limited to 'tests/end2end/fixtures/quteprocess.py')
-rw-r--r--tests/end2end/fixtures/quteprocess.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index fe656b687..d5a55d64b 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -888,12 +888,17 @@ class QuteProc(testprocess.Process):
with open(path, 'r', encoding='utf-8') as f:
return f.read()
- def get_screenshot(self, probe: QPoint = None) -> QImage:
+ def get_screenshot(
+ self,
+ *,
+ probe_pos: QPoint = None,
+ probe_color: QColor = testutils.Color(0, 0, 0),
+ ) -> QImage:
"""Get a screenshot of the current page.
Arguments:
probe: If given, only continue if the pixel at the given position isn't
- black.
+ black (or whatever is specified by probe_color).
"""
for _ in range(5):
tmp_path = self.request.getfixturevalue('tmp_path')
@@ -904,13 +909,18 @@ class QuteProc(testprocess.Process):
img = QImage(str(path))
assert not img.isNull()
- if probe is None or img.pixelColor(probe) != QColor(0, 0, 0):
+ if probe_pos is None:
+ return img
+
+ probed_color = testutils.Color(img.pixelColor(probe_pos))
+ if probed_color == probe_color:
return img
# Rendering might not be completed yet...
time.sleep(0.5)
- raise ValueError("Pixel probing failed...")
+ raise ValueError(
+ f"Pixel probing for {probe_color} failed (got {probed_color} on last try)")
def press_keys(self, keys):
"""Press the given keys using :fake-key."""