Commit 93fb2928 authored by Christian Stenger's avatar Christian Stenger

Squish: Added new test cases/suite for welcome page

Change-Id: Id01582e881b8150a76336bb4f3ea6511c4bcd249
Done-with: Jan Kerekes
Done-with: Pavol Grainda
Reviewed-by: default avatarRobert Loehning <robert.loehning@digia.com>
parent 8b9cc83b
This diff is collapsed.
......@@ -12,9 +12,14 @@ def __handleProcessExited__(object, exitCode):
global processExited
processExited = True
def openQmakeProject(projectPath, targets=QtQuickConstants.Targets.DESKTOP):
def openQmakeProject(projectPath, targets = QtQuickConstants.Targets.DESKTOP, fromWelcome = False):
cleanUpUserFiles(projectPath)
invokeMenuItem("File", "Open File or Project...")
if fromWelcome:
mouseClick(waitForObject(":OpenProject_QStyleItem"), 5, 5, 0, Qt.LeftButton)
if not platform.system() == "Darwin":
waitFor("waitForObject(':fileNameEdit_QLineEdit').focus == True")
else:
invokeMenuItem("File", "Open File or Project...")
selectFromFileDialog(projectPath)
try:
# handle update generated files dialog
......@@ -78,8 +83,11 @@ def shadowBuildDir(path, project, qtVersion, debugVersion):
# because the Simulator target is added for some cases even when Simulator has not
# been set up inside Qt versions/Toolchains
# this list can be used in __chooseTargets__()
def __createProjectSelectType__(category, template):
invokeMenuItem("File", "New File or Project...")
def __createProjectSelectType__(category, template, fromWelcome = False):
if fromWelcome:
mouseClick(waitForObject(":CreateProject_QStyleItem"), 5, 5, 0, Qt.LeftButton)
else:
invokeMenuItem("File", "New File or Project...")
categoriesView = waitForObject("{type='QTreeView' name='templateCategoryView'}", 20000)
clickItem(categoriesView, "Projects." + category, 5, 5, 0, Qt.LeftButton)
templatesView = waitForObject("{name='templatesView' type='QListView'}", 20000)
......@@ -199,12 +207,14 @@ def createProject_Qt_Console(path, projectName, checks = True):
waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 10000)
__verifyFileCreation__(path, expectedFiles)
def createNewQtQuickApplication(workingDir, projectName = None, templateFile = None, targets = QtQuickConstants.Targets.DESKTOP, qtQuickVersion=1):
def createNewQtQuickApplication(workingDir, projectName = None, templateFile = None,
targets = QtQuickConstants.Targets.DESKTOP, qtQuickVersion=1,
fromWelcome=False):
if templateFile:
available = __createProjectSelectType__(" Applications", "Qt Quick Application (from Existing QML File)")
available = __createProjectSelectType__(" Applications", "Qt Quick Application (from Existing QML File)", fromWelcome)
else:
available = __createProjectSelectType__(" Applications", "Qt Quick %d Application (Built-in Elements)"
% qtQuickVersion)
% qtQuickVersion, fromWelcome)
projectName = __createProjectSetNameAndPath__(workingDir, projectName)
if templateFile:
baseLineEd = waitForObject("{type='Utils::BaseValidatingLineEdit' unnamed='1' visible='1'}", 20000)
......
import __builtin__
# appends to line, by typing <typeWhat> after <insertAfterLine> text into <codeArea> widget
def appendToLine(codeArea, insertAfterLine, typeWhat):
......@@ -50,3 +51,23 @@ def changeAutocompleteToManual():
selectFromCombo(":Behavior.completionTrigger_QComboBox", "Manually")
verifyEnabled(":Options.OK_QPushButton")
clickButton(waitForObject(":Options.OK_QPushButton"))
# wait and verify if object item exists/not exists
def checkIfObjectItemExists(object, item, timeout = 3000):
try:
waitForObjectItem(object, item, timeout)
return True
except:
return False
# this function creates a string holding the real name of a Qml Item
# param type defines the Qml type (support is limited)
# param container defines the container of the Qml item - can be a real or symbolic name
# param clip defines the state of the clip property (true/false)
# param text a string holding the complete text property (e.g. "text='example'", "text~='ex.*'")
def getQmlItem(type, container, clip, text=""):
if (container.startswith(":")):
container = "'%s'" % container
clip = ("%s" % __builtin__.bool(clip)).lower()
return ("{clip='%s' container=%s enabled='true' %s type='%s' unnamed='1' visible='true'}"
% (clip, container, text, type))
\ No newline at end of file
......@@ -453,3 +453,20 @@ def iterateQtVersions(keepOptionsOpen=False, additionalFunction=None, *argsForAd
return result, additionalResult
else:
return result
# set "Always Start Full Help" in "Tools" -> "Options..." -> "Help" -> "General"
def setAlwaysStartFullHelp():
invokeMenuItem("Tools", "Options...")
waitForObjectItem(":Options_QListView", "Help")
clickItem(":Options_QListView", "Help", 5, 5, 0, Qt.LeftButton)
clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "General")
selectFromCombo(":Startup.contextHelpComboBox_QComboBox", "Always Start Full Help")
clickButton(waitForObject(":Options.OK_QPushButton"))
def removePackagingDirectory(projectPath):
qtcPackaging = os.path.join(projectPath, "qtc_packaging")
if os.path.exists(qtcPackaging):
test.log("Removing old packaging directory '%s'" % qtcPackaging)
deleteDirIfExists(qtcPackaging)
else:
test.log("Couldn't remove packaging directory '%s' - did not exist." % qtcPackaging)
QT_PLATFORM_PLUGIN=nonesuch
AUT=qtcreator
CLASS=
CLASSPATH=
CWD=
ENVVARS=envvars
HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAP=../objects.map
TEST_CASES=tst_WELP01 tst_WELP02 tst_WELP03 tst_WELP04
VERSION=2
WRAPPERS=Qt
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
webPageContentLoadedValue = 0
gettingStartedText = getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Getting Started'")
# wait until help gets loaded
def webPageContentLoaded(obj, param):
global webPageContentLoadedValue
objectClass = str(obj.metaObject().className())
if objectClass in ("QWebPage", "Help::Internal::HelpViewer"):
webPageContentLoadedValue += 1
def clickItemVerifyHelpCombo(qmlItem, expectedHelpComboText, testDetails):
global gettingStartedText
webPageContentLoadedValue = 0
mouseClick(waitForObject(qmlItem), 5, 5, 0, Qt.LeftButton)
waitFor("webPageContentLoadedValue == 4", 5000)
test.compare(waitForObject(":Qt Creator_HelpSelector_QComboBox").currentText,
expectedHelpComboText, testDetails)
# select "Welcome" page from left toolbar again
switchViewTo(ViewConstants.WELCOME)
test.verify(checkIfObjectExists(gettingStartedText),
"Verifying: Getting Started topic is being displayed.")
def main():
global webPageContentLoadedValue, gettingStartedText
# open Qt Creator
startApplication("qtcreator" + SettingsPath)
installLazySignalHandler(":QWebPage","loadFinished(bool)", "webPageContentLoaded")
installLazySignalHandler(":*Qt Creator_Help::Internal::HelpViewer", "loadFinished(bool)",
"webPageContentLoaded")
setAlwaysStartFullHelp()
if not test.verify(checkIfObjectExists(gettingStartedText),
"Verifying: Qt Creator displays Welcome Page with Getting Started."):
mouseClick(waitForObject(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Getting Started'")), 5, 5, 0, Qt.LeftButton)
qmlItem = getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False, "text='User Guide'")
expectedText = "QtCreator : Qt Creator Manual"
testDetails = "Verifying: Help with Creator Documentation is being opened."
# select "User Guide" topic
clickItemVerifyHelpCombo(qmlItem, expectedText, testDetails)
# check "Online Community" link
test.verify(checkIfObjectExists(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Online Community'")),
"Verifying: Link to Qt forums exists.")
test.verify(checkIfObjectExists(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Labs'")),
"Verifying: Link to Qt Labs – Developers blog exists.")
qmlItem = getQmlItem("Text", ":Qt Creator_QDeclarativeView", False, "text='IDE Overview'")
expectedText = "QtCreator : IDE Overview"
testDetails = "Verifying: Help with IDE Overview topic is being opened."
# select "IDE Overview"
clickItemVerifyHelpCombo(qmlItem, expectedText, testDetails)
qmlItem = getQmlItem("Text", ":Qt Creator_QDeclarativeView", False, "text='User Interface'")
expectedText = "QtCreator : User Interface"
testDetails = "Verifying: Help with User Interface topic is being opened."
# select "User interface"
clickItemVerifyHelpCombo(qmlItem, expectedText, testDetails)
# select "Building and Running an Example Application"
webPageContentLoadedValue = 0
mouseClick(waitForObject(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Building and Running an Example Application'")),
5, 5, 0, Qt.LeftButton)
waitFor("webPageContentLoadedValue == 4", 5000)
checkPattern = "QtCreator : Building and Running an Example( Application)?"
checkText = str(waitForObject(":Qt Creator_HelpSelector_QComboBox").currentText)
if not test.verify(re.search(checkPattern, checkText),
"Verifying: Building and Running an Example is opened."):
test.fail("Pattern does not match: '%s', text found in QComboBox is: "
"'%s'" % (checkPattern, checkText))
# select "Welcome" page from left toolbar again
switchViewTo(ViewConstants.WELCOME)
test.verify(checkIfObjectExists(gettingStartedText),
"Verifying: Getting Started topic is being displayed.")
# select "Start Developing"
mouseClick(waitForObject(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Start Developing'")), 5, 5, 0, Qt.LeftButton)
test.verify(checkIfObjectExists(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Tutorials'")),
"Verifying: Tutorials are opened in Welcome Page.")
# exit Qt Creator
invokeMenuItem("File", "Exit")
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
def main():
# prepare example project
sourceExample = os.path.join(sdkPath, "Examples", "4.7", "declarative", "animation", "basics",
"property-animation")
if not neededFilePresent(sourceExample):
return
# open Qt Creator
startApplication("qtcreator" + SettingsPath)
if not test.verify(checkIfObjectExists(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Getting Started'")),
"Verifying: Qt Creator displays Welcome Page with Getting Started."):
mouseClick(waitForObject(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Getting Started'")), 5, 5, 0, Qt.LeftButton)
# select "Develop" topic
mouseClick(waitForObject(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Develop'")), 5, 5, 0, Qt.LeftButton)
sessionsText = getQmlItem("Text", ":Qt Creator_QDeclarativeView", False, "text='Sessions'")
recentProjText = getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Recent Projects'")
test.verify(checkIfObjectExists(sessionsText) and checkIfObjectExists(recentProjText),
"Verifying: 'Develop' with 'Recently used sessions' and "
"'Recently used Projects' is being opened.")
# select "Create Project" and try to create a new project.
# create Qt Quick application from "Welcome" page -> "Develop" tab
createNewQtQuickApplication(tempDir(), "SampleApp", fromWelcome = True)
waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}",
"sourceFilesRefreshed(QStringList)")
test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
" text='SampleApp' type='QModelIndex'}"),
"Verifying: The project is opened in 'Edit' mode after configuring.")
# go to "Welcome page" -> "Develop" topic again.
switchViewTo(ViewConstants.WELCOME)
test.verify(checkIfObjectExists(sessionsText) and checkIfObjectExists(recentProjText),
"Verifying: 'Develop' with 'Sessions' and 'Recent Projects' is opened.")
# select "Open project" and select any project.
# copy example project to temp directory
examplePath = os.path.join(prepareTemplate(sourceExample), "propertyanimation.pro")
# open example project from "Welcome" page -> "Develop" tab
openQmakeProject(examplePath, fromWelcome = True)
waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}",
"sourceFilesRefreshed(QStringList)")
test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
" text='propertyanimation' type='QModelIndex'}"),
"Verifying: The project is opened in 'Edit' mode after configuring.")
# go to "Welcome page" -> "Develop" again and check if there is an information about
# recent projects in "Recent Projects".
switchViewTo(ViewConstants.WELCOME)
test.verify(checkIfObjectExists(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='propertyanimation'")) and
checkIfObjectExists(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='SampleApp'")),
"Verifying: 'Develop' is opened and the recently created and "
"opened project can be seen in 'Recent Projects'.")
# exit Qt Creator
invokeMenuItem("File", "Exit")
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
webPageContentLoadedValue = 0
# wait until help gets loaded
def webPageContentLoaded(obj, param):
global webPageContentLoadedValue
objectClass = str(obj.metaObject().className())
if objectClass in ("QWebPage", "Help::Internal::HelpViewer"):
webPageContentLoadedValue += 1
def isLoaded():
if platform.system() == "Darwin":
return webPageContentLoadedValue == 1
else:
return webPageContentLoadedValue == 3
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
def main():
global webPageContentLoadedValue
if platform.system() in ('Microsoft', 'Windows'):
test.log("Test case is currently disabled on Windows because it constantly crashes the AUT")
return
# open Qt Creator
startApplication("qtcreator" + SettingsPath)
installLazySignalHandler(":QWebPage","loadFinished(bool)", "webPageContentLoaded")
installLazySignalHandler(":*Qt Creator_Help::Internal::HelpViewer", "loadFinished(bool)",
"webPageContentLoaded")
setAlwaysStartFullHelp()
if not test.verify(checkIfObjectExists(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Getting Started'")),
"Verifying: Qt Creator displays Welcome Page with Getting Started."):
mouseClick(waitForObject(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Getting Started'")), 5, 5, 0, Qt.LeftButton)
# select "Examples" topic
mouseClick(waitForObject(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Examples'")), 5, 5, 0, Qt.LeftButton)
test.verify(checkIfObjectExists(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Examples'")),
"Verifying: 'Examples' topic is opened and the examples are shown.")
# select an example and run example
webPageContentLoadedValue = 0
cleanUpUserFiles(sdkPath + "/Examples/4.7/opengl/2dpainting/2dpainting.pro")
removePackagingDirectory(sdkPath + "/Examples/4.7/opengl/2dpainting")
mouseClick(waitForObject(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Search in Examples...'")), 5, 5, 0, Qt.LeftButton)
searchTutsAndExmpl = getQmlItem("TextInput", ":Qt Creator_QDeclarativeView", False)
replaceEditorContent(waitForObject(searchTutsAndExmpl), "qwerty")
test.verify(checkIfObjectExists("{clip='true' container=':Qt Creator_QDeclarativeView' "
"enabled='true' id='captionItem' type='Text' unnamed='1' "
"visible='true'}", False),
"Verifying: 'Tutorials' topic is opened and nothing is shown.")
replaceEditorContent(waitForObject(searchTutsAndExmpl), "2d painting")
twoDPainting = getQmlItem("Text", ":Qt Creator_QDeclarativeView", True, "text~='2D Painting.*'")
test.verify(checkIfObjectExists(twoDPainting),
"Verifying: Text and Video tutorials are shown.")
mouseClick(waitForObject(twoDPainting), 5, 5, 0, Qt.LeftButton)
handlePackagingMessageBoxes()
waitFor("isLoaded()", 5000)
test.verify("2D Painting Example" in str(waitForObject(":Qt Creator_HelpSelector_QComboBox").currentText),
"Verifying: The example application is opened.")
switchViewTo(ViewConstants.EDIT)
test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"
" text='2dpainting' type='QModelIndex'}"),
"Verifying: The project is shown in 'Edit' mode.")
openItemContextMenu(waitForObject(":Qt Creator_Utils::NavigationTreeView"),
"2dpainting", 5, 5, 0)
activateItem(waitForObjectItem(":Qt Creator.Project.Menu.Project_QMenu",
'Close Project "2dpainting"'))
# close example and go to "Welcome" page -> "Examples" again and choose another example
webPageContentLoadedValue = 0
switchViewTo(ViewConstants.WELCOME)
cleanUpUserFiles(sdkPath + "/Examples/4.7/itemviews/addressbook/addressbook.pro")
removePackagingDirectory(sdkPath + "/Examples/4.7/itemviews/addressbook")
replaceEditorContent(waitForObject(searchTutsAndExmpl),
"address book")
addressBook = getQmlItem("Text", ":Qt Creator_QDeclarativeView", True, "text~='Address Book.*'")
test.verify(checkIfObjectExists(addressBook),
"Verifying: Text and Video tutorials are shown.")
mouseClick(waitForObject(addressBook), 5, 5, 0, Qt.LeftButton)
handlePackagingMessageBoxes()
waitFor("isLoaded()", 5000)
test.verify("Address Book Example" in str(waitForObject(":Qt Creator_HelpSelector_QComboBox").currentText),
"Verifying: First example is closed and another application is opened.")
# close second example application
switchViewTo(ViewConstants.EDIT)
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.")
openItemContextMenu(waitForObject(":Qt Creator_Utils::NavigationTreeView"),
"addressbook", 5, 5, 0)
activateItem(waitForObjectItem(":Qt Creator.Project.Menu.Project_QMenu",
'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
removePackagingDirectory(sdkPath + "/Examples/4.7/opengl/2dpainting")
removePackagingDirectory(sdkPath + "/Examples/4.7/itemviews/addressbook")
# exit Qt Creator
invokeMenuItem("File", "Exit")
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
def main():
# open Qt Creator
startApplication("qtcreator" + SettingsPath)
if not test.verify(checkIfObjectExists(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Getting Started'")),
"Verifying: Qt Creator displays Welcome Page with Getting Started."):
mouseClick(waitForObject(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Getting Started'")), 5, 5, 0, Qt.LeftButton)
# select "Tutorials" topic
mouseClick(waitForObject(getQmlItem("LinkedText", ":Qt Creator_QDeclarativeView", False,
"text='Tutorials'")), 5, 5, 0, Qt.LeftButton)
mouseClick(waitForObject(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Search in Tutorials...'")), 5, 5, 0, Qt.LeftButton)
searchTutsAndExmpl = getQmlItem("TextInput", ":Qt Creator_QDeclarativeView", False)
replaceEditorContent(waitForObject(searchTutsAndExmpl), "qwerty")
test.verify(checkIfObjectExists(getQmlItem("Text", ":Qt Creator_QDeclarativeView", False,
"text='Tutorials'")) and
checkIfObjectExists("{clip='true' container=':Qt Creator_QDeclarativeView' "
"enabled='true' id='captionItem' type='Text' unnamed='1' "
"visible='true'}", False),
"Verifying: 'Tutorials' topic is opened and nothing is shown.")
replaceEditorContent(waitForObject(searchTutsAndExmpl),
"building and running an example application")
bldRunExmpl = getQmlItem("Text", ":Qt Creator_QDeclarativeView", True,
"text='Building and Running an Example Application'")
test.verify(checkIfObjectExists(bldRunExmpl), "Verifying: Text and Video tutorials are shown.")
# select a text tutorial
mouseClick(waitForObject(bldRunExmpl), 5, 5, 0, Qt.LeftButton)
test.verify(checkIfObjectExists(":Qt Creator.Go to Help Mode_QToolButton") and
checkIfObjectExists(":DebugModeWidget.Debugger Toolbar_QDockWidget", False) and
checkIfObjectExists(":Qt Creator.Analyzer Toolbar_QDockWidget", False),
"Verifying: The tutorial is opened and located to the right part. "
"The view is in 'Edit' mode.")
# go to "Welcome" page -> "Tutorials" topic again and check the video tutorial link
switchViewTo(ViewConstants.WELCOME)
replaceEditorContent(waitForObject(searchTutsAndExmpl), "meet qt quick")
test.verify(checkIfObjectExists(getQmlItem("Text", ":Qt Creator_QDeclarativeView", True,
"text='Meet Qt Quick'")),
"Verifying: Link to the video tutorial exists.")
# exit Qt Creator
invokeMenuItem("File", "Exit")
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