forked from qt-creator/qt-creator
Squish: Adapt tst_WELP02 to latest Welcome page changes
Additionally move common used code for interacting with the Welcome page into separate file. Change-Id: If863ae529c7c81d095f310f0a34926b324c77fa8 Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
@@ -34,10 +34,11 @@ def openQbsProject(projectPath):
|
||||
def openQmakeProject(projectPath, targets=Targets.desktopTargetClasses(), fromWelcome=False):
|
||||
cleanUpUserFiles(projectPath)
|
||||
if fromWelcome:
|
||||
welcomePage = ":Qt Creator.WelcomePage_QQuickWidget"
|
||||
mouseClick(waitForObject("{clip='false' container='%s' enabled='true' text='Open Project' "
|
||||
"type='Button' unnamed='1' visible='true'}" % welcomePage),
|
||||
5, 5, 0, Qt.LeftButton)
|
||||
wsButtonFrame, wsButtonLabel = getWelcomeScreenMainButton('Open Project')
|
||||
if not all((wsButtonFrame, wsButtonLabel)):
|
||||
test.fatal("Could not find 'Open Project' button on Welcome Page.")
|
||||
return []
|
||||
mouseClick(wsButtonLabel)
|
||||
else:
|
||||
invokeMenuItem("File", "Open File or Project...")
|
||||
selectFromFileDialog(projectPath)
|
||||
@@ -82,10 +83,11 @@ def openCmakeProject(projectPath, buildDir):
|
||||
# this list can be used in __chooseTargets__()
|
||||
def __createProjectOrFileSelectType__(category, template, fromWelcome = False, isProject=True):
|
||||
if fromWelcome:
|
||||
welcomePage = ":Qt Creator.WelcomePage_QQuickWidget"
|
||||
mouseClick(waitForObject("{clip='false' container='%s' enabled='true' text='New Project' "
|
||||
"type='Button' unnamed='1' visible='true'}" % welcomePage),
|
||||
5, 5, 0, Qt.LeftButton)
|
||||
wsButtonFrame, wsButtonLabel = getWelcomeScreenMainButton("New Project")
|
||||
if not all((wsButtonFrame, wsButtonLabel)):
|
||||
test.fatal("Could not find 'New Project' button on Welcome Page")
|
||||
return []
|
||||
mouseClick(wsButtonLabel)
|
||||
else:
|
||||
invokeMenuItem("File", "New File or Project...")
|
||||
categoriesView = waitForObject(":New.templateCategoryView_QTreeView")
|
||||
|
@@ -52,6 +52,7 @@ source("../../shared/project_explorer.py")
|
||||
source("../../shared/hook_utils.py")
|
||||
source("../../shared/debugger.py")
|
||||
source("../../shared/clang.py")
|
||||
source("../../shared/welcome.py")
|
||||
source("../../shared/workarounds.py") # include this at last
|
||||
|
||||
# ATTENTION: if a test case calls startApplication("qtcreator...") for several times this
|
||||
|
53
tests/system/shared/welcome.py
Normal file
53
tests/system/shared/welcome.py
Normal file
@@ -0,0 +1,53 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (C) 2017 The Qt Company Ltd.
|
||||
# Contact: https://www.qt.io/licensing/
|
||||
#
|
||||
# This file is part of Qt Creator.
|
||||
#
|
||||
# Commercial License Usage
|
||||
# Licensees holding valid commercial Qt licenses may use this file in
|
||||
# accordance with the commercial license agreement provided with the
|
||||
# Software or, alternatively, in accordance with the terms contained in
|
||||
# a written agreement between you and The Qt Company. For licensing terms
|
||||
# and conditions see https://www.qt.io/terms-conditions. For further
|
||||
# information use the contact form at https://www.qt.io/contact-us.
|
||||
#
|
||||
# GNU General Public License Usage
|
||||
# Alternatively, this file may be used under the terms of the GNU
|
||||
# General Public License version 3 as published by the Free Software
|
||||
# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
# included in the packaging of this file. Please review the following
|
||||
# information to ensure the GNU General Public License requirements will
|
||||
# be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
def __getWelcomeScreenButtonHelper__(buttonLabel, widgetWithQFrames):
|
||||
frames = [child for child in object.children(widgetWithQFrames) if className(child) == 'QFrame']
|
||||
for frame in frames:
|
||||
label = getChildByClass(frame, 'QLabel')
|
||||
if str(label.text) == buttonLabel:
|
||||
return frame, label
|
||||
return None, None
|
||||
|
||||
def getWelcomeScreenSideBarButton(buttonLabel):
|
||||
sideBar = waitForObject("{type='Welcome::Internal::SideBar' unnamed='1' "
|
||||
"window=':Qt Creator_Core::Internal::MainWindow'}")
|
||||
return __getWelcomeScreenButtonHelper__(buttonLabel, sideBar)
|
||||
|
||||
def getWelcomeScreenMainButton(buttonLabel):
|
||||
stackedWidget = waitForObject("{type='QWidget' unnamed='1' visible='1' "
|
||||
"leftWidget={type='QWidget' unnamed='1' visible='1' "
|
||||
"leftWidget={type='Welcome::Internal::SideBar' unnamed='1' "
|
||||
"window=':Qt Creator_Core::Internal::MainWindow'}}}")
|
||||
currentStackWidget = stackedWidget.currentWidget()
|
||||
return __getWelcomeScreenButtonHelper__(buttonLabel, currentStackWidget)
|
||||
|
||||
def getWelcomeTreeView(treeViewLabel):
|
||||
try:
|
||||
return waitForObject("{aboveWidget={text='%s' type='QLabel' unnamed='1' visible='1' "
|
||||
"window=':Qt Creator_Core::Internal::MainWindow'} "
|
||||
"type='QTreeView' unnamed='1' visible='1'}" % treeViewLabel)
|
||||
except:
|
||||
return None
|
@@ -57,27 +57,6 @@ def waitForButtonsState(projectsActive, examplesActive, tutorialsActive, timeout
|
||||
'and buttonActive(exmpButton) == examplesActive '
|
||||
'and buttonActive(tutoButton) == tutorialsActive', timeout)
|
||||
|
||||
def __getWelcomeScreenButtonHelper__(buttonLabel, widgetWithQFrames):
|
||||
frames = [child for child in object.children(widgetWithQFrames) if className(child) == 'QFrame']
|
||||
for frame in frames:
|
||||
label = getChildByClass(frame, 'QLabel')
|
||||
if str(label.text) == buttonLabel:
|
||||
return frame, label
|
||||
return None, None
|
||||
|
||||
def getWelcomeScreenSideBarButton(buttonLabel):
|
||||
sideBar = waitForObject("{type='Welcome::Internal::SideBar' unnamed='1' "
|
||||
"window=':Qt Creator_Core::Internal::MainWindow'}")
|
||||
return __getWelcomeScreenButtonHelper__(buttonLabel, sideBar)
|
||||
|
||||
def getWelcomeScreenMainButton(buttonLabel):
|
||||
stackedWidget = waitForObject("{type='QWidget' unnamed='1' visible='1' "
|
||||
"leftWidget={type='QWidget' unnamed='1' visible='1' "
|
||||
"leftWidget={type='Welcome::Internal::SideBar' unnamed='1' "
|
||||
"window=':Qt Creator_Core::Internal::MainWindow'}}}")
|
||||
currentStackWidget = stackedWidget.currentWidget()
|
||||
return __getWelcomeScreenButtonHelper__(buttonLabel, currentStackWidget)
|
||||
|
||||
def checkTableViewForContent(tableViewStr, expectedRegExTitle, section, atLeastOneText):
|
||||
try:
|
||||
tableView = findObject(tableViewStr) # waitForObject does not work - visible is 0?
|
||||
|
@@ -24,14 +24,44 @@
|
||||
############################################################################
|
||||
|
||||
source("../../shared/qtcreator.py")
|
||||
source("../../shared/suites_qtta.py")
|
||||
|
||||
welcomePage = ":Qt Creator.WelcomePage_QQuickWidget"
|
||||
|
||||
def checkTypeAndProperties(typePropertiesDetails):
|
||||
for (qType, props, detail) in typePropertiesDetails:
|
||||
test.verify(checkIfObjectExists(getQmlItem(qType, welcomePage, False, props)),
|
||||
"Verifying: Qt Creator displays %s." % detail)
|
||||
if qType == "QPushButton":
|
||||
wsButtonFrame, wsButtonLabel = getWelcomeScreenSideBarButton(props)
|
||||
test.verify(all((wsButtonFrame, wsButtonLabel)),
|
||||
"Verifying: Qt Creator displays Welcome Page with %s." % detail)
|
||||
elif qType == 'QTreeView':
|
||||
treeView = getWelcomeTreeView(props)
|
||||
test.verify(treeView is not None,
|
||||
"Verifying: Qt Creator displays Welcome Page with %s." % detail)
|
||||
elif qType == 'SessionModelIndex':
|
||||
# for SessionModelIndex props must be a tuple with 2 elements, the first is just
|
||||
# as for others (additional properties) while the second is either True or False and
|
||||
# indicating whether to check the found index for being the default and current session
|
||||
treeView = getWelcomeTreeView("Sessions")
|
||||
if not treeView:
|
||||
test.fatal("Failed to find Sessions tree view, cannot check for %s." % detail)
|
||||
continue
|
||||
indices = dumpIndices(treeView.model())
|
||||
found = False
|
||||
for index in indices:
|
||||
if props[0] == str(index.data()):
|
||||
# 257 -> DefaultSessionRole, 259 -> ActiveSessionRole [sessionmodel.h]
|
||||
isDefaultAndCurrent = index.data(257).toBool() and index.data(259).toBool()
|
||||
if not props[1] or isDefaultAndCurrent:
|
||||
found = True
|
||||
break
|
||||
test.verify(found, "Verifying: Qt Creator displays Welcome Page with %s." % detail)
|
||||
elif qType == 'ProjectModelIndex':
|
||||
treeView = getWelcomeTreeView("Recent Projects")
|
||||
if not treeView:
|
||||
test.fatal("Failed to find Projects tree view, cannot check for %s." % detail)
|
||||
continue
|
||||
test.verify(props in dumpItems(treeView.model()),
|
||||
"Verifying: Qt Creator displays Welcome Page with %s." % detail)
|
||||
else:
|
||||
test.fatal("Unhandled qType '%s' found..." % qType)
|
||||
|
||||
def main():
|
||||
# prepare example project
|
||||
@@ -44,11 +74,10 @@ def main():
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
|
||||
typePropDet = (("Button", "text='Get Started Now' id='gettingStartedButton'",
|
||||
"Get Started Now button"),
|
||||
("Text", "text='Sessions' id='sessionsTitle'", "Sessions section"),
|
||||
("Text", "text='default'", "default session listed"),
|
||||
("Text", "text='Recent Projects' id='recentProjectsTitle'", "Projects section"),
|
||||
typePropDet = (("QPushButton", "Get Started Now", "Get Started Now button"),
|
||||
("QTreeView", "Sessions", "Sessions section"),
|
||||
("SessionModelIndex", ("default", False), "default session listed"),
|
||||
("QTreeView", "Recent Projects", "Projects section")
|
||||
)
|
||||
checkTypeAndProperties(typePropDet)
|
||||
|
||||
@@ -59,12 +88,10 @@ def main():
|
||||
"Verifying: The project is opened in 'Edit' mode after configuring.")
|
||||
# go to "Welcome page" again and verify updated information
|
||||
switchViewTo(ViewConstants.WELCOME)
|
||||
typePropDet = (("Text", "text='Sessions' id='sessionsTitle'", "Sessions section"),
|
||||
("Text", "text='default (current session)'",
|
||||
"default session as current listed"),
|
||||
("Text", "text='Recent Projects' id='recentProjectsTitle'", "Projects section"),
|
||||
("Text", "text='SampleApp'",
|
||||
"current project listed in projects section")
|
||||
typePropDet = (("QTreeView", "Sessions", "Sessions section"),
|
||||
("SessionModelIndex", ("default", True), "default session as current listed"),
|
||||
("QTreeView", "Recent Projects", "Projects section"),
|
||||
("ProjectModelIndex", "SampleApp", "current project listed in projects section")
|
||||
)
|
||||
checkTypeAndProperties(typePropDet)
|
||||
|
||||
@@ -77,11 +104,12 @@ def main():
|
||||
"Verifying: The project is opened in 'Edit' mode after configuring.")
|
||||
# go to "Welcome page" again and check if there is an information about recent projects
|
||||
switchViewTo(ViewConstants.WELCOME)
|
||||
test.verify(checkIfObjectExists(getQmlItem("Text", welcomePage, False,
|
||||
"text='animation'")) and
|
||||
checkIfObjectExists(getQmlItem("Text", welcomePage, False,
|
||||
"text='SampleApp'")),
|
||||
"Verifying: 'Welcome page' displays information about recently created and "
|
||||
"opened projects.")
|
||||
treeView = getWelcomeTreeView('Recent Projects')
|
||||
if treeView is None:
|
||||
test.fatal("Cannot verify Recent Projects on Welcome Page - failed to find tree view.")
|
||||
else:
|
||||
typePropDet = (("ProjectModelIndex", "animation", "one project"),
|
||||
("ProjectModelIndex", "SampleApp", "other project"))
|
||||
checkTypeAndProperties(typePropDet)
|
||||
# exit Qt Creator
|
||||
invokeMenuItem("File", "Exit")
|
||||
|
Reference in New Issue
Block a user