forked from qt-creator/qt-creator
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:
@@ -374,24 +374,38 @@ def addBranchWildcardToRoot(rootNode):
|
|||||||
return rootNode[:pos] + " [[]*[]]" + rootNode[pos:]
|
return rootNode[:pos] + " [[]*[]]" + rootNode[pos:]
|
||||||
|
|
||||||
def openDocument(treeElement):
|
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:
|
try:
|
||||||
|
parentIndex = None
|
||||||
selectFromCombo(":Qt Creator_Core::Internal::NavComboBox", "Projects")
|
selectFromCombo(":Qt Creator_Core::Internal::NavComboBox", "Projects")
|
||||||
navigator = waitForObject(":Qt Creator_Utils::NavigationTreeView")
|
navigator = waitForObject(":Qt Creator_Utils::NavigationTreeView")
|
||||||
try:
|
|
||||||
item = waitForObjectItem(navigator, treeElement, 3000)
|
for i, t in enumerate(treePathElements):
|
||||||
except:
|
indices = dumpIndices(navigator.model(), parentIndex)
|
||||||
treeElement = addBranchWildcardToRoot(treeElement)
|
foundT = False
|
||||||
item = waitForObjectItem(navigator, treeElement)
|
for index in indices:
|
||||||
expected = str(item.text).split("/")[-1]
|
iText = str(index.text)
|
||||||
for _ in range(2):
|
if (iText == t
|
||||||
# Expands items as needed what might make scrollbars appear.
|
or (i == 0 and re.match(t + " [[].+[]]", iText) is not None)):
|
||||||
# These might cover the item to click.
|
foundT = True
|
||||||
# In this case, do it again to hit the item then.
|
parentIndex = index
|
||||||
doubleClickItem(navigator, treeElement, 5, 5, 0, Qt.LeftButton)
|
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")
|
mainWindow = waitForObject(":Qt Creator_Core::Internal::MainWindow")
|
||||||
if waitFor("str(mainWindow.windowTitle).startswith(expected + ' ')", 5000):
|
if waitFor("str(mainWindow.windowTitle).startswith(treePathElements[-1] + ' ')", 5000):
|
||||||
return True
|
return True
|
||||||
test.log("Expected file (%s) was not being opened in openDocument()" % expected)
|
test.log("Expected file (%s) was not being opened in openDocument()" % treePathElements[-1])
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
t,v = sys.exc_info()[:2]
|
t,v = sys.exc_info()[:2]
|
||||||
|
Reference in New Issue
Block a user