Commit 98c926f7 authored by Jan Kerekes's avatar Jan Kerekes Committed by Christian Stenger
Browse files

Added new test cases/suite for QML support



initial commit

Change-Id: Ifff6a8f9f6b74e099a906fafeb7db2c74aa3bc6f
Reviewed-by: default avatarRobert Löhning <robert.loehning@nokia.com>
Reviewed-by: default avatarChristian Stenger <christian.stenger@nokia.com>
parent 8ddf1fd4
......@@ -38,3 +38,13 @@ def checkSyntaxError(issuesView, expectedTextsArray, warnIfMoreIssues = True):
def checkIfObjectExists(name, shouldExist = True, timeout = 3000):
return waitFor("object.exists(name) == shouldExist", timeout)
# change autocomplete options to manual
def changeAutocompleteToManual():
invokeMenuItem("Tools", "Options...")
mouseClick(waitForObjectItem(":Options_QListView", "Text Editor"), 5, 5, 0, Qt.LeftButton)
clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Completion")
ensureChecked(waitForObject(":Behavior.Autocomplete common prefix_QCheckBox"), False)
selectFromCombo(":Behavior.completionTrigger_QComboBox", "Manually")
verifyEnabled(":Options.OK_QPushButton")
clickButton(waitForObject(":Options.OK_QPushButton"))
......@@ -43,15 +43,8 @@ def main():
"Step 4: Verifying if: Word 'void' is completed because only one option is available.")
# Step 5: From "Tools -> Options -> Text Editor -> Completion" select Activate completion Manually,
# uncheck Autocomplete common prefix and press Apply and then Ok . Return to Edit mode.
invokeMenuItem("Tools", "Options...")
waitForObjectItem(":Options_QListView", "Text Editor")
clickItem(":Options_QListView", "Text Editor", 5, 5, 0, Qt.LeftButton)
clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Completion")
clickButton(waitForObject(":Behavior.Autocomplete common prefix_QCheckBox"))
selectFromCombo(":Behavior.completionTrigger_QComboBox", "Manually")
test.verify(object.exists(":Options.OK_QPushButton"),
"Step 5: Verifying if: Code completion preferences can be changed.")
clickButton(waitForObject(":Options.OK_QPushButton"))
test.log("Step 5: Change Code Completion settings")
changeAutocompleteToManual()
# Step 6: Insert text "ret" and press Ctrl+Space.
editorWidget = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
mouseClick(editorWidget, 5, 5, 0, Qt.LeftButton)
......
QT_PLATFORM_PLUGIN=nonesuch
:Behavior.Autocomplete common prefix_QCheckBox {container=':CppTools__Internal__CompletionSettingsPage.Behavior_QGroupBox' name='partiallyComplete' text='Autocomplete common prefix' type='QCheckBox' visible='1'}
:Behavior.completionTrigger_QComboBox {container=':CppTools__Internal__CompletionSettingsPage.Behavior_QGroupBox' name='completionTrigger' type='QComboBox' visible='1'}
:CppTools__Internal__CompletionSettingsPage.Behavior_QGroupBox {container=':qt_tabwidget_stackedwidget.CppTools__Internal__CompletionSettingsPage_QWidget' name='groupBox' title='Behavior' type='QGroupBox' visible='1'}
:New Qt Quick Application.Add to version control:_QLabel {name='addToVersionControlLabel' text='Add to version control:' type='QLabel' visible='1'}
:Next_QPushButton {name='__qt__passive_wizardbutton1' text~='(Next.*|Continue)' type='QPushButton' visible='1'}
:Options.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':Options_Core::Internal::SettingsDialog'}
:Options.qt_tabwidget_stackedwidget_QStackedWidget {name='qt_tabwidget_stackedwidget' type='QStackedWidget' visible='1' window=':Options_Core::Internal::SettingsDialog'}
:Options.qt_tabwidget_tabbar_QTabBar {name='qt_tabwidget_tabbar' type='QTabBar' visible='1' window=':Options_Core::Internal::SettingsDialog'}
:Options_Core::Internal::SettingsDialog {type='Core::Internal::SettingsDialog' unnamed='1' visible='1' windowTitle~='(Options|Preferences)'}
:Options_QListView {type='QListView' unnamed='1' visible='1' window=':Options_Core::Internal::SettingsDialog'}
:Qt Creator.Issues_QListView {type='QListView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Issues'}
:Qt Creator.QtCreator.MenuBar_QMenuBar {name='QtCreator.MenuBar' type='QMenuBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Core::Internal::MainWindow {type='Core::Internal::MainWindow' unnamed='1' visible='1'}
:Qt Creator_QmlJSEditor::QmlJSTextEditorWidget {type='QmlJSEditor::QmlJSTextEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Utils::NavigationTreeView {type='Utils::NavigationTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:addToVersionControlComboBox_QComboBox {buddy=':New Qt Quick Application.Add to version control:_QLabel' name='addToVersionControlComboBox' type='QComboBox' visible='1'}
:m_popupFrame_QListView {container=':m_popupFrame_TextEditor::GenericProposalWidget' type='QListView' unnamed='1' visible='1'}
:m_popupFrame_TextEditor::GenericProposalWidget {name='m_popupFrame' type='TextEditor::GenericProposalWidget' visible='1'}
:qt_tabwidget_stackedwidget.CppTools__Internal__CompletionSettingsPage_QWidget {container=':Options.qt_tabwidget_stackedwidget_QStackedWidget' name='CppTools__Internal__CompletionSettingsPage' type='QWidget' visible='1'}
AUT=qtcreator
CLASS=
CLASSPATH=
ENVVARS=envvars
HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
TEST_CASES=tst_QMLS01 tst_QMLS02
VERSION=2
WRAPPERS=Qt
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.py")
# go to proper line, make backup, type needed text
def __beginTestSuggestions__(editorArea, lineText, textToType):
# make source code backup to clipboard
type(editorArea, "<Ctrl+A>")
type(editorArea, "<Ctrl+C>")
# place cursor to proper position and start typing
if not placeCursorToLine(editorArea, lineText):
return False
type(editorArea, "<Return>")
type(editorArea, textToType)
return True
# verify whether suggestions makes sense for typed textToType
def verifySuggestions(textToType):
popup = findObject(":m_popupFrame_QListView")
model = popup.model()
for row in range(model.rowCount()):
index = model.index(row, 0)
text = str(model.data(index).toString())
test.verify(textToType.lower() in text.lower(),
"Checking whether suggestion '%s' makes sense for typed '%s'"
% (text, textToType))
# restore source code from clipboard backup
def __endTestSuggestions__(editorArea):
type(editorArea, "<Ctrl+A>")
type(editorArea, "<Ctrl+V>")
def testSuggestionsAuto(lineText, textToType, expectedText, keyToUseSuggestion):
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# go to proper line, make backup, type needed text
if not __beginTestSuggestions__(editorArea, lineText, textToType):
return False
# check if suggestions are shown
test.verify(checkIfObjectExists(":m_popupFrame_QListView"),
"Verifying if suggestions in automatic mode are shown.")
# verify proposed suggestions
verifySuggestions(textToType)
# test if suggestion can be selected with keyToUseSuggestion
type(findObject(":m_popupFrame_QListView"), keyToUseSuggestion)
# get text which was written by usage of suggestion
typedText = str(lineUnderCursor(editorArea)).strip()
# verify if expected text is written
test.compare(typedText, expectedText,
"Verifying automatic suggestions usage with: " + keyToUseSuggestion + ", for text: " + textToType)
__endTestSuggestions__(editorArea)
return True
def testSuggestionsManual(lineText, textToType, expectedText):
# get editor
editorArea = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# go to proper line, make backup, type needed text
if not __beginTestSuggestions__(editorArea, lineText, textToType):
return False
# wait if automatic popup displayed - if yes then fail, because we are in manual mode
test.verify(checkIfObjectExists(":m_popupFrame_QListView", False),
"Verifying if suggestions in manual mode are properly not automatically shown")
# test if suggestion can be invoked manually
if platform.system() == "Darwin":
type(editorArea, "<Meta+Space>")
else:
type(editorArea, "<Ctrl+Space>")
# check if suggestions are shown
test.verify(checkIfObjectExists(":m_popupFrame_QListView"),
"Verifying if suggestions in manual mode are shown manually")
# verify proposed suggestions
verifySuggestions(textToType)
# test if suggestion can be used
type(findObject(":m_popupFrame_QListView"), "<Return>")
# get text which was written by usage of suggestion
typedText = str(lineUnderCursor(editorArea)).strip()
# verify if expected text is written
test.compare(typedText, expectedText,
"Verifying manual suggestions usage for text: " + textToType)
__endTestSuggestions__(editorArea)
return True
def saveAndExit():
invokeMenuItem("File", "Save All")
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)
# test "color: " suggestion usage with Enter key
if not testSuggestionsAuto("Text {", "col", "color:", "<Return>"):
saveAndExit()
return
# test "color: " suggestion usage with Tab key
if not testSuggestionsAuto("Text {", "col", "color:", "<Tab>"):
saveAndExit()
return
# test "textChanged: " suggestion - automatic insert, because only one suggestion available
shortcutToSuggestions = "<Ctrl+Space>"
if platform.system() == "Darwin":
shortcutToSuggestions = "<Meta+Space>"
if not testSuggestionsAuto("Text {","textChan", "textChanged:", shortcutToSuggestions):
saveAndExit()
return
# change settings to manual insertion of suggestions
changeAutocompleteToManual()
# test manual suggestions
testSuggestionsManual("Text {", "col", "color:")
# exit qt creator
saveAndExit()
source("../../shared/qtcreator.py")
source("../../shared/suites_qtta.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")
return
# write code with error (C should be lower case)
testingCodeLine = 'Color : "blue"'
type(editorArea, "<Return>")
type(editorArea, testingCodeLine)
# invoke QML parsing
invokeMenuItem("Tools", "QML/JS", "Run Checks")
# verify that error properly reported
issuesView = waitForObject(":Qt Creator.Issues_QListView")
test.verify(checkSyntaxError(issuesView, ["invalid property name 'Color'"], True),
"Verifying if error is properly reported")
# repair error - go to written line
placeCursorToLine(editorArea, testingCodeLine)
moveTextCursor(editorArea, QTextCursor.Left, QTextCursor.MoveAnchor, 14)
moveTextCursor(editorArea, QTextCursor.Right, QTextCursor.KeepAnchor, 1)
type(editorArea, "c")
# invoke QML parsing
invokeMenuItem("Tools", "QML/JS", "Run Checks")
# verify that there is no error/errors cleared
issuesView = waitForObject(":Qt Creator.Issues_QListView")
issuesModel = issuesView.model()
# wait for issues
test.verify(waitFor("issuesModel.rowCount() == 0", 3000),
"Verifying if error was properly cleared after code fix")
#save and exit
invokeMenuItem("File", "Save All")
invokeMenuItem("File", "Exit")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment