diff options
-rw-r--r-- | tests/system/shared/editor_utils.py | 17 | ||||
-rw-r--r-- | tests/system/suite_CSUP/tst_CSUP05/test.py | 6 | ||||
-rw-r--r-- | tests/system/suite_QMLS/tst_QMLS02/test.py | 2 | ||||
-rw-r--r-- | tests/system/suite_editors/tst_qml_indent/test.py | 14 | ||||
-rw-r--r-- | tests/system/suite_editors/tst_rename_macros/test.py | 6 | ||||
-rw-r--r-- | tests/system/suite_editors/tst_revert_changes/test.py | 8 | ||||
-rw-r--r-- | tests/system/suite_qtquick/tst_qml_outline/test.py | 6 |
7 files changed, 25 insertions, 34 deletions
diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 45d533420e..c438804429 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -68,17 +68,12 @@ def openContextMenuOnTextCursorPosition(editor): waitFor("menuVisibleAtEditor(editor, menuInList)", 5000) return menuInList[0] -# this function marks/selects the text inside the given editor from position -# startPosition to endPosition (both inclusive) -def markText(editor, startPosition, endPosition): - cursor = editor.textCursor() - cursor.setPosition(startPosition) - cursor.movePosition(QTextCursor.StartOfLine) - editor.setTextCursor(cursor) - cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor, endPosition-startPosition) - cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor) - cursor.setPosition(endPosition, QTextCursor.KeepAnchor) - editor.setTextCursor(cursor) +# this function marks/selects the text inside the given editor from current cursor position +# param direction is one of "Left", "Right", "Up", "Down", but "End" and combinations work as well +# param typeCount defines how often the cursor will be moved in the given direction (while marking) +def markText(editor, direction, typeCount=1): + for i in range(typeCount): + type(editor, "<Shift+%s>" % direction) # works for all standard editors def replaceEditorContent(editor, newcontent): diff --git a/tests/system/suite_CSUP/tst_CSUP05/test.py b/tests/system/suite_CSUP/tst_CSUP05/test.py index 2017fb6e94..f3d065ed0e 100644 --- a/tests/system/suite_CSUP/tst_CSUP05/test.py +++ b/tests/system/suite_CSUP/tst_CSUP05/test.py @@ -28,8 +28,7 @@ def main(): invokeMenuItem("File", "Exit") return type(editorWidget, "<Left>") - for i in range(6): - type(editorWidget, "<Shift+Left>") + markText(editorWidget, "Left", 6) type(editorWidget, "<Ctrl+F>") # verify if find toolbar exists and if search text contains selected word test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar"), @@ -49,8 +48,7 @@ def main(): placeCursorToLine(editorWidget, "find.setOrientation(QmlApplicationfind::ScreenOrientationAuto);") for i in range(25): type(editorWidget, "<Left>") - for i in range(18): - type(editorWidget, "<Shift+Left>") + markText(editorWidget, "Left", 18) invokeMenuItem("Edit", "Find/Replace", "Find/Replace") replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "QmlApplicationViewer") oldCodeText = str(editorWidget.plainText) diff --git a/tests/system/suite_QMLS/tst_QMLS02/test.py b/tests/system/suite_QMLS/tst_QMLS02/test.py index 7f29524b83..e238bbde13 100644 --- a/tests/system/suite_QMLS/tst_QMLS02/test.py +++ b/tests/system/suite_QMLS/tst_QMLS02/test.py @@ -18,7 +18,7 @@ def main(): placeCursorToLine(editorArea, testingCodeLine) for i in range(14): type(editorArea, "<Left>") - type(editorArea, "<Shift+Right>") + markText(editorArea, "Right") type(editorArea, "c") # invoke QML parsing invokeMenuItem("Tools", "QML/JS", "Run Checks") diff --git a/tests/system/suite_editors/tst_qml_indent/test.py b/tests/system/suite_editors/tst_qml_indent/test.py index 23889a18d4..e38f766906 100644 --- a/tests/system/suite_editors/tst_qml_indent/test.py +++ b/tests/system/suite_editors/tst_qml_indent/test.py @@ -25,13 +25,19 @@ def prepareQmlFile(): for i in range(3): content = "%s" % editor.plainText start = content.find("Text {") - end = content.rfind("}") - end = content.rfind("}", end-1) - if start==-1 or end==-1: + if not placeCursorToLine(editor, "Text {"): test.fatal("Couldn't find line(s) I'm looking for - QML file seems to " "have changed!\nLeaving test...") return False - markText(editor, start, end) + type(editor, "<Right>") + type(editor, "<Up>") + # mark until the end of file + if platform.system() == 'Darwin': + markText(editor, "End") + else: + markText(editor, "Ctrl+End") + # unmark the last line + type(editor, "<Shift+Up>") type(editor, "<Ctrl+C>") for j in range(10): type(editor, "<Ctrl+V>") diff --git a/tests/system/suite_editors/tst_rename_macros/test.py b/tests/system/suite_editors/tst_rename_macros/test.py index 79cee380f1..ec1eec4a63 100644 --- a/tests/system/suite_editors/tst_rename_macros/test.py +++ b/tests/system/suite_editors/tst_rename_macros/test.py @@ -27,8 +27,7 @@ def testRenameMacroAfterSourceModification(): type(cppEditorStr, "<Command+Left>") else: type(cppEditorStr, "<Home>") - for i in range(5): - type(cppEditorStr, "<Shift+Down>") + markText(cppEditorStr, "Down", 5) type(cppEditorStr, "<Delete>") test.log("Testing rename macro after modifying source.") @@ -54,8 +53,7 @@ def testRenameMacroAfterSourceMoving(): type(cppEditorStr, "<Command+Left>") else: type(cppEditorStr, "<Home>") - for i in range(4): - type(cppEditorStr, "<Shift+Down>") + markText(cppEditorStr, "Down", 4) invokeMenuItem("Edit", "Cut") def __paste__(): diff --git a/tests/system/suite_editors/tst_revert_changes/test.py b/tests/system/suite_editors/tst_revert_changes/test.py index fc1983a5f1..afe11dde78 100644 --- a/tests/system/suite_editors/tst_revert_changes/test.py +++ b/tests/system/suite_editors/tst_revert_changes/test.py @@ -62,8 +62,7 @@ def __modifyHeader__(): global cppEditorStr, homeShortCut, endShortCut if placeCursorToLine(cppEditorStr, "class.+", True): type(cppEditorStr, homeShortCut) - for i in range(5): - type(cppEditorStr, "<Shift+Down>") + markText(cppEditorStr, "Down", 5) invokeMenuItem("Edit", "Cut") type(cppEditorStr, endShortCut) type(cppEditorStr, "<Return>") @@ -74,12 +73,11 @@ def __modifySource__(): global cppEditorStr, homeShortCut if placeCursorToLine(cppEditorStr, "void function1(int a);"): type(cppEditorStr, homeShortCut) - type(cppEditorStr, "<Shift+Down>") + markText(cppEditorStr, "Down") type(cppEditorStr, "<Delete>") if placeCursorToLine(cppEditorStr, "bool function1(int a) {"): type(cppEditorStr, homeShortCut) - for i in range(4): - type(cppEditorStr, "<Shift+Down>") + markText(cppEditorStr, "Down", 4) type(cppEditorStr, "<Delete>") def revertChanges(files): diff --git a/tests/system/suite_qtquick/tst_qml_outline/test.py b/tests/system/suite_qtquick/tst_qml_outline/test.py index 3ee4dd3560..56155824f6 100644 --- a/tests/system/suite_qtquick/tst_qml_outline/test.py +++ b/tests/system/suite_qtquick/tst_qml_outline/test.py @@ -85,13 +85,9 @@ def performModification(afterLine, typing, markCount, markDirection, newText): return if typing: type(qmlEditor, typing) - markText(qmlEditor, markCount, markDirection) + markText(qmlEditor, markDirection, markCount) type(qmlEditor, newText) -def markText(editor, charCount, direction): - for i in range(charCount): - type(editor, "<Shift+%s>" % direction) - # used to create the tsv file(s) def __writeOutlineFile__(outlinePseudoTree, filename): f = open(filename, "w+") |