summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kerekes <jan.kerekes@ixonos.com>2012-04-03 14:49:47 +0200
committerChristian Stenger <christian.stenger@nokia.com>2012-04-24 15:36:17 +0200
commit98c926f7e57a47066cf92dc719a07112cc17680a (patch)
tree353cb55f8804cd737d1cc9bc88eef503e86338ae
parent8ddf1fd40cb5b6e2d85014e92a0f93831f521e5e (diff)
downloadqt-creator-98c926f7e57a47066cf92dc719a07112cc17680a.tar.gz
Added new test cases/suite for QML support
initial commit Change-Id: Ifff6a8f9f6b74e099a906fafeb7db2c74aa3bc6f Reviewed-by: Robert Löhning <robert.loehning@nokia.com> Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
-rwxr-xr-xtests/system/shared/suites_qtta.py10
-rw-r--r--tests/system/suite_CSUP/tst_CSUP01/test.py11
-rw-r--r--tests/system/suite_QMLS/envvars1
-rw-r--r--tests/system/suite_QMLS/objects.map19
-rw-r--r--tests/system/suite_QMLS/suite.conf10
-rw-r--r--tests/system/suite_QMLS/tst_QMLS01/test.py113
-rw-r--r--tests/system/suite_QMLS/tst_QMLS02/test.py41
7 files changed, 196 insertions, 9 deletions
diff --git a/tests/system/shared/suites_qtta.py b/tests/system/shared/suites_qtta.py
index a83ea23332..a3cb36d8d3 100755
--- a/tests/system/shared/suites_qtta.py
+++ b/tests/system/shared/suites_qtta.py
@@ -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"))
+
diff --git a/tests/system/suite_CSUP/tst_CSUP01/test.py b/tests/system/suite_CSUP/tst_CSUP01/test.py
index 8bf70f6982..90d8ec295a 100644
--- a/tests/system/suite_CSUP/tst_CSUP01/test.py
+++ b/tests/system/suite_CSUP/tst_CSUP01/test.py
@@ -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)
diff --git a/tests/system/suite_QMLS/envvars b/tests/system/suite_QMLS/envvars
new file mode 100644
index 0000000000..00aad3eab7
--- /dev/null
+++ b/tests/system/suite_QMLS/envvars
@@ -0,0 +1 @@
+QT_PLATFORM_PLUGIN=nonesuch
diff --git a/tests/system/suite_QMLS/objects.map b/tests/system/suite_QMLS/objects.map
new file mode 100644
index 0000000000..b3e0ada750
--- /dev/null
+++ b/tests/system/suite_QMLS/objects.map
@@ -0,0 +1,19 @@
+: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'}
diff --git a/tests/system/suite_QMLS/suite.conf b/tests/system/suite_QMLS/suite.conf
new file mode 100644
index 0000000000..dbc7c20a6b
--- /dev/null
+++ b/tests/system/suite_QMLS/suite.conf
@@ -0,0 +1,10 @@
+AUT=qtcreator
+CLASS=
+CLASSPATH=
+ENVVARS=envvars
+HOOK_SUB_PROCESSES=false
+IMPLICITAUTSTART=0
+LANGUAGE=Python
+TEST_CASES=tst_QMLS01 tst_QMLS02
+VERSION=2
+WRAPPERS=Qt
diff --git a/tests/system/suite_QMLS/tst_QMLS01/test.py b/tests/system/suite_QMLS/tst_QMLS01/test.py
new file mode 100644
index 0000000000..92a62f985b
--- /dev/null
+++ b/tests/system/suite_QMLS/tst_QMLS01/test.py
@@ -0,0 +1,113 @@
+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()
+
diff --git a/tests/system/suite_QMLS/tst_QMLS02/test.py b/tests/system/suite_QMLS/tst_QMLS02/test.py
new file mode 100644
index 0000000000..0cfc9e88ff
--- /dev/null
+++ b/tests/system/suite_QMLS/tst_QMLS02/test.py
@@ -0,0 +1,41 @@
+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")
+