2012-05-10 10:53:06 +02:00
|
|
|
source("../shared/qmls.py")
|
2012-04-25 09:57:22 +02:00
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
projectDir = tempDir()
|
2012-05-10 10:53:06 +02:00
|
|
|
editorArea = startQtCreatorWithNewAppAtQMLEditor(projectDir, "SampleApp", "Text {")
|
|
|
|
|
if not editorArea:
|
2012-04-25 09:57:22 +02:00
|
|
|
return
|
2012-05-25 11:52:01 +02:00
|
|
|
for i in range(5):
|
|
|
|
|
type(editorArea, "<Left>")
|
2012-04-25 09:57:22 +02:00
|
|
|
# invoke Refactoring - Move Component into separate file
|
2013-02-20 19:49:32 +01:00
|
|
|
invokeContextMenuItem(editorArea, "Refactoring", "Move Component into Separate File")
|
2012-04-25 09:57:22 +02:00
|
|
|
# give component name and proceed
|
|
|
|
|
replaceEditorContent(waitForObject(":Dialog.componentNameEdit_QLineEdit"), "MyComponent")
|
|
|
|
|
clickButton(waitForObject(":Dialog.OK_QPushButton"))
|
2012-05-16 18:13:55 +02:00
|
|
|
try:
|
|
|
|
|
waitForObject(":Add to Version Control_QMessageBox", 5000)
|
|
|
|
|
clickButton(waitForObject(":Add to Version Control.No_QPushButton"))
|
|
|
|
|
except:
|
|
|
|
|
pass
|
2012-04-25 09:57:22 +02:00
|
|
|
# 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)
|
2013-01-31 16:47:16 +01:00
|
|
|
myCompTE = "SampleApp.QML.qml/SampleApp.MyComponent\\.qml"
|
|
|
|
|
appeared = False
|
2012-04-25 09:57:22 +02:00
|
|
|
# there should be new QML file generated with name "MyComponent.qml"
|
|
|
|
|
try:
|
2013-01-31 16:47:16 +01:00
|
|
|
waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", myCompTE, 3000)
|
2012-04-25 09:57:22 +02:00
|
|
|
except:
|
2013-01-31 16:47:16 +01:00
|
|
|
try:
|
|
|
|
|
waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", addBranchWildcardToRoot(myCompTE), 1000)
|
|
|
|
|
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")
|
|
|
|
|
test.passes("Refactoring - file MyComponent.qml was generated properly in project explorer")
|
|
|
|
|
# open MyComponent.qml file for verification
|
|
|
|
|
if not openDocument(myCompTE):
|
|
|
|
|
test.fatal("Could not open MyComponent.qml.")
|
2012-04-25 09:57:22 +02:00
|
|
|
invokeMenuItem("File", "Save All")
|
|
|
|
|
invokeMenuItem("File", "Exit")
|
2013-01-31 16:47:16 +01:00
|
|
|
return
|
2012-04-25 09:57:22 +02:00
|
|
|
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")
|
|
|
|
|
|