forked from qt-creator/qt-creator
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:
@@ -87,14 +87,16 @@ def renameFile(projectDir, proFile, branch, oldname, newname):
|
|||||||
oldFilePath = os.path.join(projectDir, oldname)
|
oldFilePath = os.path.join(projectDir, oldname)
|
||||||
newFilePath = os.path.join(projectDir, newname)
|
newFilePath = os.path.join(projectDir, newname)
|
||||||
oldFileText = readFile(oldFilePath)
|
oldFileText = readFile(oldFilePath)
|
||||||
itemText = branch + "." + oldname.replace(".", "\\.")
|
oldItemText = branch + "." + oldname.replace(".", "\\.")
|
||||||
|
newItemText = branch + "." + newname.replace(".", "\\.")
|
||||||
treeview = waitForObject(":Qt Creator_Utils::NavigationTreeView")
|
treeview = waitForObject(":Qt Creator_Utils::NavigationTreeView")
|
||||||
try:
|
try:
|
||||||
openItemContextMenu(treeview, itemText, 5, 5, 0)
|
openItemContextMenu(treeview, oldItemText, 5, 5, 0)
|
||||||
except:
|
except:
|
||||||
itemWithWildcard = addBranchWildcardToRoot(itemText)
|
oldItemText = addBranchWildcardToRoot(oldItemText)
|
||||||
waitForObjectItem(treeview, itemWithWildcard, 10000)
|
newItemText = addBranchWildcardToRoot(newItemText)
|
||||||
openItemContextMenu(treeview, itemWithWildcard, 5, 5, 0)
|
waitForObjectItem(treeview, oldItemText, 10000)
|
||||||
|
openItemContextMenu(treeview, oldItemText, 5, 5, 0)
|
||||||
if oldname.lower().endswith(".qrc"):
|
if oldname.lower().endswith(".qrc"):
|
||||||
menu = ":Qt Creator.Project.Menu.Folder_QMenu"
|
menu = ":Qt Creator.Project.Menu.Folder_QMenu"
|
||||||
else:
|
else:
|
||||||
@@ -130,6 +132,13 @@ def renameFile(projectDir, proFile, branch, oldname, newname):
|
|||||||
test.verify(oldname not in os.listdir(projectDir),
|
test.verify(oldname not in os.listdir(projectDir),
|
||||||
"Verify that file with old name does not exist: %s" % oldFilePath)
|
"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):
|
def safeReadFile(filename):
|
||||||
text = ""
|
text = ""
|
||||||
while text == "":
|
while text == "":
|
||||||
|
Reference in New Issue
Block a user