From 5254e3e547f1957a4bd08da432a63882d32ea66a Mon Sep 17 00:00:00 2001 From: Jan Kerekes Date: Thu, 16 Feb 2012 15:07:31 +0100 Subject: [PATCH] Added new test cases/suite for simple project compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit initial commit Change-Id: I06d211ba9878852839cd4774b930efd8cde244ae Reviewed-by: Christian Stenger Reviewed-by: Robert Löhning --- tests/system/shared/suites_qtta.py | 36 ++++++++++++++++++ tests/system/suite_SCOM/envvars | 1 + tests/system/suite_SCOM/objects.map | 17 +++++++++ tests/system/suite_SCOM/suite.conf | 10 +++++ tests/system/suite_SCOM/tst_SCOM01/test.py | 25 ++++++++++++ tests/system/suite_SCOM/tst_SCOM02/test.py | 25 ++++++++++++ tests/system/suite_SCOM/tst_SCOM04/test.py | 36 ++++++++++++++++++ tests/system/suite_SCOM/tst_SCOM05/test.py | 44 ++++++++++++++++++++++ 8 files changed, 194 insertions(+) create mode 100755 tests/system/shared/suites_qtta.py create mode 100644 tests/system/suite_SCOM/envvars create mode 100644 tests/system/suite_SCOM/objects.map create mode 100644 tests/system/suite_SCOM/suite.conf create mode 100644 tests/system/suite_SCOM/tst_SCOM01/test.py create mode 100644 tests/system/suite_SCOM/tst_SCOM02/test.py create mode 100644 tests/system/suite_SCOM/tst_SCOM04/test.py create mode 100644 tests/system/suite_SCOM/tst_SCOM05/test.py diff --git a/tests/system/shared/suites_qtta.py b/tests/system/shared/suites_qtta.py new file mode 100755 index 00000000000..1c52ca3ebe4 --- /dev/null +++ b/tests/system/shared/suites_qtta.py @@ -0,0 +1,36 @@ + +# appends to line, by typing after text into widget +def appendToLine(codeArea, insertAfterLine, typeWhat): + if not placeCursorToLine(codeArea, insertAfterLine): + return False + type(codeArea, typeWhat) + return True + +# checks if error is properly reported, returns True if succeeded and False if not. +# Current implementation is focused on allowing different compilers, and it is enough if one of the expected messages +# is found in issues view. warnIfMoreIssues should warn if there are more than one issue, no matter how many +# expected texts are in array (because they are alternatives). +def checkSyntaxError(issuesView, expectedTextsArray, warnIfMoreIssues = True): + issuesModel = issuesView.model() + # wait for issues + waitFor("issuesModel.rowCount() > 0", 5000) + # warn if more issues reported + if(warnIfMoreIssues and issuesModel.rowCount() > 1): + test.warning("More than one expected issues reported") + # iterate issues and check if there exists "Unexpected token" message + for row in range(issuesModel.rowCount()): + # enum Roles { File = Qt::UserRole, Line, MovedLine, Description, FileNotFound, Type, Category, Icon, Task_t }; + index = issuesModel.index(row, 0) + description = str(index.data(Qt.UserRole + 3).toString()) + type = str(index.data(Qt.UserRole + 5).toString()) + # check if at least one of expected texts found in issue text + for expectedText in expectedTextsArray: + if expectedText in description: + # check if it is error and warn if not - returns False which leads to fail + if type is not "1": + test.warning("Expected error text found, but is not of type: 'error'") + return False + else: + return True + return False + diff --git a/tests/system/suite_SCOM/envvars b/tests/system/suite_SCOM/envvars new file mode 100644 index 00000000000..00aad3eab7d --- /dev/null +++ b/tests/system/suite_SCOM/envvars @@ -0,0 +1 @@ +QT_PLATFORM_PLUGIN=nonesuch diff --git a/tests/system/suite_SCOM/objects.map b/tests/system/suite_SCOM/objects.map new file mode 100644 index 00000000000..2b93d8dc9fd --- /dev/null +++ b/tests/system/suite_SCOM/objects.map @@ -0,0 +1,17 @@ +: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'} +:Qt Creator.Build Project_Core::Internal::FancyToolButton {text='Build Project' type='Core::Internal::FancyToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator.Compile Output_Core::OutputWindow {type='Core::OutputWindow' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Compile Output'} +:Qt Creator.Issues_QListView {type='QListView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Issues'} +:Qt Creator.Project.Menu.Project_QMenu {name='Project.Menu.Project' type='QMenu' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator.QtCreator.MenuBar_QMenuBar {name='QtCreator.MenuBar' type='QMenuBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator.scrollArea_QScrollArea {name='scrollArea' type='QScrollArea' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator_Core::Internal::IssuesPaneToggleButton {type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator_Core::Internal::MainWindow {type='Core::Internal::MainWindow' unnamed='1' visible='1'} +:Qt Creator_Core::Internal::OutputPaneToggleButton {occurrence='4' type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Qt Creator_CppEditor::Internal::CPPEditorWidget {type='CppEditor::Internal::CPPEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +: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'} +:scrollArea.Edit build configuration:_QComboBox {container=':Qt Creator.scrollArea_QScrollArea' leftWidget=':scrollArea.Edit build configuration:_QLabel' type='QComboBox' unnamed='1' visible='1'} +:scrollArea.Edit build configuration:_QLabel {container=':Qt Creator.scrollArea_QScrollArea' text='Edit build configuration:' type='QLabel' unnamed='1' visible='1'} diff --git a/tests/system/suite_SCOM/suite.conf b/tests/system/suite_SCOM/suite.conf new file mode 100644 index 00000000000..a1a1dc9996b --- /dev/null +++ b/tests/system/suite_SCOM/suite.conf @@ -0,0 +1,10 @@ +AUT=qtcreator +CLASS= +CLASSPATH= +ENVVARS=envvars +HOOK_SUB_PROCESSES=false +IMPLICITAUTSTART=0 +LANGUAGE=Python +TEST_CASES=tst_SCOM01 tst_SCOM02 tst_SCOM04 tst_SCOM05 +VERSION=2 +WRAPPERS=Qt diff --git a/tests/system/suite_SCOM/tst_SCOM01/test.py b/tests/system/suite_SCOM/tst_SCOM01/test.py new file mode 100644 index 00000000000..4b4fb5f21e9 --- /dev/null +++ b/tests/system/suite_SCOM/tst_SCOM01/test.py @@ -0,0 +1,25 @@ +source("../../shared/qtcreator.py") +source("../../shared/suites_qtta.py") + +# entry of test +def main(): + startApplication("qtcreator" + SettingsPath) + # create qt quick application + createNewQtQuickApplication(tempDir(), "SampleApp") + # build it - on all (except Qt 4.7.0 (would fail)) build configurations + for config in iterateBuildConfigs(1, 0, "(?!.*4\.7\.0.*)"): + selectBuildConfig(1, 0, config) + # try to compile + test.log("Testing build configuration: " + config) + clickButton(waitForObject(":Qt Creator.Build Project_Core::Internal::FancyToolButton")) + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)") + # check output if build successful + ensureChecked(waitForObject(":Qt Creator_Core::Internal::OutputPaneToggleButton")) + compileOutput = waitForObject(":Qt Creator.Compile Output_Core::OutputWindow") + if not test.verify(str(compileOutput.plainText).endswith("exited normally."), + "Verifying building of simple qt quick application."): + test.log(compileOutput.plainText) + # exit qt creator + invokeMenuItem("File", "Exit") +# no cleanup needed, as whole testing directory gets properly removed after test finished + diff --git a/tests/system/suite_SCOM/tst_SCOM02/test.py b/tests/system/suite_SCOM/tst_SCOM02/test.py new file mode 100644 index 00000000000..82b94a20514 --- /dev/null +++ b/tests/system/suite_SCOM/tst_SCOM02/test.py @@ -0,0 +1,25 @@ +source("../../shared/qtcreator.py") +source("../../shared/suites_qtta.py") + +# entry of test +def main(): + startApplication("qtcreator" + SettingsPath) + # create qt quick application + createNewQtQuickApplication(tempDir(), "SampleApp") + # create syntax error in qml file + doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.QML.qml/SampleApp.main\\.qml", 5, 5, 0, Qt.LeftButton) + if not appendToLine(waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget"), "Text {", "SyntaxError"): + invokeMenuItem("File", "Exit") + return + # save all to invoke qml parsing + invokeMenuItem("File", "Save All") + # open issues list view + ensureChecked(waitForObject(":Qt Creator_Core::Internal::IssuesPaneToggleButton")) + issuesView = waitForObject(":Qt Creator.Issues_QListView") + # verify that error is properly reported + test.verify(checkSyntaxError(issuesView, ["Unexpected token"], True), + "Verifying QML syntax error while parsing simple qt quick application.") + # exit qt creator + invokeMenuItem("File", "Exit") +# no cleanup needed, as whole testing directory gets properly removed after test finished + diff --git a/tests/system/suite_SCOM/tst_SCOM04/test.py b/tests/system/suite_SCOM/tst_SCOM04/test.py new file mode 100644 index 00000000000..fecef36c571 --- /dev/null +++ b/tests/system/suite_SCOM/tst_SCOM04/test.py @@ -0,0 +1,36 @@ +source("../../shared/qtcreator.py") +source("../../shared/suites_qtta.py") + +# entry of test +def main(): + # expected error texts - for different compilers + expectedErrorAlternatives = ["'SyntaxError' was not declared in this scope", + "'SyntaxError' : undeclared identifier"] + startApplication("qtcreator" + SettingsPath) + # create qt quick application + createNewQtQuickApplication(tempDir(), "SampleApp") + # create syntax error in cpp file + doubleClickItem(":Qt Creator_Utils::NavigationTreeView", "SampleApp.Sources.main\\.cpp", 5, 5, 0, Qt.LeftButton) + if not appendToLine(waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget"), "viewer.showExpanded();", "SyntaxError"): + invokeMenuItem("File", "Exit") + return + # save all + invokeMenuItem("File", "Save All") + # build it - on all (except Qt 4.7.0 (would fail)) build configurations + for config in iterateBuildConfigs(1, 0, "(?!.*4\.7\.0.*)"): + selectBuildConfig(1, 0, config) + # try to compile + test.log("Testing build configuration: " + config) + clickButton(waitForObject(":Qt Creator.Build Project_Core::Internal::FancyToolButton")) + # wait until build finished + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)") + # open issues list view + ensureChecked(waitForObject(":Qt Creator_Core::Internal::IssuesPaneToggleButton")) + issuesView = waitForObject(":Qt Creator.Issues_QListView") + # verify that error is properly reported + test.verify(checkSyntaxError(issuesView, expectedErrorAlternatives, False), + "Verifying cpp syntax error while building simple qt quick application.") + # exit qt creator + invokeMenuItem("File", "Exit") +# no cleanup needed, as whole testing directory gets properly removed after test finished + diff --git a/tests/system/suite_SCOM/tst_SCOM05/test.py b/tests/system/suite_SCOM/tst_SCOM05/test.py new file mode 100644 index 00000000000..eb4ebbdf7e3 --- /dev/null +++ b/tests/system/suite_SCOM/tst_SCOM05/test.py @@ -0,0 +1,44 @@ +source("../../shared/qtcreator.py") +source("../../shared/suites_qtta.py") + +def verifyChangeProject(projectName): + # select project + projItem = waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", projectName) + openItemContextMenu(waitForObject(":Qt Creator_Utils::NavigationTreeView"), projectName, 5, 5, 0) + activateItem(waitForObjectItem(":Qt Creator.Project.Menu.Project_QMenu", "Set as Active Project")) + waitFor("projItem.font.bold==True",3000) + # check if bold is right project + test.verify(projItem.font.bold == True, + "Simple Qt Quick App - multiple projects - verifying if properly set to project: " + projectName) + +def main(): + projectName1 = "SampleApp1" + projectName2 = "SampleApp2" + startApplication("qtcreator" + SettingsPath) + # create qt quick application 1 + createNewQtQuickApplication(tempDir(), projectName1) + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 5000) + # create qt quick application 2 + createNewQtQuickApplication(tempDir(), projectName2) + waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 5000) + # change to project 1 + verifyChangeProject(projectName1) + # change to project 2 + verifyChangeProject(projectName2) + # build project 2 + clickButton(waitForObject(":Qt Creator.Build Project_Core::Internal::FancyToolButton")) + # wait for build to complete + waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)") + # check output if build successful + ensureChecked(waitForObject(":Qt Creator_Core::Internal::OutputPaneToggleButton")) + outputLog = str(waitForObject(":Qt Creator.Compile Output_Core::OutputWindow").plainText) + # verify that project was built successfully + test.verify(outputLog.endswith("exited normally."), + "Verifying building of simple qt quick application while multiple projects are open.") + # verify that proper project (project 2) was build + test.verify(projectName2 in outputLog and projectName1 not in outputLog, + "Verifying that proper project " + projectName2 + " was built.") + # exit qt creator + invokeMenuItem("File", "Exit") +# no cleanup needed, as whole testing directory gets properly removed after test finished +