2022-03-22 21:17:19 +01:00
|
|
|
# Copyright (C) 2022 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2013-05-15 13:17:33 +02:00
|
|
|
|
2012-09-18 12:48:40 +02:00
|
|
|
source("../../shared/qtcreator.py")
|
|
|
|
|
source("../../shared/suites_qtta.py")
|
|
|
|
|
|
|
|
|
|
def handlePackagingMessageBoxes():
|
|
|
|
|
if platform.system() == "Darwin":
|
|
|
|
|
messageBox = "{type='QMessageBox' unnamed='1' visible='1'}"
|
|
|
|
|
else:
|
|
|
|
|
messageBox = ("{type='QMessageBox' unnamed='1' visible='1' "
|
|
|
|
|
"windowTitle='Add Packaging Files to Project'}")
|
|
|
|
|
while (True):
|
|
|
|
|
try:
|
|
|
|
|
waitForObject(messageBox, 3000)
|
|
|
|
|
clickButton(waitForObject("{text='Yes' type='QPushButton' unnamed='1' visible='1' "
|
|
|
|
|
"window=%s}" % messageBox))
|
|
|
|
|
except:
|
|
|
|
|
break
|
|
|
|
|
|
2023-07-04 10:36:24 +02:00
|
|
|
|
|
|
|
|
def openExample(examplesLineEdit, input, exampleRegex, exampleName, waitForChildCount=0):
|
2017-02-07 13:11:07 +01:00
|
|
|
replaceEditorContent(examplesLineEdit, input)
|
2023-10-11 13:11:39 +02:00
|
|
|
listView = waitForObject("{type='QListView' name='AllItemsView' visible='1' "
|
2017-02-07 13:11:07 +01:00
|
|
|
"window=':Qt Creator_Core::Internal::MainWindow'}")
|
2023-10-11 13:11:39 +02:00
|
|
|
filterModel = __childrenOfType__(listView, 'QSortFilterProxyModel')
|
|
|
|
|
if len(filterModel) != 1:
|
|
|
|
|
test.fatal("Failed to find filter proxy model.")
|
|
|
|
|
return None
|
2023-07-04 10:36:24 +02:00
|
|
|
|
2023-10-11 13:11:39 +02:00
|
|
|
filterModel = filterModel[0]
|
|
|
|
|
if waitForChildCount > 0:
|
|
|
|
|
waitFor("filterModel.rowCount() == waitForChildCount", 3000)
|
2023-07-04 10:36:24 +02:00
|
|
|
|
2022-02-14 17:03:11 +01:00
|
|
|
waitFor('findExampleOrTutorial(listView, exampleRegex) is not None', 3000)
|
|
|
|
|
example = findExampleOrTutorial(listView, exampleRegex, True)
|
2017-02-07 13:11:07 +01:00
|
|
|
if test.verify(example is not None, "Verifying: Example (%s) is shown." % exampleName):
|
2023-10-11 13:11:39 +02:00
|
|
|
mouseClick(waitForObjectItem(listView, str(example.text)))
|
2017-02-07 13:11:07 +01:00
|
|
|
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
|
|
|
|
|
|
2012-09-18 12:48:40 +02:00
|
|
|
def main():
|
|
|
|
|
# open Qt Creator
|
2018-08-22 14:37:34 +02:00
|
|
|
startQC()
|
2013-02-22 14:31:39 +01:00
|
|
|
if not startedWithoutPluginError():
|
|
|
|
|
return
|
2016-08-19 12:56:03 +02:00
|
|
|
qchs = []
|
2023-02-22 13:49:54 +01:00
|
|
|
for p in QtPath.getPaths(QtPath.DOCS):
|
2014-07-24 12:33:36 +02:00
|
|
|
qchs.extend([os.path.join(p, "qtopengl.qch"), os.path.join(p, "qtwidgets.qch")])
|
2013-06-18 10:27:42 +02:00
|
|
|
addHelpDocumentation(qchs)
|
2017-11-28 15:29:37 +01:00
|
|
|
setFixedHelpViewer(HelpViewer.HELPMODE)
|
2022-02-14 17:03:11 +01:00
|
|
|
wsButtonFrame, wsButtonLabel = getWelcomeScreenSideBarButton('Get Started')
|
2017-02-07 13:11:07 +01:00
|
|
|
if not test.verify(all((wsButtonFrame, wsButtonLabel)),
|
2012-09-18 12:48:40 +02:00
|
|
|
"Verifying: Qt Creator displays Welcome Page with Getting Started."):
|
2014-07-24 12:33:36 +02:00
|
|
|
test.fatal("Something's wrong - leaving test.")
|
|
|
|
|
invokeMenuItem("File", "Exit")
|
|
|
|
|
return
|
2012-09-18 12:48:40 +02:00
|
|
|
# select "Examples" topic
|
2018-07-10 13:57:16 +02:00
|
|
|
switchToSubMode('Examples')
|
2022-02-14 17:03:11 +01:00
|
|
|
expect = (("QListView", "unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'",
|
2017-02-07 13:11:07 +01:00
|
|
|
"examples list"),
|
|
|
|
|
("QLineEdit", "placeholderText='Search in Examples...'", "examples search line edit"),
|
2018-04-16 14:40:59 +02:00
|
|
|
("QComboBox", "currentText~='.*Qt.*' visible='1'", "Qt version combo box"))
|
2017-02-07 13:11:07 +01:00
|
|
|
search = "{type='%s' %s}"
|
|
|
|
|
test.verify(all(map(checkIfObjectExists, (search % (exp[0], exp[1]) for exp in expect))),
|
2012-09-18 12:48:40 +02:00
|
|
|
"Verifying: 'Examples' topic is opened and the examples are shown.")
|
2017-02-07 13:11:07 +01:00
|
|
|
|
|
|
|
|
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")
|
2023-10-11 13:11:39 +02:00
|
|
|
listView = waitForObject("{type='QListView' name='AllItemsView'}")
|
2022-02-14 17:03:11 +01:00
|
|
|
waitFor('findExampleOrTutorial(listView, ".*") is None', 3000)
|
|
|
|
|
example = findExampleOrTutorial(listView, ".*", True)
|
2017-02-07 13:11:07 +01:00
|
|
|
test.verify(example is None, "Verifying: No example is shown.")
|
|
|
|
|
|
2022-03-22 21:17:19 +01:00
|
|
|
proFiles = [os.path.join(p, "opengl", "2dpainting", "2dpainting.pro")
|
2023-02-22 13:49:54 +01:00
|
|
|
for p in QtPath.getPaths(QtPath.EXAMPLES)]
|
2014-07-24 12:33:36 +02:00
|
|
|
cleanUpUserFiles(proFiles)
|
|
|
|
|
for p in proFiles:
|
|
|
|
|
removePackagingDirectory(os.path.dirname(p))
|
2017-02-07 13:11:07 +01:00
|
|
|
|
|
|
|
|
example = openExample(examplesLineEdit, "2d painting", "2D Painting.*", "2D Painting Example")
|
|
|
|
|
if example is not None:
|
|
|
|
|
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")
|
2018-07-10 14:24:27 +02:00
|
|
|
waitFor("navTree.model().rowCount(navTree.rootIndex()) == 0", 2000)
|
2017-02-07 13:11:07 +01:00
|
|
|
test.verify(not checkIfObjectItemExists(":Qt Creator_Utils::NavigationTreeView", "2dpainting"),
|
|
|
|
|
"Verifying: The first example is closed.")
|
2013-06-18 10:27:42 +02:00
|
|
|
# clean up created packaging directories
|
2014-07-24 12:33:36 +02:00
|
|
|
for p in proFiles:
|
|
|
|
|
removePackagingDirectory(os.path.dirname(p))
|
2013-06-18 10:27:42 +02:00
|
|
|
|
2014-07-24 12:33:36 +02:00
|
|
|
# go to "Welcome" page and choose another example
|
2012-09-18 12:48:40 +02:00
|
|
|
switchViewTo(ViewConstants.WELCOME)
|
2022-03-22 21:17:19 +01:00
|
|
|
proFiles = [os.path.join(p, "widgets", "itemviews", "addressbook", "addressbook.pro")
|
2023-02-22 13:49:54 +01:00
|
|
|
for p in QtPath.getPaths(QtPath.EXAMPLES)]
|
2014-07-24 12:33:36 +02:00
|
|
|
cleanUpUserFiles(proFiles)
|
|
|
|
|
for p in proFiles:
|
|
|
|
|
removePackagingDirectory(os.path.dirname(p))
|
2017-02-07 13:11:07 +01:00
|
|
|
examplesLineEdit = waitForObject(search %(expect[1][0], expect[1][1]))
|
2018-03-21 22:21:56 +01:00
|
|
|
example = openExample(examplesLineEdit, "address book", "(0000 )?Address Book.*",
|
2023-07-04 10:36:24 +02:00
|
|
|
"Address Book Example", 3)
|
2017-02-07 13:11:07 +01:00
|
|
|
if example is not None:
|
|
|
|
|
# close second example application
|
|
|
|
|
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")
|
2018-07-10 14:24:27 +02:00
|
|
|
waitFor("navTree.model().rowCount(navTree.rootIndex()) == 0", 2000)
|
2017-02-07 13:11:07 +01:00
|
|
|
test.verify(not checkIfObjectItemExists(":Qt Creator_Utils::NavigationTreeView", "addressbook"),
|
|
|
|
|
"Verifying: The second example is closed.")
|
2012-09-18 12:48:40 +02:00
|
|
|
# clean up created packaging directories
|
2014-07-24 12:33:36 +02:00
|
|
|
for p in proFiles:
|
|
|
|
|
removePackagingDirectory(os.path.dirname(p))
|
2012-09-18 12:48:40 +02:00
|
|
|
# exit Qt Creator
|
|
|
|
|
invokeMenuItem("File", "Exit")
|