aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@nokia.com>2012-03-30 13:05:29 +0200
committerRobert Löhning <robert.loehning@nokia.com>2012-03-30 18:20:04 +0200
commitf3fd47f6017c3ce1020012bb51d91d6d09d6c729 (patch)
treeedcedc50f391ef39e955b6360cc00bf905ec68b4 /tests
parentf3bbbaeef61e434175d263ba4c34a39b356ac906 (diff)
Squish: Introduce new helper function
Change-Id: I6ef3022e7053c1e4993cc4276ccd2502de196754 Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/system/shared/editor_utils.py34
-rw-r--r--tests/system/suite_general/tst_select_all/test.py16
2 files changed, 43 insertions, 7 deletions
diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py
index a7656014e6..2ebf8205f9 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 690bebdfe2..f3e6851312 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 ["<Up>", "<Down>", "<Left>", "<Right>"]:
test.log("Selecting everything")