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:
Christian Stenger
2017-02-07 09:08:11 +01:00
parent c0f2bc254e
commit 9f6f5bfee2
5 changed files with 114 additions and 51 deletions

View File

@@ -34,10 +34,11 @@ def openQbsProject(projectPath):
def openQmakeProject(projectPath, targets=Targets.desktopTargetClasses(), fromWelcome=False): def openQmakeProject(projectPath, targets=Targets.desktopTargetClasses(), fromWelcome=False):
cleanUpUserFiles(projectPath) cleanUpUserFiles(projectPath)
if fromWelcome: if fromWelcome:
welcomePage = ":Qt Creator.WelcomePage_QQuickWidget" wsButtonFrame, wsButtonLabel = getWelcomeScreenMainButton('Open Project')
mouseClick(waitForObject("{clip='false' container='%s' enabled='true' text='Open Project' " if not all((wsButtonFrame, wsButtonLabel)):
"type='Button' unnamed='1' visible='true'}" % welcomePage), test.fatal("Could not find 'Open Project' button on Welcome Page.")
5, 5, 0, Qt.LeftButton) return []
mouseClick(wsButtonLabel)
else: else:
invokeMenuItem("File", "Open File or Project...") invokeMenuItem("File", "Open File or Project...")
selectFromFileDialog(projectPath) selectFromFileDialog(projectPath)
@@ -82,10 +83,11 @@ def openCmakeProject(projectPath, buildDir):
# this list can be used in __chooseTargets__() # this list can be used in __chooseTargets__()
def __createProjectOrFileSelectType__(category, template, fromWelcome = False, isProject=True): def __createProjectOrFileSelectType__(category, template, fromWelcome = False, isProject=True):
if fromWelcome: if fromWelcome:
welcomePage = ":Qt Creator.WelcomePage_QQuickWidget" wsButtonFrame, wsButtonLabel = getWelcomeScreenMainButton("New Project")
mouseClick(waitForObject("{clip='false' container='%s' enabled='true' text='New Project' " if not all((wsButtonFrame, wsButtonLabel)):
"type='Button' unnamed='1' visible='true'}" % welcomePage), test.fatal("Could not find 'New Project' button on Welcome Page")
5, 5, 0, Qt.LeftButton) return []
mouseClick(wsButtonLabel)
else: else:
invokeMenuItem("File", "New File or Project...") invokeMenuItem("File", "New File or Project...")
categoriesView = waitForObject(":New.templateCategoryView_QTreeView") categoriesView = waitForObject(":New.templateCategoryView_QTreeView")

View File

@@ -52,6 +52,7 @@ source("../../shared/project_explorer.py")
source("../../shared/hook_utils.py") source("../../shared/hook_utils.py")
source("../../shared/debugger.py") source("../../shared/debugger.py")
source("../../shared/clang.py") source("../../shared/clang.py")
source("../../shared/welcome.py")
source("../../shared/workarounds.py") # include this at last source("../../shared/workarounds.py") # include this at last
# ATTENTION: if a test case calls startApplication("qtcreator...") for several times this # ATTENTION: if a test case calls startApplication("qtcreator...") for several times this

View 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

View File

@@ -57,27 +57,6 @@ def waitForButtonsState(projectsActive, examplesActive, tutorialsActive, timeout
'and buttonActive(exmpButton) == examplesActive ' 'and buttonActive(exmpButton) == examplesActive '
'and buttonActive(tutoButton) == tutorialsActive', timeout) '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): def checkTableViewForContent(tableViewStr, expectedRegExTitle, section, atLeastOneText):
try: try:
tableView = findObject(tableViewStr) # waitForObject does not work - visible is 0? tableView = findObject(tableViewStr) # waitForObject does not work - visible is 0?

View File

@@ -24,14 +24,44 @@
############################################################################ ############################################################################
source("../../shared/qtcreator.py") source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
welcomePage = ":Qt Creator.WelcomePage_QQuickWidget"
def checkTypeAndProperties(typePropertiesDetails): def checkTypeAndProperties(typePropertiesDetails):
for (qType, props, detail) in typePropertiesDetails: for (qType, props, detail) in typePropertiesDetails:
test.verify(checkIfObjectExists(getQmlItem(qType, welcomePage, False, props)), if qType == "QPushButton":
"Verifying: Qt Creator displays %s." % detail) 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(): def main():
# prepare example project # prepare example project
@@ -44,11 +74,10 @@ def main():
if not startedWithoutPluginError(): if not startedWithoutPluginError():
return return
typePropDet = (("Button", "text='Get Started Now' id='gettingStartedButton'", typePropDet = (("QPushButton", "Get Started Now", "Get Started Now button"),
"Get Started Now button"), ("QTreeView", "Sessions", "Sessions section"),
("Text", "text='Sessions' id='sessionsTitle'", "Sessions section"), ("SessionModelIndex", ("default", False), "default session listed"),
("Text", "text='default'", "default session listed"), ("QTreeView", "Recent Projects", "Projects section")
("Text", "text='Recent Projects' id='recentProjectsTitle'", "Projects section"),
) )
checkTypeAndProperties(typePropDet) checkTypeAndProperties(typePropDet)
@@ -59,12 +88,10 @@ def main():
"Verifying: The project is opened in 'Edit' mode after configuring.") "Verifying: The project is opened in 'Edit' mode after configuring.")
# go to "Welcome page" again and verify updated information # go to "Welcome page" again and verify updated information
switchViewTo(ViewConstants.WELCOME) switchViewTo(ViewConstants.WELCOME)
typePropDet = (("Text", "text='Sessions' id='sessionsTitle'", "Sessions section"), typePropDet = (("QTreeView", "Sessions", "Sessions section"),
("Text", "text='default (current session)'", ("SessionModelIndex", ("default", True), "default session as current listed"),
"default session as current listed"), ("QTreeView", "Recent Projects", "Projects section"),
("Text", "text='Recent Projects' id='recentProjectsTitle'", "Projects section"), ("ProjectModelIndex", "SampleApp", "current project listed in projects section")
("Text", "text='SampleApp'",
"current project listed in projects section")
) )
checkTypeAndProperties(typePropDet) checkTypeAndProperties(typePropDet)
@@ -77,11 +104,12 @@ def main():
"Verifying: The project is opened in 'Edit' mode after configuring.") "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 # go to "Welcome page" again and check if there is an information about recent projects
switchViewTo(ViewConstants.WELCOME) switchViewTo(ViewConstants.WELCOME)
test.verify(checkIfObjectExists(getQmlItem("Text", welcomePage, False, treeView = getWelcomeTreeView('Recent Projects')
"text='animation'")) and if treeView is None:
checkIfObjectExists(getQmlItem("Text", welcomePage, False, test.fatal("Cannot verify Recent Projects on Welcome Page - failed to find tree view.")
"text='SampleApp'")), else:
"Verifying: 'Welcome page' displays information about recently created and " typePropDet = (("ProjectModelIndex", "animation", "one project"),
"opened projects.") ("ProjectModelIndex", "SampleApp", "other project"))
checkTypeAndProperties(typePropDet)
# exit Qt Creator # exit Qt Creator
invokeMenuItem("File", "Exit") invokeMenuItem("File", "Exit")