diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index a7656014e67..2ebf8205f99 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -225,3 +225,37 @@ def verifyProperties(properties, expectedProps): else: result[key] = None return result + +def getEditorForFileSuffix(curFile): + cppEditorSuffixes = ["cpp", "cc", "CC", "h", "H", "cp", "cxx", "C", "c++", "inl", "moc", "qdoc", + "tcc", "tpp", "t++", "c", "cu", "m", "mm", "hh", "hxx", "h++", "hpp", "hp"] + qmlEditorSuffixes = ["qml", "qmlproject", "js", "qs", "qtt"] + proEditorSuffixes = ["pro", "pri", "prf"] + suffix = __getFileSuffix__(curFile) + if suffix in cppEditorSuffixes: + editor = waitForObject("{type='CppEditor::Internal::CPPEditorWidget' unnamed='1' " + "visible='1' window=':Qt Creator_Core::Internal::MainWindow'}") + elif suffix in qmlEditorSuffixes: + editor = waitForObject("{type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' " + "visible='1' window=':Qt Creator_Core::Internal::MainWindow'}") + elif suffix in proEditorSuffixes: + editor = waitForObject("{type='Qt4ProjectManager::Internal::ProFileEditorWidget' unnamed='1' " + "visible='1' window=':Qt Creator_Core::Internal::MainWindow'}") + else: + test.log("Trying PlainTextEditor (file suffix: %s)" % suffix) + try: + editor = waitForObject("{type='TextEditor::PlainTextEditorWidget' unnamed='1' " + "visible='1' window=':Qt Creator_Core::Internal::MainWindow'}", 3000) + except: + test.fatal("Unsupported file suffix for file '%s'" % curFile) + editor = None + return editor + +# helper that determines the file suffix of the given fileName +# (doesn't matter if fileName contains the path as well) +def __getFileSuffix__(fileName): + suffix = os.path.basename(fileName).rsplit(".", 1) + if len(suffix) == 1: + return None + else: + return suffix[1] diff --git a/tests/system/suite_general/tst_select_all/test.py b/tests/system/suite_general/tst_select_all/test.py index 690bebdfe21..f3e68513125 100644 --- a/tests/system/suite_general/tst_select_all/test.py +++ b/tests/system/suite_general/tst_select_all/test.py @@ -10,21 +10,23 @@ def charactersInFile(filename): return len(content) def main(): - filesAndEditors = {srcPath + "/creator/README" : "TextEditor::PlainTextEditorWidget", - srcPath + "/creator/qtcreator.pri" : "Qt4ProjectManager::Internal::ProFileEditorWidget", - srcPath + "/creator/doc/snippets/qml/list-of-transitions.qml" : "QmlJSEditor::QmlJSTextEditorWidget"} - for currentFile in filesAndEditors: + files = [srcPath + "/creator/README", srcPath + "/creator/qtcreator.pri", + srcPath + "/creator/doc/snippets/qml/list-of-transitions.qml"] + for currentFile in files: if not neededFilePresent(currentFile): return startApplication("qtcreator" + SettingsPath) - for currentFile in filesAndEditors: + for currentFile in files: test.log("Opening file %s" % currentFile) size = charactersInFile(currentFile) invokeMenuItem("File", "Open File or Project...") selectFromFileDialog(currentFile) - editor = waitForObject("{type='%s' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}" - % filesAndEditors[currentFile], 20000) + editor = getEditorForFileSuffix(currentFile) + if editor == None: + test.fatal("Could not get the editor for '%s'" % currentFile, + "Skipping this file for now.") + continue JIRA.performWorkaroundIfStillOpen(6918, JIRA.Bug.CREATOR, editor) for key in ["", "", "", ""]: test.log("Selecting everything")