From 25a1fb4e9c3b7ee6f179a36092ed1a65d8fd8709 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 11 Oct 2023 13:11:39 +0200 Subject: [PATCH] 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 Reviewed-by: David Schulz --- src/plugins/coreplugin/welcomepagehelper.cpp | 1 + tests/system/shared/welcome.py | 10 +++++++++- tests/system/suite_WELP/tst_WELP01/test.py | 2 +- tests/system/suite_WELP/tst_WELP03/test.py | 18 ++++++++++-------- tests/system/suite_WELP/tst_WELP04/test.py | 8 ++++---- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/plugins/coreplugin/welcomepagehelper.cpp b/src/plugins/coreplugin/welcomepagehelper.cpp index 8129a644ae1..d80942f13d4 100644 --- a/src/plugins/coreplugin/welcomepagehelper.cpp +++ b/src/plugins/coreplugin/welcomepagehelper.cpp @@ -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); diff --git a/tests/system/shared/welcome.py b/tests/system/shared/welcome.py index e945956b6e6..8066f271318 100644 --- a/tests/system/shared/welcome.py +++ b/tests/system/shared/welcome.py @@ -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: diff --git a/tests/system/suite_WELP/tst_WELP01/test.py b/tests/system/suite_WELP/tst_WELP01/test.py index b64edcd2b7f..0bc65d1f001 100644 --- a/tests/system/suite_WELP/tst_WELP01/test.py +++ b/tests/system/suite_WELP/tst_WELP01/test.py @@ -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") diff --git a/tests/system/suite_WELP/tst_WELP03/test.py b/tests/system/suite_WELP/tst_WELP03/test.py index 7c672464eb3..b09fa9e2a90 100644 --- a/tests/system/suite_WELP/tst_WELP03/test.py +++ b/tests/system/suite_WELP/tst_WELP03/test.py @@ -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.") diff --git a/tests/system/suite_WELP/tst_WELP04/test.py b/tests/system/suite_WELP/tst_WELP04/test.py index 557059a3309..c9a18066693 100644 --- a/tests/system/suite_WELP/tst_WELP04/test.py +++ b/tests/system/suite_WELP/tst_WELP04/test.py @@ -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)