diff options
author | Robert Loehning <robert.loehning@nokia.com> | 2012-05-23 15:36:30 +0200 |
---|---|---|
committer | Robert Löhning <robert.loehning@nokia.com> | 2012-05-23 17:16:19 +0200 |
commit | 53fb9d4ae84443ceca67ed6ac793a82640274209 (patch) | |
tree | 05bf5343e3d17476dd15536631ff587f3eb4bbac | |
parent | a71b76867540d63c9c46899f288249d92924a03c (diff) | |
download | qt-creator-53fb9d4ae84443ceca67ed6ac793a82640274209.tar.gz |
Squish: Simplified placeCursorToLine
Change-Id: Ib56bc7b2596ac61233e147fb62f763a594abe9df
Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
-rw-r--r-- | tests/system/shared/editor_utils.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 2ebf8205f9..ae5fc8cfde 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -5,7 +5,7 @@ import re; # and goes to the end of the line # line can be a regex - but if so, remember to set isRegex to True # the function returns True if this went fine, False on error -def placeCursorToLine(editor,line,isRegex=False): +def placeCursorToLine(editor, line, isRegex=False): cursor = editor.textCursor() oldPosition = 0 cursor.setPosition(oldPosition) @@ -15,26 +15,17 @@ def placeCursorToLine(editor,line,isRegex=False): regex = re.compile(line) while not found: currentLine = str(lineUnderCursor(editor)).strip() - if isRegex: - if regex.match(currentLine): - found = True - else: - moveTextCursor(editor, QTextCursor.Down, QTextCursor.MoveAnchor) - if oldPosition==editor.textCursor().position(): - break - oldPosition = editor.textCursor().position() - else: - if currentLine==line: - found = True - else: - moveTextCursor(editor, QTextCursor.Down, QTextCursor.MoveAnchor) - if oldPosition==editor.textCursor().position(): - break - oldPosition = editor.textCursor().position() + found = isRegex and regex.match(currentLine) or not isRegex and currentLine == line + if not found: + type(editor, "<Down>") + newPosition = editor.textCursor().position() + if oldPosition == newPosition: + break + oldPosition = newPosition if not found: test.fatal("Couldn't find line matching\n\n%s\n\nLeaving test..." % line) return False - cursor=editor.textCursor() + cursor = editor.textCursor() cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.MoveAnchor) editor.setTextCursor(cursor) return True |