diff options
author | Christian Stenger <christian.stenger@qt.io> | 2018-08-22 14:37:34 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2018-09-05 09:24:18 +0000 |
commit | 1016dc0603051c20ba38644827abf88dd874bc90 (patch) | |
tree | dbc4b75667ad474b735a64bb5c42faafe5e2ccc0 /tests/system/shared | |
parent | c30b629b524597f6ae9d4308301244642fc98e5c (diff) |
Squish: Refactor starting Qt Creator from Squish
Change-Id: I7cbce7db2a22a7cb327965b9b7918eb46266b260
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Diffstat (limited to 'tests/system/shared')
-rw-r--r-- | tests/system/shared/clang.py | 22 | ||||
-rw-r--r-- | tests/system/shared/qtcreator.py | 37 |
2 files changed, 21 insertions, 38 deletions
diff --git a/tests/system/shared/clang.py b/tests/system/shared/clang.py index d1a5660828..f012b12c54 100644 --- a/tests/system/shared/clang.py +++ b/tests/system/shared/clang.py @@ -23,10 +23,11 @@ # ############################################################################ -def startCreatorTryingClang(): +def startCreatorVerifyingClang(useClang): try: - # start Qt Creator with enabled ClangCodeModel plugin (without modifying settings) - startApplication("qtcreator -load ClangCodeModel" + SettingsPath) + # start Qt Creator with / without enabled ClangCodeModel plugin (without modifying settings) + loadOrNoLoad = '-load' if useClang else '-noload' + startQC([loadOrNoLoad, 'ClangCodeModel']) except RuntimeError: t, v = sys.exc_info()[:2] strv = str(v) @@ -35,26 +36,17 @@ def startCreatorTryingClang(): else: test.fatal("Exception caught", "%s(%s)" % (str(t), strv)) return False + if platform.system() not in ('Microsoft', 'Windows'): # only Win uses dialogs for this + return startedWithoutPluginError() errorMsg = "{type='QMessageBox' unnamed='1' visible='1' windowTitle='Qt Creator'}" errorOK = "{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}" % errorMsg if not waitFor("object.exists(errorOK)", 5000): - return True + return startedWithoutPluginError() clickButton(errorOK) # Error message clickButton(errorOK) # Help message test.fatal("ClangCodeModel plugin not available.") return False -def startCreator(useClang): - try: - if useClang: - if not startCreatorTryingClang(): - return False - else: - startApplication("qtcreator -noload ClangCodeModel" + SettingsPath) - finally: - overrideStartApplication() - return startedWithoutPluginError() - def __openCodeModelOptions__(): invokeMenuItem("Tools", "Options...") waitForObjectItem(":Options_QListView", "C++") diff --git a/tests/system/shared/qtcreator.py b/tests/system/shared/qtcreator.py index 6172a12d76..734a65f0d5 100644 --- a/tests/system/shared/qtcreator.py +++ b/tests/system/shared/qtcreator.py @@ -37,11 +37,10 @@ from datetime import datetime,timedelta; import __builtin__ srcPath = '' -SettingsPath = '' +SettingsPath = [] tmpSettingsDir = '' testSettings.logScreenshotOnFail = True testSettings.logScreenshotOnError = True -__origStartApplication__ = None source("../../shared/classes.py") source("../../shared/utils.py") @@ -55,24 +54,18 @@ source("../../shared/clang.py") source("../../shared/welcome.py") source("../../shared/workarounds.py") # include this at last -# ATTENTION: if a test case calls startApplication("qtcreator...") for several times this -# function must be called BEFORE any call except the first (which is done always automatically) -def overrideStartApplication(): - global startApplication, __origStartApplication__ - if (platform.system() == "Linux"): - return - if (__origStartApplication__ == None): - __origStartApplication__ = startApplication - def startApplication(*args): - args = list(args) - if str(args[0]).startswith('qtcreator'): - if platform.system() == 'Darwin': - args[0] = args[0].replace('qtcreator', '"Qt Creator"', 1) - test.log("Using workaround for MacOS (different AUT name)") - else: - args[0] = args[0] + ' -platform windows:dialogs=none' - test.log("Using workaround for Windows (failing to hook into native FileDialog)") - return __origStartApplication__(*args) +# additionalParameters must be a list or tuple of strings or None +def startQC(additionalParameters=None, withPreparedSettingsPath=True): + global SettingsPath + appWithOptions = ['"Qt Creator"' if platform.system() == 'Darwin' else "qtcreator"] + if withPreparedSettingsPath: + appWithOptions.extend(SettingsPath) + if additionalParameters is not None: + appWithOptions.extend(additionalParameters) + if platform.system() in ('Microsoft', 'Windows'): # for hooking into native file dialog + appWithOptions.extend(('-platform', 'windows:dialogs=none')) + test.log("Starting now: %s" % ' '.join(appWithOptions)) + startApplication(' '.join(appWithOptions)) def startedWithoutPluginError(): try: @@ -304,7 +297,7 @@ def copySettingsToTmpDir(destination=None, omitFiles=[]): elif platform.system() in ('Windows', 'Microsoft'): substituteCdb(tmpSettingsDir) substituteUnchosenTargetABIs(tmpSettingsDir) - SettingsPath = ' -settingspath "%s"' % tmpSettingsDir + SettingsPath = ['-settingspath', '"%s"' % tmpSettingsDir] # current dir is directory holding qtcreator.py origSettingsDir = os.path.abspath(os.path.join(os.getcwd(), "..", "..", "settings")) @@ -320,8 +313,6 @@ else: srcPath = os.getenv("SYSTEST_SRCPATH", os.path.expanduser(os.path.join("~", "squish-data"))) -overrideStartApplication() - # the following only doesn't work if the test ends in an exception if os.getenv("SYSTEST_NOSETTINGSPATH") != "1": copySettingsToTmpDir() |