Squish: Adapt tst_WELP03 to latest Welcome page changes

Change-Id: Ia62813cf94b31a82fedb191eaf11f752d1d30bf0
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
Christian Stenger
2017-02-07 13:11:07 +01:00
parent 9f6f5bfee2
commit e03132f517

View File

@@ -40,6 +40,33 @@ def handlePackagingMessageBoxes():
except: except:
break break
def findExample(tableView, exampleRegex, verbose=False):
model = tableView.model()
children = [ch for ch in object.children(tableView) if className(ch) == 'QModelIndex']
for child in children:
if re.match(exampleRegex, str(child.text)):
if verbose:
test.log("Returning matching example '%s'." % str(child.text), exampleRegex)
return child
return None
def openExample(examplesLineEdit, input, exampleRegex, exampleName):
replaceEditorContent(examplesLineEdit, input)
tableView = waitForObject("{type='QTableView' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}")
waitFor('findExample(tableView, exampleRegex) is not None', 3000)
example = findExample(tableView, exampleRegex, True)
if test.verify(example is not None, "Verifying: Example (%s) is shown." % exampleName):
mouseClick(example)
handlePackagingMessageBoxes()
helpWidget = waitForObject(":Help Widget_Help::Internal::HelpWidget")
test.verify(waitFor('exampleName in str(helpWidget.windowTitle)', 5000),
"Verifying: The example application is opened inside Help.")
sendEvent("QCloseEvent", helpWidget)
# assume the correct kit is selected, hit Configure Project
clickButton(waitForObject(":Qt Creator.Configure Project_QPushButton"))
return example
def main(): def main():
welcomePage = ":Qt Creator.WelcomePage_QQuickWidget" welcomePage = ":Qt Creator.WelcomePage_QQuickWidget"
# open Qt Creator # open Qt Creator
@@ -51,54 +78,50 @@ def main():
qchs.extend([os.path.join(p, "qtopengl.qch"), os.path.join(p, "qtwidgets.qch")]) qchs.extend([os.path.join(p, "qtopengl.qch"), os.path.join(p, "qtwidgets.qch")])
addHelpDocumentation(qchs) addHelpDocumentation(qchs)
setAlwaysStartFullHelp() setAlwaysStartFullHelp()
getStartedNow = getQmlItem("Button", welcomePage, False, wsButtonFrame, wsButtonLabel = getWelcomeScreenSideBarButton('Get Started Now')
"text='Get Started Now' id='gettingStartedButton'") if not test.verify(all((wsButtonFrame, wsButtonLabel)),
if not test.verify(checkIfObjectExists(getStartedNow),
"Verifying: Qt Creator displays Welcome Page with Getting Started."): "Verifying: Qt Creator displays Welcome Page with Getting Started."):
test.fatal("Something's wrong - leaving test.") test.fatal("Something's wrong - leaving test.")
invokeMenuItem("File", "Exit") invokeMenuItem("File", "Exit")
return return
# select "Examples" topic # select "Examples" topic
mouseClick(waitForObject(getQmlItem("Button", welcomePage, False, "text='Examples'")), wsButtonFrame, wsButtonLabel = getWelcomeScreenSideBarButton('Examples')
5, 5, 0, Qt.LeftButton) if all((wsButtonFrame, wsButtonLabel)):
test.verify(checkIfObjectExists(getQmlItem("Text", welcomePage, False, "text='Examples'")), mouseClick(wsButtonLabel)
expect = (("QTableView", "unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'",
"examples list"),
("QLineEdit", "placeholderText='Search in Examples...'", "examples search line edit"),
("QComboBox", "text~='.*Qt.*' visible='1'", "Qt version combo box"))
search = "{type='%s' %s}"
test.verify(all(map(checkIfObjectExists, (search % (exp[0], exp[1]) for exp in expect))),
"Verifying: 'Examples' topic is opened and the examples are shown.") "Verifying: 'Examples' topic is opened and the examples are shown.")
examplesLineEdit = waitForObject(search % (expect[1][0], expect[1][1]))
mouseClick(examplesLineEdit)
combo = waitForObject(search % (expect[2][0], expect[2][1]))
test.log("Using examples from Kit %s." % str(combo.currentText))
replaceEditorContent(examplesLineEdit, "qwerty")
tableView = waitForObject(search % (expect[0][0], expect[0][1]))
waitFor('findExample(tableView, ".*") is None', 3000)
example = findExample(tableView, ".*", True)
test.verify(example is None, "Verifying: No example is shown.")
proFiles = map(lambda p: os.path.join(p, "opengl", "2dpainting", "2dpainting.pro"), proFiles = map(lambda p: os.path.join(p, "opengl", "2dpainting", "2dpainting.pro"),
Qt5Path.getPaths(Qt5Path.EXAMPLES)) Qt5Path.getPaths(Qt5Path.EXAMPLES))
cleanUpUserFiles(proFiles) cleanUpUserFiles(proFiles)
for p in proFiles: for p in proFiles:
removePackagingDirectory(os.path.dirname(p)) removePackagingDirectory(os.path.dirname(p))
examplesLineEdit = getQmlItem("TextField", welcomePage,
False, "id='lineEdit' placeholderText='Search in Examples...'") example = openExample(examplesLineEdit, "2d painting", "2D Painting.*", "2D Painting Example")
mouseClick(waitForObject(examplesLineEdit), 5, 5, 0, Qt.LeftButton) if example is not None:
test.log("Using examples from Kit %s." test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
% (waitForObject(getQmlItem("ComboBox", welcomePage, " text='2dpainting' type='QModelIndex'}"),
False, "id='comboBox'")).currentText)) "Verifying: The project is shown in 'Edit' mode.")
replaceEditorContent(waitForObject(examplesLineEdit), "qwerty") invokeContextMenuOnProject('2dpainting', 'Close Project "2dpainting"')
test.verify(checkIfObjectExists(getQmlItem("Delegate", welcomePage, navTree = waitForObject(":Qt Creator_Utils::NavigationTreeView")
False, "id='delegate' radius='0' caption~='.*'"), res = waitFor("navTree.model().rowCount(navTree.rootIndex()) == 0", 2000)
False), "Verifying: No example is shown.") test.verify(not checkIfObjectItemExists(":Qt Creator_Utils::NavigationTreeView", "2dpainting"),
replaceEditorContent(waitForObject(examplesLineEdit), "2d painting") "Verifying: The first example is closed.")
twoDPainting = getQmlItem("Delegate", welcomePage,
False, "id='delegate' radius='0' caption~='2D Painting.*'")
test.verify(checkIfObjectExists(twoDPainting),
"Verifying: Example (2D Painting) is shown.")
mouseClick(waitForObject(twoDPainting), 5, 5, 0, Qt.LeftButton)
handlePackagingMessageBoxes()
helpWidget = waitForObject(":Help Widget_Help::Internal::HelpWidget")
test.verify(waitFor('"2D Painting Example" in str(helpWidget.windowTitle)', 5000),
"Verifying: The example application is opened inside Help.")
sendEvent("QCloseEvent", helpWidget)
# assume the correct kit is selected, hit Configure Project
clickButton(waitForObject(":Qt Creator.Configure Project_QPushButton"))
test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
" text='2dpainting' type='QModelIndex'}"),
"Verifying: The project is shown in 'Edit' mode.")
invokeContextMenuOnProject('2dpainting', 'Close Project "2dpainting"')
navTree = waitForObject(":Qt Creator_Utils::NavigationTreeView")
res = waitFor("navTree.model().rowCount(navTree.rootIndex()) == 0", 2000)
test.verify(not checkIfObjectItemExists(":Qt Creator_Utils::NavigationTreeView", "2dpainting"),
"Verifying: The first example is closed.")
# clean up created packaging directories # clean up created packaging directories
for p in proFiles: for p in proFiles:
removePackagingDirectory(os.path.dirname(p)) removePackagingDirectory(os.path.dirname(p))
@@ -110,31 +133,21 @@ def main():
cleanUpUserFiles(proFiles) cleanUpUserFiles(proFiles)
for p in proFiles: for p in proFiles:
removePackagingDirectory(os.path.dirname(p)) removePackagingDirectory(os.path.dirname(p))
examplesLineEditWidget = waitForObject(examplesLineEdit) examplesLineEdit = waitForObject(search %(expect[1][0], expect[1][1]))
mouseClick(examplesLineEditWidget) example = openExample(examplesLineEdit, "address book", "Address Book.*",
replaceEditorContent(examplesLineEditWidget, "address book") "Address Book Example")
addressBook = getQmlItem("Delegate", welcomePage, if example is not None:
False, "id='delegate' radius='0' caption~='Address Book.*'") # close second example application
test.verify(checkIfObjectExists(addressBook), "Verifying: Example (address book) is shown.") test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
mouseClick(waitForObject(addressBook), 5, 5, 0, Qt.LeftButton) " text='propertyanimation' type='QModelIndex'}", False) and
handlePackagingMessageBoxes() checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
helpWidget = waitForObject(":Help Widget_Help::Internal::HelpWidget") " text='addressbook' type='QModelIndex'}"),
test.verify(waitFor('"Address Book Example" in str(helpWidget.windowTitle)', 5000), "Verifying: The project is shown in 'Edit' mode while old project isn't.")
"Verifying: The example application is opened inside Help.") invokeContextMenuOnProject('addressbook', 'Close Project "addressbook"')
sendEvent("QCloseEvent", helpWidget) navTree = waitForObject(":Qt Creator_Utils::NavigationTreeView")
# assume the correct kit is selected, hit Configure Project res = waitFor("navTree.model().rowCount(navTree.rootIndex()) == 0", 2000)
clickButton(waitForObject(":Qt Creator.Configure Project_QPushButton")) test.verify(not checkIfObjectItemExists(":Qt Creator_Utils::NavigationTreeView", "addressbook"),
# close second example application "Verifying: The second example is closed.")
test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
" text='propertyanimation' type='QModelIndex'}", False) and
checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
" text='addressbook' type='QModelIndex'}"),
"Verifying: The project is shown in 'Edit' mode while old project isn't.")
invokeContextMenuOnProject('addressbook', 'Close Project "addressbook"')
navTree = waitForObject(":Qt Creator_Utils::NavigationTreeView")
res = waitFor("navTree.model().rowCount(navTree.rootIndex()) == 0", 2000)
test.verify(not checkIfObjectItemExists(":Qt Creator_Utils::NavigationTreeView", "addressbook"),
"Verifying: The second example is closed.")
# clean up created packaging directories # clean up created packaging directories
for p in proFiles: for p in proFiles:
removePackagingDirectory(os.path.dirname(p)) removePackagingDirectory(os.path.dirname(p))