Commit c31af631 authored by Christian Stenger's avatar Christian Stenger

AutoTest: Provide setting to outvote automatically disabling parser

Test parser is normally disabled as long neither test tree nor results
pane is opened. The new setting allows the user to enable the parser
without the need to have one of these widgets opened.

Task-number: QTCREATORBUG-15669
Change-Id: I354e1a3cb91eeca2302f2344fd443c81c4b15406
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
parent 537a5c00
...@@ -135,6 +135,9 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri ...@@ -135,6 +135,9 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
addAutoReleasedObject(new TestNavigationWidgetFactory); addAutoReleasedObject(new TestNavigationWidgetFactory);
addAutoReleasedObject(TestResultsPane::instance()); addAutoReleasedObject(TestResultsPane::instance());
if (m_settings->alwaysParse)
TestTreeModel::instance()->enableParsingFromSettings();
return true; return true;
} }
......
...@@ -37,11 +37,12 @@ static const char omitInternalKey[] = "OmitInternal"; ...@@ -37,11 +37,12 @@ static const char omitInternalKey[] = "OmitInternal";
static const char omitRunConfigWarnKey[] = "OmitRCWarnings"; static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
static const char limitResultOutputKey[] = "LimitResultOutput"; static const char limitResultOutputKey[] = "LimitResultOutput";
static const char autoScrollKey[] = "AutoScrollResults"; static const char autoScrollKey[] = "AutoScrollResults";
static const char alwaysParseKey[] = "AlwaysParse";
static const int defaultTimeout = 60000; static const int defaultTimeout = 60000;
TestSettings::TestSettings() TestSettings::TestSettings()
: timeout(defaultTimeout), metrics(Walltime), omitInternalMssg(true), omitRunConfigWarn(false), : timeout(defaultTimeout), metrics(Walltime), omitInternalMssg(true), omitRunConfigWarn(false),
limitResultOutput(true), autoScroll(true) limitResultOutput(true), autoScroll(true), alwaysParse(false)
{ {
} }
...@@ -54,6 +55,7 @@ void TestSettings::toSettings(QSettings *s) const ...@@ -54,6 +55,7 @@ void TestSettings::toSettings(QSettings *s) const
s->setValue(QLatin1String(omitRunConfigWarnKey), omitRunConfigWarn); s->setValue(QLatin1String(omitRunConfigWarnKey), omitRunConfigWarn);
s->setValue(QLatin1String(limitResultOutputKey), limitResultOutput); s->setValue(QLatin1String(limitResultOutputKey), limitResultOutput);
s->setValue(QLatin1String(autoScrollKey), autoScroll); s->setValue(QLatin1String(autoScrollKey), autoScroll);
s->setValue(QLatin1String(alwaysParseKey), alwaysParse);
s->endGroup(); s->endGroup();
} }
...@@ -84,6 +86,7 @@ void TestSettings::fromSettings(const QSettings *s) ...@@ -84,6 +86,7 @@ void TestSettings::fromSettings(const QSettings *s)
omitRunConfigWarn = s->value(root + QLatin1String(omitRunConfigWarnKey), false).toBool(); omitRunConfigWarn = s->value(root + QLatin1String(omitRunConfigWarnKey), false).toBool();
limitResultOutput = s->value(root + QLatin1String(limitResultOutputKey), true).toBool(); limitResultOutput = s->value(root + QLatin1String(limitResultOutputKey), true).toBool();
autoScroll = s->value(root + QLatin1String(autoScrollKey), true).toBool(); autoScroll = s->value(root + QLatin1String(autoScrollKey), true).toBool();
alwaysParse = s->value(root + QLatin1String(alwaysParseKey), false).toBool();
} }
bool TestSettings::equals(const TestSettings &rhs) const bool TestSettings::equals(const TestSettings &rhs) const
...@@ -92,7 +95,8 @@ bool TestSettings::equals(const TestSettings &rhs) const ...@@ -92,7 +95,8 @@ bool TestSettings::equals(const TestSettings &rhs) const
&& omitInternalMssg == rhs.omitInternalMssg && omitInternalMssg == rhs.omitInternalMssg
&& omitRunConfigWarn == rhs.omitRunConfigWarn && omitRunConfigWarn == rhs.omitRunConfigWarn
&& limitResultOutput == rhs.limitResultOutput && limitResultOutput == rhs.limitResultOutput
&& autoScroll == rhs.autoScroll; && autoScroll == rhs.autoScroll
&& alwaysParse == rhs.alwaysParse;
} }
QString TestSettings::metricsTypeToOption(const MetricsType type) QString TestSettings::metricsTypeToOption(const MetricsType type)
......
...@@ -57,6 +57,7 @@ struct TestSettings ...@@ -57,6 +57,7 @@ struct TestSettings
bool omitRunConfigWarn; bool omitRunConfigWarn;
bool limitResultOutput; bool limitResultOutput;
bool autoScroll; bool autoScroll;
bool alwaysParse;
}; };
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); }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "autotestconstants.h" #include "autotestconstants.h"
#include "testsettingspage.h" #include "testsettingspage.h"
#include "testsettings.h" #include "testsettings.h"
#include "testtreemodel.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
...@@ -49,6 +50,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings) ...@@ -49,6 +50,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn); m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn);
m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput); m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput);
m_ui.autoScrollCB->setChecked(settings.autoScroll); m_ui.autoScrollCB->setChecked(settings.autoScroll);
m_ui.alwaysParseCB->setChecked(settings.alwaysParse);
switch (settings.metrics) { switch (settings.metrics) {
case MetricsType::Walltime: case MetricsType::Walltime:
...@@ -79,6 +81,7 @@ TestSettings TestSettingsWidget::settings() const ...@@ -79,6 +81,7 @@ TestSettings TestSettingsWidget::settings() const
result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked(); result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked();
result.limitResultOutput = m_ui.limitResultOutputCB->isChecked(); result.limitResultOutput = m_ui.limitResultOutputCB->isChecked();
result.autoScroll = m_ui.autoScrollCB->isChecked(); result.autoScroll = m_ui.autoScrollCB->isChecked();
result.alwaysParse = m_ui.alwaysParseCB->isChecked();
if (m_ui.walltimeRB->isChecked()) if (m_ui.walltimeRB->isChecked())
result.metrics = MetricsType::Walltime; result.metrics = MetricsType::Walltime;
...@@ -125,6 +128,10 @@ void TestSettingsPage::apply() ...@@ -125,6 +128,10 @@ void TestSettingsPage::apply()
if (newSettings != *m_settings) { if (newSettings != *m_settings) {
*m_settings = newSettings; *m_settings = newSettings;
m_settings->toSettings(Core::ICore::settings()); m_settings->toSettings(Core::ICore::settings());
if (m_settings->alwaysParse)
TestTreeModel::instance()->enableParsingFromSettings();
else
TestTreeModel::instance()->disableParsingFromSettings();
} }
} }
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>420</width> <width>451</width>
<height>244</height> <height>271</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -73,6 +73,16 @@ ...@@ -73,6 +73,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="alwaysParseCB">
<property name="toolTip">
<string>Parse for tests even when no Tests related widget is displayed.</string>
</property>
<property name="text">
<string>Always parse current project for tests</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0"> <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0">
<property name="spacing"> <property name="spacing">
......
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
****************************************************************************/ ****************************************************************************/
#include "autotestconstants.h" #include "autotestconstants.h"
#include "autotestplugin.h"
#include "testcodeparser.h" #include "testcodeparser.h"
#include "testsettings.h"
#include "testtreeitem.h" #include "testtreeitem.h"
#include "testtreemodel.h" #include "testtreemodel.h"
...@@ -113,7 +115,16 @@ TestTreeModel::~TestTreeModel() ...@@ -113,7 +115,16 @@ TestTreeModel::~TestTreeModel()
void TestTreeModel::enableParsing() void TestTreeModel::enableParsing()
{ {
m_refCounter.ref(); m_refCounter.ref();
setupParsingConnections();
}
void TestTreeModel::enableParsingFromSettings()
{
setupParsingConnections();
}
void TestTreeModel::setupParsingConnections()
{
if (!m_connectionsInitialized) if (!m_connectionsInitialized)
m_parser->setDirty(); m_parser->setDirty();
...@@ -143,7 +154,13 @@ void TestTreeModel::enableParsing() ...@@ -143,7 +154,13 @@ void TestTreeModel::enableParsing()
void TestTreeModel::disableParsing() void TestTreeModel::disableParsing()
{ {
if (!m_refCounter.deref()) if (!m_refCounter.deref() && !AutotestPlugin::instance()->settings()->alwaysParse)
m_parser->setState(TestCodeParser::Disabled);
}
void TestTreeModel::disableParsingFromSettings()
{
if (!m_refCounter.load())
m_parser->setState(TestCodeParser::Disabled); m_parser->setState(TestCodeParser::Disabled);
} }
......
...@@ -54,7 +54,9 @@ public: ...@@ -54,7 +54,9 @@ public:
static TestTreeModel* instance(); static TestTreeModel* instance();
~TestTreeModel(); ~TestTreeModel();
void enableParsing(); void enableParsing();
void enableParsingFromSettings();
void disableParsing(); void disableParsing();
void disableParsingFromSettings();
bool setData(const QModelIndex &index, const QVariant &value, int role) override; bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Qt::ItemFlags flags(const QModelIndex &index) const override; Qt::ItemFlags flags(const QModelIndex &index) const override;
...@@ -100,6 +102,7 @@ private: ...@@ -100,6 +102,7 @@ private:
void modifyTestSubtree(QModelIndex &toBeModifiedIndex, const TestTreeItem *newItem); void modifyTestSubtree(QModelIndex &toBeModifiedIndex, const TestTreeItem *newItem);
void processChildren(QModelIndex &parentIndex, const TestTreeItem *newItem, void processChildren(QModelIndex &parentIndex, const TestTreeItem *newItem,
const int upperBound, const QHash<QString, Qt::CheckState> &checkStates); const int upperBound, const QHash<QString, Qt::CheckState> &checkStates);
void setupParsingConnections();
TestTreeItem *m_autoTestRootItem; TestTreeItem *m_autoTestRootItem;
TestTreeItem *m_quickTestRootItem; TestTreeItem *m_quickTestRootItem;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment