From 85e656b04183d0cba01fa5ddeedde7ffdbfb7dbe Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 7 Sep 2017 12:45:01 +0200 Subject: [PATCH] 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 --- tests/system/shared/utils.py | 12 ++++++++---- .../system/suite_general/tst_tasks_handling/test.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index db4c4e1cd5..b331ddb667 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -243,7 +243,7 @@ def getOutputFromCmdline(cmdline, environment=None, acceptedError=0): test.warning("Command '%s' returned %d" % (e.cmd, e.returncode)) return e.output -def selectFromFileDialog(fileName, waitForFile=False): +def selectFromFileDialog(fileName, waitForFile=False, ignoreFinalSnooze=False): if platform.system() == "Darwin": snooze(1) nativeType("") @@ -253,7 +253,8 @@ def selectFromFileDialog(fileName, waitForFile=False): nativeType("") snooze(3) nativeType("") - snooze(1) + if not ignoreFinalSnooze: + snooze(1) else: fName = os.path.basename(os.path.abspath(fileName)) pName = os.path.dirname(os.path.abspath(fileName)) + os.sep @@ -271,9 +272,12 @@ def selectFromFileDialog(fileName, waitForFile=False): nativeType("") nativeType("") 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("") - snooze(3) + if not ignoreFinalSnooze: + snooze(3) if waitForFile: fileCombo = waitForObject(":Qt Creator_FilenameQComboBox") if not waitFor("str(fileCombo.currentText) in fileName", 5000): diff --git a/tests/system/suite_general/tst_tasks_handling/test.py b/tests/system/suite_general/tst_tasks_handling/test.py index 69e7a6719c..6870cceead 100644 --- a/tests/system/suite_general/tst_tasks_handling/test.py +++ b/tests/system/suite_general/tst_tasks_handling/test.py @@ -99,7 +99,7 @@ def main(): model = waitForObject(":Qt Creator.Issues_QListView").model() test.verify(model.rowCount() == 0, 'Got an empty issue list to start from.') invokeMenuItem("File", "Open File or Project...") - selectFromFileDialog(tasksFile) + selectFromFileDialog(tasksFile, False, True) starttime = datetime.utcnow() waitFor("model.rowCount() == expectedNo", 10000) endtime = datetime.utcnow() -- GitLab