1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
# Copyright (C) 2016 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import builtins
# for easier re-usage (because Python hasn't an enum type)
class Targets:
ALL_TARGETS = tuple(range(4))
if os.getenv("SYSTEST_NEW_SETTINGS") != "1":
(DESKTOP_5_4_1_GCC,
DESKTOP_5_10_1_DEFAULT,
DESKTOP_5_14_1_DEFAULT,
DESKTOP_6_2_4) = ALL_TARGETS
__TARGET_NAME_DICT__ = dict(zip(ALL_TARGETS,
["Desktop 5.4.1 GCC",
"Desktop 5.10.1 default",
"Desktop 5.14.1 default",
"Desktop 6.2.4"]))
else:
(DESKTOP_6_7_3_GCC,
DESKTOP_5_10_1_DEFAULT,
DESKTOP_5_14_1_DEFAULT,
DESKTOP_6_2_4) = ALL_TARGETS
__TARGET_NAME_DICT__ = dict(zip(ALL_TARGETS,
["Desktop 6.7.3 GCC",
"Desktop 5.10.1 default",
"Desktop 5.14.1 default",
"Desktop 6.2.4"]))
@staticmethod
def isOnlineInstaller(target):
onlineInstallerTargets = [Targets.DESKTOP_6_2_4]
if os.getenv("SYSTEST_NEW_SETTINGS") == "1":
onlineInstallerTargets.append(Targets.DESKTOP_6_7_3_GCC)
return target in onlineInstallerTargets
@staticmethod
def availableTargetClasses(ignoreValidity=False):
availableTargets = set(Targets.ALL_TARGETS)
if platform.system() not in ('Windows', 'Microsoft'):
if os.getenv("SYSTEST_NEW_SETTINGS") == "1":
availableTargets.remove(Targets.DESKTOP_6_7_3_GCC)
else:
availableTargets.remove(Targets.DESKTOP_5_4_1_GCC)
return availableTargets
@staticmethod
def desktopTargetClasses():
return Targets.availableTargetClasses()
@staticmethod
def getStringForTarget(target):
return Targets.__TARGET_NAME_DICT__[target]
@staticmethod
def getTargetsAsStrings(targets):
return set(map(Targets.getStringForTarget, targets))
@staticmethod
def getIdForTargetName(targetName):
return {v:k for k, v in Targets.__TARGET_NAME_DICT__.items()}[targetName]
@staticmethod
def getDefaultKit():
return Targets.DESKTOP_5_14_1_DEFAULT
# this class holds some constants for easier usage inside the Projects view
class ProjectSettings:
BUILD = 1
RUN = 2
# this class defines some constants for the views of the creator's MainWindow
class ViewConstants:
WELCOME, EDIT, DESIGN, DEBUG, PROJECTS, EXTENSIONS, HELP = range(7)
FIRST_AVAILABLE = 0
# always adjust the following to the highest value of the available ViewConstants when adding new
LAST_AVAILABLE = HELP
class LibType:
SHARED = 0
STATIC = 1
QT_PLUGIN = 2
@staticmethod
def getStringForLib(libType):
if libType == LibType.SHARED:
return "Shared Library"
if libType == LibType.STATIC:
return "Statically Linked Library"
if libType == LibType.QT_PLUGIN:
return "Qt Plugin"
return None
class QtPath:
DOCS = 0
EXAMPLES = 1
@staticmethod
def getPaths(pathSpec):
qtTargets = [Targets.DESKTOP_5_10_1_DEFAULT, Targets.DESKTOP_5_14_1_DEFAULT,
Targets.DESKTOP_6_2_4]
if platform.system() in ('Windows', 'Microsoft'):
if os.getenv("SYSTEST_NEW_SETTINGS") == "1":
qtTargets.append(Targets.DESKTOP_6_7_3_GCC)
else:
qtTargets.append(Targets.DESKTOP_5_4_1_GCC)
if pathSpec == QtPath.DOCS:
return map(lambda target: QtPath.docsPath(target), qtTargets)
elif pathSpec == QtPath.EXAMPLES:
return map(lambda target: QtPath.examplesPath(target), qtTargets)
else:
test.fatal("Unknown pathSpec given: %s" % str(pathSpec))
return []
@staticmethod
def __preCheckAndExtractQtVersionStr__(target):
if target not in Targets.ALL_TARGETS:
raise Exception("Unexpected target '%s'" % str(target))
matcher = re.match("^Desktop ([56]\.\\d{1,2}\.\\d{1,2}).*$", Targets.getStringForTarget(target))
if matcher is None:
raise Exception("Currently this is supported for Desktop Qt5/Qt6 only, got target '%s'"
% str(Targets.getStringForTarget(target)))
return matcher.group(1)
@staticmethod
def __createPlatformQtPath__(qt5Minor):
if platform.system() in ('Microsoft', 'Windows'):
return "C:/Qt/Qt5.%d.1" % qt5Minor
else:
return os.path.expanduser("~/Qt5.%d.1" % qt5Minor)
@staticmethod
def __createQtOnlineInstallerPath__():
qtBasePath = os.getenv('SYSTEST_QTOI_BASEPATH', None)
if qtBasePath is None:
qtBasePath = 'C:/Qt' if platform.system() in ('Microsoft', 'Windows') else '~/Qt'
qtBasePath = os.path.expanduser(qtBasePath)
if not os.path.exists(qtBasePath):
test.fatal("Unexpected Qt install path '%s'" % qtBasePath)
return ""
return qtBasePath
@staticmethod
def toVersionTuple(versionString):
return tuple(map(builtins.int, versionString.split(".")))
@staticmethod
def getQtVersion(target):
qtVersionStr = QtPath.__preCheckAndExtractQtVersionStr__(target)
versionTuple = QtPath.toVersionTuple(qtVersionStr)
return versionTuple
@staticmethod
def examplesPath(target):
qtMajorVersion, qtMinorVersion, qtPatchVersion = QtPath.getQtVersion(target)
if qtMajorVersion == 5 and qtMinorVersion < 10:
path = "Examples/Qt-%d.%d" % (qtMajorVersion, qtMinorVersion)
else:
path = "Examples/Qt-%d.%d.%d" % (qtMajorVersion, qtMinorVersion, qtPatchVersion)
if Targets.isOnlineInstaller(target):
return os.path.join(QtPath.__createQtOnlineInstallerPath__(), path)
return os.path.join(QtPath.__createPlatformQtPath__(qtMinorVersion), path)
@staticmethod
def docsPath(target):
qtMajorVersion, qtMinorVersion, qtPatchVersion = QtPath.getQtVersion(target)
if qtMajorVersion == 5 and qtMinorVersion < 10:
path = "Docs/Qt-%d.%d" % (qtMajorVersion, qtMinorVersion)
else:
path = "Docs/Qt-%d.%d.%d" % (qtMajorVersion, qtMinorVersion, qtPatchVersion)
if Targets.isOnlineInstaller(target):
return os.path.join(QtPath.__createQtOnlineInstallerPath__(), path)
return os.path.join(QtPath.__createPlatformQtPath__(qtMinorVersion), path)
class TestSection:
def __init__(self, description):
self.description = description
def __enter__(self):
test.startSection(self.description)
def __exit__(self, exc_type, exc_value, traceback):
test.endSection()
|