summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@nokia.com>2012-05-25 11:52:01 +0200
committerRobert Löhning <robert.loehning@nokia.com>2012-05-25 13:11:17 +0200
commitea63b86e49d2f15eb2aff1548aae1fce1af70090 (patch)
treee40f0d6076aa9eaa3895e8ff8f19ee627952de97
parent53fb9d4ae84443ceca67ed6ac793a82640274209 (diff)
downloadqt-creator-ea63b86e49d2f15eb2aff1548aae1fce1af70090.tar.gz
Squish: Replaced function moveTextCursor
Change-Id: Ie4cccd0de668690a3d66baf422bcfff7acae7345 Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
-rw-r--r--tests/system/shared/editor_utils.py15
-rw-r--r--tests/system/suite_QMLS/tst_QMLS02/test.py5
-rw-r--r--tests/system/suite_QMLS/tst_QMLS03/test.py9
-rw-r--r--tests/system/suite_QMLS/tst_QMLS04/test.py3
-rw-r--r--tests/system/suite_QMLS/tst_QMLS05/test.py24
5 files changed, 22 insertions, 34 deletions
diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py
index ae5fc8cfde..8f7b74026f 100644
--- a/tests/system/shared/editor_utils.py
+++ b/tests/system/shared/editor_utils.py
@@ -30,21 +30,6 @@ def placeCursorToLine(editor, line, isRegex=False):
editor.setTextCursor(cursor)
return True
-# this function moves the text cursor of an editor by using Qt internal functions
-# this is more reliable (especially on Mac) than the type() approach
-# param editor an editor object
-# param moveOperation a value of enum MoveOperation (of QTextCursor)
-# param moveAnchor a value of enum MoveMode (of QTextCursor)
-# param n how often repeat the move operation?
-def moveTextCursor(editor, moveOperation, moveAnchor, n=1):
- if not editor or isinstance(editor, (str,unicode)):
- test.fatal("Either got a NoneType or a string instead of an editor object")
- return False
- textCursor = editor.textCursor()
- result = textCursor.movePosition(moveOperation, moveAnchor, n)
- editor.setTextCursor(textCursor)
- return result
-
# this function returns True if a QMenu is
# popped up above the given editor
# param editor is the editor where the menu should appear
diff --git a/tests/system/suite_QMLS/tst_QMLS02/test.py b/tests/system/suite_QMLS/tst_QMLS02/test.py
index 3c65ac020f..7f29524b83 100644
--- a/tests/system/suite_QMLS/tst_QMLS02/test.py
+++ b/tests/system/suite_QMLS/tst_QMLS02/test.py
@@ -16,8 +16,9 @@ def main():
"Verifying if error is properly reported")
# repair error - go to written line
placeCursorToLine(editorArea, testingCodeLine)
- moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 14)
- moveTextCursor(editorArea, QTextCursor.Right, QTextCursor.KeepAnchor, 1)
+ for i in range(14):
+ type(editorArea, "<Left>")
+ type(editorArea, "<Shift+Right>")
type(editorArea, "c")
# invoke QML parsing
invokeMenuItem("Tools", "QML/JS", "Run Checks")
diff --git a/tests/system/suite_QMLS/tst_QMLS03/test.py b/tests/system/suite_QMLS/tst_QMLS03/test.py
index c492a4d268..bbd4facd23 100644
--- a/tests/system/suite_QMLS/tst_QMLS03/test.py
+++ b/tests/system/suite_QMLS/tst_QMLS03/test.py
@@ -59,7 +59,8 @@ def main():
if not placeCursorToLine(editorArea, "Rectangle {"):
invokeMenuItem("File", "Exit")
return
- moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 5)
+ for i in range(5):
+ type(editorArea, "<Left>")
ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Find Usages"))
# check if usage was properly found
@@ -77,7 +78,8 @@ def main():
if not placeCursorToLine(editorArea, "anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }"):
invokeMenuItem("File", "Exit")
return
- moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 87)
+ for i in range(87):
+ type(editorArea, "<Left>")
invokeMenuItem("Tools", "QML/JS", "Find Usages")
# check if usage was properly found
expectedResults = [ExpectedResult("color-animation.qml", 50, "anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }"),
@@ -94,7 +96,8 @@ def main():
if not placeCursorToLine(editorArea, "SequentialAnimation on opacity {"):
invokeMenuItem("File", "Exit")
return
- moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 5)
+ for i in range(5):
+ type(editorArea, "<Left>")
type(editorArea, "<Ctrl+Shift+U>")
# check if usage was properly found
expectedResults = [ExpectedResult("color-animation.qml", 87, "SequentialAnimation on opacity {")]
diff --git a/tests/system/suite_QMLS/tst_QMLS04/test.py b/tests/system/suite_QMLS/tst_QMLS04/test.py
index e62b72dc6a..e14f79804a 100644
--- a/tests/system/suite_QMLS/tst_QMLS04/test.py
+++ b/tests/system/suite_QMLS/tst_QMLS04/test.py
@@ -5,7 +5,8 @@ def main():
editorArea = startQtCreatorWithNewAppAtQMLEditor(projectDir, "SampleApp", "Text {")
if not editorArea:
return
- moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 5)
+ for i in range(5):
+ type(editorArea, "<Left>")
# invoke Refactoring - Move Component into separate file
ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring"))
diff --git a/tests/system/suite_QMLS/tst_QMLS05/test.py b/tests/system/suite_QMLS/tst_QMLS05/test.py
index 694460eea3..f2e0fb5072 100644
--- a/tests/system/suite_QMLS/tst_QMLS05/test.py
+++ b/tests/system/suite_QMLS/tst_QMLS05/test.py
@@ -4,12 +4,17 @@ def main():
editorArea = startQtCreatorWithNewAppAtQMLEditor(tempDir(), "SampleApp", "Text {")
if not editorArea:
return
- moveTextCursor(editorArea, QTextCursor.StartOfLine, QTextCursor.MoveAnchor)
+ homeKey = "<Home>"
+ if platform.system() == "Darwin":
+ homeKey = "<Ctrl+Left>"
+ for i in range(2):
+ type(editorArea, homeKey)
type(editorArea, "<Return>")
- moveTextCursor(editorArea, QTextCursor.Up, QTextCursor.MoveAnchor)
+ type(editorArea, "<Up>")
type(editorArea, "<Tab>")
type(editorArea, "Item { x: 10; y: 20; width: 10 }")
- moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 30)
+ for i in range(30):
+ type(editorArea, "<Left>")
invokeMenuItem("File", "Save All")
# activate menu and apply 'Refactoring - Split initializer'
numLinesExpected = len(str(editorArea.plainText).splitlines()) + 4
@@ -20,16 +25,9 @@ def main():
waitFor("len(str(editorArea.plainText).splitlines()) == numLinesExpected", 5000)
# verify if refactoring was properly applied - each part on separate line
verifyMessage = "Verifying split initializer functionality at element line."
- verifyCurrentLine(editorArea, "Item {", verifyMessage)
- moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
- verifyCurrentLine(editorArea, "x: 10;", verifyMessage)
- moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
- verifyCurrentLine(editorArea, "y: 20;", verifyMessage)
- moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
- verifyCurrentLine(editorArea, "width: 10", verifyMessage)
- moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
- verifyCurrentLine(editorArea, "}", verifyMessage)
- moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
+ for line in ["Item {", "x: 10;", "y: 20;", "width: 10", "}"]:
+ verifyCurrentLine(editorArea, line, verifyMessage)
+ type(editorArea, "<Down>")
#save and exit
invokeMenuItem("File", "Save All")
invokeMenuItem("File", "Exit")