Squish: Workaround Squish issues when using nativeType

When using nativeType() Squish sends single key press events for
any char to type.
nativeType() does not wait until these events have been processed
which leads to complete useless time measurings inside
tst_tasks_handling as timestamps are taken too early if nativeType
had to be used - which happens when a native FileDialog is used.

Change-Id: I446de898fd99b2e169ca39bef1adb4306d6ee530
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
Christian Stenger
2017-09-07 12:45:01 +02:00
parent 5b48bd0420
commit 85e656b041
2 changed files with 9 additions and 5 deletions

View File

@@ -243,7 +243,7 @@ def getOutputFromCmdline(cmdline, environment=None, acceptedError=0):
test.warning("Command '%s' returned %d" % (e.cmd, e.returncode)) test.warning("Command '%s' returned %d" % (e.cmd, e.returncode))
return e.output return e.output
def selectFromFileDialog(fileName, waitForFile=False): def selectFromFileDialog(fileName, waitForFile=False, ignoreFinalSnooze=False):
if platform.system() == "Darwin": if platform.system() == "Darwin":
snooze(1) snooze(1)
nativeType("<Command+Shift+g>") nativeType("<Command+Shift+g>")
@@ -253,7 +253,8 @@ def selectFromFileDialog(fileName, waitForFile=False):
nativeType("<Return>") nativeType("<Return>")
snooze(3) snooze(3)
nativeType("<Return>") nativeType("<Return>")
snooze(1) if not ignoreFinalSnooze:
snooze(1)
else: else:
fName = os.path.basename(os.path.abspath(fileName)) fName = os.path.basename(os.path.abspath(fileName))
pName = os.path.dirname(os.path.abspath(fileName)) + os.sep pName = os.path.dirname(os.path.abspath(fileName)) + os.sep
@@ -271,9 +272,12 @@ def selectFromFileDialog(fileName, waitForFile=False):
nativeType("<Ctrl+a>") nativeType("<Ctrl+a>")
nativeType("<Delete>") nativeType("<Delete>")
nativeType(pName + fName) nativeType(pName + fName)
snooze(1) seconds = len(pName + fName) / 20
test.log("Using snooze(%d) [problems with event processing of nativeType()]" % seconds)
snooze(seconds)
nativeType("<Return>") nativeType("<Return>")
snooze(3) if not ignoreFinalSnooze:
snooze(3)
if waitForFile: if waitForFile:
fileCombo = waitForObject(":Qt Creator_FilenameQComboBox") fileCombo = waitForObject(":Qt Creator_FilenameQComboBox")
if not waitFor("str(fileCombo.currentText) in fileName", 5000): if not waitFor("str(fileCombo.currentText) in fileName", 5000):

View File

@@ -99,7 +99,7 @@ def main():
model = waitForObject(":Qt Creator.Issues_QListView").model() model = waitForObject(":Qt Creator.Issues_QListView").model()
test.verify(model.rowCount() == 0, 'Got an empty issue list to start from.') test.verify(model.rowCount() == 0, 'Got an empty issue list to start from.')
invokeMenuItem("File", "Open File or Project...") invokeMenuItem("File", "Open File or Project...")
selectFromFileDialog(tasksFile) selectFromFileDialog(tasksFile, False, True)
starttime = datetime.utcnow() starttime = datetime.utcnow()
waitFor("model.rowCount() == expectedNo", 10000) waitFor("model.rowCount() == expectedNo", 10000)
endtime = datetime.utcnow() endtime = datetime.utcnow()