Commit 4cb9f675 authored by Christian Stenger's avatar Christian Stenger
Browse files

Squish: use new approach for markText()

This new approach is a bit slower than using Qt functionality,
but it's now completely relying on user-interaction.

Change-Id: I361f6f201dfff8122a11aae30204eb79967fe4ae
Reviewed-by: default avatarRobert Loehning <>
parent 37828fb1
......@@ -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.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor, endPosition-startPosition)
cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor)
cursor.setPosition(endPosition, QTextCursor.KeepAnchor)
# 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):
......@@ -28,8 +28,7 @@ def main():
invokeMenuItem("File", "Exit")
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)
......@@ -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")
......@@ -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")
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>")
......@@ -27,8 +27,7 @@ def testRenameMacroAfterSourceModification():
type(cppEditorStr, "<Command+Left>")
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>")
type(cppEditorStr, "<Home>")
for i in range(4):
type(cppEditorStr, "<Shift+Down>")
markText(cppEditorStr, "Down", 4)
invokeMenuItem("Edit", "Cut")
def __paste__():
......@@ -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):
......@@ -85,13 +85,9 @@ def performModification(afterLine, typing, markCount, markDirection, newText):
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+")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment