From ea829fa6d51b46d1c2f06d14150c0948ffd044d5 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 9 Sep 2019 11:14:46 +0200 Subject: Squish: Workaround bad focus issue when using Squish When interacting with the file dialog QC seems to lose its focus and never gets it completely back. This in turn makes lots of short cuts useless and (context) menu entries disappear or being disabled. Avoid this by explicitly closing the popup of the line edit if there is one. Change-Id: I79f86b3133d2d0780d73d75e15416d59f35dfa1e Reviewed-by: Robert Loehning --- tests/system/shared/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index e8bc1425a7..ef46aca7b2 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -235,6 +235,11 @@ def getOutputFromCmdline(cmdline, environment=None, acceptedError=0): return e.output def selectFromFileDialog(fileName, waitForFile=False, ignoreFinalSnooze=False): + def __closePopupIfNecessary__(): + if not isNull(QApplication.activePopupWidget()): + test.log("Closing active popup widget") + QApplication.activePopupWidget().close() + if platform.system() == "Darwin": snooze(1) nativeType("") @@ -252,12 +257,13 @@ def selectFromFileDialog(fileName, waitForFile=False, ignoreFinalSnooze=False): try: waitForObject("{name='QFileDialog' type='QFileDialog' visible='1'}", 5000) pathLine = waitForObject("{name='fileNameEdit' type='QLineEdit' visible='1'}") - snooze(1) replaceEditorContent(pathLine, pName) + snooze(1) clickButton(waitForObject("{text='Open' type='QPushButton'}")) waitFor("str(pathLine.text)==''") - snooze(1) replaceEditorContent(pathLine, fName) + snooze(1) + __closePopupIfNecessary__() clickButton(waitForObject("{text='Open' type='QPushButton'}")) except: nativeType("") -- cgit v1.2.3