summaryrefslogtreecommitdiff
path: root/tests/system/suite_qtquick
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@digia.com>2012-10-19 13:03:32 +0200
committerRobert Loehning <robert.loehning@digia.com>2012-10-19 14:21:24 +0200
commitfa655dd40784346db8fb3fd47d54e59c7e7e5763 (patch)
tree4ec82c70301870ea7087232a6f1a9c06d6ae271b /tests/system/suite_qtquick
parentb262d50f132980ebbdb19074e39de270b708f94e (diff)
downloadqt-creator-fa655dd40784346db8fb3fd47d54e59c7e7e5763.tar.gz
Squish: Moved editor tests to editors suite
Change-Id: I82bd92db762f7f997460ece4c2f77d0381dca6b5 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'tests/system/suite_qtquick')
-rw-r--r--tests/system/suite_qtquick/suite.conf2
-rw-r--r--tests/system/suite_qtquick/tst_qml_editor/test.py199
-rw-r--r--tests/system/suite_qtquick/tst_qml_indent/test.py85
3 files changed, 1 insertions, 285 deletions
diff --git a/tests/system/suite_qtquick/suite.conf b/tests/system/suite_qtquick/suite.conf
index fe58474d69..7700a40c5a 100644
--- a/tests/system/suite_qtquick/suite.conf
+++ b/tests/system/suite_qtquick/suite.conf
@@ -7,6 +7,6 @@ HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAP=../objects.map
-TEST_CASES=tst_qtquick_creation tst_qtquick_creation2 tst_qtquick_creation3 tst_qtquick_creation4 tst_qml_indent tst_qml_editor
+TEST_CASES=tst_qtquick_creation tst_qtquick_creation2 tst_qtquick_creation3 tst_qtquick_creation4
VERSION=2
WRAPPERS=Qt
diff --git a/tests/system/suite_qtquick/tst_qml_editor/test.py b/tests/system/suite_qtquick/tst_qml_editor/test.py
deleted file mode 100644
index 73605f7a30..0000000000
--- a/tests/system/suite_qtquick/tst_qml_editor/test.py
+++ /dev/null
@@ -1,199 +0,0 @@
-source("../../shared/qtcreator.py")
-
-workingDir = None
-templateDir = None
-searchFinished = False
-
-def main():
- global workingDir,templateDir
- sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/keyinteraction/focus")
- qmlFile = os.path.join("qml", "focus.qml")
- if not neededFilePresent(os.path.join(sourceExample, qmlFile)):
- return
- startApplication("qtcreator" + SettingsPath)
- # add docs to have the correct tool tips
- addHelpDocumentationFromSDK()
- # using a temporary directory won't mess up an eventually exisiting
- workingDir = tempDir()
- templateDir = prepareTemplate(sourceExample)
- prepareForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)")
- installLazySignalHandler("{type='Core::FutureProgress' unnamed='1'}", "finished()", "__handleFutureProgress__")
- createNewQtQuickApplication(workingDir, "untitled", os.path.join(templateDir, qmlFile))
- # wait for parsing to complete
- waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)")
- testRenameId()
- testFindUsages()
- testHovering()
- test.log("Test finished")
- invokeMenuItem("File", "Exit")
-
-def testRenameId():
- global searchFinished
- test.log("Testing rename of id")
- navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
- "window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
- model = navTree.model()
- files = ["Core.ContextMenu\\.qml", "Core.GridMenu\\.qml", "Core.ListMenu\\.qml", "focus\\.qml"]
- originalTexts = {}
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- # temporarily store editor content for synchronizing purpose
- # usage of formerTxt is done because I couldn't get waitForSignal() to work
- # it always stored a different object into the signalObjects map as it looked up afterwards
- # although used objectMap.realName() for both
- formerTxt = editor.plainText
- for file in files:
- doubleClickFile(navTree, file)
- # wait until editor content switched to the double-clicked file
- while formerTxt==editor.plainText:
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- # store content for next round
- formerTxt = editor.plainText
- originalTexts.setdefault(file, "%s" % formerTxt)
- test.log("stored %s's content" % file.replace("Core.","").replace("\\",""))
- # last opened file is the main file focus.qml
- line = "FocusScope\s*\{"
- if not placeCursorToLine(editor, line, True):
- test.fatal("File seems to have changed... Canceling current test")
- return False
- type(editor, "<Down>")
- searchFinished = False
- ctxtMenu = openContextMenuOnTextCursorPosition(editor)
- activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Rename Symbol Under Cursor"))
- waitFor("searchFinished")
- type(waitForObject("{leftWidget={text='Replace with:' type='QLabel' unnamed='1' visible='1'} "
- "type='Find::Internal::WideEnoughLineEdit' unnamed='1' visible='1' "
- "window=':Qt Creator_Core::Internal::MainWindow'}"), "renamedView")
- clickButton(waitForObject("{text='Replace' type='QToolButton' unnamed='1' visible='1' "
- "window=':Qt Creator_Core::Internal::MainWindow'}"))
- # store editor content for synchronizing purpose
- formerTxt = editor.plainText
- for file in files:
- doubleClickFile(navTree, file)
- # wait until editor content switched to double-clicked file
- while formerTxt==editor.plainText:
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- # store content for next round
- formerTxt = editor.plainText
- originalText = originalTexts.get(file).replace("mainView", "renamedView")
- test.compare(originalText,formerTxt, "Comparing %s" % file.replace("Core.","").replace("\\",""))
- invokeMenuItem("File","Save All")
-
-def __invokeFindUsage__(treeView, filename, line, additionalKeyPresses, expectedCount):
- global searchFinished
- doubleClickFile(treeView, filename)
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- if not placeCursorToLine(editor, line, True):
- test.fatal("File seems to have changed... Canceling current test")
- return
- for ty in additionalKeyPresses:
- type(editor, ty)
- searchFinished = False
- invokeContextMenuItem(editor, "Find Usages")
- waitFor("searchFinished")
- validateSearchResult(expectedCount)
-
-def testFindUsages():
- test.log("Testing find usage of an ID")
- navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
- "window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
- __invokeFindUsage__(navTree, "focus\\.qml", "FocusScope\s*\{", ["<Down>"], 6)
- test.log("Testing find usage of a property")
- clickButton(waitForObject(":*Qt Creator.Clear_QToolButton"))
- home = "<Home>"
- if platform.system() == "Darwin":
- home = "<Ctrl+Left>"
- __invokeFindUsage__(navTree, "focus\\.qml", "id: window", ["<Down>", "<Down>", home], 26)
-
-def testHovering():
- navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
- "window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
- test.log("Testing hovering elements")
- doubleClickFile(navTree, "focus\\.qml")
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- lines=["FocusScope\s*\{", "Rectangle\s*\{"]
- if platform.system() == "Darwin":
- home = "<Ctrl+Left>"
- else:
- home = "<Home>"
- additionalKeyPresses = [home, "<Right>"]
- expectedTypes = ["TextTip", "TextTip"]
- expectedValues = [
- {'text':'<table><tr><td valign=middle>FocusScope\n<p>The FocusScope object explicitly '
- 'creates a focus scope.</p></td><td>&nbsp;&nbsp;<img src=":/texteditor/images/f1.png"></td></tr></table>'},
- {'text':'<table><tr><td valign=middle>Rectangle\n<p>The Rectangle item provides a filled rectangle with an '
- 'optional border.</p></td><td>&nbsp;&nbsp;<img src=":/texteditor/images/f1.png"></td></tr></table>'}
- ]
- alternativeValues = [{"text":"FocusScope"}, {"text":"Rectangle"}]
- verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
- test.log("Testing hovering properties")
- doubleClickFile(navTree, "focus\\.qml")
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- lines = ['focus:\s*true', 'color:\s*"black"', 'states:\s*State\s*\{', 'transitions:\s*Transition\s*\{']
- expectedTypes = ["TextTip", "TextTip", "TextTip", "TextTip"]
- expectedValues = [
- {'text':'<table><tr><td valign=middle>boolean<p>This property indicates whether the item has focus '
- 'within the enclosing focus scope. If true, this item will gain active focus when the enclosing '
- 'focus scope gains active focus. In the following example, <tt>input</tt> will be given active focus '
- 'when <tt>scope</tt> gains active focus.</p></td><td>&nbsp;&nbsp;<img src=":/texteditor/images/f1.png"'
- '></td></tr></table>'},
- {'text':'<table><tr><td valign=middle>string<p>This property holds the color used to fill the rectangle.'
- '</p></td><td>&nbsp;&nbsp;<img src=":/texteditor/images/f1.png"></td></tr></table>'},
- {'text':'<table><tr><td valign=middle>State<p>This property holds a list of states defined by the item.'
- '</p></td><td>&nbsp;&nbsp;<img src=":/texteditor/images/f1.png"></td></tr></table>'},
- {'text':'<table><tr><td valign=middle>Transition<p>This property holds a list of transitions defined by '
- 'the item.</p></td><td>&nbsp;&nbsp;<img src=":/texteditor/images/f1.png"></td></tr></table>'}
- ]
- alternativeValues = [{"text":"boolean"}, {"text":"string"}, {"text":"State"}, {"text":"Transition"}]
- verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
- test.log("Testing hovering expressions")
- doubleClickFile(navTree, "focus\\.qml")
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- lines=['color:\s*"black"', 'color:\s*"#3E606F"']
- additionalKeyPresses = ["<Left>"]
- expectedValues = ["black", "#3E606F"]
- expectedTypes = ["ColorTip", "ColorTip"]
- verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues)
- doubleClickFile(navTree, "Core.ListMenu\\.qml")
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- lines=['Rectangle\s*\{.*color:\s*"#D1DBBD"', 'NumberAnimation\s*\{\s*.*Easing.OutQuint\s*\}']
- additionalKeyPresses = ["<Left>", "<Left>", "<Left>", "<Left>"]
- expectedTypes = ["ColorTip", "TextTip"]
- expectedValues = ["#D1DBBD", {"text":"number"}]
- verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues)
-
-def doubleClickFile(navTree, file):
- global templateDir
- treeElement = ("untitled.QML.%s/qml.%s" %
- (maskSpecialCharsForProjectTree(templateDir),file))
- waitForObjectItem(navTree, treeElement)
- doubleClickItem(navTree, treeElement, 5, 5, 0, Qt.LeftButton)
- mainWindow = waitForObject(":Qt Creator_Core::Internal::MainWindow")
- name = __getUnmaskedFilename__(file)
- waitFor("name in str(mainWindow.windowTitle)")
-
-def __getUnmaskedFilename__(maskedFilename):
- name = maskedFilename.split("\\.")
- path = name[0].rsplit(".", 1)
- if len(path) < 2:
- return ".".join(name)
- else:
- return ".".join((path[1], ".".join(name[1:])))
-
-def maskSpecialCharsForProjectTree(filename):
- filename = filename.replace("\\", "/").replace("_", "\\_").replace(".","\\.")
- # undoing mask operations on chars masked by mistake
- filename = filename.replace("/?","\\?").replace("/*","\\*")
- return filename
-
-def cleanup():
- global workingDir, templateDir
- waitForCleanShutdown()
- if workingDir!=None:
- deleteDirIfExists(workingDir)
- if templateDir!=None:
- deleteDirIfExists(os.path.dirname(templateDir))
-
-def __handleFutureProgress__(obj):
- global searchFinished
- if className(obj) == "Core::FutureProgress":
- searchFinished = True
diff --git a/tests/system/suite_qtquick/tst_qml_indent/test.py b/tests/system/suite_qtquick/tst_qml_indent/test.py
deleted file mode 100644
index 6efdb3b2fe..0000000000
--- a/tests/system/suite_qtquick/tst_qml_indent/test.py
+++ /dev/null
@@ -1,85 +0,0 @@
-source("../../shared/qtcreator.py")
-
-def main():
- global workingDir
- startApplication("qtcreator" + SettingsPath)
- # using a temporary directory won't mess up an eventually exisiting
- workingDir = tempDir()
- createNewQtQuickApplication(workingDir, "untitled")
- # wait for parsing to complete
- waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 5000)
- if not prepareQmlFile():
- invokeMenuItem("File", "Save All")
- invokeMenuItem("File", "Exit")
- return
- testReIndent()
- invokeMenuItem("File", "Save All")
- invokeMenuItem("File", "Exit")
-
-def prepareQmlFile():
- # make sure the QML file is opened
- navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' "
- "window=':Qt Creator_Core::Internal::MainWindow'}", 20000)
- model = navTree.model()
- waitForObjectItem(navTree, "untitled.QML.qml/untitled.main\\.qml")
- doubleClickItem(navTree, "untitled.QML.qml/untitled.main\\.qml", 5, 5, 0, Qt.LeftButton)
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget", 20000)
- for i in range(3):
- content = "%s" % editor.plainText
- start = content.find("Text {")
- end = content.rfind("}")
- end = content.rfind("}", end-1)
- if start==-1 or end==-1:
- test.fatal("Couldn't find line(s) I'm looking for - QML file seems to "
- "have changed!\nLeaving test...")
- return False
- markText(editor, start, end)
- type(editor, "<Ctrl+C>")
- for j in range(10):
- type(editor, "<Ctrl+V>")
- global originalText
- # assume the current editor content to be indented correctly
- originalText = "%s" % editor.plainText
- indented = editor.plainText
- lines = str(indented).splitlines()
- test.log("Using %d lines..." % len(lines))
- editor.plainText = "\n".join([line.lstrip() for line in lines]) + "\n"
- return True
-
-def handleTextChanged(object):
- global textHasChanged
- textHasChanged = True
-
-def testReIndent():
- global originalText,textHasChanged
- installLazySignalHandler(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget",
- "textChanged()", "handleTextChanged")
- textHasChanged = False
- editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
- type(editor, "<Ctrl+A>")
- test.log("calling re-indent")
- starttime = datetime.utcnow()
- type(editor, "<Ctrl+I>")
- waitFor("textHasChanged==True", 25000)
- endtime = datetime.utcnow()
- textAfterReIndent = "%s" % editor.plainText
- if originalText==textAfterReIndent:
- test.passes("Text successfully re-indented within %d seconds" % (endtime-starttime).seconds)
- else:
- # shrink the texts - it's huge output that takes long time to finish & screenshot is taken as well
- originalText = shrinkText(originalText, 20)
- textAfterReIndent = shrinkText(textAfterReIndent, 20)
- test.fail("Re-indent of text unsuccessful...",
- "Original (first 20 lines):\n%s\n\n______________________\nAfter re-indent (first 20 lines):\n%s"
- % (originalText, textAfterReIndent))
-
-def shrinkText(txt, lines=10):
- return "".join(txt.splitlines(True)[0:lines])
-
-def cleanup():
- global workingDir
- # waiting for a clean exit - for a full-remove of the temp directory
- waitForCleanShutdown()
- if workingDir!=None:
- deleteDirIfExists(workingDir)
-