forked from qt-creator/qt-creator
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:
@@ -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))
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user