summaryrefslogtreecommitdiff
path: root/tests/system/suite_QMLS/tst_QMLS04/test.py
diff options
context:
space:
mode:
authorJan Kerekes <jan.kerekes@ixonos.com>2012-04-25 09:57:22 +0200
committerRobert Löhning <robert.loehning@nokia.com>2012-05-02 18:30:52 +0200
commit9186d1ac57b607d7c2c486c6c5425e9861147477 (patch)
tree23a1879a2358a6f9ac3e101553cfefc5f08260ab /tests/system/suite_QMLS/tst_QMLS04/test.py
parent02e08c61d75b6b796e7ebbd6161e38b55c1d5efa (diff)
downloadqt-creator-9186d1ac57b607d7c2c486c6c5425e9861147477.tar.gz
Added new test cases (QMLS03, QMLS04, QMLS05) for QMLS suite
initial commit Change-Id: I955f7ca471541d4fb9c8505eb041b433cbff8b84 Reviewed-by: Christian Stenger <christian.stenger@nokia.com> Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
Diffstat (limited to 'tests/system/suite_QMLS/tst_QMLS04/test.py')
-rw-r--r--tests/system/suite_QMLS/tst_QMLS04/test.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/system/suite_QMLS/tst_QMLS04/test.py b/tests/system/suite_QMLS/tst_QMLS04/test.py
new file mode 100644
index 0000000000..3c7f76ffdc
--- /dev/null
+++ b/tests/system/suite_QMLS/tst_QMLS04/test.py
@@ -0,0 +1,59 @@
+source("../../shared/qtcreator.py")
+source("../../shared/suites_qtta.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")
+ return
+ moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 5)
+ # invoke Refactoring - Move Component into separate file
+ ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
+ activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring"))
+ activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Move Component into separate file"))
+ # give component name and proceed
+ replaceEditorContent(waitForObject(":Dialog.componentNameEdit_QLineEdit"), "MyComponent")
+ clickButton(waitForObject(":Dialog.OK_QPushButton"))
+ # verify if refactoring is done correctly
+ waitFor("'MyComponent' in str(editorArea.plainText)", 2000)
+ codeText = str(editorArea.plainText)
+ patternCodeToAdd = "MyComponent\s+\{\s*\}"
+ patternCodeToMove = "Text\s+\{.*\}"
+ # there should be empty MyComponent item instead of Text item
+ if re.search(patternCodeToAdd, codeText, re.DOTALL) and not re.search(patternCodeToMove, codeText, re.DOTALL):
+ test.passes("Refactoring was properly applied in source file")
+ else:
+ test.fail("Refactoring of Text to MyComponent failed in source file. Content of editor:\n%s" % codeText)
+ # there should be new QML file generated with name "MyComponent.qml"
+ try:
+ waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.MyComponent\\.qml", 3000)
+ test.passes("Refactoring - file MyComponent.qml was generated properly in project explorer")
+ except:
+ test.fail("Refactoring failed - file MyComponent.qml was not generated properly in project explorer")
+ #save and exit
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Exit")
+ # select MyComponent.qml file
+ doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.MyComponent\\.qml", 5, 5, 0, Qt.LeftButton)
+ editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
+ codeText = str(editorArea.plainText)
+ # there should be Text item in new file
+ if re.search(patternCodeToMove, codeText, re.DOTALL):
+ test.passes("Refactoring was properly applied to destination file")
+ else:
+ test.fail("Refactoring failed in destination file. Content of editor:\n%s" % codeText)
+ #save and exit
+ invokeMenuItem("File", "Save All")
+ # check if new file was created in file system
+ test.verify(os.path.exists(projectDir + "/SampleApp/qml/SampleApp/MyComponent.qml"),
+ "Verifying if MyComponent.qml exists in file system after save")
+ invokeMenuItem("File", "Exit")
+