forked from qt-creator/qt-creator
Squish: Reduce complexity of iterateQtVersions()
By removing dead code, code which generated unused data, unneeded generality and needless abstractions. Change-Id: Ie271363c5446ef02f32e48a78db3d8ef9be0ed29 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -167,7 +167,6 @@
|
|||||||
:Qt Creator_Utils::BuildDirectoryLineEdit {name='LineEdit' type='Utils::FancyLineEdit' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
|
:Qt Creator_Utils::BuildDirectoryLineEdit {name='LineEdit' type='Utils::FancyLineEdit' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
|
||||||
:Qt Creator_Utils::NavigationTreeView {type='Utils::NavigationTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
|
:Qt Creator_Utils::NavigationTreeView {type='Utils::NavigationTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
|
||||||
:Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit {container=':Qt Creator_Utils::NavigationTreeView' type='QExpandingLineEdit' unnamed='1' visible='1'}
|
:Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit {container=':Qt Creator_Utils::NavigationTreeView' type='QExpandingLineEdit' unnamed='1' visible='1'}
|
||||||
:QtSupport__Internal__QtVersionManager.QLabel {container=':qt_tabwidget_stackedwidget_QScrollArea' text?='Qt version *' type='QLabel' unnamed='1' visible='1'}
|
|
||||||
:QtSupport__Internal__QtVersionManager.errorLabel.QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='errorLabel' type='QLabel' visible='1'}
|
:QtSupport__Internal__QtVersionManager.errorLabel.QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='errorLabel' type='QLabel' visible='1'}
|
||||||
:QtSupport__Internal__QtVersionManager.qmake_QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='qmakePath' type='QLabel' visible='1'}
|
:QtSupport__Internal__QtVersionManager.qmake_QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='qmakePath' type='QLabel' visible='1'}
|
||||||
:QtVersionLabel_KitPage {container=':qt_tabwidget_stackedwidget_QWidget' text='Qt version:' type='QLabel' unnamed='1' visible='1'}
|
:QtVersionLabel_KitPage {container=':qt_tabwidget_stackedwidget_QWidget' text='Qt version:' type='QLabel' unnamed='1' visible='1'}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (C) 2016 The Qt Company Ltd.
|
# Copyright (C) 2022 The Qt Company Ltd.
|
||||||
# Contact: https://www.qt.io/licensing/
|
# Contact: https://www.qt.io/licensing/
|
||||||
#
|
#
|
||||||
# This file is part of Qt Creator.
|
# This file is part of Qt Creator.
|
||||||
@@ -347,10 +347,6 @@ def __checkParentAccess__(filePath):
|
|||||||
# options dialog and returns a dict holding the kits as keys
|
# options dialog and returns a dict holding the kits as keys
|
||||||
# and a list of information of its configured Qt
|
# and a list of information of its configured Qt
|
||||||
def getConfiguredKits():
|
def getConfiguredKits():
|
||||||
def __retrieveQtVersionName__(target, version):
|
|
||||||
treeView = waitForObject(":qtdirList_QTreeView")
|
|
||||||
return str(treeView.currentIndex().data().toString())
|
|
||||||
# end of internal function for iterateQtVersions
|
|
||||||
def __setQtVersionForKit__(kit, kitName, kitsQtVersionName):
|
def __setQtVersionForKit__(kit, kitName, kitsQtVersionName):
|
||||||
mouseClick(waitForObjectItem(":BuildAndRun_QTreeView", kit))
|
mouseClick(waitForObjectItem(":BuildAndRun_QTreeView", kit))
|
||||||
qtVersionStr = str(waitForObjectExists(":Kits_QtVersion_QComboBox").currentText)
|
qtVersionStr = str(waitForObjectExists(":Kits_QtVersion_QComboBox").currentText)
|
||||||
@@ -361,18 +357,15 @@ def getConfiguredKits():
|
|||||||
# end of internal function for iterate kits
|
# end of internal function for iterate kits
|
||||||
|
|
||||||
kitsWithQtVersionName = {}
|
kitsWithQtVersionName = {}
|
||||||
result = {}
|
result = []
|
||||||
# collect kits and their Qt versions
|
# collect kits and their Qt versions
|
||||||
targetsQtVersions, qtVersionNames = iterateQtVersions(True, False, __retrieveQtVersionName__)
|
qtVersionNames = iterateQtVersions()
|
||||||
# update collected Qt versions with their configured device and version
|
# update collected Qt versions with their configured device and version
|
||||||
iterateKits(True, True, __setQtVersionForKit__, kitsWithQtVersionName)
|
iterateKits(True, True, __setQtVersionForKit__, kitsWithQtVersionName)
|
||||||
# merge defined target names with their configured Qt versions and devices
|
# merge defined target names with their configured Qt versions and devices
|
||||||
for kit, qtVersion in kitsWithQtVersionName.iteritems():
|
for kit, qtVersion in kitsWithQtVersionName.iteritems():
|
||||||
if kit in ('Fremantle', 'Harmattan', 'Qt Simulator'):
|
if qtVersion in qtVersionNames:
|
||||||
test.verify(qtVersion == 'None',
|
result.append(kit)
|
||||||
"The outdated kit '%s' should not have a Qt version" % kit)
|
|
||||||
elif qtVersion in qtVersionNames:
|
|
||||||
result[kit] = targetsQtVersions[qtVersionNames.index(qtVersion)].items()[0]
|
|
||||||
else:
|
else:
|
||||||
test.fail("Qt version '%s' for kit '%s' can't be found in qtVersionNames."
|
test.fail("Qt version '%s' for kit '%s' can't be found in qtVersionNames."
|
||||||
% (qtVersion, kit))
|
% (qtVersion, kit))
|
||||||
@@ -400,35 +393,14 @@ def regexVerify(text, expectedTexts):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# function that opens Options Dialog and parses the configured Qt versions
|
# function that opens Options Dialog and parses the configured Qt versions
|
||||||
# param keepOptionsOpen set to True if the Options dialog should stay open when
|
# the function returns a list of the found Qt versions
|
||||||
# leaving this function
|
def iterateQtVersions():
|
||||||
# param alreadyOnOptionsDialog set to True if you already have opened the Options Dialog
|
qtVersionNames = []
|
||||||
# (if False this function will open it via the MenuBar -> Tools -> Options...)
|
invokeMenuItem("Tools", "Options...")
|
||||||
# param additionalFunction pass a function or name of a defined function to execute
|
|
||||||
# for each correctly configured item on the list of Qt versions
|
|
||||||
# (Qt versions having no assigned toolchain, failing qmake,... will be skipped)
|
|
||||||
# this function must take at least 2 parameters - the first is the target name
|
|
||||||
# and the second the version of the current selected Qt version item
|
|
||||||
# param argsForAdditionalFunc you can specify as much parameters as you want to pass
|
|
||||||
# to additionalFunction from the outside
|
|
||||||
# the function returns a list of dict holding target-version mappings if used without
|
|
||||||
# additionalFunction
|
|
||||||
# WATCH OUT! if you're using the additionalFunction parameter - this function will
|
|
||||||
# return the list mentioned above as well as the returned value(s) from
|
|
||||||
# additionalFunction. You MUST call this function like
|
|
||||||
# result, additionalResult = _iterateQtVersions(...)
|
|
||||||
# where additionalResult is the result of all executions of additionalFunction which
|
|
||||||
# means it is a list of results.
|
|
||||||
def iterateQtVersions(keepOptionsOpen=False, alreadyOnOptionsDialog=False,
|
|
||||||
additionalFunction=None, *argsForAdditionalFunc):
|
|
||||||
result = []
|
|
||||||
additionalResult = []
|
|
||||||
if not alreadyOnOptionsDialog:
|
|
||||||
invokeMenuItem("Tools", "Options...")
|
|
||||||
mouseClick(waitForObjectItem(":Options_QListView", "Kits"))
|
mouseClick(waitForObjectItem(":Options_QListView", "Kits"))
|
||||||
clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Qt Versions")
|
clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Qt Versions")
|
||||||
pattern = re.compile("Qt version (?P<version>.*?) for (?P<target>.*)")
|
|
||||||
treeView = waitForObject(":qtdirList_QTreeView")
|
treeView = waitForObject(":qtdirList_QTreeView")
|
||||||
model = treeView.model()
|
model = treeView.model()
|
||||||
for rootIndex in dumpIndices(model):
|
for rootIndex in dumpIndices(model):
|
||||||
@@ -436,31 +408,10 @@ def iterateQtVersions(keepOptionsOpen=False, alreadyOnOptionsDialog=False,
|
|||||||
for subIndex in dumpIndices(model, rootIndex):
|
for subIndex in dumpIndices(model, rootIndex):
|
||||||
subChildText = str(subIndex.data()).replace(".", "\\.").replace("_", "\\_")
|
subChildText = str(subIndex.data()).replace(".", "\\.").replace("_", "\\_")
|
||||||
treeView.scrollTo(subIndex)
|
treeView.scrollTo(subIndex)
|
||||||
mouseClick(waitForObjectItem(treeView, ".".join([rootChildText,subChildText])))
|
mouseClick(waitForObjectItem(treeView, ".".join([rootChildText, subChildText])))
|
||||||
currentText = str(waitForObject(":QtSupport__Internal__QtVersionManager.QLabel").text)
|
qtVersionNames.append(str(treeView.currentIndex().data().toString()))
|
||||||
matches = pattern.match(currentText)
|
return qtVersionNames
|
||||||
if matches:
|
|
||||||
target = matches.group("target").strip()
|
|
||||||
version = matches.group("version").strip()
|
|
||||||
result.append({target:version})
|
|
||||||
if additionalFunction:
|
|
||||||
try:
|
|
||||||
if isString(additionalFunction):
|
|
||||||
currResult = globals()[additionalFunction](target, version, *argsForAdditionalFunc)
|
|
||||||
else:
|
|
||||||
currResult = additionalFunction(target, version, *argsForAdditionalFunc)
|
|
||||||
except:
|
|
||||||
t,v,_ = sys.exc_info()
|
|
||||||
currResult = None
|
|
||||||
test.fatal("Function to additionally execute on Options Dialog could not be found or "
|
|
||||||
"an exception occurred while executing it.", "%s(%s)" % (str(t), str(v)))
|
|
||||||
additionalResult.append(currResult)
|
|
||||||
if not keepOptionsOpen:
|
|
||||||
clickButton(waitForObject(":Options.Cancel_QPushButton"))
|
|
||||||
if additionalFunction:
|
|
||||||
return result, additionalResult
|
|
||||||
else:
|
|
||||||
return result
|
|
||||||
|
|
||||||
# function that opens Options Dialog (if necessary) and parses the configured Kits
|
# function that opens Options Dialog (if necessary) and parses the configured Kits
|
||||||
# param keepOptionsOpen set to True if the Options dialog should stay open when
|
# param keepOptionsOpen set to True if the Options dialog should stay open when
|
||||||
|
@@ -93,7 +93,7 @@ def main():
|
|||||||
|
|
||||||
def verifyKitCheckboxes(kits, displayedPlatforms):
|
def verifyKitCheckboxes(kits, displayedPlatforms):
|
||||||
waitForObject("{type='QLabel' unnamed='1' visible='1' text='Kit Selection'}")
|
waitForObject("{type='QLabel' unnamed='1' visible='1' text='Kit Selection'}")
|
||||||
availableCheckboxes = frozenset(filter(enabledCheckBoxExists, kits.keys()))
|
availableCheckboxes = frozenset(filter(enabledCheckBoxExists, kits))
|
||||||
# verification whether expected, found and configured match
|
# verification whether expected, found and configured match
|
||||||
|
|
||||||
expectedShownKits = availableCheckboxes.intersection(displayedPlatforms)
|
expectedShownKits = availableCheckboxes.intersection(displayedPlatforms)
|
||||||
|
Reference in New Issue
Block a user