2012-05-10 10:53:06 +02:00
|
|
|
source("../shared/qmls.py")
|
2012-04-25 09:57:22 +02:00
|
|
|
|
|
|
|
|
def main():
|
2012-05-10 10:53:06 +02:00
|
|
|
editorArea = startQtCreatorWithNewAppAtQMLEditor(tempDir(), "SampleApp", "Text {")
|
|
|
|
|
if not editorArea:
|
2012-04-25 09:57:22 +02:00
|
|
|
return
|
|
|
|
|
moveTextCursor(editorArea, QTextCursor.StartOfLine, QTextCursor.MoveAnchor)
|
|
|
|
|
type(editorArea, "<Return>")
|
|
|
|
|
moveTextCursor(editorArea, QTextCursor.Up, QTextCursor.MoveAnchor)
|
|
|
|
|
type(editorArea, "<Tab>")
|
|
|
|
|
type(editorArea, "Item { x: 10; y: 20; width: 10 }")
|
|
|
|
|
moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 30)
|
|
|
|
|
invokeMenuItem("File", "Save All")
|
|
|
|
|
# activate menu and apply 'Refactoring - Split initializer'
|
|
|
|
|
numLinesExpected = len(str(editorArea.plainText).splitlines()) + 4
|
|
|
|
|
ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
|
|
|
|
|
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring"))
|
|
|
|
|
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Split initializer"))
|
|
|
|
|
# wait until refactoring ended
|
|
|
|
|
waitFor("len(str(editorArea.plainText).splitlines()) == numLinesExpected", 5000)
|
|
|
|
|
# verify if refactoring was properly applied - each part on separate line
|
2012-05-10 10:53:06 +02:00
|
|
|
verifyMessage = "Verifying split initializer functionality at element line."
|
|
|
|
|
verifyCurrentLine(editorArea, "Item {", verifyMessage)
|
2012-04-25 09:57:22 +02:00
|
|
|
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
|
2012-05-10 10:53:06 +02:00
|
|
|
verifyCurrentLine(editorArea, "x: 10;", verifyMessage)
|
2012-04-25 09:57:22 +02:00
|
|
|
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
|
2012-05-10 10:53:06 +02:00
|
|
|
verifyCurrentLine(editorArea, "y: 20;", verifyMessage)
|
2012-04-25 09:57:22 +02:00
|
|
|
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
|
2012-05-10 10:53:06 +02:00
|
|
|
verifyCurrentLine(editorArea, "width: 10", verifyMessage)
|
2012-04-25 09:57:22 +02:00
|
|
|
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
|
2012-05-10 10:53:06 +02:00
|
|
|
verifyCurrentLine(editorArea, "}", verifyMessage)
|
2012-04-25 09:57:22 +02:00
|
|
|
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
|
|
|
|
|
#save and exit
|
|
|
|
|
invokeMenuItem("File", "Save All")
|
|
|
|
|
invokeMenuItem("File", "Exit")
|
|
|
|
|
|