tests: Poll clipboard for changes.
For some reason I can't explain, since 2b0870084b
we got test failures on OS X, as the clipboard had the old value before waiting
for the change, the new (correct) value after waiting for it, but never
actually emitted 'changed'.
We could just re-check the contents after the timeout, but that'd mean we wait
1s for every test where this weird thing happens.
Instead, we poll the clipboard for every 100ms as long as the timeout (1s)
hasn't passed, and return as soon as it has the correct contents.
This commit is contained in:
parent
eef1604dcd
commit
eebed7a5a7
@ -395,9 +395,13 @@ def _wait_for_clipboard(qtbot, clipboard, mode, expected):
|
||||
while True:
|
||||
if clipboard.text(mode=mode) == expected:
|
||||
return
|
||||
with qtbot.waitSignal(clipboard.changed, timeout=timeout) as blocker:
|
||||
|
||||
# We need to poll the clipboard, as for some reason it can change with
|
||||
# emitting changed (?).
|
||||
with qtbot.waitSignal(clipboard.changed, timeout=100) as blocker:
|
||||
pass
|
||||
if not blocker.signal_triggered or timer.hasExpired(timeout):
|
||||
|
||||
if timer.hasExpired(timeout):
|
||||
mode_names = {
|
||||
QClipboard.Clipboard: 'clipboard',
|
||||
QClipboard.Selection: 'primary selection',
|
||||
|
Loading…
Reference in New Issue
Block a user