diff options
author | Christian Stenger <christian.stenger@qt.io> | 2022-12-15 12:57:29 +0100 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2023-01-27 11:33:12 +0000 |
commit | c22b4b35e1e8205a3106dd1c9c04af6a3ea8ab7c (patch) | |
tree | 60dba22d82d3840a0c5122c51af1343f6f9368f6 | |
parent | 598ffc3b1c8cddf2381861e8d6f71b9b2050e66b (diff) |
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>
-rw-r--r-- | tests/system/shared/editor_utils.py | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 57a60fd6a9..af56ed6f8d 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -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] |