forked from qt-creator/qt-creator
AutoTest: Use json based wizard
Change-Id: I75693037542ef64bcc094e092086dea65d77872c Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
SUBDIRS += %TestCaseName:l%
|
SUBDIRS += %{JS: '%{TestCaseName}'.toLowerCase()}
|
||||||
|
@@ -1,14 +1,17 @@
|
|||||||
@if "%RequireGUI%" == "true"
|
%{Cpp:LicenseTemplate}\
|
||||||
#include <QApplication>
|
@if "%{RequireGUI}" == "true"
|
||||||
|
%{JS: QtSupport.qtIncludes([ 'QtGui/QApplication' ],
|
||||||
|
[ 'QtWidgets/QApplication' ]) }\
|
||||||
@else
|
@else
|
||||||
#include <QCoreApplication>
|
%{JS: QtSupport.qtIncludes([ 'QtCore/QCoreApplication' ],
|
||||||
|
[ 'QtCore/QCoreApplication' ]) }\
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
// add necessary includes here
|
// add necessary includes here
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@if "%RequireGUI%" == "true"
|
@if "%{RequireGUI}" == "true"
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
@else
|
@else
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
@if "%RequireGUI%" == "true"
|
@if "%{RequireGUI}" == "true"
|
||||||
QT += core gui
|
QT += core gui
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
@else
|
@else
|
||||||
@@ -8,6 +8,6 @@ CONFIG -= app_bundle
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = %ProjectName%
|
TARGET = %{ProjectName}
|
||||||
|
|
||||||
SOURCES += main.%CppSourceSuffix%
|
SOURCES += %{MainCppName}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
@if "%BuildTests%" == "always"
|
@if "%{BuildTests}" == "always"
|
||||||
SUBDIRS += src \
|
SUBDIRS += src \
|
||||||
tests
|
tests
|
||||||
@else
|
@else
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
QT += testlib
|
QT += testlib
|
||||||
@if "%RequireGUI%" == "false"
|
@if "%{RequireGUI}" == "false"
|
||||||
QT -= gui
|
QT -= gui
|
||||||
|
|
||||||
CONFIG += qt console warn_on depend_includepath testcase
|
CONFIG += qt console warn_on depend_includepath testcase
|
||||||
@@ -11,4 +11,4 @@ CONFIG += qt warn_on depend_includepath testcase
|
|||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
SOURCES += tst_%TestCaseName:l%.%CppSourceSuffix%
|
SOURCES += %{TestCaseFileWithCppSuffix}
|
||||||
|
@@ -1,20 +1,22 @@
|
|||||||
|
%{Cpp:LicenseTemplate}\
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
@if "%RequireApplication%" == "true"
|
@if "%{RequireApplication}" == "true"
|
||||||
#include <QCoreApplication>
|
%{JS: QtSupport.qtIncludes([ 'QtCore/QCoreApplication' ],
|
||||||
|
[ 'QtCore/QCoreApplication' ]) }\
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
// add necessary includes here
|
// add necessary includes here
|
||||||
|
|
||||||
class %TestCaseName% : public QObject
|
class %{TestCaseName} : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
%TestCaseName%();
|
%{TestCaseName}();
|
||||||
~%TestCaseName%();
|
~%{TestCaseName}();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@if "%GenerateInitAndCleanup%" == "true"
|
@if "%{GenerateInitAndCleanup}" == "true"
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
@endif
|
@endif
|
||||||
@@ -22,37 +24,37 @@ private slots:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
%TestCaseName%::%TestCaseName%()
|
%{TestCaseName}::%{TestCaseName}()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%TestCaseName%::~%TestCaseName%()
|
%{TestCaseName}::~%{TestCaseName}()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@if "%GenerateInitAndCleanup%" == "true"
|
@if "%{GenerateInitAndCleanup}" == "true"
|
||||||
void %TestCaseName%::initTestCase()
|
void %{TestCaseName}::initTestCase()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void %TestCaseName%::cleanupTestCase()
|
void %{TestCaseName}::cleanupTestCase()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
void %TestCaseName%::test_case1()
|
void %{TestCaseName}::test_case1()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@if "%RequireApplication%" == "true"
|
@if "%{RequireApplication}" == "true"
|
||||||
QTEST_MAIN(%TestCaseName%)
|
QTEST_MAIN(%{TestCaseName})
|
||||||
@else
|
@else
|
||||||
QTEST_APPLESS_MAIN(%TestCaseName%)
|
QTEST_APPLESS_MAIN(%{TestCaseName})
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
#include "tst_%TestCaseName:l%.moc"
|
#include "%{JS: 'tst_%{TestCaseName}.moc'.toLowerCase() }"
|
||||||
|
168
share/qtcreator/templates/wizards/autotest/wizard.json
Normal file
168
share/qtcreator/templates/wizards/autotest/wizard.json
Normal file
@@ -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' )}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -1,83 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
-->
|
|
||||||
<wizard version="1" kind="project"
|
|
||||||
class="qmakeproject" firstpage="10"
|
|
||||||
id="R.AutoTest" category="H.Project"
|
|
||||||
featuresRequired="QtSupport.Wizards.FeatureQt,QtSupport.Wizards.FeatureDesktop">
|
|
||||||
<!-- "Plugin.AutotestGenerator" as required feature would disable the template if the
|
|
||||||
plugin is disabled, but it fails on the kit selection page for having no valid kit -->
|
|
||||||
<icon>autotest_24.png</icon>
|
|
||||||
<description>Creates a new project including auto test skeleton.</description>
|
|
||||||
<displayname>Auto Test</displayname>;
|
|
||||||
<displaycategory>Other Project</displaycategory>
|
|
||||||
<files>
|
|
||||||
<file source="src.pro" target="src/src.pro" />
|
|
||||||
<file source="tests.pro" target="tests/tests.pro" />
|
|
||||||
<file source="auto.pro" target="tests/auto/auto.pro"/>
|
|
||||||
<file source="tst.pro" target="tests/auto/%TestCaseName:l%/%TestCaseName:l%.pro" />
|
|
||||||
<file source="tst_src.cpp"
|
|
||||||
target="tests/auto/%TestCaseName:l%/tst_%TestCaseName:l%.%CppSourceSuffix%"
|
|
||||||
openeditor="true"/>
|
|
||||||
<file source="main.cpp" target="src/main.%CppSourceSuffix%" openeditor="true" />
|
|
||||||
<file source="tmp.pro" target="%ProjectName:l%.pro" openproject="true" />
|
|
||||||
</files>
|
|
||||||
<!-- Create a 2nd wizard page with parameters -->
|
|
||||||
<fieldpagetitle>Project and Test Information</fieldpagetitle>
|
|
||||||
<fields>
|
|
||||||
<field name="RequireGUI">
|
|
||||||
<fieldcontrol class="QCheckBox" />
|
|
||||||
<fielddescription>GUI Application</fielddescription>
|
|
||||||
</field>
|
|
||||||
<field mandatory="true" name="TestCaseName">
|
|
||||||
<fieldcontrol class="QLineEdit" validator="^[a-zA-Z_0-9]+$"
|
|
||||||
/><!-- defaulttext="" /> -->
|
|
||||||
<fielddescription>Test Case Name:</fielddescription>
|
|
||||||
</field>
|
|
||||||
<field name="RequireApplication">
|
|
||||||
<fieldcontrol class="QCheckBox" />
|
|
||||||
<fielddescription>Requires QApplication</fielddescription>
|
|
||||||
</field>
|
|
||||||
<field name="GenerateInitAndCleanup">
|
|
||||||
<fieldcontrol class="QCheckBox" />
|
|
||||||
<fielddescription>Generate initialization and cleanup code</fielddescription>
|
|
||||||
</field>
|
|
||||||
<field name="BuildAutoTests">
|
|
||||||
<fieldcontrol class="QComboBox" defaultindex="0" >
|
|
||||||
<comboentries>
|
|
||||||
<comboentry value="always" >
|
|
||||||
<comboentrytext>always</comboentrytext>
|
|
||||||
</comboentry>
|
|
||||||
<comboentry value="debug" >
|
|
||||||
<comboentrytext>debug only</comboentrytext>
|
|
||||||
</comboentry>
|
|
||||||
</comboentries>
|
|
||||||
</fieldcontrol>
|
|
||||||
<fielddescription>Build auto tests</fielddescription>
|
|
||||||
</field>
|
|
||||||
</fields>
|
|
||||||
</wizard>
|
|
Reference in New Issue
Block a user