Commit 584e0c6b authored by Christian Stenger's avatar Christian Stenger

AutoTest: Display hint if no framework is active

Change-Id: Ia569bcb5c78809cd9bc58499b55b1b26e34d5d89
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
Reviewed-by: Riitta-Leena Miettinen's avatarLeena Miettinen <riitta-leena.miettinen@qt.io>
parent e17d09a8
......@@ -151,5 +151,14 @@ bool TestFrameworkManager::isActive(const Core::Id &frameworkId) const
return framework ? framework->active() : false;
}
bool TestFrameworkManager::hasActiveFrameworks() const
{
for (ITestFramework *framework : m_registeredFrameworks.values()) {
if (framework->active())
return true;
}
return false;
}
} // namespace Internal
} // namespace Autotest
......@@ -56,6 +56,7 @@ public:
TestTreeItem *rootNodeForTestFramework(const Core::Id &frameworkId) const;
ITestParser *testParserForTestFramework(const Core::Id &frameworkId) const;
bool isActive(const Core::Id &frameworkId) const;
bool hasActiveFrameworks() const;
private:
QVector<Core::Id> activeFrameworkIds() const;
......
......@@ -24,6 +24,7 @@
****************************************************************************/
#include "testnavigationwidget.h"
#include "testframeworkmanager.h"
#include "testtreemodel.h"
#include "testtreeview.h"
#include "testtreeitemdelegate.h"
......@@ -63,9 +64,22 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
m_view->setSortingEnabled(true);
m_view->setItemDelegate(new TestTreeItemDelegate(this));
QPalette pal;
pal.setColor(QPalette::Window,
Utils::creatorTheme()->color(Utils::Theme::InfoBarBackground));
pal.setColor(QPalette::WindowText,
Utils::creatorTheme()->color(Utils::Theme::InfoBarText));
m_missingFrameworksWidget = new QFrame;
m_missingFrameworksWidget->setPalette(pal);
m_missingFrameworksWidget->setAutoFillBackground(true);
QHBoxLayout *hLayout = new QHBoxLayout;
m_missingFrameworksWidget->setLayout(hLayout);
hLayout->addWidget(new QLabel(tr("No active test frameworks.")));
m_missingFrameworksWidget->setVisible(!TestFrameworkManager::instance()->hasActiveFrameworks());
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(m_missingFrameworksWidget);
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_view));
setLayout(layout);
......@@ -85,6 +99,10 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
this, &TestNavigationWidget::onParsingFinished);
connect(m_model->parser(), &TestCodeParser::parsingFailed,
this, &TestNavigationWidget::onParsingFinished);
connect(m_model, &TestTreeModel::updatedActiveFrameworks,
[this] (int numberOfActive) {
m_missingFrameworksWidget->setVisible(numberOfActive == 0);
});
connect(m_progressTimer, &QTimer::timeout,
m_progressIndicator, &Utils::ProgressIndicator::show);
}
......
......@@ -85,6 +85,7 @@ private:
bool m_sortAlphabetically;
Utils::ProgressIndicator *m_progressIndicator;
QTimer *m_progressTimer;
QFrame *m_missingFrameworksWidget;
};
class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory
......
......@@ -30,6 +30,7 @@
#include "testtreemodel.h"
#include <coreplugin/icore.h>
#include <coreplugin/coreicons.h>
#include <utils/hostosinfo.h>
......@@ -43,8 +44,16 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
m_ui.callgrindRB->setEnabled(Utils::HostOsInfo::isAnyUnixHost()); // valgrind available on UNIX
m_ui.perfRB->setEnabled(Utils::HostOsInfo::isLinuxHost()); // according to docs perf Linux only
m_ui.frameworksWarnIcon->setVisible(false);
m_ui.frameworksWarnIcon->setPixmap(Core::Icons::WARNING.pixmap());
m_ui.frameworksWarn->setVisible(false);
m_ui.frameworksWarn->setText(tr("No active test frameworks."));
m_ui.frameworksWarn->setToolTip(tr("You will not be able to use the AutoTest plugin without "
"having at least one active test framework."));
connect(m_ui.repeatGTestsCB, &QCheckBox::toggled, m_ui.repetitionSpin, &QSpinBox::setEnabled);
connect(m_ui.shuffleGTestsCB, &QCheckBox::toggled, m_ui.seedSpin, &QSpinBox::setEnabled);
connect(m_ui.frameworkListWidget, &QListWidget::itemChanged,
this, &TestSettingsWidget::onFrameworkItemChanged);
}
void TestSettingsWidget::setSettings(const TestSettings &settings)
......@@ -141,6 +150,19 @@ QHash<Core::Id, bool> TestSettingsWidget::frameworks() const
return frameworks;
}
void TestSettingsWidget::onFrameworkItemChanged()
{
for (int row = 0, count = m_ui.frameworkListWidget->count(); row < count; ++row) {
if (m_ui.frameworkListWidget->item(row)->checkState() == Qt::Checked) {
m_ui.frameworksWarn->setVisible(false);
m_ui.frameworksWarnIcon->setVisible(false);
return;
}
}
m_ui.frameworksWarn->setVisible(true);
m_ui.frameworksWarnIcon->setVisible(true);
}
TestSettingsPage::TestSettingsPage(const QSharedPointer<TestSettings> &settings)
: m_settings(settings), m_widget(0)
{
......
......@@ -48,6 +48,7 @@ public:
private:
void populateFrameworksListWidget(const QHash<Core::Id, bool> &frameworks);
QHash<Core::Id, bool> frameworks() const;
void onFrameworkItemChanged();
Ui::TestSettingsPage m_ui;
};
......
......@@ -163,6 +163,26 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,0">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="frameworksWarnIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="frameworksWarn"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......
......@@ -203,12 +203,11 @@ void TestTreeModel::syncTestFrameworks()
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
QVector<Core::Id> sortedIds = frameworkManager->sortedActiveFrameworkIds();
// TODO display warning overlay or similar if sortedIds.isEmpty()
foreach (const Core::Id &id, sortedIds)
rootItem()->appendChild(frameworkManager->rootNodeForTestFramework(id));
m_parser->syncTestFrameworks(sortedIds);
emit updatedActiveFrameworks(sortedIds.size());
}
void TestTreeModel::removeFiles(const QStringList &files)
......
......@@ -79,6 +79,7 @@ public:
signals:
void testTreeModelChanged();
void updatedActiveFrameworks(int numberOfActiveFrameworks);
#ifdef WITH_TESTS
void sweepingDone();
#endif
......
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