summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@digia.com>2012-11-02 19:15:09 +0100
committerRobert Loehning <robert.loehning@digia.com>2012-11-05 12:57:38 +0100
commit88d52c1d594a855b2002738277fe779e35878141 (patch)
treec9fe27bb4d7cd2682f50096337af0d2cefbe23fc
parentcd7a41ca908cda4cb22e0c239779c35d47cd7b7d (diff)
downloadqt-creator-88d52c1d594a855b2002738277fe779e35878141.tar.gz
Squish: Added test case for deleting files outside of editor
Change-Id: Ib9724e0794dab7e4b2de39e72d671c8bf8f27b08 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
-rw-r--r--tests/system/objects.map3
-rw-r--r--tests/system/suite_editors/shared/testdata/files.tsv (renamed from tests/system/suite_editors/tst_select_all/testdata/files.tsv)0
-rw-r--r--tests/system/suite_editors/suite.conf2
-rw-r--r--tests/system/suite_editors/tst_delete_externally/test.py58
4 files changed, 62 insertions, 1 deletions
diff --git a/tests/system/objects.map b/tests/system/objects.map
index a8f6172529..63b11bbb74 100644
--- a/tests/system/objects.map
+++ b/tests/system/objects.map
@@ -42,6 +42,9 @@
:Dialog_QmlJSEditor::Internal::ComponentNameDialog {name='QmlJSEditor__Internal__ComponentNameDialog' type='QmlJSEditor::Internal::ComponentNameDialog' visible='1' windowTitle='Move Component into Separate File'}
:Edit Environment_ProjectExplorer::EnvironmentItemsDialog {type='ProjectExplorer::EnvironmentItemsDialog' unnamed='1' visible='1' windowTitle='Edit Environment'}
:Failed to start application_QMessageBox {type='QMessageBox' unnamed='1' visible='1' windowTitle='Failed to start application'}
+:File has been removed.Close_QPushButton {text='Close' type='QPushButton' unnamed='1' visible='1' window=':File has been removed_QMessageBox'}
+:File has been removed.Save_QPushButton {text='Save' type='QPushButton' unnamed='1' visible='1' window=':File has been removed_QMessageBox'}
+:File has been removed_QMessageBox {text?='The file * removed*. Do you want to save it under a different name, or close the editor?' type='QMessageBox' unnamed='1' visible='1'}
:Form.Startup_QGroupBox {container=':qt_tabwidget_stackedwidget.Form_QWidget' name='startupGroupBox' title='Startup' type='QGroupBox' visible='1'}
:Generator:_QComboBox {buddy=':CMake Wizard.Generator:_QLabel' type='QComboBox' unnamed='1' visible='1'}
:Hits_QCLuceneResultWidget {aboveWidget=':Hits_QLabel' type='QCLuceneResultWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
diff --git a/tests/system/suite_editors/tst_select_all/testdata/files.tsv b/tests/system/suite_editors/shared/testdata/files.tsv
index bc9ade1813..bc9ade1813 100644
--- a/tests/system/suite_editors/tst_select_all/testdata/files.tsv
+++ b/tests/system/suite_editors/shared/testdata/files.tsv
diff --git a/tests/system/suite_editors/suite.conf b/tests/system/suite_editors/suite.conf
index a93a3e3fac..e7a043be62 100644
--- a/tests/system/suite_editors/suite.conf
+++ b/tests/system/suite_editors/suite.conf
@@ -7,6 +7,6 @@ HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAP=../objects.map
-TEST_CASES=tst_basic_cpp_support tst_memberoperator tst_modify_readonly tst_qml_editor tst_qml_indent tst_rename_macros tst_revert_changes tst_select_all
+TEST_CASES=tst_basic_cpp_support tst_delete_externally tst_memberoperator tst_modify_readonly tst_qml_editor tst_qml_indent tst_rename_macros tst_revert_changes tst_select_all
VERSION=2
WRAPPERS=Qt
diff --git a/tests/system/suite_editors/tst_delete_externally/test.py b/tests/system/suite_editors/tst_delete_externally/test.py
new file mode 100644
index 0000000000..ab06f1dd82
--- /dev/null
+++ b/tests/system/suite_editors/tst_delete_externally/test.py
@@ -0,0 +1,58 @@
+source("../../shared/qtcreator.py")
+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))
+ shutil.copyfile(filepath, dst)
+ return dst
+
+def main():
+ global templateDir
+ files = map(lambda record: os.path.normpath(os.path.join(srcPath, testData.field(record, "filename"))),
+ testData.dataset("files.tsv"))
+ for currentFile in files:
+ if not neededFilePresent(currentFile):
+ return
+ templateDir = tempDir()
+ files = map(copyToTemplateDir, files)
+
+ startApplication("qtcreator" + SettingsPath)
+ for currentFile in files:
+ test.log("Opening file %s" % currentFile)
+ invokeMenuItem("File", "Open File or Project...")
+ selectFromFileDialog(currentFile)
+ editor = getEditorForFileSuffix(currentFile)
+ if editor == None:
+ test.fatal("Could not get the editor for '%s'" % currentFile,
+ "Skipping this file for now.")
+ continue
+
+ contentBefore = readFile(currentFile)
+ popupText = "The file %s was removed. Do you want to save it under a different name, or close the editor?"
+ os.remove(currentFile)
+ test.compare(waitForObject(":File has been removed_QMessageBox").text,
+ popupText % currentFile)
+ clickButton(waitForObject(":File has been removed.Save_QPushButton"))
+ waitFor("os.path.exists(currentFile)", 5000)
+ # avoids a lock-up on some Linux machines, purely empiric, might have different cause
+ waitFor("checkIfObjectExists(':File has been removed_QMessageBox', False, 0)", 5000)
+
+ test.compare(readFile(currentFile), contentBefore,
+ "Verifying that file '%s' was restored correctly" % currentFile)
+
+ # Different warning because of QTCREATORBUG-8130
+ popupText2 = "The file %s has been removed outside Qt Creator. Do you want to save it under a different name, or close the editor?"
+ os.remove(currentFile)
+ test.compare(waitForObject(":File has been removed_QMessageBox").text,
+ popupText2 % currentFile)
+ clickButton(waitForObject(":File has been removed.Close_QPushButton"))
+ invokeMenuItem("File", "Exit")