aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobert Löhning <robert.loehning@qt.io>2023-04-03 16:15:25 +0200
committerRobert Löhning <robert.loehning@qt.io>2023-04-04 09:51:01 +0000
commit892ccd2097ece7e8f77ab278dc83d83f6cc0ce7e (patch)
treeedd0df661a1fd5c9094212cd53394dc970d9d811 /tests
parent4d688c932baa41e9c4d04084bd4ce682301f7a48 (diff)
SquishTests: Add function for finding elements of project tree
Change-Id: I08c3c22a404d2b58bdb1205f22e5cf937c6027b0 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/system/shared/project_explorer.py31
-rw-r--r--tests/system/suite_QMLS/tst_QMLS04/test.py5
2 files changed, 26 insertions, 10 deletions
diff --git a/tests/system/shared/project_explorer.py b/tests/system/shared/project_explorer.py
index 8f50fae7e62..ca7952022ee 100644
--- a/tests/system/shared/project_explorer.py
+++ b/tests/system/shared/project_explorer.py
@@ -96,16 +96,33 @@ def getExecutableAndTargetFromToolTip(toolTip):
return None, target
return exe.group(1).strip(), target
+
+# treeElement is the dot-separated tree to the wanted element, e.g.
+# root.first.second.leaf
+def waitForProjectTreeItem(treeElement, timeoutMSec):
+ projectTV = ":Qt Creator_Utils::NavigationTreeView"
+ projItem = None
+ treeElementWithBranch = addBranchWildcardToRoot(treeElement)
+ for _ in range(timeoutMSec / 200):
+ try:
+ projItem = waitForObjectItem(projectTV, treeElement, 100)
+ except:
+ try:
+ projItem = waitForObjectItem(projectTV, treeElementWithBranch, 100)
+ except:
+ pass
+ if projItem:
+ return projItem
+ raise LookupError("Could not find project tree element: %s or %s"
+ % (treeElement, treeElementWithBranch))
+
+
def invokeContextMenuOnProject(projectName, menuItem):
try:
- projItem = waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", projectName, 3000)
+ projItem = waitForProjectTreeItem(projectName, 4000)
except:
- try:
- projItem = waitForObjectItem(":Qt Creator_Utils::NavigationTreeView",
- addBranchWildcardToRoot(projectName), 1000)
- except:
- test.fatal("Failed to find root node of the project '%s'." % projectName)
- return
+ test.fatal("Failed to find root node of the project '%s'." % projectName)
+ return
openItemContextMenu(waitForObject(":Qt Creator_Utils::NavigationTreeView"),
str(projItem.text).replace("_", "\\_").replace(".", "\\."), 5, 5, 0)
activateItem(waitForObjectItem("{name='Project.Menu.Project' type='QMenu' visible='1'}", menuItem))
diff --git a/tests/system/suite_QMLS/tst_QMLS04/test.py b/tests/system/suite_QMLS/tst_QMLS04/test.py
index bcb282560b9..351b59ac638 100644
--- a/tests/system/suite_QMLS/tst_QMLS04/test.py
+++ b/tests/system/suite_QMLS/tst_QMLS04/test.py
@@ -41,10 +41,9 @@ def main():
# there should be new QML file generated with name "MyComponent.qml"
try:
# openDocument() doesn't wait for expected elements, so it might be faster than the updates
- # to the tree. Explicitly wait here to avoid timing issues. Using wFOI() instead of
+ # to the tree. Explicitly wait here to avoid timing issues. Using wFPTI() instead of
# snooze() allows to proceed earlier, just in case it can find the item.
- waitForObjectItem(":Qt Creator_Utils::NavigationTreeView",
- addBranchWildcardToRoot(myCompTE), 2000)
+ waitForProjectTreeItem(myCompTE, 2000)
except:
pass
# open MyComponent.qml file for verification