Commit e7937795 authored by Robert Loehning's avatar Robert Loehning

Squish: Added test for renaming files

Task-number: QTCREATORBUG-8335
Change-Id: Ie9ca9018194c955f099b7d99ab46ba26303e354d
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 31223a55
......@@ -92,6 +92,7 @@
:Qt Creator.Go to Help Mode_QToolButton {text='Go to Help Mode' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Help_Search for:_QLineEdit {leftWidget=':Qt Creator.Search for:_QLabel' type='QLineEdit' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Issues_QListView {type='QListView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Issues'}
:Qt Creator.Project.Menu.File_QMenu {name='Project.Menu.File' type='QMenu' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Project.Menu.Project_QMenu {name='Project.Menu.Project' type='QMenu' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.QtCreator.MenuBar_QMenuBar {name='QtCreator.MenuBar' type='QMenuBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.ReRun_QToolButton {toolTip='Re-run this run-configuration' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
......@@ -123,6 +124,7 @@
:Qt Creator_SearchResult_Core::Internal::OutputPaneToggleButton {occurrence='2' type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_SystemSettings.Details_Utils::DetailsButton {occurrence='4' text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Utils::NavigationTreeView {type='Utils::NavigationTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit {container=':Qt Creator_Utils::NavigationTreeView' type='QExpandingLineEdit' unnamed='1' visible='1'}
:Qt Gui Application.Form file:_QLabel {name='formLabel' text='Form file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
:Qt Gui Application.Header file:_QLabel {name='headerLabel' text='Header file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
:Qt Gui Application.Source file:_QLabel {name='sourceLabel' text='Source file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
......
......@@ -612,3 +612,9 @@ def checkIfObjectExists(name, shouldExist = True, timeout = 3000, verboseOnFail
def progressBarWait():
checkIfObjectExists("{type='Core::Internal::ProgressBar' unnamed='1'}", True, 2000)
checkIfObjectExists("{type='Core::Internal::ProgressBar' unnamed='1'}", False, 60000)
def readFile(filename):
f = open(filename, "r")
content = f.read()
f.close()
return content
......@@ -3,12 +3,6 @@ source("../../shared/suites_qtta.py")
global templateDir
def readFile(filename):
f = open(filename, "r")
content = f.read()
f.close()
return content
def copyToTemplateDir(filepath):
global templateDir
dst = os.path.join(templateDir, os.path.basename(filepath))
......
......@@ -7,6 +7,6 @@ HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAP=../objects.map
TEST_CASES=tst_build_speedcrunch tst_cmake_speedcrunch tst_create_proj_wizard tst_default_settings tst_installed_languages tst_openqt_creator
TEST_CASES=tst_build_speedcrunch tst_cmake_speedcrunch tst_create_proj_wizard tst_default_settings tst_installed_languages tst_openqt_creator tst_rename_file
VERSION=2
WRAPPERS=Qt
source("../../shared/qtcreator.py")
def main():
# prepare example project
projectName = "declarative-music-browser"
sourceExample = os.path.join(sdkPath, "Examples", "QtMobility", projectName)
proFile = projectName + ".pro"
if not neededFilePresent(os.path.join(sourceExample, proFile)):
return
# copy example project to temp directory
templateDir = prepareTemplate(sourceExample)
startApplication("qtcreator" + SettingsPath)
if not startedWithoutPluginError():
return
usedProFile = os.path.join(templateDir, proFile)
openQmakeProject(usedProFile)
for filetype, filename in [["Headers", "utility.h"],
["Sources", "main.cpp"],
["Sources", "utility.cpp"],
["Resources", "musicbrowser.qrc"],
["QML", "musicbrowser.qml"]]:
filenames = ["ABCD" + filename.upper(), "abcd" + filename.lower(), "test", "TEST", filename]
if platform.system() == 'Darwin':
# avoid QTCREATORBUG-9197
filtered = [filenames[0]]
for i in range(1, len(filenames)):
if filenames[i].lower() != filtered[-1].lower():
filtered.append(filenames[i])
filenames = filtered
for i in range(len(filenames)):
tempFiletype = filetype
if filetype == "QML" and filenames[i - 1][-4:] != ".qml":
tempFiletype = "Other files"
# workaround QTCREATORBUG-9191
if filenames[i - 1][-4:].lower() == ".qml" and platform.system() in ('Windows',
'Microsoft'):
tempFiletype = "QML"
renameFile(templateDir, usedProFile, projectName + "." + tempFiletype,
filenames[i - 1], filenames[i])
invokeMenuItem("File", "Exit")
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(".", "\\.")
treeview = waitForObject(":Qt Creator_Utils::NavigationTreeView")
if platform.system() == 'Darwin':
JIRA.performWorkaroundForBug(8735, JIRA.Bug.CREATOR, treeview)
try:
openItemContextMenu(treeview, itemText, 5, 5, 0)
except:
openItemContextMenu(treeview, addBranchWildcardToRoot(itemText), 5, 5, 0)
activateItem(waitForObjectItem(":Qt Creator.Project.Menu.File_QMenu", "Rename..."))
type(waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit"), newname)
type(waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit"), "<Return>")
test.verify(waitFor("os.path.exists(newFilePath)", 1000),
"Verify that file with new name exists: %s" % newFilePath)
if not (oldname.lower() == newname.lower() and platform.system() in ('Windows', 'Microsoft')):
test.verify(not os.path.exists(oldFilePath),
"Verify that file with old name does not exist: %s" % oldFilePath)
test.compare(readFile(newFilePath), oldFileText,
"Comparing content of file before and after renaming")
test.verify(waitFor("newname in safeReadFile(proFile)", 2000),
"Verify that new filename '%s' was added to pro-file." % newname)
if not oldname in newname:
test.verify(not oldname in readFile(proFile),
"Verify that old filename '%s' was removed from pro-file." % oldname)
def safeReadFile(filename):
text = ""
while text == "":
try:
text = readFile(filename)
except:
pass
return text
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment