SquishTests: Fix testing of welcome page

The examples and tutorials part of the welcome page got a
new approach which is either having a sectioned grid view
or a non-sectioned grid view (while searching).
That means we have now a model holding the items of several
other (sub)models and a filter model taking care of what is
shown while searching.
While searching we need to check the filter model, while for
not-search the original list view could be used as we did
before this patch. But as there are no access or verification
of the whole list this done is just replacing the old approach.

Change-Id: I1777340f8c6ea88af3bfc20a600ee1c174a18807
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2023-10-11 13:11:39 +02:00
parent 7459fb0c75
commit 25a1fb4e9c
5 changed files with 25 additions and 14 deletions

View File

@@ -729,6 +729,7 @@ void SectionedGridView::setSearchString(const QString &searchString)
// We don't have a grid set for searching yet.
// Create all items view for filtering.
m_allItemsView.reset(new GridView);
m_allItemsView->setObjectName("AllItemsView"); // used by Squish
m_allItemsView->setModel(new ListModelFilter(m_allItemsModel.get(), m_allItemsView.get()));
if (m_itemDelegate)
m_allItemsView->setItemDelegate(m_itemDelegate);

View File

@@ -44,7 +44,15 @@ def switchToSubMode(subModeLabel):
return frameAndLabelFound
def findExampleOrTutorial(tableView, regex, verbose=False):
children = __childrenOfType__(tableView, 'QModelIndex')
filterModel = __childrenOfType__(tableView, 'QSortFilterProxyModel')
if len(filterModel) != 1:
test.fatal("Something's wrong - could not find filter proxy model.")
return None
filterModel = filterModel[0]
if filterModel.rowCount() == 0:
return None
children = dumpIndices(filterModel)
for child in children:
if re.match(regex, str(child.text)):
if verbose:

View File

@@ -137,7 +137,7 @@ def main():
for (qType, prop, info) in expect:
test.verify(checkIfObjectExists(search % (qType, prop)),
"Verifying whether %s is shown" % info)
checkTableViewForContent(search % (expect[0][0], expect[0][1]), "Help: Creating .*", "Tutorials",
checkTableViewForContent(search % (expect[0][0], expect[0][1]), "Creating .*", "Tutorials",
"Verifying that at least one tutorial is displayed.")
# exit Qt Creator
invokeMenuItem("File", "Exit")

View File

@@ -21,19 +21,21 @@ def handlePackagingMessageBoxes():
def openExample(examplesLineEdit, input, exampleRegex, exampleName, waitForChildCount=0):
replaceEditorContent(examplesLineEdit, input)
listView = waitForObject("{type='QListView' unnamed='1' visible='1' "
listView = waitForObject("{type='QListView' name='AllItemsView' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}")
filterModel = __childrenOfType__(listView, 'QSortFilterProxyModel')
if len(filterModel) != 1:
test.fatal("Failed to find filter proxy model.")
return None
filterModel = filterModel[0]
if waitForChildCount > 0:
def childCount(view):
return len(__childrenOfType__(view, 'QModelIndex'))
waitFor("childCount(listView) == waitForChildCount", 3000)
waitFor("filterModel.rowCount() == waitForChildCount", 3000)
waitFor('findExampleOrTutorial(listView, exampleRegex) is not None', 3000)
example = findExampleOrTutorial(listView, exampleRegex, True)
if test.verify(example is not None, "Verifying: Example (%s) is shown." % exampleName):
mouseClick(example)
mouseClick(waitForObjectItem(listView, str(example.text)))
handlePackagingMessageBoxes()
helpWidget = waitForObject(":Help Widget_Help::Internal::HelpWidget")
test.verify(waitFor('exampleName in str(helpWidget.windowTitle)', 5000),
@@ -74,7 +76,7 @@ def main():
combo = waitForObject(search % (expect[2][0], expect[2][1]))
test.log("Using examples from Kit %s." % str(combo.currentText))
replaceEditorContent(examplesLineEdit, "qwerty")
listView = waitForObject(search % (expect[0][0], expect[0][1]))
listView = waitForObject("{type='QListView' name='AllItemsView'}")
waitFor('findExampleOrTutorial(listView, ".*") is None', 3000)
example = findExampleOrTutorial(listView, ".*", True)
test.verify(example is None, "Verifying: No example is shown.")

View File

@@ -6,7 +6,7 @@ source("../../shared/qtcreator.py")
def __waitForListView__():
listView = waitForObject("{container=':Qt Creator.WelcomeScreenStackedWidget' "
"type='QListView' unnamed='1' visible='1'}")
"type='QListView' name='AllItemsView' visible='1'}")
return listView
@@ -34,7 +34,7 @@ def main():
tutorial = findExampleOrTutorial(listView, ".*", True)
test.verify(tutorial is None,
"Verifying: 'Tutorials' topic is opened and nothing is shown.")
bnr = "Help: Building and Running an Example"
bnr = "Building and Running an Example"
replaceEditorContent(searchTutorials, bnr.lower())
listView = __waitForListView__()
waitFor('findExampleOrTutorial(listView, "%s.*") is not None' % bnr, 3000)
@@ -43,7 +43,7 @@ def main():
# clicking before documentation was updated will open the tutorial in browser
progressBarWait(warn=False)
# select a text tutorial
mouseClick(tutorial)
mouseClick(waitForObjectItem(listView, str(tutorial.text)))
test.verify("Building and Running an Example" in
str(waitForObject(":Help Widget_Help::Internal::HelpWidget").windowTitle),
"Verifying: The tutorial is opened inside Help.")
@@ -52,7 +52,7 @@ def main():
# check a demonstration video link
mouseClick(searchTutorials)
replaceEditorContent(searchTutorials, "embedded device")
embeddedTutorial = "Online: How to install and set up Qt for Device Creation.*"
embeddedTutorial = "How to install and set up Qt for Device Creation.*"
listView = __waitForListView__()
waitFor('findExampleOrTutorial(listView, embeddedTutorial) is not None', 3000)
tutorial = findExampleOrTutorial(listView, embeddedTutorial, True)