diff --git a/share/qtcreator/templates/wizards/autotest/auto.pro b/share/qtcreator/templates/wizards/autotest/auto.pro index b39fef654c3..510a3710068 100644 --- a/share/qtcreator/templates/wizards/autotest/auto.pro +++ b/share/qtcreator/templates/wizards/autotest/auto.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += %TestCaseName:l% +SUBDIRS += %{JS: '%{TestCaseName}'.toLowerCase()} diff --git a/share/qtcreator/templates/wizards/autotest/main.cpp b/share/qtcreator/templates/wizards/autotest/main.cpp index 3ff500decd6..2eb09afb0dc 100644 --- a/share/qtcreator/templates/wizards/autotest/main.cpp +++ b/share/qtcreator/templates/wizards/autotest/main.cpp @@ -1,14 +1,17 @@ -@if "%RequireGUI%" == "true" -#include +%{Cpp:LicenseTemplate}\ +@if "%{RequireGUI}" == "true" +%{JS: QtSupport.qtIncludes([ 'QtGui/QApplication' ], + [ 'QtWidgets/QApplication' ]) }\ @else -#include +%{JS: QtSupport.qtIncludes([ 'QtCore/QCoreApplication' ], + [ 'QtCore/QCoreApplication' ]) }\ @endif // add necessary includes here int main(int argc, char *argv[]) { -@if "%RequireGUI%" == "true" +@if "%{RequireGUI}" == "true" QApplication a(argc, argv); @else QCoreApplication a(argc, argv); diff --git a/share/qtcreator/templates/wizards/autotest/src.pro b/share/qtcreator/templates/wizards/autotest/src.pro index 61fbe2a5bcf..3cbad0593f8 100644 --- a/share/qtcreator/templates/wizards/autotest/src.pro +++ b/share/qtcreator/templates/wizards/autotest/src.pro @@ -1,4 +1,4 @@ -@if "%RequireGUI%" == "true" +@if "%{RequireGUI}" == "true" QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @else @@ -8,6 +8,6 @@ CONFIG -= app_bundle @endif TEMPLATE = app -TARGET = %ProjectName% +TARGET = %{ProjectName} -SOURCES += main.%CppSourceSuffix% +SOURCES += %{MainCppName} diff --git a/share/qtcreator/templates/wizards/autotest/tmp.pro b/share/qtcreator/templates/wizards/autotest/tmp.pro index 1569bd45cb7..c64e8c288c8 100644 --- a/share/qtcreator/templates/wizards/autotest/tmp.pro +++ b/share/qtcreator/templates/wizards/autotest/tmp.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -@if "%BuildTests%" == "always" +@if "%{BuildTests}" == "always" SUBDIRS += src \ tests @else diff --git a/share/qtcreator/templates/wizards/autotest/tst.pro b/share/qtcreator/templates/wizards/autotest/tst.pro index 8aa61b767e7..f58c30fd8ea 100644 --- a/share/qtcreator/templates/wizards/autotest/tst.pro +++ b/share/qtcreator/templates/wizards/autotest/tst.pro @@ -1,5 +1,5 @@ QT += testlib -@if "%RequireGUI%" == "false" +@if "%{RequireGUI}" == "false" QT -= gui CONFIG += qt console warn_on depend_includepath testcase @@ -11,4 +11,4 @@ CONFIG += qt warn_on depend_includepath testcase TEMPLATE = app -SOURCES += tst_%TestCaseName:l%.%CppSourceSuffix% +SOURCES += %{TestCaseFileWithCppSuffix} diff --git a/share/qtcreator/templates/wizards/autotest/tst_src.cpp b/share/qtcreator/templates/wizards/autotest/tst_src.cpp index 65d49e9c18a..54a68264d2d 100644 --- a/share/qtcreator/templates/wizards/autotest/tst_src.cpp +++ b/share/qtcreator/templates/wizards/autotest/tst_src.cpp @@ -1,20 +1,22 @@ +%{Cpp:LicenseTemplate}\ #include -@if "%RequireApplication%" == "true" -#include +@if "%{RequireApplication}" == "true" +%{JS: QtSupport.qtIncludes([ 'QtCore/QCoreApplication' ], + [ 'QtCore/QCoreApplication' ]) }\ @endif // add necessary includes here -class %TestCaseName% : public QObject +class %{TestCaseName} : public QObject { Q_OBJECT public: - %TestCaseName%(); - ~%TestCaseName%(); + %{TestCaseName}(); + ~%{TestCaseName}(); private slots: -@if "%GenerateInitAndCleanup%" == "true" +@if "%{GenerateInitAndCleanup}" == "true" void initTestCase(); void cleanupTestCase(); @endif @@ -22,37 +24,37 @@ private slots: }; -%TestCaseName%::%TestCaseName%() +%{TestCaseName}::%{TestCaseName}() { } -%TestCaseName%::~%TestCaseName%() +%{TestCaseName}::~%{TestCaseName}() { } -@if "%GenerateInitAndCleanup%" == "true" -void %TestCaseName%::initTestCase() +@if "%{GenerateInitAndCleanup}" == "true" +void %{TestCaseName}::initTestCase() { } -void %TestCaseName%::cleanupTestCase() +void %{TestCaseName}::cleanupTestCase() { } @endif -void %TestCaseName%::test_case1() +void %{TestCaseName}::test_case1() { } -@if "%RequireApplication%" == "true" -QTEST_MAIN(%TestCaseName%) +@if "%{RequireApplication}" == "true" +QTEST_MAIN(%{TestCaseName}) @else -QTEST_APPLESS_MAIN(%TestCaseName%) +QTEST_APPLESS_MAIN(%{TestCaseName}) @endif -#include "tst_%TestCaseName:l%.moc" +#include "%{JS: 'tst_%{TestCaseName}.moc'.toLowerCase() }" diff --git a/share/qtcreator/templates/wizards/autotest/wizard.json b/share/qtcreator/templates/wizards/autotest/wizard.json new file mode 100644 index 00000000000..16f318aa574 --- /dev/null +++ b/share/qtcreator/templates/wizards/autotest/wizard.json @@ -0,0 +1,168 @@ +{ + "version": 1, + "supportedProjectTypes": [ "Qt4ProjectManager.Qt4Project" ], + "id": "R.AutoTest2", + "category": "H.Project", + "trDescription": "Creates a new project including auto test skeleton.", + "trDisplayName": "Qt Test project", + "trDisplayCategory": "Other Project", + "icon": "autotest_24.png", + "featuresRequired": [ "QtSupport.Wizards.FeatureQt", "QtSupport.Wizards.FeatureDesktop" ], + "enabled": "%{JS: [ %{Plugins} ].indexOf('AutoTest') >= 0}", + + "options": + [ + { "key": "ProFileName", + "value": "%{JS: Util.fileName('%{ProjectDirectory}/%{ProjectName}', 'pro')}" + }, + { "key": "IsTopLevelProject", + "value": "%{JS: !'%{Exists:ProjectExplorer.Profile.Ids}' }" + }, + { "key": "MainCppName", + "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src') }" + }, + { + "key": "TestCaseFileWithCppSuffix", + "value": "%{JS: 'tst_%{TestCaseName}.'.toLowerCase() + Util.preferredSuffix('text/x-c++src') }" + } + ], + + "pages": + [ + { + "trDisplayName": "Project Location", + "trShortTitle": "Location", + "typeId": "Project", + "data": + { + "trDescription": "This wizard creates a simple Qmake based Qt project with additional auto test skeleton." + } + }, + { + "trDisplayName": "Project and Test Information", + "trShortTitle": "Details", + "typeId": "Fields", + "data": + [ + { + "name": "RequireGUI", + "trDisplayName": "GUI Application", + "type": "CheckBox", + "data": { + "checked": false, + "checkedValue": "true", + "uncheckedValue": "false" + } + }, + { + "name": "TestCaseName", + "trDisplayName": "Test Case Name:", + "mandatory": true, + "type": "LineEdit", + "data": { "validator": "^[a-zA-Z_0-9]+$" } + }, + { + "name": "RequireApplication", + "trDisplayName": "Requires QApplication", + "type": "CheckBox", + "data": { + "checked": false, + "checkedValue": "true", + "uncheckedValue": "false" + } + }, + { + "name": "GenerateInitAndCleanup", + "trDisplayName": "Generate initialization and cleanup code", + "type": "CheckBox", + "data": { + "checked": false, + "checkedValue": "true", + "uncheckedValue": "false" + } + }, + { + "name": "BuildAutoTests", + "trDisplayName": "Build auto tests", + "type": "ComboBox", + "data": + { + "index": 0, + "items": + [ + { + "trKey": "always", + "value": "always" + }, + { + "trKey": "debug only", + "value": "debug" + } + ] + } + } + ] + }, + { + "trDisplayName": "Kit Selection", + "trShortTitle": "Kits", + "typeId": "Kits", + "enabled": "%{IsTopLevelProject}", + "data": { "projectFilePath": "%{ProFileName}" } + }, + { + "trDisplayName": "Project Management", + "trShortTitle": "Summary", + "typeId": "Summary" + } + ], + "generators": + [ + { + "typeId": "File", + "data": + [ + { + "source": "tmp.pro", + "target": "%{ProFileName}", + "openAsProject": true + }, + { + "source": "src.pro", + "target": "src/src.pro", + "openInEditor": false + }, + { + "source": "main.cpp", + "target": "src/%{MainCppName}", + "openInEditor": true + }, + { + "source": "tests.pro", + "target": "tests/tests.pro", + "openInEditor": false + }, + { + "source": "auto.pro", + "target": "tests/auto/auto.pro", + "openInEditor": false + }, + { + "source": "tst.pro", + "target": "%{JS: 'tests/auto/' + '%{TestCaseName}/%{TestCaseName}'.toLowerCase() + '.pro' }", + "openInEditor": false + }, + { + "source": "tst_src.cpp", + "target": "%{JS: 'tests/auto/' + '%{TestCaseName}/'.toLowerCase() + '%{TestCaseFileWithCppSuffix}' }", + "openInEditor": true + }, + { + "source": "../projects/git.ignore", + "target": ".gitignore", + "condition": "%{JS: ( %{IsTopLevelProject} && '%{VersionControl}' === 'G.Git' )}" + } + ] + } + ] +} diff --git a/share/qtcreator/templates/wizards/autotest/wizard.xml b/share/qtcreator/templates/wizards/autotest/wizard.xml deleted file mode 100644 index 12f0c1e0075..00000000000 --- a/share/qtcreator/templates/wizards/autotest/wizard.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - autotest_24.png - Creates a new project including auto test skeleton. - Auto Test; - Other Project - - - - - - - - - - - Project and Test Information - - - - GUI Application - - - - Test Case Name: - - - - Requires QApplication - - - - Generate initialization and cleanup code - - - - - - always - - - debug only - - - - Build auto tests - - -