Squish: Stabilize tst_rename_file

It takes a moment until the changed file appears in the project tree. A
context menu opened in that time may be in an unexpected state, so wait
until the renaming finished properly.

Change-Id: I6e1941083737b2df5855b9b0e61a973c99831304
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Robert Löhning
2021-07-13 00:31:49 +02:00
parent 47cb2e9d24
commit cbc9f4c4e1

View File

@@ -87,14 +87,16 @@ def renameFile(projectDir, proFile, branch, oldname, newname):
oldFilePath = os.path.join(projectDir, oldname)
newFilePath = os.path.join(projectDir, newname)
oldFileText = readFile(oldFilePath)
itemText = branch + "." + oldname.replace(".", "\\.")
oldItemText = branch + "." + oldname.replace(".", "\\.")
newItemText = branch + "." + newname.replace(".", "\\.")
treeview = waitForObject(":Qt Creator_Utils::NavigationTreeView")
try:
openItemContextMenu(treeview, itemText, 5, 5, 0)
openItemContextMenu(treeview, oldItemText, 5, 5, 0)
except:
itemWithWildcard = addBranchWildcardToRoot(itemText)
waitForObjectItem(treeview, itemWithWildcard, 10000)
openItemContextMenu(treeview, itemWithWildcard, 5, 5, 0)
oldItemText = addBranchWildcardToRoot(oldItemText)
newItemText = addBranchWildcardToRoot(newItemText)
waitForObjectItem(treeview, oldItemText, 10000)
openItemContextMenu(treeview, oldItemText, 5, 5, 0)
if oldname.lower().endswith(".qrc"):
menu = ":Qt Creator.Project.Menu.Folder_QMenu"
else:
@@ -130,6 +132,13 @@ def renameFile(projectDir, proFile, branch, oldname, newname):
test.verify(oldname not in os.listdir(projectDir),
"Verify that file with old name does not exist: %s" % oldFilePath)
if newItemText.endswith("\\.qml"):
newItemText = newItemText.replace(".Other files.", ".QML.")
else:
newItemText = newItemText.replace(".QML.", ".Other files.")
waitForObjectItem(treeview, newItemText)
def safeReadFile(filename):
text = ""
while text == "":