summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@theqtcompany.com>2016-02-11 14:13:30 +0100
committerRobert Loehning <robert.loehning@theqtcompany.com>2016-02-16 13:14:35 +0000
commit9d8e4aa922daac8446d470e196ed5d297ae5e3c5 (patch)
tree958503abeb09c045f359f10749a883c84ca4c9d3
parent0d079062d9d0b532619d4e0a6ed238a484dd030a (diff)
downloadqt-creator-9d8e4aa922daac8446d470e196ed5d297ae5e3c5.tar.gz
Squish: Test overwriting of files when adding class
Change-Id: I86ed9a3749f692fe9ead13c31e0ba62c2baa3020 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
-rw-r--r--tests/system/shared/project.py9
-rw-r--r--tests/system/suite_general/tst_new_class/test.py31
2 files changed, 37 insertions, 3 deletions
diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py
index f77df6bc59..03a6597463 100644
--- a/tests/system/shared/project.py
+++ b/tests/system/shared/project.py
@@ -799,10 +799,15 @@ def addCPlusPlusFileToCurrentProject(name, template, forceOverwrite=False, addTo
test.compare(str(waitForObject("{name='HdrFileName' type='QLineEdit' visible='1'}").text),
expectedHeaderName)
clickButton(waitForObject(":Next_QPushButton"))
- fileExistedBefore = os.path.exists(os.path.join(basePath, name))
+ fileExistedBefore = False
+ if template == "C++ Class":
+ fileExistedBefore = (os.path.exists(os.path.join(basePath, name.lower() + ".cpp"))
+ or os.path.exists(os.path.join(basePath, name.lower() + ".h")))
+ else:
+ fileExistedBefore = os.path.exists(os.path.join(basePath, name))
__createProjectHandleLastPage__(expectedFiles, addToVersionControl=addToVCS)
if (fileExistedBefore):
- overwriteDialog = "{type='Core::Internal::PromptOverwriteDialog' unnamed='1' visible='1'}"
+ overwriteDialog = "{type='Core::PromptOverwriteDialog' unnamed='1' visible='1'}"
waitForObject(overwriteDialog)
if forceOverwrite:
buttonToClick = 'OK'
diff --git a/tests/system/suite_general/tst_new_class/test.py b/tests/system/suite_general/tst_new_class/test.py
index 7fc1a2e466..9fb3502c9e 100644
--- a/tests/system/suite_general/tst_new_class/test.py
+++ b/tests/system/suite_general/tst_new_class/test.py
@@ -34,10 +34,12 @@ def main():
newClassName = "MyNewClass"
headerFileName = newClassName.lower() + ".h"
sourceFileName = newClassName.lower() + ".cpp"
+ basePath = tempDir()
+ notOverwrittenComment = "// If you can read this, the file was not overwritten."
startApplication("qtcreator" + SettingsPath)
if not startedWithoutPluginError():
return
- addCPlusPlusFileToCurrentProject(newClassName, "C++ Class", newBasePath=tempDir(),
+ addCPlusPlusFileToCurrentProject(newClassName, "C++ Class", newBasePath=basePath,
expectedSourceName=sourceFileName,
expectedHeaderName=headerFileName)
@@ -51,6 +53,9 @@ def main():
"Header included in source file?")
test.verify(newClassName + "::" + newClassName + "()" in editorText,
"Ctor implementation in source file?")
+ type(editor, notOverwrittenComment)
+ type(editor, "<Return>")
+ invokeMenuItem("File", "Save All")
clickButton(waitForObject(":Qt Creator.CloseDoc_QToolButton"))
if test.verify(waitFor("headerFileName in str(mainWindow.windowTitle)", 1000),
"Header file was shown after closing source?"):
@@ -69,5 +74,29 @@ def main():
"No signals in non-Qt header file?")
test.verify("slots" not in editorText, # QTCREATORBUG-14949
"No slots in non-Qt header file?")
+ type(editor, notOverwrittenComment)
+ type(editor, "<Return>")
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Close All")
+
+ def overwritten(filename):
+ return notOverwrittenComment not in readFile(os.path.join(basePath, filename))
+
+ addCPlusPlusFileToCurrentProject(newClassName, "C++ Class", False, newBasePath=basePath,
+ expectedSourceName=sourceFileName,
+ expectedHeaderName=headerFileName)
+ test.verify(not waitFor("overwritten(sourceFileName)", 500),
+ "Source file should not be overwritten.")
+ test.verify(not waitFor("overwritten(headerFileName)", 500),
+ "Header file should not be overwritten.")
+
+ addCPlusPlusFileToCurrentProject(newClassName, "C++ Class", True, newBasePath=basePath,
+ expectedSourceName=sourceFileName,
+ expectedHeaderName=headerFileName)
+ test.verify(waitFor("overwritten(sourceFileName)", 500),
+ "Source file should be overwritten.")
+ test.verify(waitFor("overwritten(headerFileName)", 500),
+ "Header file should be overwritten.")
+
invokeMenuItem("File", "Exit")
return