forked from qt-creator/qt-creator
Provide test settings and make use of them
Change-Id: Ia6fef10bc577f9722b6c063c2df4d1651a8be50d Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -22,7 +22,9 @@ SOURCES += \
|
|||||||
testresultspane.cpp \
|
testresultspane.cpp \
|
||||||
testresultmodel.cpp \
|
testresultmodel.cpp \
|
||||||
testresultdelegate.cpp \
|
testresultdelegate.cpp \
|
||||||
testtreeitemdelegate.cpp
|
testtreeitemdelegate.cpp \
|
||||||
|
testsettings.cpp \
|
||||||
|
testsettingspage.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
testtreeview.h \
|
testtreeview.h \
|
||||||
@@ -40,8 +42,13 @@ HEADERS += \
|
|||||||
testresultspane.h \
|
testresultspane.h \
|
||||||
testresultmodel.h \
|
testresultmodel.h \
|
||||||
testresultdelegate.h \
|
testresultdelegate.h \
|
||||||
testtreeitemdelegate.h
|
testtreeitemdelegate.h \
|
||||||
|
testsettings.h \
|
||||||
|
testsettingspage.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
autotest.qrc
|
autotest.qrc
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
testsettingspage.ui
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
|
<file>images/autotest.png</file>
|
||||||
<file>images/class.png</file>
|
<file>images/class.png</file>
|
||||||
<file>images/func.png</file>
|
<file>images/func.png</file>
|
||||||
<file>images/expand.png</file>
|
<file>images/expand.png</file>
|
||||||
|
|||||||
@@ -24,12 +24,13 @@
|
|||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
const char ACTION_ID[] = "AutoTest.Action";
|
const char ACTION_ID[] = "AutoTest.Action";
|
||||||
const char MENU_ID[] = "AutoTest.Menu";
|
const char MENU_ID[] = "AutoTest.Menu";
|
||||||
const char AUTOTEST_ID[] = "AutoTest.ATP";
|
const char AUTOTEST_ID[] = "AutoTest.ATP";
|
||||||
const char AUTOTEST_CONTEXT[] = "Auto Tests";
|
const char AUTOTEST_CONTEXT[] = "Auto Tests";
|
||||||
const char TASK_INDEX[] = "AutoTest.Task.Index";
|
const char TASK_INDEX[] = "AutoTest.Task.Index";
|
||||||
const char UNNAMED_QUICKTESTS[] = QT_TR_NOOP("<unnamed>");
|
const char UNNAMED_QUICKTESTS[] = QT_TR_NOOP("<unnamed>");
|
||||||
|
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
|
||||||
|
|
||||||
} // namespace Autotest
|
} // namespace Autotest
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "autotestplugin.h"
|
#include "autotestplugin.h"
|
||||||
#include "autotestconstants.h"
|
#include "autotestconstants.h"
|
||||||
#include "testrunner.h"
|
#include "testrunner.h"
|
||||||
|
#include "testsettings.h"
|
||||||
|
#include "testsettingspage.h"
|
||||||
#include "testtreeview.h"
|
#include "testtreeview.h"
|
||||||
#include "testtreemodel.h"
|
#include "testtreemodel.h"
|
||||||
#include "testresultspane.h"
|
#include "testresultspane.h"
|
||||||
@@ -43,9 +45,13 @@
|
|||||||
|
|
||||||
using namespace Autotest::Internal;
|
using namespace Autotest::Internal;
|
||||||
|
|
||||||
|
static AutotestPlugin *m_instance = 0;
|
||||||
|
|
||||||
AutotestPlugin::AutotestPlugin()
|
AutotestPlugin::AutotestPlugin()
|
||||||
|
: m_settings(new TestSettings)
|
||||||
{
|
{
|
||||||
// Create your members
|
// Create your members
|
||||||
|
m_instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutotestPlugin::~AutotestPlugin()
|
AutotestPlugin::~AutotestPlugin()
|
||||||
@@ -58,6 +64,11 @@ AutotestPlugin::~AutotestPlugin()
|
|||||||
delete runner;
|
delete runner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutotestPlugin *AutotestPlugin::instance()
|
||||||
|
{
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorString)
|
bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||||
{
|
{
|
||||||
// Register objects in the plugin manager's object pool
|
// Register objects in the plugin manager's object pool
|
||||||
@@ -90,6 +101,10 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
|
|||||||
menu->addAction(cmd);
|
menu->addAction(cmd);
|
||||||
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
|
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
|
||||||
|
|
||||||
|
m_settings->fromSettings(Core::ICore::settings());
|
||||||
|
TestSettingsPage *settingsPage = new TestSettingsPage(m_settings);
|
||||||
|
addAutoReleasedObject(settingsPage);
|
||||||
|
|
||||||
addAutoReleasedObject(new TestViewFactory);
|
addAutoReleasedObject(new TestViewFactory);
|
||||||
addAutoReleasedObject(TestResultsPane::instance());
|
addAutoReleasedObject(TestResultsPane::instance());
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
struct TestSettings;
|
||||||
|
|
||||||
class AutotestPlugin : public ExtensionSystem::IPlugin
|
class AutotestPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -35,12 +37,19 @@ public:
|
|||||||
AutotestPlugin();
|
AutotestPlugin();
|
||||||
~AutotestPlugin();
|
~AutotestPlugin();
|
||||||
|
|
||||||
|
static AutotestPlugin *instance();
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorString);
|
bool initialize(const QStringList &arguments, QString *errorString);
|
||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
ShutdownFlag aboutToShutdown();
|
ShutdownFlag aboutToShutdown();
|
||||||
|
|
||||||
|
QSharedPointer<TestSettings> settings() const { return m_settings; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void triggerAction();
|
void triggerAction();
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QSharedPointer<TestSettings> m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
BIN
plugins/autotest/images/autotest.png
Normal file
BIN
plugins/autotest/images/autotest.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 683 B |
@@ -16,10 +16,12 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "autotestplugin.h"
|
||||||
#include "testresultspane.h"
|
#include "testresultspane.h"
|
||||||
#include "testresultmodel.h"
|
#include "testresultmodel.h"
|
||||||
#include "testresultdelegate.h"
|
#include "testresultdelegate.h"
|
||||||
#include "testrunner.h"
|
#include "testrunner.h"
|
||||||
|
#include "testsettings.h"
|
||||||
#include "testtreemodel.h"
|
#include "testtreemodel.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
@@ -271,6 +273,11 @@ void TestResultsPane::onRunSelectedTriggered()
|
|||||||
|
|
||||||
void TestResultsPane::initializeFilterMenu()
|
void TestResultsPane::initializeFilterMenu()
|
||||||
{
|
{
|
||||||
|
const bool omitIntern = AutotestPlugin::instance()->settings()->omitInternalMssg;
|
||||||
|
// FilterModel has all messages enabled by default
|
||||||
|
if (omitIntern)
|
||||||
|
m_filterModel->toggleTestResultType(ResultType::MESSAGE_INTERNAL);
|
||||||
|
|
||||||
QMap<ResultType, QString> textAndType;
|
QMap<ResultType, QString> textAndType;
|
||||||
textAndType.insert(ResultType::PASS, tr("Pass"));
|
textAndType.insert(ResultType::PASS, tr("Pass"));
|
||||||
textAndType.insert(ResultType::FAIL, tr("Fail"));
|
textAndType.insert(ResultType::FAIL, tr("Fail"));
|
||||||
@@ -285,7 +292,7 @@ void TestResultsPane::initializeFilterMenu()
|
|||||||
QAction *action = new QAction(m_filterMenu);
|
QAction *action = new QAction(m_filterMenu);
|
||||||
action->setText(textAndType.value(result));
|
action->setText(textAndType.value(result));
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setChecked(true);
|
action->setChecked(result != ResultType::MESSAGE_INTERNAL || !omitIntern);
|
||||||
action->setData(result);
|
action->setData(result);
|
||||||
m_filterMenu->addAction(action);
|
m_filterMenu->addAction(action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,10 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "autotestconstants.h"
|
#include "autotestconstants.h"
|
||||||
|
#include "autotestplugin.h"
|
||||||
#include "testresultspane.h"
|
#include "testresultspane.h"
|
||||||
#include "testrunner.h"
|
#include "testrunner.h"
|
||||||
|
#include "testsettings.h"
|
||||||
|
|
||||||
#include <QDebug> // REMOVE
|
#include <QDebug> // REMOVE
|
||||||
|
|
||||||
@@ -112,6 +114,53 @@ static bool xmlExtractTypeFileLine(const QString &code, const QString &tagStart,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// adapted from qplaintestlogger.cpp
|
||||||
|
static QString formatResult(double value)
|
||||||
|
{
|
||||||
|
if (value < 0 || value == NAN)
|
||||||
|
return QLatin1String("NAN");
|
||||||
|
if (value == 0)
|
||||||
|
return QLatin1String("0");
|
||||||
|
|
||||||
|
int significantDigits = 0;
|
||||||
|
qreal divisor = 1;
|
||||||
|
|
||||||
|
while (value / divisor >= 1) {
|
||||||
|
divisor *= 10;
|
||||||
|
++significantDigits;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString beforeDecimalPoint = QString::number(value, 'f', 0);
|
||||||
|
QString afterDecimalPoint = QString::number(value, 'f', 20);
|
||||||
|
afterDecimalPoint.remove(0, beforeDecimalPoint.count() + 1);
|
||||||
|
|
||||||
|
const int beforeUse = qMin(beforeDecimalPoint.count(), significantDigits);
|
||||||
|
const int beforeRemove = beforeDecimalPoint.count() - beforeUse;
|
||||||
|
|
||||||
|
beforeDecimalPoint.chop(beforeRemove);
|
||||||
|
for (int i = 0; i < beforeRemove; ++i)
|
||||||
|
beforeDecimalPoint.append(QLatin1Char('0'));
|
||||||
|
|
||||||
|
int afterUse = significantDigits - beforeUse;
|
||||||
|
if (beforeDecimalPoint == QLatin1String("0") && !afterDecimalPoint.isEmpty()) {
|
||||||
|
++afterUse;
|
||||||
|
int i = 0;
|
||||||
|
while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == QLatin1Char('0'))
|
||||||
|
++i;
|
||||||
|
afterUse += i;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int afterRemove = afterDecimalPoint.count() - afterUse;
|
||||||
|
afterDecimalPoint.chop(afterRemove);
|
||||||
|
|
||||||
|
QString result = beforeDecimalPoint;
|
||||||
|
if (afterUse > 0)
|
||||||
|
result.append(QLatin1Char('.'));
|
||||||
|
result += afterDecimalPoint;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static bool xmlExtractBenchmarkInformation(const QString &code, const QString &tagStart,
|
static bool xmlExtractBenchmarkInformation(const QString &code, const QString &tagStart,
|
||||||
QString &description)
|
QString &description)
|
||||||
{
|
{
|
||||||
@@ -134,9 +183,9 @@ static bool xmlExtractBenchmarkInformation(const QString &code, const QString &t
|
|||||||
else if (metric == QLatin1String("CPUCycles")) // -perf
|
else if (metric == QLatin1String("CPUCycles")) // -perf
|
||||||
metricsTxt = QLatin1String("CPU cycles");
|
metricsTxt = QLatin1String("CPU cycles");
|
||||||
description = QObject::tr("%1 %2 per iteration (total: %3, iterations: %4)")
|
description = QObject::tr("%1 %2 per iteration (total: %3, iterations: %4)")
|
||||||
.arg(QString::number(value, 'f', 6))
|
.arg(formatResult(value))
|
||||||
.arg(metricsTxt)
|
.arg(metricsTxt)
|
||||||
.arg(QString::number(value * (double)iterations, 'g', 3))
|
.arg(formatResult(value * (double)iterations))
|
||||||
.arg(iterations);
|
.arg(iterations);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -282,7 +331,7 @@ static QString which(const QString &path, const QString &cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool performExec(const QString &cmd, const QStringList &args, const QString &workingDir,
|
bool performExec(const QString &cmd, const QStringList &args, const QString &workingDir,
|
||||||
const Utils::Environment &env, int timeout = 60000)
|
const Utils::Environment &env, int timeout)
|
||||||
{
|
{
|
||||||
QString runCmd;
|
QString runCmd;
|
||||||
if (!QDir::toNativeSeparators(cmd).contains(QDir::separator())) {
|
if (!QDir::toNativeSeparators(cmd).contains(QDir::separator())) {
|
||||||
@@ -354,6 +403,10 @@ void performTestRun(QFutureInterface<void> &future, const QList<TestConfiguratio
|
|||||||
future.setProgressRange(0, testCaseCount);
|
future.setProgressRange(0, testCaseCount);
|
||||||
future.setProgressValue(0);
|
future.setProgressValue(0);
|
||||||
|
|
||||||
|
const QSharedPointer<TestSettings> settings = AutotestPlugin::instance()->settings();
|
||||||
|
const int timeout = settings->timeout;
|
||||||
|
const QString metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
|
||||||
|
|
||||||
foreach (const TestConfiguration *tc, selectedTests) {
|
foreach (const TestConfiguration *tc, selectedTests) {
|
||||||
if (future.isCanceled())
|
if (future.isCanceled())
|
||||||
break;
|
break;
|
||||||
@@ -363,10 +416,12 @@ void performTestRun(QFutureInterface<void> &future, const QList<TestConfiguratio
|
|||||||
Utils::Environment env = tc->environment();
|
Utils::Environment env = tc->environment();
|
||||||
|
|
||||||
args << QLatin1String("-xml");
|
args << QLatin1String("-xml");
|
||||||
|
if (!metricsOption.isEmpty())
|
||||||
|
args << metricsOption;
|
||||||
if (tc->testCases().count())
|
if (tc->testCases().count())
|
||||||
args << tc->testCases();
|
args << tc->testCases();
|
||||||
|
|
||||||
performExec(cmd, args, workDir, env);
|
performExec(cmd, args, workDir, env, timeout);
|
||||||
}
|
}
|
||||||
future.setProgressValue(testCaseCount);
|
future.setProgressValue(testCaseCount);
|
||||||
|
|
||||||
|
|||||||
97
plugins/autotest/testsettings.cpp
Normal file
97
plugins/autotest/testsettings.cpp
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 Digia Plc
|
||||||
|
** All rights reserved.
|
||||||
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Creator Enterprise Auto Test Add-on.
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Enterprise licenses may use this file in
|
||||||
|
** accordance with the Qt Enterprise License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please use
|
||||||
|
** contact form at http://qt.digia.com
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "testsettings.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
namespace Autotest {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
static const char group[] = "Autotest";
|
||||||
|
static const char timeoutKey[] = "Timeout";
|
||||||
|
static const char metricsKey[] = "Metrics";
|
||||||
|
static const char omitInternalKey[] = "OmitInternal";
|
||||||
|
static const int defaultTimeout = 60000;
|
||||||
|
|
||||||
|
TestSettings::TestSettings()
|
||||||
|
: timeout(defaultTimeout), metrics(Walltime), omitInternalMssg(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSettings::toSettings(QSettings *s) const
|
||||||
|
{
|
||||||
|
s->beginGroup(QLatin1String(group));
|
||||||
|
s->setValue(QLatin1String(timeoutKey), timeout);
|
||||||
|
s->setValue(QLatin1String(metricsKey), metrics);
|
||||||
|
s->setValue(QLatin1String(omitInternalKey), omitInternalMssg);
|
||||||
|
s->endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MetricsType intToMetrics(int value)
|
||||||
|
{
|
||||||
|
switch (value) {
|
||||||
|
case Walltime:
|
||||||
|
return Walltime;
|
||||||
|
case TickCounter:
|
||||||
|
return TickCounter;
|
||||||
|
case EventCounter:
|
||||||
|
return EventCounter;
|
||||||
|
case CallGrind:
|
||||||
|
return CallGrind;
|
||||||
|
case Perf:
|
||||||
|
return Perf;
|
||||||
|
default:
|
||||||
|
return Walltime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSettings::fromSettings(const QSettings *s)
|
||||||
|
{
|
||||||
|
const QString root = QLatin1String(group) + QLatin1Char('/');
|
||||||
|
timeout = s->value(root + QLatin1String(timeoutKey), defaultTimeout).toInt();
|
||||||
|
metrics = intToMetrics(s->value(root + QLatin1String(metricsKey), Walltime).toInt());
|
||||||
|
omitInternalMssg = s->value(root + QLatin1String(omitInternalKey), true).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TestSettings::equals(const TestSettings &rhs) const
|
||||||
|
{
|
||||||
|
return timeout == rhs.timeout && metrics == rhs.metrics
|
||||||
|
&& omitInternalMssg == rhs.omitInternalMssg;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TestSettings::metricsTypeToOption(const MetricsType type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case MetricsType::Walltime:
|
||||||
|
return QString();
|
||||||
|
case MetricsType::TickCounter:
|
||||||
|
return QLatin1String("-tickcounter");
|
||||||
|
case MetricsType::EventCounter:
|
||||||
|
return QLatin1String("-eventcounter");
|
||||||
|
case MetricsType::CallGrind:
|
||||||
|
return QLatin1String("-callgrind");
|
||||||
|
case MetricsType::Perf:
|
||||||
|
return QLatin1String("-perf");
|
||||||
|
default:
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Autotest
|
||||||
58
plugins/autotest/testsettings.h
Normal file
58
plugins/autotest/testsettings.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 Digia Plc
|
||||||
|
** All rights reserved.
|
||||||
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Creator Enterprise Auto Test Add-on.
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Enterprise licenses may use this file in
|
||||||
|
** accordance with the Qt Enterprise License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please use
|
||||||
|
** contact form at http://qt.digia.com
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TESTSETTINGS_H
|
||||||
|
#define TESTSETTINGS_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QSettings;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Autotest {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
enum MetricsType {
|
||||||
|
Walltime,
|
||||||
|
TickCounter,
|
||||||
|
EventCounter,
|
||||||
|
CallGrind,
|
||||||
|
Perf
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TestSettings
|
||||||
|
{
|
||||||
|
TestSettings();
|
||||||
|
void toSettings(QSettings *s) const;
|
||||||
|
void fromSettings(const QSettings *s);
|
||||||
|
bool equals(const TestSettings &rhs) const;
|
||||||
|
static QString metricsTypeToOption(const MetricsType type);
|
||||||
|
|
||||||
|
int timeout;
|
||||||
|
MetricsType metrics;
|
||||||
|
bool omitInternalMssg;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const TestSettings &s1, const TestSettings &s2) { return s1.equals(s2); }
|
||||||
|
inline bool operator!=(const TestSettings &s1, const TestSettings &s2) { return !s1.equals(s2); }
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Autotest
|
||||||
|
|
||||||
|
#endif // TESTSETTINGS_H
|
||||||
119
plugins/autotest/testsettingspage.cpp
Normal file
119
plugins/autotest/testsettingspage.cpp
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 Digia Plc
|
||||||
|
** All rights reserved.
|
||||||
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Creator Enterprise Auto Test Add-on.
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Enterprise licenses may use this file in
|
||||||
|
** accordance with the Qt Enterprise License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please use
|
||||||
|
** contact form at http://qt.digia.com
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "autotestconstants.h"
|
||||||
|
#include "testsettingspage.h"
|
||||||
|
#include "testsettings.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <utils/hostosinfo.h>
|
||||||
|
|
||||||
|
namespace Autotest {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
m_ui.setupUi(this);
|
||||||
|
m_ui.callgrindRB->setEnabled(Utils::HostOsInfo::isAnyUnixHost()); // valgrind available on UNIX
|
||||||
|
m_ui.perfRB->setEnabled(Utils::HostOsInfo::isLinuxHost()); // according to docs perf Linux only
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSettingsWidget::setSettings(const TestSettings &settings)
|
||||||
|
{
|
||||||
|
m_ui.timeoutSpin->setValue(settings.timeout / 1000); // we store milliseconds
|
||||||
|
m_ui.omitInternalMsgCB->setChecked(settings.omitInternalMssg);
|
||||||
|
|
||||||
|
switch (settings.metrics) {
|
||||||
|
case MetricsType::Walltime:
|
||||||
|
m_ui.walltimeRB->setChecked(true);
|
||||||
|
break;
|
||||||
|
case MetricsType::TickCounter:
|
||||||
|
m_ui.tickcounterRB->setChecked(true);
|
||||||
|
break;
|
||||||
|
case MetricsType::EventCounter:
|
||||||
|
m_ui.eventCounterRB->setChecked(true);
|
||||||
|
break;
|
||||||
|
case MetricsType::CallGrind:
|
||||||
|
m_ui.callgrindRB->setChecked(true);
|
||||||
|
break;
|
||||||
|
case MetricsType::Perf:
|
||||||
|
m_ui.perfRB->setChecked(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_ui.walltimeRB->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TestSettings TestSettingsWidget::settings() const
|
||||||
|
{
|
||||||
|
TestSettings result;
|
||||||
|
result.timeout = m_ui.timeoutSpin->value() * 1000; // we display seconds
|
||||||
|
result.omitInternalMssg = m_ui.omitInternalMsgCB->isChecked();
|
||||||
|
|
||||||
|
if (m_ui.walltimeRB->isChecked())
|
||||||
|
result.metrics = MetricsType::Walltime;
|
||||||
|
else if (m_ui.tickcounterRB->isChecked())
|
||||||
|
result.metrics = MetricsType::TickCounter;
|
||||||
|
else if (m_ui.eventCounterRB->isChecked())
|
||||||
|
result.metrics = MetricsType::EventCounter;
|
||||||
|
else if (m_ui.callgrindRB->isChecked())
|
||||||
|
result.metrics = MetricsType::CallGrind;
|
||||||
|
else if (m_ui.perfRB->isChecked())
|
||||||
|
result.metrics = MetricsType::Perf;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
TestSettingsPage::TestSettingsPage(const QSharedPointer<TestSettings> &settings)
|
||||||
|
: m_settings(settings), m_widget(0)
|
||||||
|
{
|
||||||
|
setId("A.General");
|
||||||
|
setDisplayName(tr("General"));
|
||||||
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||||
|
setDisplayCategory(tr("Test Settings"));
|
||||||
|
setCategoryIcon(QLatin1String(":/images/autotest.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TestSettingsPage::~TestSettingsPage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *TestSettingsPage::widget()
|
||||||
|
{
|
||||||
|
if (!m_widget) {
|
||||||
|
m_widget = new TestSettingsWidget;
|
||||||
|
m_widget->setSettings(*m_settings);
|
||||||
|
}
|
||||||
|
return m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSettingsPage::apply()
|
||||||
|
{
|
||||||
|
if (!m_widget) // page was not shown at all
|
||||||
|
return;
|
||||||
|
const TestSettings newSettings = m_widget->settings();
|
||||||
|
if (newSettings != *m_settings) {
|
||||||
|
*m_settings = newSettings;
|
||||||
|
m_settings->toSettings(Core::ICore::settings());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Autotest
|
||||||
66
plugins/autotest/testsettingspage.h
Normal file
66
plugins/autotest/testsettingspage.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 Digia Plc
|
||||||
|
** All rights reserved.
|
||||||
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Creator Enterprise Auto Test Add-on.
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Enterprise licenses may use this file in
|
||||||
|
** accordance with the Qt Enterprise License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please use
|
||||||
|
** contact form at http://qt.digia.com
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TESTSETTINGSPAGE_H
|
||||||
|
#define TESTSETTINGSPAGE_H
|
||||||
|
|
||||||
|
#include "ui_testsettingspage.h"
|
||||||
|
|
||||||
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
namespace Autotest {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
struct TestSettings;
|
||||||
|
|
||||||
|
class TestSettingsWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TestSettingsWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
|
void setSettings(const TestSettings &settings);
|
||||||
|
TestSettings settings() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::TestSettingsPage m_ui;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TestSettingsPage : public Core::IOptionsPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TestSettingsPage(const QSharedPointer<TestSettings> &settings);
|
||||||
|
~TestSettingsPage();
|
||||||
|
|
||||||
|
QWidget *widget();
|
||||||
|
void apply();
|
||||||
|
void finish() { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSharedPointer<TestSettings> m_settings;
|
||||||
|
QPointer<TestSettingsWidget> m_widget;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Autotest
|
||||||
|
|
||||||
|
#endif // TESTSETTINGSPAGE_H
|
||||||
258
plugins/autotest/testsettingspage.ui
Normal file
258
plugins/autotest/testsettingspage.ui
Normal file
@@ -0,0 +1,258 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Autotest::Internal::TestSettingsPage</class>
|
||||||
|
<widget class="QWidget" name="Autotest::Internal::TestSettingsPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>462</width>
|
||||||
|
<height>292</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Timeout used when executing test cases. This will apply for each test case on its own, not the whole project.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Timeout:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="timeoutSpin">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Timeout used when executing test cases. This will apply for each test case on its own, not the whole project.</string>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string> s</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>36000</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>60</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="omitInternalMsgCB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>If checked Internal Messages won't be shown by default. (You can still enable them on the test results filter)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Omit Internal Messages</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Benchmark Metrics</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="walltimeRB">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use Walltime metrics for executing benchmarks. (default)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Walltime</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="tickcounterRB">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use tick counter for executing benchmarks.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tickcounter</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="eventCounterRB">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use event counter when executing benchmarks.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Eventcounter</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="callgrindRB">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use callgrind when executing benchmark. (valgrind must be installed)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Callgrind</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="perfRB">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use perf when executing benchmarks. (perf must be installed)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Perf</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user