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 <robert.loehning@qt.io>
This commit is contained in:
Christian Stenger
2019-09-09 11:14:46 +02:00
parent d907df0349
commit ea829fa6d5

View File

@@ -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("<Command+Shift+g>")
@@ -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("<Ctrl+a>")