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 ...@@ -151,5 +151,14 @@ bool TestFrameworkManager::isActive(const Core::Id &frameworkId) const
return framework ? framework->active() : false; 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 Internal
} // namespace Autotest } // namespace Autotest
...@@ -56,6 +56,7 @@ public: ...@@ -56,6 +56,7 @@ public:
TestTreeItem *rootNodeForTestFramework(const Core::Id &frameworkId) const; TestTreeItem *rootNodeForTestFramework(const Core::Id &frameworkId) const;
ITestParser *testParserForTestFramework(const Core::Id &frameworkId) const; ITestParser *testParserForTestFramework(const Core::Id &frameworkId) const;
bool isActive(const Core::Id &frameworkId) const; bool isActive(const Core::Id &frameworkId) const;
bool hasActiveFrameworks() const;
private: private:
QVector<Core::Id> activeFrameworkIds() const; QVector<Core::Id> activeFrameworkIds() const;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
****************************************************************************/ ****************************************************************************/
#include "testnavigationwidget.h" #include "testnavigationwidget.h"
#include "testframeworkmanager.h"
#include "testtreemodel.h" #include "testtreemodel.h"
#include "testtreeview.h" #include "testtreeview.h"
#include "testtreeitemdelegate.h" #include "testtreeitemdelegate.h"
...@@ -63,9 +64,22 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) : ...@@ -63,9 +64,22 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
m_view->setSortingEnabled(true); m_view->setSortingEnabled(true);
m_view->setItemDelegate(new TestTreeItemDelegate(this)); 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; QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0); layout->setMargin(0);
layout->setSpacing(0); layout->setSpacing(0);
layout->addWidget(m_missingFrameworksWidget);
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_view)); layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_view));
setLayout(layout); setLayout(layout);
...@@ -85,6 +99,10 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) : ...@@ -85,6 +99,10 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
this, &TestNavigationWidget::onParsingFinished); this, &TestNavigationWidget::onParsingFinished);
connect(m_model->parser(), &TestCodeParser::parsingFailed, connect(m_model->parser(), &TestCodeParser::parsingFailed,
this, &TestNavigationWidget::onParsingFinished); this, &TestNavigationWidget::onParsingFinished);
connect(m_model, &TestTreeModel::updatedActiveFrameworks,
[this] (int numberOfActive) {
m_missingFrameworksWidget->setVisible(numberOfActive == 0);
});
connect(m_progressTimer, &QTimer::timeout, connect(m_progressTimer, &QTimer::timeout,
m_progressIndicator, &Utils::ProgressIndicator::show); m_progressIndicator, &Utils::ProgressIndicator::show);
} }
......
...@@ -85,6 +85,7 @@ private: ...@@ -85,6 +85,7 @@ private:
bool m_sortAlphabetically; bool m_sortAlphabetically;
Utils::ProgressIndicator *m_progressIndicator; Utils::ProgressIndicator *m_progressIndicator;
QTimer *m_progressTimer; QTimer *m_progressTimer;
QFrame *m_missingFrameworksWidget;
}; };
class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "testtreemodel.h" #include "testtreemodel.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/coreicons.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
...@@ -43,8 +44,16 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent) ...@@ -43,8 +44,16 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
m_ui.callgrindRB->setEnabled(Utils::HostOsInfo::isAnyUnixHost()); // valgrind available on UNIX 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.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.repeatGTestsCB, &QCheckBox::toggled, m_ui.repetitionSpin, &QSpinBox::setEnabled);
connect(m_ui.shuffleGTestsCB, &QCheckBox::toggled, m_ui.seedSpin, &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) void TestSettingsWidget::setSettings(const TestSettings &settings)
...@@ -141,6 +150,19 @@ QHash<Core::Id, bool> TestSettingsWidget::frameworks() const ...@@ -141,6 +150,19 @@ QHash<Core::Id, bool> TestSettingsWidget::frameworks() const
return frameworks; 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) TestSettingsPage::TestSettingsPage(const QSharedPointer<TestSettings> &settings)
: m_settings(settings), m_widget(0) : m_settings(settings), m_widget(0)
{ {
......
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
private: private:
void populateFrameworksListWidget(const QHash<Core::Id, bool> &frameworks); void populateFrameworksListWidget(const QHash<Core::Id, bool> &frameworks);
QHash<Core::Id, bool> frameworks() const; QHash<Core::Id, bool> frameworks() const;
void onFrameworkItemChanged();
Ui::TestSettingsPage m_ui; Ui::TestSettingsPage m_ui;
}; };
......
...@@ -163,6 +163,26 @@ ...@@ -163,6 +163,26 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
</item> </item>
......
...@@ -203,12 +203,11 @@ void TestTreeModel::syncTestFrameworks() ...@@ -203,12 +203,11 @@ void TestTreeModel::syncTestFrameworks()
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance(); TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
QVector<Core::Id> sortedIds = frameworkManager->sortedActiveFrameworkIds(); QVector<Core::Id> sortedIds = frameworkManager->sortedActiveFrameworkIds();
// TODO display warning overlay or similar if sortedIds.isEmpty()
foreach (const Core::Id &id, sortedIds) foreach (const Core::Id &id, sortedIds)
rootItem()->appendChild(frameworkManager->rootNodeForTestFramework(id)); rootItem()->appendChild(frameworkManager->rootNodeForTestFramework(id));
m_parser->syncTestFrameworks(sortedIds); m_parser->syncTestFrameworks(sortedIds);
emit updatedActiveFrameworks(sortedIds.size());
} }
void TestTreeModel::removeFiles(const QStringList &files) void TestTreeModel::removeFiles(const QStringList &files)
......
...@@ -79,6 +79,7 @@ public: ...@@ -79,6 +79,7 @@ public:
signals: signals:
void testTreeModelChanged(); void testTreeModelChanged();
void updatedActiveFrameworks(int numberOfActiveFrameworks);
#ifdef WITH_TESTS #ifdef WITH_TESTS
void sweepingDone(); void sweepingDone();
#endif #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