Commit 2c93654e authored by Christian Stenger's avatar Christian Stenger

Squish: Improve testing of Welcome page

Verification of URLs used for "link labels" on the Welcome page
is now possible again.

Change-Id: Id48ab40201a9c2a60dc3c991052f45bee93707bc
Reviewed-by: default avatarRobert Loehning <robert.loehning@qt.io>
parent 2559ad48
......@@ -23,18 +23,27 @@
#
############################################################################
def __getWelcomeScreenButtonHelper__(buttonLabel, widgetWithQFrames):
frames = [child for child in object.children(widgetWithQFrames) if className(child) == 'QWidget']
def __childrenOfType__(parentObject, typeName):
return [child for child in object.children(parentObject) if className(child) == typeName]
def __getWelcomeScreenButtonHelper__(buttonLabel, widgetWithQFrames, isUrlButton = False):
frames = __childrenOfType__(widgetWithQFrames, 'QWidget')
for frame in frames:
label = getChildByClass(frame, 'QLabel')
if str(label.text) == buttonLabel:
return frame, label
childCount = 1 # incorrect but okay for framed sidebar buttons
if isUrlButton:
childCount = len(__childrenOfType__(frame, 'QLabel'))
for occurrence in range(1, childCount + 1):
label = getChildByClass(frame, 'QLabel', occurrence)
if label is None:
continue
if str(label.text) == buttonLabel:
return frame, label
return None, None
def getWelcomeScreenSideBarButton(buttonLabel):
def getWelcomeScreenSideBarButton(buttonLabel, isUrlButton = False):
sideBar = waitForObject("{type='Welcome::Internal::SideBar' unnamed='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}")
return __getWelcomeScreenButtonHelper__(buttonLabel, sideBar)
return __getWelcomeScreenButtonHelper__(buttonLabel, sideBar, isUrlButton)
def getWelcomeScreenMainButton(buttonLabel):
stackedWidget = waitForObject("{type='QStackedWidget' name='WelcomeScreenStackedWidget' "
......@@ -52,7 +61,7 @@ def getWelcomeTreeView(treeViewLabel):
def findExampleOrTutorial(tableView, regex, verbose=False):
model = tableView.model()
children = [ch for ch in object.children(tableView) if className(ch) == 'QModelIndex']
children = __childrenOfType__(tableView, 'QModelIndex')
for child in children:
if re.match(regex, str(child.text)):
if verbose:
......
......@@ -109,11 +109,10 @@ def main():
'User Guide':'qthelp://org.qt-project.qtcreator/doc/index.html'
}
for text, url in textUrls.items():
test.verify(checkIfObjectExists("{type='QLabel' text='%s' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}"
% text),
"Verifying whether link button (%s) exists." % text)
# TODO find way to verify URLs (or tweak source code of Welcome page to become able)
button, label = getWelcomeScreenSideBarButton(text, True)
if test.verify(all((button, label)),
"Verifying whether link button (%s) exists." % text):
test.compare(str(button.toolTip), url, "Verifying URL for %s" % text)
wsButtonFrame, wsButtonLabel = getWelcomeScreenSideBarButton(getStarted)
if wsButtonLabel is not None:
mouseClick(wsButtonLabel)
......
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