SquishTests: Redo open document from navigation view

For unknown reasons this does no more work on a couple of machines.
Re-doing the original approach by explicitly expanding the tree as
necessary up to the file we want to open.

Change-Id: I329e18f3e2162e381e11fb6164a448ae67def606
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Stenger
2022-12-15 12:57:29 +01:00
parent 598ffc3b1c
commit c22b4b35e1

View File

@@ -374,24 +374,38 @@ def addBranchWildcardToRoot(rootNode):
return rootNode[:pos] + " [[]*[]]" + rootNode[pos:]
def openDocument(treeElement):
# split into tree elements
treePathElements = re.split(r"(?<!\\)\.", treeElement)
# 'unmask' the extension delimiter
treePathElements = list(x.replace("\\.", ".") for x in treePathElements)
try:
parentIndex = None
selectFromCombo(":Qt Creator_Core::Internal::NavComboBox", "Projects")
navigator = waitForObject(":Qt Creator_Utils::NavigationTreeView")
try:
item = waitForObjectItem(navigator, treeElement, 3000)
except:
treeElement = addBranchWildcardToRoot(treeElement)
item = waitForObjectItem(navigator, treeElement)
expected = str(item.text).split("/")[-1]
for _ in range(2):
# Expands items as needed what might make scrollbars appear.
# These might cover the item to click.
# In this case, do it again to hit the item then.
doubleClickItem(navigator, treeElement, 5, 5, 0, Qt.LeftButton)
mainWindow = waitForObject(":Qt Creator_Core::Internal::MainWindow")
if waitFor("str(mainWindow.windowTitle).startswith(expected + ' ')", 5000):
return True
test.log("Expected file (%s) was not being opened in openDocument()" % expected)
for i, t in enumerate(treePathElements):
indices = dumpIndices(navigator.model(), parentIndex)
foundT = False
for index in indices:
iText = str(index.text)
if (iText == t
or (i == 0 and re.match(t + " [[].+[]]", iText) is not None)):
foundT = True
parentIndex = index
break
if not foundT:
raise Exception("Failed to get index '%s' (%d)." % (t, i))
if not navigator.isExpanded(parentIndex):
navigator.scrollTo(parentIndex)
rect = navigator.visualRect(parentIndex)
doubleClick(navigator, rect.x + 50, rect.y + 5, 0, Qt.LeftButton)
# now we should have a full expanded tree up to the requested file
rect = navigator.visualRect(parentIndex)
doubleClick(navigator, rect.x + 50, rect.y + 5, 0, Qt.LeftButton)
mainWindow = waitForObject(":Qt Creator_Core::Internal::MainWindow")
if waitFor("str(mainWindow.windowTitle).startswith(treePathElements[-1] + ' ')", 5000):
return True
test.log("Expected file (%s) was not being opened in openDocument()" % treePathElements[-1])
return False
except:
t,v = sys.exc_info()[:2]