Commit b2ff8d87 authored by Christian Stenger's avatar Christian Stenger
Browse files

Squish: Fix tst_create_proj_wizard



Replace waiting for signal textChanged() and handle new Qt Quick wizards.

Change-Id: Id452703fe21b3162800671db59f722821e7dd3fa
Reviewed-by: default avatarRobert Loehning <robert.loehning@digia.com>
parent 3e8f02e2
......@@ -154,7 +154,12 @@ def __createProjectHandleQtQuickSelection__(qtQuickVersion, withControls):
selectFromCombo(comboBox, "Qt Quick 2.0")
else:
test.fatal("Got unknown Qt Quick version: %s - trying to continue." % str(qtQuickVersion))
label = waitForObject("{type='QLabel' unnamed='1' visible='1' text?='Creates a *' }")
requires = re.match(".*Requires Qt (\d\.\d).*", str(label.text))
if requires:
requires = requires.group(1)
clickButton(waitForObject(":Next_QPushButton"))
return requires
# Selects the Qt versions for a project
# param checks turns tests in the function on if set to True
......@@ -187,6 +192,30 @@ def __verifyFileCreation__(path, expectedFiles):
filename = os.path.join(path, filename)
test.verify(os.path.exists(filename), "Checking if '" + filename + "' was created")
def __modifyAvailableTargets__(available, requiredQt, asStrings=False):
threeDigits = re.compile("\d{3}")
requiredQtVersion = requiredQt.replace(".", "") + "0"
tmp = list(available) # we need a deep copy
for currentItem in tmp:
if asStrings:
item = currentItem
else:
item = Targets.getStringForTarget(currentItem)
found = threeDigits.search(item)
if found:
if found.group(0) < requiredQtVersion:
# Quick 1.1 supports 4.7.4 only for running, debugging is unsupported
# so the least required version is 4.8, but 4.7.4 will be still listed
if not (requiredQtVersion == "480" and found.group(0) == "474"):
available.remove(currentItem)
if requiredQtVersion > "480":
toBeRemoved = [Targets.EMBEDDED_LINUX, Targets.SIMULATOR]
if asStrings:
toBeRemoved = Targets.getTargetsAsStrings(toBeRemoved)
for t in toBeRemoved:
if t in available:
available.remove(t)
# Creates a Qt GUI project
# param path specifies where to create the project
# param projectName is the name for the new project
......@@ -256,7 +285,8 @@ def createNewQtQuickApplication(workingDir, projectName = None,
fromWelcome=False, withControls=False):
available = __createProjectOrFileSelectType__(" Applications", "Qt Quick Application", fromWelcome)
projectName = __createProjectSetNameAndPath__(workingDir, projectName)
__createProjectHandleQtQuickSelection__(qtQuickVersion, withControls)
requiredQt = __createProjectHandleQtQuickSelection__(qtQuickVersion, withControls)
__modifyAvailableTargets__(available, requiredQt)
checkedTargets = __chooseTargets__(targets, available)
snooze(1)
clickButton(waitForObject(":Next_QPushButton"))
......
......@@ -33,7 +33,7 @@ import re
def main():
global tmpSettingsDir
global textChanged
quickCombinations = [[1,False], [2,False], [2,True]]
sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/text/textselection")
qmlFile = os.path.join("qml", "textselection.qml")
if not neededFilePresent(os.path.join(sourceExample, qmlFile)):
......@@ -42,9 +42,6 @@ def main():
startApplication("qtcreator" + SettingsPath)
if not startedWithoutPluginError():
return
overrideInstallLazySignalHandler()
installLazySignalHandler(":frame.templateDescription_QTextBrowser",
"textChanged()","__handleTextChanged__")
kits = getConfiguredKits()
test.log("Collecting potential project types...")
availableProjectTypes = []
......@@ -71,59 +68,67 @@ def main():
for template in dumpItems(templatesView.model(), templatesView.rootIndex()):
template = template.replace(".", "\\.")
# skip non-configurable
if not (template in ("Qt Quick 1 UI", "Qt Quick 2 UI", "Qt Quick 2 UI with Controls")
or "(CMake Build)" in template or "(Qbs Build)" in template):
if (template != "Qt Quick UI" and "(CMake Build)" not in template
and "(Qbs Build)" not in template):
availableProjectTypes.append({category:template})
clickButton(waitForObject("{text='Cancel' type='QPushButton' unnamed='1' visible='1'}"))
for current in availableProjectTypes:
category = current.keys()[0]
template = current.values()[0]
invokeMenuItem("File", "New File or Project...")
selectFromCombo(waitForObject(":New.comboBox_QComboBox"), "All Templates")
categoriesView = waitForObject(":New.templateCategoryView_QTreeView")
clickItem(categoriesView, "Projects." + category, 5, 5, 0, Qt.LeftButton)
templatesView = waitForObject("{name='templatesView' type='QListView' visible='1'}")
test.log("Verifying '%s' -> '%s'" % (category.replace("\\.", "."), template.replace("\\.", ".")))
textChanged = False
clickItem(templatesView, template, 5, 5, 0, Qt.LeftButton)
waitFor("textChanged", 2000)
text = waitForObject(":frame.templateDescription_QTextBrowser").plainText
displayedPlatforms = __getSupportedPlatforms__(str(text), template, True)[0]
clickButton(waitForObject("{text='Choose...' type='QPushButton' unnamed='1' visible='1'}"))
# don't check because project could exist
__createProjectSetNameAndPath__(os.path.expanduser("~"), 'untitled', False)
displayedPlatforms = __createProject__(category, template)
if template == "Qt Quick Application":
for counter, qComb in enumerate(quickCombinations):
requiredQtVersion = __createProjectHandleQtQuickSelection__(qComb[0], qComb[1])
__modifyAvailableTargets__(displayedPlatforms, requiredQtVersion, True)
verifyKitCheckboxes(kits, displayedPlatforms)
# FIXME: if QTBUG-35203 is fixed replace by triggering the shortcut for Back
clickButton(waitForObject("{type='QPushButton' text='Cancel'}"))
# are there more Quick combinations - then recreate this project
if counter < len(quickCombinations) - 1:
displayedPlatforms = __createProject__(category, template)
continue
try:
waitForObject("{name='mainQmlFileGroupBox' title='Main HTML File' type='QGroupBox' visible='1'}", 1000)
clickButton(waitForObject(":Next_QPushButton"))
except LookupError:
try:
waitForObject("{text='Select Existing QML file' type='QLabel' visible='1'}", 1000)
baseLineEd = waitForObject("{type='Utils::BaseValidatingLineEdit' unnamed='1' visible='1'}")
type(baseLineEd, os.path.join(templateDir, qmlFile))
clickButton(waitForObject(":Next_QPushButton"))
except LookupError:
pass
waitForObject("{type='QLabel' unnamed='1' visible='1' text='Kit Selection'}")
availableCheckboxes = filter(visibleCheckBoxExists, kits.keys())
# verification whether expected, found and configured match
for t in kits:
if t in displayedPlatforms:
if t in availableCheckboxes:
test.passes("Found expected kit '%s' on 'Kit Selection' page." % t)
availableCheckboxes.remove(t)
else:
test.fail("Expected kit '%s' missing on 'Kit Selection' page." % t)
else:
if t in availableCheckboxes:
test.fail("Kit '%s' found on 'Kit Selection' page - but was not expected!" % t)
else:
test.passes("Irrelevant kit '%s' not found on 'Kit Selection' page." % t)
if len(availableCheckboxes) != 0:
test.fail("Found unexpected additional kit(s) %s on 'Kit Selection' page."
% str(availableCheckboxes))
clickButton(waitForObject("{text='Cancel' type='QPushButton' unnamed='1' visible='1'}"))
pass
verifyKitCheckboxes(kits, displayedPlatforms)
clickButton(waitForObject("{type='QPushButton' text='Cancel'}"))
invokeMenuItem("File", "Exit")
def __handleTextChanged__(*args):
global textChanged
textChanged = True
def verifyKitCheckboxes(kits, displayedPlatforms):
waitForObject("{type='QLabel' unnamed='1' visible='1' text='Kit Selection'}")
availableCheckboxes = filter(visibleCheckBoxExists, kits.keys())
# verification whether expected, found and configured match
for t in kits:
if t in displayedPlatforms:
if t in availableCheckboxes:
test.passes("Found expected kit '%s' on 'Kit Selection' page." % t)
availableCheckboxes.remove(t)
else:
test.fail("Expected kit '%s' missing on 'Kit Selection' page." % t)
else:
if t in availableCheckboxes:
test.fail("Kit '%s' found on 'Kit Selection' page - but was not expected!" % t)
else:
test.passes("Irrelevant kit '%s' not found on 'Kit Selection' page." % t)
if len(availableCheckboxes) != 0:
test.fail("Found unexpected additional kit(s) %s on 'Kit Selection' page."
% str(availableCheckboxes))
def __createProject__(category, template):
invokeMenuItem("File", "New File or Project...")
selectFromCombo(waitForObject(":New.comboBox_QComboBox"), "All Templates")
categoriesView = waitForObject(":New.templateCategoryView_QTreeView")
clickItem(categoriesView, "Projects." + category, 5, 5, 0, Qt.LeftButton)
templatesView = waitForObject("{name='templatesView' type='QListView' visible='1'}")
test.log("Verifying '%s' -> '%s'" % (category.replace("\\.", "."), template.replace("\\.", ".")))
textBrowser = findObject(":frame.templateDescription_QTextBrowser")
origTxt = str(textBrowser.plainText)
clickItem(templatesView, template, 5, 5, 0, Qt.LeftButton)
waitFor("origTxt != str(textBrowser.plainText)", 2000)
displayedPlatforms = __getSupportedPlatforms__(str(textBrowser.plainText), template, True)[0]
clickButton(waitForObject("{text='Choose...' type='QPushButton' unnamed='1' visible='1'}"))
# don't check because project could exist
__createProjectSetNameAndPath__(os.path.expanduser("~"), 'untitled', False)
return displayedPlatforms
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment