Refactoring of QMLS suites

- moved common parts to shared script

Change-Id: I25ac888d7103ee36edff9ead502fa432a5dc2937
Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
This commit is contained in:
Jan Kerekes
2012-05-10 10:53:06 +02:00
committed by Robert Löhning
parent 131424ed81
commit 7b51bfc845
5 changed files with 42 additions and 52 deletions

View File

@@ -0,0 +1,24 @@
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
def startQtCreatorWithNewAppAtQMLEditor(projectDir, projectName, line = None):
startApplication("qtcreator" + SettingsPath)
# create qt quick application
createNewQtQuickApplication(projectDir, projectName)
# open qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", projectName + ".QML.qml/" +
projectName + ".main\\.qml", 5, 5, 0, Qt.LeftButton)
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# place to line if needed
if line:
# place cursor to component
if not placeCursorToLine(editorArea, line):
invokeMenuItem("File", "Exit")
return None
return editorArea
def verifyCurrentLine(editorArea, currentLineExpectedText, verifyMessage):
currentLineText = str(lineUnderCursor(editorArea)).strip();
return test.compare(currentLineText, currentLineExpectedText, verifyMessage)

View File

@@ -1,5 +1,4 @@
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
source("../shared/qmls.py")
# go to proper line, make backup, type needed text
def __beginTestSuggestions__(editorArea, lineText, textToType):
@@ -84,11 +83,8 @@ def saveAndExit():
invokeMenuItem("File", "Exit")
def main():
startApplication("qtcreator" + SettingsPath)
# create qt quick application
createNewQtQuickApplication(tempDir(), "SampleApp")
# open qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.main\\.qml", 5, 5, 0, Qt.LeftButton)
if not startQtCreatorWithNewAppAtQMLEditor(tempDir(), "SampleApp"):
return
# test "color: " suggestion usage with Enter key
if not testSuggestionsAuto("Text {", "col", "color:", "<Return>"):
saveAndExit()

View File

@@ -1,16 +1,8 @@
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
source("../shared/qmls.py")
def main():
startApplication("qtcreator" + SettingsPath)
# create qt quick application
createNewQtQuickApplication(tempDir(), "SampleApp")
# open qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.main\\.qml", 5, 5, 0, Qt.LeftButton)
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
if not placeCursorToLine(editorArea, "Text {"):
invokeMenuItem("File", "Exit")
editorArea = startQtCreatorWithNewAppAtQMLEditor(tempDir(), "SampleApp", "Text {")
if not editorArea:
return
# write code with error (C should be lower case)
testingCodeLine = 'Color : "blue"'

View File

@@ -1,18 +1,9 @@
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
source("../shared/qmls.py")
def main():
startApplication("qtcreator" + SettingsPath)
# create qt quick application
projectDir = tempDir()
createNewQtQuickApplication(projectDir, "SampleApp")
# open qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.main\\.qml", 5, 5, 0, Qt.LeftButton)
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# place cursor to component
if not placeCursorToLine(editorArea, "Text {"):
invokeMenuItem("File", "Exit")
editorArea = startQtCreatorWithNewAppAtQMLEditor(projectDir, "SampleApp", "Text {")
if not editorArea:
return
moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 5)
# invoke Refactoring - Move Component into separate file

View File

@@ -1,22 +1,8 @@
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
def verifyCurrentLine(editorArea, currentLineExpectedText):
verifyMessage = "Verifying split initializer functionality at element line."
currentLineText = str(lineUnderCursor(editorArea)).strip();
return test.compare(currentLineText, currentLineExpectedText, verifyMessage)
source("../shared/qmls.py")
def main():
startApplication("qtcreator" + SettingsPath)
# create qt quick application
createNewQtQuickApplication(tempDir(), "SampleApp")
# open qml file
doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.main\\.qml", 5, 5, 0, Qt.LeftButton)
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# prepare code for test - type one-line element
if not placeCursorToLine(editorArea, "Text {"):
invokeMenuItem("File", "Exit")
editorArea = startQtCreatorWithNewAppAtQMLEditor(tempDir(), "SampleApp", "Text {")
if not editorArea:
return
moveTextCursor(editorArea, QTextCursor.StartOfLine, QTextCursor.MoveAnchor)
type(editorArea, "<Return>")
@@ -33,15 +19,16 @@ def main():
# wait until refactoring ended
waitFor("len(str(editorArea.plainText).splitlines()) == numLinesExpected", 5000)
# verify if refactoring was properly applied - each part on separate line
verifyCurrentLine(editorArea, "Item {")
verifyMessage = "Verifying split initializer functionality at element line."
verifyCurrentLine(editorArea, "Item {", verifyMessage)
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
verifyCurrentLine(editorArea, "x: 10;")
verifyCurrentLine(editorArea, "x: 10;", verifyMessage)
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
verifyCurrentLine(editorArea, "y: 20;")
verifyCurrentLine(editorArea, "y: 20;", verifyMessage)
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
verifyCurrentLine(editorArea, "width: 10")
verifyCurrentLine(editorArea, "width: 10", verifyMessage)
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
verifyCurrentLine(editorArea, "}")
verifyCurrentLine(editorArea, "}", verifyMessage)
moveTextCursor(editorArea, QTextCursor.Down, QTextCursor.MoveAnchor, 1)
#save and exit
invokeMenuItem("File", "Save All")