From 4d6cb992b12fdf9b2da7ebb1bd0f8b9ec7a59873 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 2 Dec 2013 18:57:23 +0100 Subject: [PATCH] Squish: Use generic function textUnderCursor(...) Change-Id: I7ea6e9af1435e716266f4dfd917fe9ac568a67a5 Reviewed-by: Christian Stenger --- tests/system/shared/utils.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 3279980aab7..b46499d8b2c 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -112,19 +112,16 @@ def selectFromLocator(filter, itemName = None): doubleClick(wantedItem, 5, 5, 0, Qt.LeftButton) def wordUnderCursor(window): - cursor = window.textCursor() - oldposition = cursor.position() - cursor.movePosition(QTextCursor.StartOfWord) - cursor.movePosition(QTextCursor.EndOfWord, QTextCursor.KeepAnchor) - returnValue = cursor.selectedText() - cursor.setPosition(oldposition) - return returnValue + return textUnderCursor(window, QTextCursor.StartOfWord, QTextCursor.EndOfWord) def lineUnderCursor(window): + return textUnderCursor(window, QTextCursor.StartOfLine, QTextCursor.EndOfLine) + +def textUnderCursor(window, fromPos, toPos): cursor = window.textCursor() oldposition = cursor.position() - cursor.movePosition(QTextCursor.StartOfLine) - cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor) + cursor.movePosition(fromPos) + cursor.movePosition(toPos, QTextCursor.KeepAnchor) returnValue = cursor.selectedText() cursor.setPosition(oldposition) return returnValue