Commit a9933fbb authored by Eike Ziller's avatar Eike Ziller Committed by The Qt Project
Browse files

Merge "Add autotest plugin"

parents 647a351c 63c16600
TEMPLATE = subdirs
SUBDIRS += %TestCaseName:l%
@if "%RequireGUI%" == "true"
#include <QApplication>
@else
#include <QCoreApplication>
@endif
// add necessary includes here
int main(int argc, char *argv[])
{
@if "%RequireGUI%" == "true"
QApplication a(argc, argv);
@else
QCoreApplication a(argc, argv);
@endif
return a.exec();
}
@if "%RequireGUI%" == "true"
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
@else
QT -= gui
CONFIG += console
CONFIG -= app_bundle
@endif
TEMPLATE = app
TARGET = %ProjectName%
SOURCES += main.%CppSourceSuffix%
TEMPLATE = subdirs
@if "%BuildTests%" == "always"
SUBDIRS += src \
tests
@else
SUBDIRS += src
CONFIG(debug, debug|release) {
SUBDIRS += tests
}
@endif
QT += testlib
@if "%RequireGUI%" == "false"
QT -= gui
CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle
@else
QT += gui
CONFIG += qt warn_on depend_includepath testcase
@endif
TEMPLATE = app
SOURCES += tst_%TestCaseName:l%.%CppSourceSuffix%
#include <QtTest>
@if "%RequireApplication%" == "true"
#include <QCoreApplication>
@endif
// add necessary includes here
class %TestCaseName% : public QObject
{
Q_OBJECT
public:
%TestCaseName%();
~%TestCaseName%();
private slots:
@if "%GenerateInitAndCleanup%" == "true"
void initTestCase();
void cleanupTestCase();
@endif
void test_case1();
};
%TestCaseName%::%TestCaseName%()
{
}
%TestCaseName%::~%TestCaseName%()
{
}
@if "%GenerateInitAndCleanup%" == "true"
void %TestCaseName%::initTestCase()
{
}
void %TestCaseName%::cleanupTestCase()
{
}
@endif
void %TestCaseName%::test_case1()
{
}
@if "%RequireApplication%" == "true"
QTEST_MAIN(%TestCaseName%)
@else
QTEST_APPLESS_MAIN(%TestCaseName%)
@endif
#include "tst_%TestCaseName:l%.moc"
<?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>
{
\"Name\" : \"AutoTest\",
\"Version\" : \"$$QTCREATOR_VERSION\",
\"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\",
\"Experimental\" : true,
\"Vendor\" : \"The Qt Company Ltd\",
\"Copyright\" : \"(C) 2015 The Qt Company Ltd\",
\"License\" : [ \"Commercial Usage\",
\"\",
\"Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt 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.\",
\"\",
\"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.\"
],
\"Description\" : \"Auto Test plugin.\",
\"Url\" : \"http://www.qt.io\",
$$dependencyList
}
TARGET = AutoTest
TEMPLATE = lib
include(../../qtcreatorplugin.pri)
include(autotest_dependencies.pri)
DEFINES += AUTOTEST_LIBRARY
SOURCES += \
testtreeview.cpp \
testtreemodel.cpp \
testtreeitem.cpp \
testvisitor.cpp \
testinfo.cpp \
testcodeparser.cpp \
autotestplugin.cpp \
testrunner.cpp \
testconfiguration.cpp \
testresult.cpp \
testresultspane.cpp \
testresultmodel.cpp \
testresultdelegate.cpp \
testtreeitemdelegate.cpp \
testsettings.cpp \
testsettingspage.cpp \
testnavigationwidget.cpp \
testoutputreader.cpp
HEADERS += \
testtreeview.h \
testtreemodel.h \
testtreeitem.h \
testvisitor.h \
testinfo.h \
testcodeparser.h \
autotestplugin.h \
autotest_global.h \
autotest_utils.h \
autotestconstants.h \
testrunner.h \
testconfiguration.h \
testresult.h \
testresultspane.h \
testresultmodel.h \
testresultdelegate.h \
testtreeitemdelegate.h \
testsettings.h \
testsettingspage.h \
testnavigationwidget.h \
testoutputreader.h \
autotesticons.h
RESOURCES += \
autotest.qrc
FORMS += \
testsettingspage.ui
equals(TEST, 1) {
HEADERS += autotestunittests.h
SOURCES += autotestunittests.cpp
RESOURCES += autotestunittests.qrc
}
import qbs
QtcCommercialPlugin {
name: "AutoTest"
Depends { name: "Core" }
Depends { name: "CppTools" }
Depends { name: "CPlusPlus" }
Depends { name: "ProjectExplorer" }
Depends { name: "QmlJS" }
Depends { name: "QmlJSTools" }
Depends { name: "Utils" }
pluginTestDepends: [
"QbsProjectManager",
"QmakeProjectManager"
]
Depends {
name: "QtSupport"
condition: project.testsEnabled
}
Depends {
name: "Qt.test"
condition: project.testsEnabled
}
Depends { name: "Qt.widgets" }
files: [
"autotest.qrc",
"autotesticons.h",
"autotest_global.h",
"autotest_utils.h",
"autotestconstants.h",
"autotestplugin.cpp",
"autotestplugin.h",
"testcodeparser.cpp",
"testcodeparser.h",
"testconfiguration.cpp",
"testconfiguration.h",
"testinfo.cpp",
"testinfo.h",
"testnavigationwidget.cpp",
"testnavigationwidget.h",
"testresult.cpp",
"testresult.h",
"testresultdelegate.cpp",
"testresultdelegate.h",
"testresultmodel.cpp",
"testresultmodel.h",
"testresultspane.cpp",
"testresultspane.h",
"testrunner.cpp",
"testrunner.h",
"testsettings.cpp",
"testsettings.h",
"testsettingspage.cpp",
"testsettingspage.h",
"testsettingspage.ui",
"testtreeitem.cpp",
"testtreeitem.h",
"testtreeitemdelegate.cpp",
"testtreeitemdelegate.h",
"testtreemodel.cpp",
"testtreemodel.h",
"testtreeview.cpp",
"testtreeview.h",
"testvisitor.cpp",
"testvisitor.h",
"testoutputreader.cpp",
"testoutputreader.h",
]
Group {
name: "Test sources"
condition: project.testsEnabled
files: [
"autotestunittests.cpp",
"autotestunittests.h",
"autotestunittests.qrc",
]
}
Group {
name: "Auto Test Wizard"
prefix: "../../shared/autotest/"
files: [
"*"
]
fileTags: []
qbs.install: true
qbs.installDir: project.ide_data_path + "/templates/wizards/autotest"
}
}
<RCC>
<qresource prefix="/">
<file>images/autotest.png</file>
<file>images/class.png</file>
<file>images/func.png</file>
<file>images/expand.png</file>
<file>images/expand@2x.png</file>
<file>images/collapse.png</file>
<file>images/collapse@2x.png</file>
<file>images/sort.png</file>
<file>images/sort@2x.png</file>
<file>images/leafsort.png</file>
<file>images/leafsort@2x.png</file>
<file>images/debug.png</file>
<file>images/fail.png</file>
<file>images/fatal.png</file>
<file>images/pass.png</file>
<file>images/skip.png</file>
<file>images/warn.png</file>
<file>images/xfail.png</file>
<file>images/xpass.png</file>
<file>images/blacklisted_fail.png</file>
<file>images/blacklisted_pass.png</file>
<file>images/benchmark.png</file>
<file>images/runselected_boxes.png</file>
<file>images/runselected_boxes@2x.png</file>
<file>images/runselected_tickmarks.png</file>
<file>images/runselected_tickmarks@2x.png</file>
<file>images/data.png</file>
</qresource>
</RCC>
QTC_PLUGIN_NAME = AutoTest
QTC_PLUGIN_DEPENDS += \
coreplugin \
projectexplorer \
cpptools \
qmljstools
QTC_LIB_DEPENDS += \
cplusplus \
qmljs \
utils
QTC_TEST_DEPENDS += \
qbsprojectmanager \
qmakeprojectmanager \
qtsupport
#QTC_PLUGIN_RECOMMENDS += \
/****************************************************************************
**
** 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.
**
****************************************************************************/
#ifndef AUTOTEST_GLOBAL_H
#define AUTOTEST_GLOBAL_H
#include <QtGlobal>
#if defined(AUTOTEST_LIBRARY)
# define AUTOTESTSHARED_EXPORT Q_DECL_EXPORT
#else
# define AUTOTESTSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // AUTOTEST_GLOBAL_H
/****************************************************************************
**
** 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.
**
****************************************************************************/
#ifndef AUTOTEST_UTILS_H
#define AUTOTEST_UTILS_H
#include <QStringList>
namespace Autotest {
namespace Internal {
class TestUtils
{
public:
static bool isGTestMacro(const QString &macro)
{
static QStringList valid = {
QStringLiteral("TEST"), QStringLiteral("TEST_F"), QStringLiteral("TEST_P")
};
return valid.contains(macro);
}
static bool isGTestParameterized(const QString &macro)
{
return macro == QStringLiteral("TEST_P");
}
static bool isQTestMacro(const QByteArray &macro)
{
static QByteArrayList valid = {"QTEST_MAIN", "QTEST_APPLESS_MAIN", "QTEST_GUILESS_MAIN"};
return valid.contains(macro);
}
static bool isQuickTestMacro(const QByteArray &macro)
{
static const QByteArrayList valid = {"QUICK_TEST_MAIN", "QUICK_TEST_OPENGL_MAIN"};
return valid.contains(macro);
}
};
} // namespace Internal
} // namespace Autotest
#endif // AUTOTEST_UTILS_H
/****************************************************************************
**
** 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.
**
****************************************************************************/
#ifndef AUTOTESTCONSTANTS_H
#define AUTOTESTCONSTANTS_H
#include <QtGlobal>
namespace Autotest {
namespace Constants {
const char ACTION_SCAN_ID[] = "AutoTest.ScanAction";
const char ACTION_RUN_ALL_ID[] = "AutoTest.RunAll";
const char ACTION_RUN_SELECTED_ID[] = "AutoTest.RunSelected";
const char MENU_ID[] = "AutoTest.Menu";
const char AUTOTEST_ID[] = "AutoTest.ATP";
const char AUTOTEST_CONTEXT[] = "Auto Tests";
const char TASK_INDEX[] = "AutoTest.Task.Index";
const char TASK_PARSE[] = "AutoTest.Task.Parse";
const char UNNAMED_QUICKTESTS[] = QT_TR_NOOP("<unnamed>");
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
} // namespace Constants
namespace Internal {
enum TestType
{
TestTypeQt,
TestTypeGTest
};
} // namespace Internal
} // namespace Autotest
#endif // AUTOTESTCONSTANTS_H