diff --git a/tests/system/suite_QMLS/shared/qmls.py b/tests/system/suite_QMLS/shared/qmls.py new file mode 100644 index 0000000000000000000000000000000000000000..37bcdcb622244cfa46c64aed5fcdb0ab59b4b255 --- /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 92a62f985bcc4413b34b3752862020ceda28d288..b76dd10106ce97cbddc59147607657386b760adc 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 0cfc9e88ffb43d409b243152a22f6ef132fbfc7f..3c65ac020f4cddd099057b9fe33689903b6bacff 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 3c7f76ffdc41cf8aebd81b7ab30cc077c8430da9..e62b72dc6ae29adf85a187e635fd6f12049443e7 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 5f018bde2a4fec9a4cfbed44aefe6174f1eb0e93..694460eea3277c7c968a5e050c972f4ca27b3979 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")