SquishTests: Fix welcome page test

When the view is populated and sorted it gets its items
one by one. If multiple matches for opening an example are
possible we may end up using the wrong one which in turn
makes the test error out. So, wait for an expected amount
of items.

Change-Id: If6f6abfa757ede33311a8e617ab7d570df1240a4
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
This commit is contained in:
Christian Stenger
2023-07-04 10:36:24 +02:00
parent 707d3dd7aa
commit cdea404957

View File

@@ -18,10 +18,18 @@ def handlePackagingMessageBoxes():
except: except:
break break
def openExample(examplesLineEdit, input, exampleRegex, exampleName):
def openExample(examplesLineEdit, input, exampleRegex, exampleName, waitForChildCount=0):
replaceEditorContent(examplesLineEdit, input) replaceEditorContent(examplesLineEdit, input)
listView = waitForObject("{type='QListView' unnamed='1' visible='1' " listView = waitForObject("{type='QListView' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}") "window=':Qt Creator_Core::Internal::MainWindow'}")
if waitForChildCount > 0:
def childCount(view):
return len(__childrenOfType__(view, 'QModelIndex'))
waitFor("childCount(listView) == waitForChildCount", 3000)
waitFor('findExampleOrTutorial(listView, exampleRegex) is not None', 3000) waitFor('findExampleOrTutorial(listView, exampleRegex) is not None', 3000)
example = findExampleOrTutorial(listView, exampleRegex, True) example = findExampleOrTutorial(listView, exampleRegex, True)
if test.verify(example is not None, "Verifying: Example (%s) is shown." % exampleName): if test.verify(example is not None, "Verifying: Example (%s) is shown." % exampleName):
@@ -100,7 +108,7 @@ def main():
removePackagingDirectory(os.path.dirname(p)) removePackagingDirectory(os.path.dirname(p))
examplesLineEdit = waitForObject(search %(expect[1][0], expect[1][1])) examplesLineEdit = waitForObject(search %(expect[1][0], expect[1][1]))
example = openExample(examplesLineEdit, "address book", "(0000 )?Address Book.*", example = openExample(examplesLineEdit, "address book", "(0000 )?Address Book.*",
"Address Book Example") "Address Book Example", 3)
if example is not None: if example is not None:
# close second example application # close second example application
test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'" test.verify(checkIfObjectExists("{column='0' container=':Qt Creator_Utils::NavigationTreeView'"