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>
This commit is contained in:
Robert Löhning
2023-04-03 16:15:25 +02:00
parent 4d688c932b
commit 892ccd2097
2 changed files with 26 additions and 10 deletions

View File

@@ -96,13 +96,30 @@ def getExecutableAndTargetFromToolTip(toolTip):
return None, target
return exe.group(1).strip(), target
def invokeContextMenuOnProject(projectName, menuItem):
# 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(":Qt Creator_Utils::NavigationTreeView", projectName, 3000)
projItem = waitForObjectItem(projectTV, treeElement, 100)
except:
try:
projItem = waitForObjectItem(":Qt Creator_Utils::NavigationTreeView",
addBranchWildcardToRoot(projectName), 1000)
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 = waitForProjectTreeItem(projectName, 4000)
except:
test.fatal("Failed to find root node of the project '%s'." % projectName)
return

View File

@@ -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