aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Kerekes <jan.kerekes@ixonos.com>2012-03-29 12:13:53 +0200
committerRobert Löhning <robert.loehning@nokia.com>2012-04-13 11:10:58 +0200
commit9d263a1b34302940f761f40eaa06cb7bf9dfa84a (patch)
treedb08f446cba1bb0b6b424200847be90f5f625329 /tests
parent4cabd8b0a18a27179e2fc7a3a62d38387e483a9d (diff)
Added new test cases/suite for c support
initial commit Change-Id: I8eb36efa0e7e577597708d97a2efe52c07801f02 Reviewed-by: Christian Stenger <christian.stenger@nokia.com> Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/system/shared/suites_qtta.py5
-rw-r--r--tests/system/suite_CSUP/envvars1
-rw-r--r--tests/system/suite_CSUP/objects.map17
-rw-r--r--tests/system/suite_CSUP/suite.conf10
-rw-r--r--tests/system/suite_CSUP/tst_CSUP01/test.py78
-rw-r--r--tests/system/suite_CSUP/tst_CSUP02/test.py55
6 files changed, 166 insertions, 0 deletions
diff --git a/tests/system/shared/suites_qtta.py b/tests/system/shared/suites_qtta.py
index d435b154e7..a83ea23332 100755
--- a/tests/system/shared/suites_qtta.py
+++ b/tests/system/shared/suites_qtta.py
@@ -33,3 +33,8 @@ def checkSyntaxError(issuesView, expectedTextsArray, warnIfMoreIssues = True):
else:
return True
return False
+
+# wait and verify if object exists/not exists
+def checkIfObjectExists(name, shouldExist = True, timeout = 3000):
+ return waitFor("object.exists(name) == shouldExist", timeout)
+
diff --git a/tests/system/suite_CSUP/envvars b/tests/system/suite_CSUP/envvars
new file mode 100644
index 0000000000..00aad3eab7
--- /dev/null
+++ b/tests/system/suite_CSUP/envvars
@@ -0,0 +1 @@
+QT_PLATFORM_PLUGIN=nonesuch
diff --git a/tests/system/suite_CSUP/objects.map b/tests/system/suite_CSUP/objects.map
new file mode 100644
index 0000000000..d35b66b20a
--- /dev/null
+++ b/tests/system/suite_CSUP/objects.map
@@ -0,0 +1,17 @@
+: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'}
+:Next_QPushButton {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.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' windowTitle?='*Qt Creator'}
+:Qt Creator_CppEditor::Internal::CPPEditorWidget {type='CppEditor::Internal::CPPEditorWidget' 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 {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_CSUP/suite.conf b/tests/system/suite_CSUP/suite.conf
new file mode 100644
index 0000000000..9f50e3f128
--- /dev/null
+++ b/tests/system/suite_CSUP/suite.conf
@@ -0,0 +1,10 @@
+AUT=qtcreator
+CLASS=
+CLASSPATH=
+ENVVARS=envvars
+HOOK_SUB_PROCESSES=false
+IMPLICITAUTSTART=0
+LANGUAGE=Python
+TEST_CASES=tst_CSUP01 tst_CSUP02
+VERSION=2
+WRAPPERS=Qt
diff --git a/tests/system/suite_CSUP/tst_CSUP01/test.py b/tests/system/suite_CSUP/tst_CSUP01/test.py
new file mode 100644
index 0000000000..8bf70f6982
--- /dev/null
+++ b/tests/system/suite_CSUP/tst_CSUP01/test.py
@@ -0,0 +1,78 @@
+source("../../shared/suites_qtta.py")
+source("../../shared/qtcreator.py")
+
+# entry of test
+def main():
+ startApplication("qtcreator" + SettingsPath)
+ # create qt quick application
+# Step 1: Open test .pro project.
+ createNewQtQuickApplication(tempDir(), "SampleApp")
+ waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)")
+ test.verify(waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp"),
+ "Step 1: Verifying if: Project is opened.")
+# Step 2: Open .cpp file in Edit mode.
+ doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.Sources.main\\.cpp", 5, 5, 0, Qt.LeftButton)
+ test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"),
+ "Step 2: Verifying if: .cpp file is opened in Edit mode.")
+# Step 3: Insert text "re" to new line in Editor mode and press Ctrl+Space.
+ editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
+ mouseClick(editorWidget, 5, 5, 0, Qt.LeftButton)
+ type(editorWidget, "<Return>")
+ type(editorWidget, "<Up>")
+ type(editorWidget, "re")
+ if platform.system() == "Darwin":
+ type(editorWidget, "<Meta+Space>")
+ else:
+ type(editorWidget, "<Ctrl+Space>")
+ waitForObjectItem(":m_popupFrame_QListView", "register")
+ doubleClickItem(":m_popupFrame_QListView", "register", 5, 5, 0, Qt.LeftButton)
+ test.verify(str(editorWidget.plainText).startswith("register"),
+ "Step 3: Verifying if: The list of suggestions is opened. It is "
+ "possible to select one of the suggestions.")
+# Step 4: Insert text "voi" to new line and press Tab.
+ mouseClick(editorWidget, 5, 5, 0, Qt.LeftButton)
+ if platform.system() == "Darwin":
+ type(editorWidget, "<Meta+Shift+Right>")
+ else:
+ type(editorWidget, "<Shift+End>")
+ type(editorWidget, "<Del>")
+ type(editorWidget, "voi")
+ waitForObjectItem(":m_popupFrame_QListView", "void")
+ type(waitForObject(":m_popupFrame_QListView"), "<Tab>")
+ test.verify(str(editorWidget.plainText).startswith("void"),
+ "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"))
+# Step 6: Insert text "ret" and press Ctrl+Space.
+ editorWidget = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
+ mouseClick(editorWidget, 5, 5, 0, Qt.LeftButton)
+ if platform.system() == "Darwin":
+ type(editorWidget, "<Meta+Shift+Right>")
+ else:
+ type(editorWidget, "<Shift+End>")
+ type(editorWidget, "<Del>")
+ type(editorWidget, "ret")
+ if platform.system() == "Darwin":
+ type(editorWidget, "<Meta+Space>")
+ else:
+ type(editorWidget, "<Ctrl+Space>")
+ waitForObjectItem(":m_popupFrame_QListView", "return")
+ type(editorWidget, "<Right>")
+ type(editorWidget, "<Backspace>")
+ test.verify(str(editorWidget.plainText).startswith("ret#"),
+ "Step 6: Verifying if: Suggestion is displayed but text is not "
+ "completed automatically even there is only one suggestion.")
+ # exit qt creator
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Exit")
+# no cleanup needed, as whole testing directory gets properly removed after test finished
+
diff --git a/tests/system/suite_CSUP/tst_CSUP02/test.py b/tests/system/suite_CSUP/tst_CSUP02/test.py
new file mode 100644
index 0000000000..493b50bf48
--- /dev/null
+++ b/tests/system/suite_CSUP/tst_CSUP02/test.py
@@ -0,0 +1,55 @@
+source("../../shared/suites_qtta.py")
+source("../../shared/qtcreator.py")
+
+# entry of test
+def main():
+ startApplication("qtcreator" + SettingsPath)
+ # create qt quick application
+# Step 1: Open test .pro project.
+ createNewQtQuickApplication(tempDir(), "SampleApp")
+ waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)")
+ test.verify(waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp"),
+ "Step 1: Verifying if: Project is opened.")
+# Step 2: Open .cpp file in Edit mode.
+ doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.Sources.main\\.cpp", 5, 5, 0, Qt.LeftButton)
+ test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"),
+ "Step 2: Verifying if: .cpp file is opened in Edit mode.")
+# Steps 3&4: Insert text "class" to new line in Editor mode and press Ctrl+Space.
+# Focus "class derived from QObject" in the list and press Tab or Enter to complete the code.
+ editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
+ mouseClick(editorWidget, 5, 5, 0, Qt.LeftButton)
+ type(editorWidget, "<Return>")
+ type(editorWidget, "<Up>")
+ type(editorWidget, "class")
+ if platform.system() == "Darwin":
+ type(editorWidget, "<Meta+Space>")
+ else:
+ type(editorWidget, "<Ctrl+Space>")
+ type(waitForObject(":m_popupFrame_QListView"), "<Down>")
+ type(waitForObject(":m_popupFrame_QListView"), "<Down>")
+ listView = waitForObject(":m_popupFrame_QListView")
+ test.compare("class derived from QObject", str(listView.model().data(listView.currentIndex())),
+ "Verifying selecting the correct entry.")
+ type(waitForObject(":m_popupFrame_QListView"), "<Return>")
+ test.verify(str(editorWidget.plainText).startswith("class name : public QObject"),
+ "Steps 3&4: Verifying if: The list of suggestions is opened. It is "
+ "possible to select one of the suggestions. Code with several "
+ "variables is inserted.")
+# Step 5: Press Tab to move between the variables and specify values for them. For example write "Myname" for variable "name".
+ type(editorWidget, "<Tab>")
+ type(editorWidget, "<Tab>")
+ type(editorWidget, "<Tab>")
+ type(editorWidget, "Myname")
+ pattern = "(?<=class)\s+Myname\s*:\s*public\s+QObject\s*\{\s*Q_OBJECT\s+public:\s+Myname\(\)\s*\{\}\s+virtual\s+~Myname\(\)\s*\{\}\s+\};"
+ result = re.search(pattern, str(editorWidget.plainText))
+ if result:
+ test.passes("Step 5: Verifying if: A value for a variable is inserted and all "
+ "instances of the variable within the snippet are renamed.")
+ else:
+ test.fail("Step 5: Seems that not all instances of variable had been renamed "
+ "- Content of editor:\n%s" % editorWidget.plainText)
+ # exit qt creator
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Exit")
+# no cleanup needed, as whole testing directory gets properly removed after test finished
+