From 7b51bfc845b1c768dbeca64a517f1f81fd8dd843 Mon Sep 17 00:00:00 2001 From: Jan Kerekes <jan.kerekes@ixonos.com> Date: Thu, 10 May 2012 10:53:06 +0200 Subject: [PATCH] Refactoring of QMLS suites MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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> --- tests/system/suite_QMLS/shared/qmls.py | 24 +++++++++++++++++ tests/system/suite_QMLS/tst_QMLS01/test.py | 10 +++---- tests/system/suite_QMLS/tst_QMLS02/test.py | 14 +++------- tests/system/suite_QMLS/tst_QMLS04/test.py | 15 +++-------- tests/system/suite_QMLS/tst_QMLS05/test.py | 31 +++++++--------------- 5 files changed, 42 insertions(+), 52 deletions(-) create mode 100644 tests/system/suite_QMLS/shared/qmls.py diff --git a/tests/system/suite_QMLS/shared/qmls.py b/tests/system/suite_QMLS/shared/qmls.py new file mode 100644 index 00000000000..37bcdcb6222 --- /dev/null +++ b/tests/system/suite_QMLS/shared/qmls.py @@ -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) + diff --git a/tests/system/suite_QMLS/tst_QMLS01/test.py b/tests/system/suite_QMLS/tst_QMLS01/test.py index 92a62f985bc..b76dd10106c 100644 --- a/tests/system/suite_QMLS/tst_QMLS01/test.py +++ b/tests/system/suite_QMLS/tst_QMLS01/test.py @@ -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() diff --git a/tests/system/suite_QMLS/tst_QMLS02/test.py b/tests/system/suite_QMLS/tst_QMLS02/test.py index 0cfc9e88ffb..3c65ac020f4 100644 --- a/tests/system/suite_QMLS/tst_QMLS02/test.py +++ b/tests/system/suite_QMLS/tst_QMLS02/test.py @@ -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"' diff --git a/tests/system/suite_QMLS/tst_QMLS04/test.py b/tests/system/suite_QMLS/tst_QMLS04/test.py index 3c7f76ffdc4..e62b72dc6ae 100644 --- a/tests/system/suite_QMLS/tst_QMLS04/test.py +++ b/tests/system/suite_QMLS/tst_QMLS04/test.py @@ -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 diff --git a/tests/system/suite_QMLS/tst_QMLS05/test.py b/tests/system/suite_QMLS/tst_QMLS05/test.py index 5f018bde2a4..694460eea32 100644 --- a/tests/system/suite_QMLS/tst_QMLS05/test.py +++ b/tests/system/suite_QMLS/tst_QMLS05/test.py @@ -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") -- GitLab