Skip to content
Snippets Groups Projects
Commit 867068c4 authored by Christian Stenger's avatar Christian Stenger
Browse files

Squish: Fix tst_modify_readonly


Change-Id: I31b7624ecab6d2d03c5ec6bd36e790a222c1deaa
Reviewed-by: default avatarRobert Loehning <robert.loehning@digia.com>
parent 22c5d99f
No related branches found
No related tags found
No related merge requests found
...@@ -145,6 +145,7 @@ ...@@ -145,6 +145,7 @@
:Session Manager_ProjectExplorer::Internal::SessionDialog {name='ProjectExplorer__Internal__SessionDialog' type='ProjectExplorer::Internal::SessionDialog' visible='1' windowTitle='Session Manager'} :Session Manager_ProjectExplorer::Internal::SessionDialog {name='ProjectExplorer__Internal__SessionDialog' type='ProjectExplorer::Internal::SessionDialog' visible='1' windowTitle='Session Manager'}
:Startup.contextHelpComboBox_QComboBox {container=':Form.Startup_QGroupBox' name='contextHelpComboBox' type='QComboBox' visible='1'} :Startup.contextHelpComboBox_QComboBox {container=':Form.Startup_QGroupBox' name='contextHelpComboBox' type='QComboBox' visible='1'}
:User Interface.languageBox_QComboBox {container=':Core__Internal__GeneralSettings.User Interface_QGroupBox' name='languageBox' type='QComboBox' visible='1'} :User Interface.languageBox_QComboBox {container=':Core__Internal__GeneralSettings.User Interface_QGroupBox' name='languageBox' type='QComboBox' visible='1'}
:WritePermissions_Core::Internal::ReadOnlyFilesDialog {name='Core__Internal__ReadOnlyFilesDialog' type='Core::Internal::ReadOnlyFilesDialog' visible='1' windowTitle='Files Without Write Permissions'}
:addToVersionControlComboBox_QComboBox {name='addToVersionControlComboBox' type='QComboBox' visible='1'} :addToVersionControlComboBox_QComboBox {name='addToVersionControlComboBox' type='QComboBox' visible='1'}
:fileNameEdit_QLineEdit {buddy=':Open File.File name:_QLabel' name='fileNameEdit' type='QLineEdit' visible='1'} :fileNameEdit_QLineEdit {buddy=':Open File.File name:_QLabel' name='fileNameEdit' type='QLineEdit' visible='1'}
:formFileLineEdit_Utils::FileNameValidatingLineEdit {buddy=':Qt Gui Application.Form file:_QLabel' name='formFileLineEdit' type='Utils::FileNameValidatingLineEdit' visible='1'} :formFileLineEdit_Utils::FileNameValidatingLineEdit {buddy=':Qt Gui Application.Form file:_QLabel' name='formFileLineEdit' type='Utils::FileNameValidatingLineEdit' visible='1'}
......
...@@ -90,11 +90,6 @@ def testModifyFile(fileName, editor, line, expectWarning): ...@@ -90,11 +90,6 @@ def testModifyFile(fileName, editor, line, expectWarning):
def testSaveChangesAndMakeWritable(modifiedFiles, readOnlyFiles): def testSaveChangesAndMakeWritable(modifiedFiles, readOnlyFiles):
saveDlgStr = ("{name='Core__Internal__SaveItemsDialog' type='Core::Internal::SaveItemsDialog' " saveDlgStr = ("{name='Core__Internal__SaveItemsDialog' type='Core::Internal::SaveItemsDialog' "
"visible='1' windowTitle='Save Changes'}") "visible='1' windowTitle='Save Changes'}")
readOnlyMBoxStr = ("{type='QMessageBox' unnamed='1' visible='1' text~='The file <i>.+</i> "
"is read only\.'}")
cannotResetStr = ("{text='Cannot set permissions to writable.' type='QMessageBox' "
"unnamed='1' visible='1'}")
filePattern = re.compile('The file <i>(.+)</i> is read only\.')
try: try:
waitForObject(saveDlgStr) waitForObject(saveDlgStr)
except: except:
...@@ -105,45 +100,36 @@ def testSaveChangesAndMakeWritable(modifiedFiles, readOnlyFiles): ...@@ -105,45 +100,36 @@ def testSaveChangesAndMakeWritable(modifiedFiles, readOnlyFiles):
checkUnsavedChangesContains(treeWidget.model(), modifiedFiles) checkUnsavedChangesContains(treeWidget.model(), modifiedFiles)
clickButton(waitForObject("{text='Save All' type='QPushButton' unnamed='1' visible='1' " clickButton(waitForObject("{text='Save All' type='QPushButton' unnamed='1' visible='1' "
"window=%s}" % saveDlgStr)) "window=%s}" % saveDlgStr))
# iterating over the number of modified files (order is unpredictable) try:
for i in range(len(modifiedFiles)): filesTree = waitForObject("{name='treeWidget' type='QTreeWidget' visible='1' "
try: "window=':WritePermissions_Core::Internal::ReadOnlyFilesDialog'}")
currentText = str(waitForObject(readOnlyMBoxStr, 3000).text) items = map(os.path.join, dumpItems(filesTree.model(), column=4),
currentFile = filePattern.match(currentText).group(1) dumpItems(filesTree.model(), column=3))
clickButton(waitForObject("{text='Make Writable' type='QPushButton' unnamed='1' " difference = set(readOnlyFiles) ^ set(items)
"visible='1' window=%s}" % readOnlyMBoxStr)) test.verify(len(difference) == 0, "Verifying whether all modified files without write "
try: "permission are listed.")
if not waitFor('__checkForMsgBoxOrQuit__(cannotResetStr)', 3000): clickButton("{text='Change Permission' type='QPushButton' visible='1' unnamed='1' "
raise Exception('Unexpected messagebox did not appear (EXPECTED!).') "window=':WritePermissions_Core::Internal::ReadOnlyFilesDialog'}")
# should not be possible except:
test.fail("Could not reset file '%s' to writable state." % currentFile) test.fatal("Missing dialog regarding missing permission on read only files.")
clickButton("{text='OK' type='QPushButton' window=%s}" % cannotResetStr) exitCanceled = False
except: try:
if isWritable(currentFile): mBoxStr = "{type='QMessageBox' unnamed='1' visible='1' text?='*Could not save the files.'}"
if currentFile in readOnlyFiles: msgBox = waitForObject(mBoxStr, 3000)
test.passes("File '%s' reset to writable state and saved." % currentFile) test.fatal("Creator failed to set permissions.", str(msgBox.text))
readOnlyFiles.remove(currentFile) exitCanceled = True
else: clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' "
test.fatal("Creator states file '%s' is read-only - but supposed to be " "window=%s}" % mBoxStr))
"writable." % currentFile) except:
else: for current in readOnlyFiles:
test.fail("Creator states file '%s' had been made writable - " test.verify(isWritable(current),
"but it's still read only." % currentFile) "Checking whether Creator made '%s' writable again." % current)
except: if exitCanceled:
if len(readOnlyFiles) != 0: invokeMenuItem("File", "Exit")
test.fail("Missing QMessageBox about a read only file.") test.log("Exiting without saving.")
if not test.compare(len(readOnlyFiles), 0, waitForObject(saveDlgStr)
"Checking whether all files have been handled correctly."): clickButton(waitForObject("{text='Do not Save' type='QPushButton' unnamed='1' "
try: "visible='1' window=%s}" % saveDlgStr))
invokeMenuItem("File", "Exit")
waitForObject(saveDlgStr)
clickButton(waitForObject("{text='Do not Save' type='QPushButton' unnamed='1' "
"visible='1' window=%s}" % saveDlgStr))
except:
pass
def __checkForMsgBoxOrQuit__(crs):
return currentApplicationContext().isRunning and object.exists(crs)
def checkOpenDocumentsContains(itemName): def checkOpenDocumentsContains(itemName):
openDocsTreeViewModel = waitForObject(":OpenDocuments_Widget").model() openDocsTreeViewModel = waitForObject(":OpenDocuments_Widget").model()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment